mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 15:55:48 +00:00
refactor(FE-363): Use SWR key+fetcher with params for logistic report
This commit is contained in:
@@ -154,23 +154,35 @@ const PurchasesPerSupplierTab = () => {
|
|||||||
|
|
||||||
// ===== DATA FETCHING =====
|
// ===== DATA FETCHING =====
|
||||||
const { data: purchasePerSupplier, isLoading } = useSWR(
|
const { data: purchasePerSupplier, isLoading } = useSWR(
|
||||||
() =>
|
() => {
|
||||||
LogisticApi.getLogisticStockReport(
|
const params = {
|
||||||
tableFilterState.area_id ? Number(tableFilterState.area_id) : undefined,
|
area_id: tableFilterState.area_id
|
||||||
tableFilterState.supplier_id
|
? Number(tableFilterState.area_id)
|
||||||
|
: undefined,
|
||||||
|
supplier_id: tableFilterState.supplier_id
|
||||||
? Number(tableFilterState.supplier_id)
|
? Number(tableFilterState.supplier_id)
|
||||||
: undefined,
|
: undefined,
|
||||||
tableFilterState.product_id
|
product_id: tableFilterState.product_id
|
||||||
? Number(tableFilterState.product_id)
|
? Number(tableFilterState.product_id)
|
||||||
: undefined,
|
: undefined,
|
||||||
tableFilterState.received_date || undefined,
|
received_date: tableFilterState.received_date || undefined,
|
||||||
tableFilterState.po_date || undefined,
|
po_date: tableFilterState.po_date || undefined,
|
||||||
tableFilterState.start_date || undefined,
|
start_date: tableFilterState.start_date || undefined,
|
||||||
tableFilterState.end_date || undefined
|
end_date: tableFilterState.end_date || undefined,
|
||||||
),
|
};
|
||||||
{
|
|
||||||
revalidateOnFocus: false,
|
return ['logistic-purchase-report', params];
|
||||||
}
|
},
|
||||||
|
([, params]) =>
|
||||||
|
LogisticApi.getLogisticStockReport(
|
||||||
|
params.area_id,
|
||||||
|
params.supplier_id,
|
||||||
|
params.product_id,
|
||||||
|
params.received_date,
|
||||||
|
params.po_date,
|
||||||
|
params.start_date,
|
||||||
|
params.end_date
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
const data: LogisticPurchasePerSupplier[] = isResponseSuccess(
|
const data: LogisticPurchasePerSupplier[] = isResponseSuccess(
|
||||||
|
|||||||
Reference in New Issue
Block a user