feat: [품질관리] 수주 연결 동기화 + 개소별 데이터 저장
- transformApiToFrontend에 orderId, inspectionData 매핑 추가 - transformFormToApi에 order_ids 추가 - updateInspection에 order_ids 동기화 + locations 데이터 전송
This commit is contained in:
@@ -220,6 +220,7 @@ function transformApiToFrontend(api: ProductInspectionApi): ProductInspection {
|
||||
},
|
||||
orderItems: (api.order_items || []).map((item) => ({
|
||||
id: item.id,
|
||||
orderId: item.order_id,
|
||||
orderNumber: item.order_number,
|
||||
siteName: item.site_name || '',
|
||||
deliveryDate: item.delivery_date || '',
|
||||
@@ -230,6 +231,7 @@ function transformApiToFrontend(api: ProductInspectionApi): ProductInspection {
|
||||
constructionWidth: item.construction_width,
|
||||
constructionHeight: item.construction_height,
|
||||
changeReason: item.change_reason,
|
||||
inspectionData: item.inspection_data || undefined,
|
||||
})),
|
||||
};
|
||||
}
|
||||
@@ -281,6 +283,8 @@ function transformFormToApi(data: InspectionFormData): Record<string, unknown> {
|
||||
phone: data.supervisor?.phone || '',
|
||||
},
|
||||
},
|
||||
// 수주 연결
|
||||
order_ids: data.orderItems?.map((item) => item.orderId ?? Number(item.id)) ?? [],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -555,6 +559,23 @@ export async function updateInspection(
|
||||
apiData.options = options;
|
||||
}
|
||||
|
||||
// 수주 연결 동기화 (orderItems에서 orderId 추출)
|
||||
if (data.orderItems !== undefined) {
|
||||
apiData.order_ids = data.orderItems.map((item) => {
|
||||
// orderId가 있으면 사용, 없으면 id를 숫자로 변환
|
||||
return item.orderId ?? Number(item.id);
|
||||
});
|
||||
|
||||
// 개소별 데이터 (시공규격, 변경사유, 검사데이터)
|
||||
apiData.locations = data.orderItems.map((item) => ({
|
||||
id: Number(item.id),
|
||||
post_width: item.constructionWidth || null,
|
||||
post_height: item.constructionHeight || null,
|
||||
change_reason: item.changeReason || null,
|
||||
inspection_data: item.inspectionData || null,
|
||||
}));
|
||||
}
|
||||
|
||||
const result = await executeServerAction<ProductInspectionApi>({
|
||||
url: buildApiUrl(`/api/v1/quality/documents/${id}`),
|
||||
method: 'PUT',
|
||||
|
||||
Reference in New Issue
Block a user