mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 16:19:01 +00:00
Map API response fields to form state in getWorkOrderById
- workerOrderNumber → workOrderNumber - assignee → assignedTo - Format dates for date input fields - Default empty strings for null fields
This commit is contained in:
parent
fad2b7d661
commit
cdf7477059
1 changed files with 16 additions and 1 deletions
|
|
@ -13,7 +13,22 @@ export const getWorkOrders = async (params = {}) => {
|
||||||
|
|
||||||
export const getWorkOrderById = async (id) => {
|
export const getWorkOrderById = async (id) => {
|
||||||
try {
|
try {
|
||||||
return await workOrderApi.getById(id);
|
const wo = await workOrderApi.getById(id);
|
||||||
|
return {
|
||||||
|
id: wo.id,
|
||||||
|
workOrderNumber: wo.workerOrderNumber ?? wo.workOrderNumber ?? "",
|
||||||
|
title: wo.title ?? wo.workerOrderTitle ?? "",
|
||||||
|
location: wo.location ?? "",
|
||||||
|
assignedTo: wo.assignee ?? wo.assignedTo ?? "",
|
||||||
|
dueDate: wo.dueDate ? wo.dueDate.split("T")[0] : "",
|
||||||
|
createdDate: wo.createdDate ? wo.createdDate.split("T")[0] : "",
|
||||||
|
description: wo.description ?? "",
|
||||||
|
priority: wo.priority ?? "",
|
||||||
|
status: wo.status ?? "Open",
|
||||||
|
estimatedHours: wo.estimatedHours ?? "",
|
||||||
|
po: wo.po ?? "",
|
||||||
|
tt: wo.tt ?? "",
|
||||||
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching work order:", error);
|
console.error("Error fetching work order:", error);
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue