refactor(FE): Add Unit VP approval and rename Manager

This commit is contained in:
rstubryan
2026-01-12 11:11:11 +07:00
parent 2b2dd0a026
commit ec16c6c47e
4 changed files with 239 additions and 47 deletions
+116 -8
View File
@@ -169,13 +169,13 @@ export class ExpenseApiService extends BaseApiService<
}
}
async approveManager(
async approveHeadArea(
id: number,
notes?: string
): Promise<BaseApiResponse<Expense> | undefined> {
try {
const approveRes = await httpClient<BaseApiResponse<Expense>>(
`${this.basePath}/approvals/manager`,
`${this.basePath}/approvals/head-area`,
{
method: 'POST',
body: {
@@ -196,13 +196,67 @@ export class ExpenseApiService extends BaseApiService<
}
}
async bulkApproveManager(
async bulkApproveHeadArea(
ids: number[],
notes?: string
): Promise<BaseApiResponse<Expense> | undefined> {
try {
const bulkApproveRes = await httpClient<BaseApiResponse<Expense>>(
`${this.basePath}/approvals/manager`,
`${this.basePath}/approvals/head-area`,
{
method: 'POST',
body: {
action: 'APPROVED',
approvable_ids: ids,
notes: notes,
},
}
);
return bulkApproveRes;
} catch (error) {
if (axios.isAxiosError<BaseApiResponse<Expense>>(error)) {
return error.response?.data;
}
return undefined;
}
}
async approveUnitVicePresident(
id: number,
notes?: string
): Promise<BaseApiResponse<Expense> | undefined> {
try {
const approveRes = await httpClient<BaseApiResponse<Expense>>(
`${this.basePath}/approvals/unit-vice-president`,
{
method: 'POST',
body: {
action: 'APPROVED',
approvable_ids: [id],
notes: notes,
},
}
);
return approveRes;
} catch (error) {
if (axios.isAxiosError<BaseApiResponse<Expense>>(error)) {
return error.response?.data;
}
return undefined;
}
}
async bulkApproveUnitVicePresident(
ids: number[],
notes?: string
): Promise<BaseApiResponse<Expense> | undefined> {
try {
const bulkApproveRes = await httpClient<BaseApiResponse<Expense>>(
`${this.basePath}/approvals/unit-vice-president`,
{
method: 'POST',
body: {
@@ -277,13 +331,13 @@ export class ExpenseApiService extends BaseApiService<
}
}
async rejectManager(
async rejectHeadArea(
id: number,
notes?: string
): Promise<BaseApiResponse<Expense> | undefined> {
try {
const rejectRes = await httpClient<BaseApiResponse<Expense>>(
`${this.basePath}/approvals/manager`,
`${this.basePath}/approvals/head-area`,
{
method: 'POST',
body: {
@@ -304,13 +358,67 @@ export class ExpenseApiService extends BaseApiService<
}
}
async bulkRejectManager(
async bulkRejectHeadArea(
ids: number[],
notes?: string
): Promise<BaseApiResponse<Expense> | undefined> {
try {
const bulkRejectRes = await httpClient<BaseApiResponse<Expense>>(
`${this.basePath}/approvals/manager`,
`${this.basePath}/approvals/head-area`,
{
method: 'POST',
body: {
action: 'REJECTED',
approvable_ids: ids,
notes: notes,
},
}
);
return bulkRejectRes;
} catch (error) {
if (axios.isAxiosError<BaseApiResponse<Expense>>(error)) {
return error.response?.data;
}
return undefined;
}
}
async rejectUnitVicePresident(
id: number,
notes?: string
): Promise<BaseApiResponse<Expense> | undefined> {
try {
const rejectRes = await httpClient<BaseApiResponse<Expense>>(
`${this.basePath}/approvals/unit-vice-president`,
{
method: 'POST',
body: {
action: 'REJECTED',
approvable_ids: [id],
notes: notes,
},
}
);
return rejectRes;
} catch (error) {
if (axios.isAxiosError<BaseApiResponse<Expense>>(error)) {
return error.response?.data;
}
return undefined;
}
}
async bulkRejectUnitVicePresident(
ids: number[],
notes?: string
): Promise<BaseApiResponse<Expense> | undefined> {
try {
const bulkRejectRes = await httpClient<BaseApiResponse<Expense>>(
`${this.basePath}/approvals/unit-vice-president`,
{
method: 'POST',
body: {