From 67b5187d39a4e858bd4ccf704f3fec6f53d6439d Mon Sep 17 00:00:00 2001 From: rstubryan Date: Thu, 11 Dec 2025 15:47:21 +0700 Subject: [PATCH] feat(FE-363): Add Logistic API service and update types --- src/services/api/logistic.ts | 40 ++++++++++++++++++++++++ src/types/api/report/logistic-stock.d.ts | 6 ++-- 2 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 src/services/api/logistic.ts diff --git a/src/services/api/logistic.ts b/src/services/api/logistic.ts new file mode 100644 index 00000000..41c25135 --- /dev/null +++ b/src/services/api/logistic.ts @@ -0,0 +1,40 @@ +import { BaseApiService } from '@/services/api/base'; +import { BaseApiResponse } from '@/types/api/api-general'; +import { LogisticPurchasePerSupplierReport } from '@/types/api/report/logistic-stock'; + +export class LogisticApi extends BaseApiService< + LogisticPurchasePerSupplierReport, + unknown, + unknown +> { + constructor(basePath: string = '') { + super(basePath); + } + + async getLogisticStockReport( + area_id?: number, + supplier_id?: number, + product_id?: number, + received_date?: string, + po_date?: string, + start_date?: string, + end_date?: string + ): Promise | undefined> { + return await this.customRequest< + BaseApiResponse + >(`purchase-supplier`, { + method: 'GET', + params: { + area_id: area_id, + supplier_id: supplier_id, + product_id: product_id, + received_date: received_date, + po_date: po_date, + start_date: start_date, + end_date: end_date, + }, + }); + } +} + +export const LogisticService = new LogisticApi('/reports'); diff --git a/src/types/api/report/logistic-stock.d.ts b/src/types/api/report/logistic-stock.d.ts index c8f0f391..27193186 100644 --- a/src/types/api/report/logistic-stock.d.ts +++ b/src/types/api/report/logistic-stock.d.ts @@ -3,7 +3,7 @@ import { Supplier } from '@/types/api/supplier/supplier'; import { Product } from '@/types/api/product/product'; import { Area } from '@types/api/area/area'; -export type LogisticStockItems = { +export type LogisticPurchasePerSupplierItems = { id: number; received_date: string; po_date: string; @@ -20,11 +20,11 @@ export type LogisticStockItems = { travel_number: string; }; -export type BaseLogisticStockReport = { +export type BaseLogisticPurchasePerSupplierReport = { id: number; supplier: Supplier; items: LogisticStockItems[]; }; -export type LogisticStockReportResponse = BaseMetadata & +export type LogisticPurchasePerSupplierReport = BaseMetadata & BaseLogisticStockReport;