diff --git a/src/components/pages/purchase/form/request/PurchaseRequestForm.schema.ts b/src/components/pages/purchase/form/request/PurchaseRequestForm.schema.ts index 39e9a879..af84c68b 100644 --- a/src/components/pages/purchase/form/request/PurchaseRequestForm.schema.ts +++ b/src/components/pages/purchase/form/request/PurchaseRequestForm.schema.ts @@ -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, + }, + ], });