영업관리자 전체 누적 실적 집계 로직 업데이트 및 신규 테넌트 데이터 연동

This commit is contained in:
2026-01-04 19:15:56 +09:00
parent 0a59899d4a
commit f8546431e9
2 changed files with 41 additions and 8 deletions

View File

@@ -3824,6 +3824,7 @@
const [isHelpOpen, setIsHelpOpen] = useState(false);
const [selectedRole, setSelectedRole] = useState('영업관리'); // 기본값: 영업관리
const [organizationData, setOrganizationData] = useState(null);
const [systemTotalStats, setSystemTotalStats] = useState(null);
const [isOrgLoading, setIsOrgLoading] = useState(false);
// Session states
@@ -3903,9 +3904,11 @@
const result = await res.json();
if (result.success) {
setOrganizationData(result.org_tree);
setSystemTotalStats(result.total_stats);
} else {
console.error('Performance fetch failed:', result.error);
setOrganizationData(null);
setSystemTotalStats(null);
}
} catch (err) {
console.error('Fetch error:', err);
@@ -3954,7 +3957,12 @@
{/* Dashbaord & Org Tree */}
{selectedRole === '영업관리' && (
<SalesManagementDashboard organizationData={organizationData} onRefresh={fetchPerformanceData} isLoading={isOrgLoading} />
<SalesManagementDashboard
organizationData={organizationData}
systemTotalStats={systemTotalStats}
onRefresh={fetchPerformanceData}
isLoading={isOrgLoading}
/>
)}
{/* NEW: Profit & Tenant Management Section */}
@@ -4026,7 +4034,7 @@
// ... (SimulatorSection, SalesList, CommissionDetailModal remain same) ...
// 6. Sales Management Dashboard Component
const SalesManagementDashboard = ({ organizationData, onRefresh, isLoading }) => {
const SalesManagementDashboard = ({ organizationData, systemTotalStats, onRefresh, isLoading }) => {
const [periodType, setPeriodType] = useState('current_month'); // current_month, custom
const [startYear, setStartYear] = useState(new Date().getFullYear());
const [startMonth, setStartMonth] = useState(new Date().getMonth() + 1);
@@ -4161,7 +4169,13 @@
setPeriodOrgData(filtered);
}, [periodType, startYear, startMonth, endYear, endMonth, organizationData]);
const totalStats = calculateTotalStats(organizationData);
const totalStats = systemTotalStats ? {
totalRevenue: systemTotalStats.totalSales,
totalCommission: systemTotalStats.totalCommission,
totalCount: systemTotalStats.totalCount,
commissionRate: systemTotalStats.totalSales > 0 ? ((systemTotalStats.totalCommission / systemTotalStats.totalSales) * 100).toFixed(1) : 0
} : calculateTotalStats(organizationData);
const periodStats = calculatePeriodStats(periodOrgData);
const years = Array.from({ length: 5 }, (_, i) => new Date().getFullYear() - i);