mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 07:45:47 +00:00
refactor(FE-212): update purchase types and payloads for requisition handling
This commit is contained in:
@@ -1,88 +1,12 @@
|
|||||||
import { sleep } from '@/lib/helper';
|
|
||||||
import { BaseApiService } from './base';
|
|
||||||
import { BaseApiResponse } from '@/types/api/api-general';
|
|
||||||
import {
|
import {
|
||||||
CreatePurchaseRequestPayload,
|
CreatePurchaseRequisitionsPayload,
|
||||||
Purchase,
|
Purchase,
|
||||||
UpdatePurchaseRequestPayload,
|
UpdatePurchaseRequisitionsPayload,
|
||||||
} from '@/types/api/purchase/purchase';
|
} from '@/types/api/purchase/purchase';
|
||||||
|
import { BaseApiService } from '@/services/api/base';
|
||||||
|
|
||||||
const GET_ALL_PURCHASE_DUMMY_DATA: BaseApiResponse<Purchase[]> = {
|
export const PurchaseApi = new BaseApiService<
|
||||||
code: 200,
|
|
||||||
status: 'success',
|
|
||||||
message: 'Successfully get all purchase data!',
|
|
||||||
meta: {
|
|
||||||
page: 1,
|
|
||||||
limit: 10,
|
|
||||||
total_pages: 1,
|
|
||||||
total_results: 1,
|
|
||||||
},
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
pr_number: 'PR-001',
|
|
||||||
po_number: 'PO-001',
|
|
||||||
po_date: '2024-01-15',
|
|
||||||
supplier: {
|
|
||||||
id: 1,
|
|
||||||
name: 'Supplier A',
|
|
||||||
address: '123 Main St, Cityville',
|
|
||||||
account_number: 'ACC-12345',
|
|
||||||
alias: 'SupA',
|
|
||||||
category: 'Electronics',
|
|
||||||
type: 'Local',
|
|
||||||
phone: '555-1234',
|
|
||||||
email: 'email@.com',
|
|
||||||
npwp: '12.345.678.9-012.345',
|
|
||||||
pic: 'John Doe',
|
|
||||||
balance: 1000000,
|
|
||||||
hatchery: 'N/A',
|
|
||||||
due_date: 30,
|
|
||||||
created_at: '2024-01-10T10:00:00Z',
|
|
||||||
updated_at: '2024-01-12T12:00:00Z',
|
|
||||||
created_user: {
|
|
||||||
id: 2,
|
|
||||||
id_user: 2,
|
|
||||||
email: 'a@email.com',
|
|
||||||
name: 'Admin User',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
credit_term: 30,
|
|
||||||
due_date: '2024-02-14',
|
|
||||||
grand_total: 1500000,
|
|
||||||
deleted_at: null,
|
|
||||||
created_at: '2024-01-10T10:00:00Z',
|
|
||||||
updated_at: '2024-01-12T12:00:00Z',
|
|
||||||
created_by: 2,
|
|
||||||
created_user: {
|
|
||||||
id: 2,
|
|
||||||
id_user: 2,
|
|
||||||
email: 'a@email.com',
|
|
||||||
name: 'Admin User',
|
|
||||||
},
|
|
||||||
notes: 'Urgent delivery required',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
export class PurchaseService extends BaseApiService<
|
|
||||||
Purchase,
|
Purchase,
|
||||||
CreatePurchaseRequestPayload,
|
CreatePurchaseRequisitionsPayload,
|
||||||
UpdatePurchaseRequestPayload
|
UpdatePurchaseRequisitionsPayload
|
||||||
> {
|
>('/purchases/requisitions');
|
||||||
constructor(basePath: string = '') {
|
|
||||||
super(basePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
override async getAllFetcher(
|
|
||||||
endpoint: string
|
|
||||||
): Promise<BaseApiResponse<Purchase[]>> {
|
|
||||||
// return await httpClientFetcher<BaseApiResponse<T[]>>(endpoint);
|
|
||||||
|
|
||||||
await sleep(750);
|
|
||||||
|
|
||||||
return GET_ALL_PURCHASE_DUMMY_DATA;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const PurchaseApi = new PurchaseService('/purchase-requests');
|
|
||||||
|
|||||||
Vendored
+16
-9
@@ -3,13 +3,15 @@ import { Supplier } from '@/types/api/master-data/supplier';
|
|||||||
import { Warehouse } from '@/types/api/master-data/warehouse';
|
import { Warehouse } from '@/types/api/master-data/warehouse';
|
||||||
import { Product } from '@/types/api/master-data/product';
|
import { Product } from '@/types/api/master-data/product';
|
||||||
import { ProductWarehouse } from '@/types/api/inventory/product-warehouse';
|
import { ProductWarehouse } from '@/types/api/inventory/product-warehouse';
|
||||||
|
import { Area } from '@/types/api/master-data/area';
|
||||||
|
import { Location } from '@/types/api/master-data/location';
|
||||||
|
|
||||||
export type PurchaseItem = {
|
export type PurchaseItem = {
|
||||||
id: number;
|
id: number;
|
||||||
warehouse: Warehouse;
|
warehouse: Warehouse;
|
||||||
product: Product;
|
product: Product;
|
||||||
product_warehouse: ProductWarehouse;
|
product_warehouse: ProductWarehouse;
|
||||||
sub_qty: number;
|
quantity: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type BasePurchase = {
|
export type BasePurchase = {
|
||||||
@@ -24,21 +26,26 @@ export type BasePurchase = {
|
|||||||
notes?: string | null;
|
notes?: string | null;
|
||||||
deleted_at?: string | null;
|
deleted_at?: string | null;
|
||||||
created_by: number;
|
created_by: number;
|
||||||
purchase_items?: PurchaseItem[];
|
area?: Area;
|
||||||
|
location?: Location;
|
||||||
|
warehouse?: Warehouse;
|
||||||
|
items?: PurchaseItem[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Purchase = BaseMetadata & BasePurchase;
|
export type Purchase = BaseMetadata & BasePurchase;
|
||||||
|
|
||||||
export type CreatePurchaseRequestPayload = {
|
export type CreatePurchaseRequisitionsPayload = {
|
||||||
supplier_id: number;
|
supplier_id: number;
|
||||||
credit_term: number;
|
area_id: number;
|
||||||
|
location_id: number;
|
||||||
|
warehouse_id: number;
|
||||||
notes?: string | null;
|
notes?: string | null;
|
||||||
purchase_items: {
|
items: {
|
||||||
warehouse_id: number;
|
|
||||||
product_id: number;
|
|
||||||
product_warehouse_id: number;
|
product_warehouse_id: number;
|
||||||
sub_qty: number;
|
product_id: number;
|
||||||
|
quantity: number;
|
||||||
}[];
|
}[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UpdatePurchaseRequestPayload = CreatePurchaseRequestPayload;
|
export type UpdatePurchaseRequisitionsPayload =
|
||||||
|
CreatePurchaseRequisitionsPayload;
|
||||||
|
|||||||
Reference in New Issue
Block a user