fix: [품질관리] 실적신고 API 응답 snake_case → camelCase 변환 추가
- transformReport: 실적신고 목록 데이터 변환 - transformStats: 통계 데이터 변환 - transformMissedReport: 누락체크 데이터 변환 - 백엔드 snake_case 응답을 프론트 camelCase 타입에 매핑
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user