refactor(FE-208,212): initialize items in PurchaseRequestForm with initial values

This commit is contained in:
rstubryan
2025-11-20 14:50:36 +07:00
parent 655e971788
commit f1e5692f8f
@@ -140,5 +140,29 @@ export const getPurchaseRequestFormInitialValues = (
: null,
location_id: initialValues?.location?.id ?? undefined,
notes: initialValues?.notes ?? null,
items: [],
items: initialValues?.items?.length ? initialValues.items.map((item) => ({
warehouse: item.warehouse
? {
value: item.warehouse.id,
label: item.warehouse.name,
}
: null,
warehouse_id: item.warehouse?.id ?? 0,
product: item.product
? {
value: item.product.id,
label: item.product.name,
}
: null,
product_id: item.product?.id ?? 0,
qty: item.qty ?? 0,
})) : [
{
warehouse: null,
warehouse_id: 0,
product: null,
product_id: 0,
qty: 0,
},
],
});