mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
chore: add transfer_context query when fetching source warehouse
This commit is contained in:
@@ -86,6 +86,15 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
|
||||
}
|
||||
|
||||
// ===== USE SELECT HOOKS =====
|
||||
const {
|
||||
setInputValue: setSourceWarehouseSelectInputValue,
|
||||
isLoadingOptions: isLoadingSourceWarehouses,
|
||||
loadMore: loadMoreSourceWarehouses,
|
||||
rawData: sourceWarehouses,
|
||||
} = useSelect<Warehouse>(WarehouseApi.basePath, 'id', 'name', 'search', {
|
||||
transfer_context: 'inventory_transfer',
|
||||
});
|
||||
|
||||
const {
|
||||
setInputValue: setWarehouseSelectInputValue,
|
||||
isLoadingOptions: isLoadingWarehouses,
|
||||
@@ -136,6 +145,25 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
|
||||
return stockMap;
|
||||
}, [allProductWarehouses]);
|
||||
|
||||
const sourceWarehouseOptions = useMemo(() => {
|
||||
if (!isResponseSuccess(sourceWarehouses)) return [];
|
||||
|
||||
return (
|
||||
sourceWarehouses?.data.map((w) => {
|
||||
warehouseStockMap.get(w.id);
|
||||
return {
|
||||
value: w.id,
|
||||
label: w.name,
|
||||
area: w.area?.name,
|
||||
location:
|
||||
'type' in w && (w.type === 'LOKASI' || w.type === 'KANDANG')
|
||||
? w.location?.name
|
||||
: undefined,
|
||||
};
|
||||
}) || []
|
||||
);
|
||||
}, [sourceWarehouses, warehouseStockMap]);
|
||||
|
||||
const warehouseOptions = useMemo(() => {
|
||||
if (!isResponseSuccess(warehouses)) return [];
|
||||
|
||||
@@ -1354,10 +1382,10 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
|
||||
placeholder='Pilih gudang asal...'
|
||||
value={formik.values.source_warehouse}
|
||||
onChange={handleSourceWarehouseChange}
|
||||
options={warehouseOptions}
|
||||
onInputChange={setWarehouseSelectInputValue}
|
||||
onMenuScrollToBottom={loadMoreWarehouses}
|
||||
isLoading={isLoadingWarehouses}
|
||||
options={sourceWarehouseOptions}
|
||||
onInputChange={setSourceWarehouseSelectInputValue}
|
||||
onMenuScrollToBottom={loadMoreSourceWarehouses}
|
||||
isLoading={isLoadingSourceWarehouses}
|
||||
isError={
|
||||
formik.touched.source_warehouse_id &&
|
||||
Boolean(formik.errors.source_warehouse_id)
|
||||
|
||||
Reference in New Issue
Block a user