mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +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 =====
|
||||
const { data: purchasePerSupplier, isLoading } = useSWR(
|
||||
() =>
|
||||
LogisticApi.getLogisticStockReport(
|
||||
tableFilterState.area_id ? Number(tableFilterState.area_id) : undefined,
|
||||
tableFilterState.supplier_id
|
||||
() => {
|
||||
const params = {
|
||||
area_id: tableFilterState.area_id
|
||||
? Number(tableFilterState.area_id)
|
||||
: undefined,
|
||||
supplier_id: tableFilterState.supplier_id
|
||||
? Number(tableFilterState.supplier_id)
|
||||
: undefined,
|
||||
tableFilterState.product_id
|
||||
product_id: tableFilterState.product_id
|
||||
? Number(tableFilterState.product_id)
|
||||
: undefined,
|
||||
tableFilterState.received_date || undefined,
|
||||
tableFilterState.po_date || undefined,
|
||||
tableFilterState.start_date || undefined,
|
||||
tableFilterState.end_date || undefined
|
||||
),
|
||||
{
|
||||
revalidateOnFocus: false,
|
||||
}
|
||||
received_date: tableFilterState.received_date || undefined,
|
||||
po_date: tableFilterState.po_date || undefined,
|
||||
start_date: tableFilterState.start_date || undefined,
|
||||
end_date: tableFilterState.end_date || undefined,
|
||||
};
|
||||
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user