refactor(FE-363): Replace LogisticService with LogisticApi instance

This commit is contained in:
rstubryan
2025-12-13 11:51:41 +07:00
parent fdb3e0481a
commit fd2e1f8b96
2 changed files with 22 additions and 46 deletions
@@ -10,7 +10,7 @@ import DateInput from '@/components/input/DateInput';
import { AreaApi } from '@/services/api/master-data';
import { SupplierApi } from '@/services/api/master-data';
import { ProductApi } from '@/services/api/master-data';
import { LogisticService } from '@/services/api/logistic';
import { LogisticApi } from '@/services/api/logistic';
import Table from '@/components/Table';
import { ColumnDef } from '@tanstack/react-table';
import { formatCurrency, formatDate } from '@/lib/helper';
@@ -38,11 +38,7 @@ const PurchasesPerSupplierTab = () => {
);
// ===== TABLE FILTER STATE =====
const {
state: tableFilterState,
updateFilter,
toQueryString: getTableFilterQueryString,
} = useTableFilter({
const { state: tableFilterState, updateFilter } = useTableFilter({
initial: {
area_id: '',
supplier_id: '',
@@ -158,8 +154,23 @@ const PurchasesPerSupplierTab = () => {
// ===== DATA FETCHING =====
const { data: purchasePerSupplier, isLoading } = useSWR(
`${LogisticService.basePath}/purchase-supplier${getTableFilterQueryString()}`,
LogisticService.getAllFetcher
() =>
LogisticApi.getLogisticStockReport(
tableFilterState.area_id ? Number(tableFilterState.area_id) : undefined,
tableFilterState.supplier_id
? Number(tableFilterState.supplier_id)
: undefined,
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,
}
);
const data: LogisticPurchasePerSupplier[] = isResponseSuccess(