From 10c6e20db489144d59faf1206e901bac5ad3da07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Thu, 5 Mar 2026 20:29:50 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[=ED=92=88=EC=A7=88=EA=B4=80=EB=A6=AC]?= =?UTF-8?q?=20=EC=8B=A4=EC=A0=81=EC=8B=A0=EA=B3=A0=20API=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20snake=5Fcase=20=E2=86=92=20camelCase=20=EB=B3=80?= =?UTF-8?q?=ED=99=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - transformReport: 실적신고 목록 데이터 변환 - transformStats: 통계 데이터 변환 - transformMissedReport: 누락체크 데이터 변환 - 백엔드 snake_case 응답을 프론트 camelCase 타입에 매핑 --- .../PerformanceReportManagement/actions.ts | 53 +++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/src/components/quality/PerformanceReportManagement/actions.ts b/src/components/quality/PerformanceReportManagement/actions.ts index 1d330625..602fb1f3 100644 --- a/src/components/quality/PerformanceReportManagement/actions.ts +++ b/src/components/quality/PerformanceReportManagement/actions.ts @@ -29,6 +29,49 @@ import { // 개발환경 Mock 데이터 fallback 플래그 const USE_MOCK_FALLBACK = false; +// ===== API 응답 → 프론트 타입 변환 ===== + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function transformReport(item: any): PerformanceReport { + return { + id: String(item.id ?? ''), + qualityDocNumber: item.quality_doc_number ?? '', + createdDate: item.created_date ?? '', + siteName: item.site_name ?? '', + client: item.client ?? '', + locationCount: item.location_count ?? 0, + requiredInfo: item.required_info ?? '', + confirmStatus: item.confirm_status === 'confirmed' ? '확정' : '미확정', + confirmDate: item.confirm_date ?? '', + memo: item.memo ?? '', + year: item.year ?? new Date().getFullYear(), + quarter: item.quarter ?? 'Q1', + }; +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function transformStats(item: any): PerformanceReportStats { + return { + totalCount: item.total_count ?? 0, + confirmedCount: item.confirmed_count ?? 0, + unconfirmedCount: item.unconfirmed_count ?? 0, + totalLocations: item.total_locations ?? 0, + }; +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function transformMissedReport(item: any): MissedReport { + return { + id: String(item.id ?? ''), + qualityDocNumber: item.quality_doc_number ?? item.order_number ?? '', + siteName: item.site_name ?? '', + client: item.client ?? '', + locationCount: item.location_count ?? 0, + inspectionCompleteDate: item.delivery_date ?? '', + memo: item.memo ?? '', + }; +} + // ===== 페이지네이션 ===== interface PaginationMeta { @@ -91,9 +134,11 @@ export async function getPerformanceReports(params?: { } const d = result.data; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const items = (d?.items || []).map((item: any) => transformReport(item)); return { success: true, - data: d?.items || [], + data: items, pagination: { currentPage: d?.current_page || 1, lastPage: d?.last_page || 1, @@ -126,7 +171,7 @@ export async function getPerformanceReportStats(params?: { if (USE_MOCK_FALLBACK) return { success: true, data: mockPerformanceReportStats }; return { success: false, error: result.error, __authError: result.__authError }; } - return { success: true, data: result.data }; + return { success: true, data: result.data ? transformStats(result.data) : undefined }; } // ===== 누락체크 목록 조회 ===== @@ -176,9 +221,11 @@ export async function getMissedReports(params?: { } const d = result.data; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const items = (d?.items || []).map((item: any) => transformMissedReport(item)); return { success: true, - data: d?.items || [], + data: items, pagination: { currentPage: d?.current_page || 1, lastPage: d?.last_page || 1,