From 381413a49c2ba02354d7da2b94925cd38e0e4aae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A0=EB=B3=91=EC=B2=A0?= Date: Wed, 28 Jan 2026 15:58:27 +0900 Subject: [PATCH] =?UTF-8?q?fix(WEB):=20=EC=98=A4=EB=8A=98=EC=9D=98=20?= =?UTF-8?q?=EC=9D=B4=EC=8A=88=20badge=20=EB=A7=A4=ED=95=91=20=EB=B0=B1?= =?UTF-8?q?=EC=97=94=EB=93=9C=20=EB=8F=99=EA=B8=B0=ED=99=94=20=EB=B0=8F=20?= =?UTF-8?q?fallback=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit transformers.ts: - NOTIFICATION_TYPE_TO_BADGE 백엔드 TodayIssue.php와 동기화 - BADGE_TO_NOTIFICATION_TYPE 역방향 매핑 추가 (fallback용) - validateNotificationType에 badge 기반 추론 로직 추가 Co-Authored-By: Claude Opus 4.5 --- .../sections/TodayIssueSection.tsx | 9 ++-- src/components/business/CEODashboard/types.ts | 11 +++-- src/lib/api/dashboard/transformers.ts | 47 +++++++++++++++---- 3 files changed, 50 insertions(+), 17 deletions(-) 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];