mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-21 22:05:45 +00:00
refactor(FE-212): add DeletePurchaseRequestItemPayload and implement PurchaseDeleteItemsService
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
CreateStaffApprovalRequestPayload,
|
||||
CreateManagerApprovalRequestPayload,
|
||||
CreateAcceptApprovalRequestPayload,
|
||||
DeletePurchaseRequestItemPayload,
|
||||
} from '@/types/api/purchase/purchase';
|
||||
import { BaseApiService } from '@/services/api/base';
|
||||
import { BaseApiResponse } from '@/types/api/api-general';
|
||||
@@ -18,18 +19,18 @@ export const PurchaseRequestApi = new BaseApiService<
|
||||
export class StaffApprovalService extends BaseApiService<
|
||||
Purchase,
|
||||
CreateStaffApprovalRequestPayload,
|
||||
CreateAcceptApprovalRequestPayload
|
||||
unknown
|
||||
> {
|
||||
constructor(basePath: string = '') {
|
||||
super(basePath);
|
||||
}
|
||||
|
||||
async createStaffApproval(
|
||||
purchaseRequisitionId: number,
|
||||
purchaseRequestId: number,
|
||||
payload: CreateStaffApprovalRequestPayload
|
||||
): Promise<BaseApiResponse<{ message: string }> | undefined> {
|
||||
return await this.customRequest<BaseApiResponse<{ message: string }>>(
|
||||
`${purchaseRequisitionId}/approvals/staff`,
|
||||
`${purchaseRequestId}/approvals/staff`,
|
||||
{
|
||||
method: 'POST',
|
||||
payload,
|
||||
@@ -48,11 +49,11 @@ export class ManagerApprovalService extends BaseApiService<
|
||||
}
|
||||
|
||||
async createManagerApproval(
|
||||
purchaseRequisitionId: number,
|
||||
purchaseRequestId: number,
|
||||
payload: CreateManagerApprovalRequestPayload
|
||||
): Promise<BaseApiResponse<{ message: string }> | undefined> {
|
||||
return await this.customRequest<BaseApiResponse<{ message: string }>>(
|
||||
`${purchaseRequisitionId}/approvals/manager`,
|
||||
`${purchaseRequestId}/approvals/manager`,
|
||||
{
|
||||
method: 'POST',
|
||||
payload,
|
||||
@@ -64,18 +65,41 @@ export class ManagerApprovalService extends BaseApiService<
|
||||
export class AcceptApprovalService extends BaseApiService<
|
||||
Purchase,
|
||||
CreateAcceptApprovalRequestPayload,
|
||||
CreateAcceptApprovalRequestPayload
|
||||
unknown
|
||||
> {
|
||||
constructor(basePath: string = '') {
|
||||
super(basePath);
|
||||
}
|
||||
|
||||
async acceptApproval(
|
||||
purchaseRequisitionId: number,
|
||||
purchaseRequestId: number,
|
||||
payload: CreateAcceptApprovalRequestPayload
|
||||
): Promise<BaseApiResponse<{ message: string }> | undefined> {
|
||||
return await this.customRequest<BaseApiResponse<{ message: string }>>(
|
||||
`${purchaseRequisitionId}/approvals/receipts`,
|
||||
`${purchaseRequestId}/approvals/receipts`,
|
||||
{
|
||||
method: 'POST',
|
||||
payload,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class PurchaseDeleteItemsService extends BaseApiService<
|
||||
Purchase,
|
||||
DeletePurchaseRequestItemPayload,
|
||||
unknown
|
||||
> {
|
||||
constructor(basePath: string = '') {
|
||||
super(basePath);
|
||||
}
|
||||
|
||||
async deleteItems(
|
||||
purchaseRequestId: number,
|
||||
payload: DeletePurchaseRequestItemPayload
|
||||
): Promise<BaseApiResponse<{ message: string }> | undefined> {
|
||||
return await this.customRequest<BaseApiResponse<{ message: string }>>(
|
||||
`${purchaseRequestId}/items`,
|
||||
{
|
||||
method: 'POST',
|
||||
payload,
|
||||
@@ -89,3 +113,7 @@ export const StaffApprovalApi = new StaffApprovalService('/purchases');
|
||||
export const ManagerApprovalApi = new ManagerApprovalService('/purchases');
|
||||
|
||||
export const AcceptApprovalApi = new AcceptApprovalService('/purchases');
|
||||
|
||||
export const PurchaseDeleteItemsApi = new PurchaseDeleteItemsService(
|
||||
'/purchases'
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user