mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE-212): simplify PurchaseRequestService to a constant API instance
This commit is contained in:
@@ -9,45 +9,11 @@ import {
|
||||
import { BaseApiService } from '@/services/api/base';
|
||||
import { BaseApiResponse } from '@/types/api/api-general';
|
||||
|
||||
export class PurchaseRequestService extends BaseApiService<
|
||||
export const PurchaseRequestApi = new BaseApiService<
|
||||
Purchase,
|
||||
CreatePurchaseRequestPayload,
|
||||
UpdatePurchaseRequestPayload
|
||||
> {
|
||||
constructor(basePath: string = '/purchases') {
|
||||
super(basePath);
|
||||
}
|
||||
|
||||
async approve(
|
||||
idOrIds: number | number[],
|
||||
notes?: string
|
||||
): Promise<BaseApiResponse<Purchase[]> | undefined> {
|
||||
const approvable_ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
|
||||
return await this.customRequest<BaseApiResponse<Purchase[]>>('approvals', {
|
||||
method: 'POST',
|
||||
payload: {
|
||||
action: 'APPROVED',
|
||||
approvable_ids,
|
||||
notes,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async reject(
|
||||
idOrIds: number | number[],
|
||||
notes: string = 'Rejected via Form'
|
||||
): Promise<BaseApiResponse<Purchase[]> | undefined> {
|
||||
const approvable_ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
|
||||
return await this.customRequest<BaseApiResponse<Purchase[]>>('approvals', {
|
||||
method: 'POST',
|
||||
payload: {
|
||||
action: 'REJECTED',
|
||||
approvable_ids,
|
||||
notes,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
>('/purchases');
|
||||
|
||||
export class StaffApprovalService extends BaseApiService<
|
||||
Purchase,
|
||||
@@ -118,8 +84,6 @@ export class AcceptApprovalService extends BaseApiService<
|
||||
}
|
||||
}
|
||||
|
||||
export const PurchaseRequestApi = new PurchaseRequestService();
|
||||
|
||||
export const StaffApprovalApi = new StaffApprovalService('/purchases');
|
||||
|
||||
export const ManagerApprovalApi = new ManagerApprovalService('/purchases');
|
||||
|
||||
Reference in New Issue
Block a user