From a1dc13ceb42e9543ad335a7041f630f4ce5df19a Mon Sep 17 00:00:00 2001 From: rstubryan Date: Fri, 10 Oct 2025 13:36:22 +0700 Subject: [PATCH] feat(FE-62): enhance MovementForm with area and location display for warehouse selection --- .../inventory/movement/form/MovementForm.tsx | 90 +++++++++++++++++-- 1 file changed, 82 insertions(+), 8 deletions(-) diff --git a/src/components/pages/inventory/movement/form/MovementForm.tsx b/src/components/pages/inventory/movement/form/MovementForm.tsx index 14c6fc45..22e39642 100644 --- a/src/components/pages/inventory/movement/form/MovementForm.tsx +++ b/src/components/pages/inventory/movement/form/MovementForm.tsx @@ -198,6 +198,11 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => { return touchedField && Boolean(errorField?.[column as string]); }; + interface WarehouseOptionType extends OptionType { + area?: string; + location?: string; + } + // Warehouse selection const [warehouseSelectInputValue, setWarehouseSelectInputValue] = useState(''); @@ -207,7 +212,15 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => { WarehouseApi.getAllFetcher ); const warehouseOptions = isResponseSuccess(warehouses) - ? warehouses?.data.map((w) => ({ value: w.id, label: w.name })) + ? warehouses?.data.map((w) => ({ + value: w.id, + label: w.name, + area: w.area?.name, + location: + 'type' in w && (w.type === 'LOKASI' || w.type === 'KANDANG') + ? w.location?.name + : undefined, + })) : []; // Product selection @@ -291,16 +304,17 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => { {/* Warehouse cards */}
-
+
+

Gudang Asal

{ formik.setFieldValue('warehouse_asal', val); formik.setFieldValue( 'warehouse_asal_id', - (val as OptionType)?.value + (val as WarehouseOptionType)?.value ); }} options={warehouseOptions} @@ -314,20 +328,51 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => { isDisabled={type === 'detail'} isClearable /> + + {/* Area and Location Info */} +
+ + +
-
+
+

Gudang Tujuan

{ formik.setFieldValue('warehouse_tujuan', val); formik.setFieldValue( 'warehouse_tujuan_id', - (val as OptionType)?.value + (val as WarehouseOptionType)?.value ); }} options={warehouseOptions} @@ -341,10 +386,39 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => { isDisabled={type === 'detail'} isClearable /> + + {/* Area and Location Info */} +
+ + +
- {/* Products table */}