diff --git a/src/components/business/CEODashboard/sections/TodayIssueSection.tsx b/src/components/business/CEODashboard/sections/TodayIssueSection.tsx index 580a3bc3..7ed0c77a 100644 --- a/src/components/business/CEODashboard/sections/TodayIssueSection.tsx +++ b/src/components/business/CEODashboard/sections/TodayIssueSection.tsx @@ -81,11 +81,12 @@ const FILTER_KEYS = [ ] as const; // notification_type → 한글 라벨 매핑 (필터 표시용) +// 백엔드 TodayIssue.php BADGE 상수와 동기화! const NOTIFICATION_TYPE_LABELS: Record = { - sales_order: '수주 성공', - bad_debt: '추심 이슈', - safety_stock: '적정 재고', - expected_expense: '지출예상내역서', + sales_order: '수주등록', + bad_debt: '추심이슈', + safety_stock: '안전재고', + expected_expense: '지출 승인대기', vat_report: '세금 신고', approval_request: '결재 요청', new_vendor: '신규거래처', diff --git a/src/components/business/CEODashboard/types.ts b/src/components/business/CEODashboard/types.ts index 89b5c431..03cd8e34 100644 --- a/src/components/business/CEODashboard/types.ts +++ b/src/components/business/CEODashboard/types.ts @@ -69,12 +69,13 @@ export type TodayIssueNotificationType = | 'withdrawal' // 출금 | 'other'; // 기타 -// 오늘의 이슈 뱃지 타입 (한글 표시용 - deprecated, notificationType 사용 권장) +// 오늘의 이슈 뱃지 타입 (한글 표시용) +// 백엔드 TodayIssue.php BADGE 상수와 동기화! export type TodayIssueListBadgeType = - | '수주 성공' - | '추심 이슈' - | '적정 재고' - | '지출예상내역서' + | '수주등록' + | '추심이슈' + | '안전재고' + | '지출 승인대기' | '세금 신고' | '결재 요청' | '신규거래처' diff --git a/src/lib/api/dashboard/transformers.ts b/src/lib/api/dashboard/transformers.ts index 56b86368..ee16cd38 100644 --- a/src/lib/api/dashboard/transformers.ts +++ b/src/lib/api/dashboard/transformers.ts @@ -617,12 +617,14 @@ const VALID_NOTIFICATION_TYPES: TodayIssueNotificationType[] = [ 'other', ]; -/** notification_type → 한글 badge 변환 매핑 */ +/** notification_type → 한글 badge 변환 매핑 + * 백엔드 TodayIssue.php BADGE 상수와 동기화! + */ const NOTIFICATION_TYPE_TO_BADGE: Record = { - sales_order: '수주 성공', - bad_debt: '추심 이슈', - safety_stock: '적정 재고', - expected_expense: '지출예상내역서', + sales_order: '수주등록', + bad_debt: '추심이슈', + safety_stock: '안전재고', + expected_expense: '지출 승인대기', vat_report: '세금 신고', approval_request: '결재 요청', new_vendor: '신규거래처', @@ -631,14 +633,42 @@ const NOTIFICATION_TYPE_TO_BADGE: Record = { + // === 백엔드 실제 값 (TodayIssue.php 상수) === + '수주등록': 'sales_order', + '추심이슈': 'bad_debt', + '안전재고': 'safety_stock', + '지출 승인대기': 'expected_expense', + '세금 신고': 'vat_report', + '결재 요청': 'approval_request', + '신규거래처': 'new_vendor', + '입금': 'deposit', + '출금': 'withdrawal', + // === 혹시 모를 변형 (안전장치) === + '수주 등록': 'sales_order', + '추심 이슈': 'bad_debt', + '안전 재고': 'safety_stock', + '지출승인대기': 'expected_expense', + '세금신고': 'vat_report', + '결재요청': 'approval_request', +}; + /** * API notification_type → Frontend notificationType 변환 - * 유효하지 않은 타입은 'other'로 폴백 + * notification_type이 없으면 badge에서 추론 */ -function validateNotificationType(notificationType: string | null): TodayIssueNotificationType { +function validateNotificationType(notificationType: string | null, badge?: string): TodayIssueNotificationType { + // 1. notification_type이 유효하면 그대로 사용 if (notificationType && VALID_NOTIFICATION_TYPES.includes(notificationType as TodayIssueNotificationType)) { return notificationType as TodayIssueNotificationType; } + // 2. notification_type이 없으면 badge에서 추론 + if (badge && BADGE_TO_NOTIFICATION_TYPE[badge]) { + return BADGE_TO_NOTIFICATION_TYPE[badge]; + } return 'other'; } @@ -653,7 +683,8 @@ export function transformTodayIssueResponse(api: TodayIssueApiResponse): { } { return { items: api.items.map((item) => { - const notificationType = validateNotificationType(item.notification_type); + // notification_type이 없으면 badge에서 추론 + const notificationType = validateNotificationType(item.notification_type, item.badge); // badge는 API 응답 그대로 사용하되, 없으면 notification_type에서 변환 const badge = item.badge || NOTIFICATION_TYPE_TO_BADGE[notificationType];