mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 05:22:02 +00:00
fix: bulkApprovals method
This commit is contained in:
@@ -351,6 +351,47 @@ export class ExpenseApiService extends BaseApiService<
|
||||
}
|
||||
}
|
||||
|
||||
async bulkApprovals(
|
||||
ids: number[],
|
||||
status:
|
||||
| BulkApproveExpensePayload['status']
|
||||
| 'SELESAI',
|
||||
date?: string,
|
||||
notes?: string
|
||||
): Promise<BaseApiResponse<Expense | Expense[]> | undefined> {
|
||||
if (status === 'SELESAI') {
|
||||
const responses = await Promise.all(ids.map((id) => this.complete(id)));
|
||||
const failedResponse = responses.find(
|
||||
(response) => response?.status !== 'success'
|
||||
);
|
||||
|
||||
if (failedResponse) {
|
||||
return failedResponse;
|
||||
}
|
||||
|
||||
const completedExpenses = responses.flatMap((response) =>
|
||||
response?.status === 'success' ? [response.data] : []
|
||||
);
|
||||
|
||||
return {
|
||||
code: 200,
|
||||
status: 'success',
|
||||
message:
|
||||
completedExpenses.length === 1
|
||||
? 'Submit expense approval successfully'
|
||||
: 'Submit expense approvals successfully',
|
||||
data: completedExpenses,
|
||||
};
|
||||
}
|
||||
|
||||
return this.bulkApproveToStatus({
|
||||
approvable_ids: ids,
|
||||
status,
|
||||
date: date || undefined,
|
||||
notes: notes || undefined,
|
||||
});
|
||||
}
|
||||
|
||||
async rejectHeadArea(
|
||||
id: number,
|
||||
notes?: string
|
||||
|
||||
Reference in New Issue
Block a user