mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 23:35:45 +00:00
feat(FE-208,212): implement PurchaseService for fetching purchase request data with dummy response
This commit is contained in:
@@ -0,0 +1,88 @@
|
|||||||
|
import { sleep } from '@/lib/helper';
|
||||||
|
import { BaseApiService } from './base';
|
||||||
|
import { BaseApiResponse } from '@/types/api/api-general';
|
||||||
|
import {
|
||||||
|
CreatePurchaseRequestPayload,
|
||||||
|
Purchase,
|
||||||
|
UpdatePurchaseRequestPayload,
|
||||||
|
} from '@/types/api/purchase/purchase';
|
||||||
|
|
||||||
|
const GET_ALL_PURCHASE_DUMMY_DATA: BaseApiResponse<Purchase[]> = {
|
||||||
|
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,
|
||||||
|
CreatePurchaseRequestPayload,
|
||||||
|
UpdatePurchaseRequestPayload
|
||||||
|
> {
|
||||||
|
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');
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import { BaseApiService } from './base';
|
|
||||||
import {
|
|
||||||
CreatePurchaseRequestPayload,
|
|
||||||
Purchase,
|
|
||||||
UpdatePurchaseRequestPayload,
|
|
||||||
} from '@/types/api/purchase/purchase';
|
|
||||||
|
|
||||||
export const PurchaseApi = new BaseApiService<
|
|
||||||
Purchase,
|
|
||||||
CreatePurchaseRequestPayload,
|
|
||||||
UpdatePurchaseRequestPayload
|
|
||||||
>('/purchase-requests');
|
|
||||||
Reference in New Issue
Block a user