mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-23 23:05:46 +00:00
refactor(FE): Add Unit VP approval and rename Manager
This commit is contained in:
@@ -59,34 +59,40 @@ const ExpenseRequestContent = ({
|
||||
|
||||
const isLatestApprovalRejectedOrDone =
|
||||
isLatestApprovalRejected ||
|
||||
initialValues?.latest_approval.step_number === 5;
|
||||
initialValues?.latest_approval.step_number === 6;
|
||||
|
||||
const isCurrentApprovalOnManager =
|
||||
const isCurrentApprovalOnHeadArea =
|
||||
!isLatestApprovalRejected &&
|
||||
initialValues?.latest_approval.step_number === 1;
|
||||
|
||||
const isCurrentApprovalOnFinance =
|
||||
const isCurrentApprovalOnUnitVicePresident =
|
||||
!isLatestApprovalRejected &&
|
||||
initialValues?.latest_approval.step_number === 2;
|
||||
|
||||
const isCurrentApprovalOnFinance =
|
||||
!isLatestApprovalRejected &&
|
||||
initialValues?.latest_approval.step_number === 3;
|
||||
|
||||
const isCurrentApprovalOnRealization =
|
||||
!isLatestApprovalRejected &&
|
||||
initialValues?.latest_approval.step_number === 4;
|
||||
initialValues?.latest_approval.step_number === 5;
|
||||
|
||||
const showEditButton =
|
||||
initialValues?.latest_approval.step_number !== 5 &&
|
||||
initialValues?.latest_approval.step_number !== 6 &&
|
||||
(initialValues?.latest_approval.step_number === 1 ||
|
||||
initialValues?.latest_approval.step_number === 2 ||
|
||||
initialValues?.latest_approval.step_number === 3);
|
||||
initialValues?.latest_approval.step_number === 3 ||
|
||||
initialValues?.latest_approval.step_number === 4);
|
||||
|
||||
const showRejectButton =
|
||||
!isLatestApprovalRejected &&
|
||||
(initialValues?.latest_approval.step_number === 1 ||
|
||||
initialValues?.latest_approval.step_number === 2);
|
||||
initialValues?.latest_approval.step_number === 2 ||
|
||||
initialValues?.latest_approval.step_number === 3);
|
||||
|
||||
const isExpenseCanBeRealized =
|
||||
!isLatestApprovalRejected &&
|
||||
initialValues?.latest_approval.step_number === 3;
|
||||
initialValues?.latest_approval.step_number === 4;
|
||||
|
||||
// Modal hooks
|
||||
const deleteModal = useModal();
|
||||
@@ -174,8 +180,15 @@ const ExpenseRequestContent = ({
|
||||
|
||||
let approveResponse: BaseApiResponse<Expense> | undefined = undefined;
|
||||
|
||||
if (isCurrentApprovalOnManager) {
|
||||
approveResponse = await ExpenseApi.approveManager(
|
||||
if (isCurrentApprovalOnHeadArea) {
|
||||
approveResponse = await ExpenseApi.approveHeadArea(
|
||||
initialValues.id,
|
||||
notes
|
||||
);
|
||||
}
|
||||
|
||||
if (isCurrentApprovalOnUnitVicePresident) {
|
||||
approveResponse = await ExpenseApi.approveUnitVicePresident(
|
||||
initialValues.id,
|
||||
notes
|
||||
);
|
||||
@@ -207,8 +220,15 @@ const ExpenseRequestContent = ({
|
||||
|
||||
let rejectResponse: BaseApiResponse<Expense> | undefined = undefined;
|
||||
|
||||
if (isCurrentApprovalOnManager) {
|
||||
rejectResponse = await ExpenseApi.rejectManager(initialValues.id, notes);
|
||||
if (isCurrentApprovalOnHeadArea) {
|
||||
rejectResponse = await ExpenseApi.rejectHeadArea(initialValues.id, notes);
|
||||
}
|
||||
|
||||
if (isCurrentApprovalOnUnitVicePresident) {
|
||||
rejectResponse = await ExpenseApi.rejectUnitVicePresident(
|
||||
initialValues.id,
|
||||
notes
|
||||
);
|
||||
}
|
||||
|
||||
if (isCurrentApprovalOnFinance) {
|
||||
@@ -255,8 +275,8 @@ const ExpenseRequestContent = ({
|
||||
{/* TODO: apply RBAC */}
|
||||
|
||||
<div className='w-full max-w-5xl mx-auto flex flex-col sm:flex-row justify-end gap-2'>
|
||||
{isCurrentApprovalOnManager && (
|
||||
<RequirePermission permissions='lti.expense.approve.manager'>
|
||||
{isCurrentApprovalOnHeadArea && (
|
||||
<RequirePermission permissions='lti.expense.approve.head_area'>
|
||||
<Button
|
||||
variant='outline'
|
||||
color='info'
|
||||
@@ -264,7 +284,21 @@ const ExpenseRequestContent = ({
|
||||
className='w-full sm:w-fit'
|
||||
>
|
||||
<Icon icon='lucide-lab:farm' width={24} height={24} />
|
||||
Approve Manager
|
||||
Approve Head Area
|
||||
</Button>
|
||||
</RequirePermission>
|
||||
)}
|
||||
|
||||
{isCurrentApprovalOnUnitVicePresident && (
|
||||
<RequirePermission permissions='lti.expense.approve.unit_vice_president'>
|
||||
<Button
|
||||
variant='outline'
|
||||
color='success'
|
||||
onClick={approveClickHandler}
|
||||
className='w-full sm:w-fit'
|
||||
>
|
||||
<Icon icon='tdesign:money' width={24} height={24} />
|
||||
Approve Unit Vice President
|
||||
</Button>
|
||||
</RequirePermission>
|
||||
)}
|
||||
@@ -304,7 +338,8 @@ const ExpenseRequestContent = ({
|
||||
{showRejectButton && (
|
||||
<RequirePermission
|
||||
permissions={[
|
||||
'lti.expense.approve.manager',
|
||||
'lti.expense.approve.head_area',
|
||||
'lti.expense.approve.unit_vice_president',
|
||||
'lti.expense.approve.finance',
|
||||
]}
|
||||
>
|
||||
@@ -454,8 +489,8 @@ const ExpenseRequestContent = ({
|
||||
<th>:</th>
|
||||
<td>
|
||||
{formatCurrency(
|
||||
initialValues?.latest_approval.step_number === 4 ||
|
||||
initialValues?.latest_approval.step_number === 5
|
||||
initialValues?.latest_approval.step_number === 5 ||
|
||||
initialValues?.latest_approval.step_number === 6
|
||||
? (initialValues?.total_realisasi ?? 0)
|
||||
: (initialValues?.total_pengajuan ?? 0)
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user