mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE): Use StatusBadge instead of PillBadge
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import PillBadge from '@/components/PillBadge';
|
import StatusBadge from '@/components/helper/StatusBadge';
|
||||||
|
|
||||||
import { BaseApproval } from '@/types/api/api-general';
|
import { BaseApproval } from '@/types/api/api-general';
|
||||||
|
import { Color } from '@/types/theme';
|
||||||
|
|
||||||
interface ExpenseStatusBadgeProps {
|
interface ExpenseStatusBadgeProps {
|
||||||
approval?: BaseApproval;
|
approval?: BaseApproval;
|
||||||
@@ -11,49 +12,45 @@ const ExpenseStatusBadge = ({ approval }: ExpenseStatusBadgeProps) => {
|
|||||||
|
|
||||||
const latestApprovalStepNumber = approval?.step_number;
|
const latestApprovalStepNumber = approval?.step_number;
|
||||||
|
|
||||||
let expenseStatusPillBadgeColor:
|
let expenseStatusBadgeColor: Color = 'neutral';
|
||||||
| 'yellow'
|
|
||||||
| 'green'
|
|
||||||
| 'gray'
|
|
||||||
| 'red'
|
|
||||||
| 'purple'
|
|
||||||
| 'blue' = 'gray';
|
|
||||||
|
|
||||||
switch (latestApprovalStepNumber) {
|
switch (latestApprovalStepNumber) {
|
||||||
case 1:
|
case 1:
|
||||||
expenseStatusPillBadgeColor = 'gray';
|
expenseStatusBadgeColor = 'neutral';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
expenseStatusPillBadgeColor = 'purple';
|
expenseStatusBadgeColor = 'info';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
expenseStatusPillBadgeColor = 'blue';
|
expenseStatusBadgeColor = 'warning';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
expenseStatusPillBadgeColor = 'yellow';
|
expenseStatusBadgeColor = 'error';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
expenseStatusPillBadgeColor = 'green';
|
expenseStatusBadgeColor = 'success';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
expenseStatusPillBadgeColor = 'green';
|
expenseStatusBadgeColor = 'success';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLatestApprovalRejected) {
|
if (isLatestApprovalRejected) {
|
||||||
expenseStatusPillBadgeColor = 'red';
|
expenseStatusBadgeColor = 'error';
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PillBadge
|
<StatusBadge
|
||||||
content={isLatestApprovalRejected ? 'Ditolak' : approval?.step_name}
|
color={expenseStatusBadgeColor}
|
||||||
color={expenseStatusPillBadgeColor}
|
text={isLatestApprovalRejected ? 'Ditolak' : (approval?.step_name ?? '')}
|
||||||
className='text-xs'
|
className={{
|
||||||
|
badge: 'w-fit',
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import PillBadge from '@/components/PillBadge';
|
import StatusBadge from '@/components/helper/StatusBadge';
|
||||||
|
|
||||||
import { BaseApproval } from '@/types/api/api-general';
|
import { BaseApproval } from '@/types/api/api-general';
|
||||||
|
import { Color } from '@/types/theme';
|
||||||
|
|
||||||
interface RealizationStatusBadgeProps {
|
interface RealizationStatusBadgeProps {
|
||||||
approval?: BaseApproval;
|
approval?: BaseApproval;
|
||||||
@@ -15,23 +16,21 @@ const RealizationStatusBadge = ({ approval }: RealizationStatusBadgeProps) => {
|
|||||||
? 'Sudah Realisasi'
|
? 'Sudah Realisasi'
|
||||||
: 'Belum Realisasi';
|
: 'Belum Realisasi';
|
||||||
|
|
||||||
let realizationStatusPillBadgeColor:
|
let realizationStatusBadgeColor: Color = isExpenseRealized
|
||||||
| 'yellow'
|
? 'success'
|
||||||
| 'green'
|
: 'warning';
|
||||||
| 'gray'
|
|
||||||
| 'red'
|
|
||||||
| 'purple'
|
|
||||||
| 'blue' = isExpenseRealized ? 'green' : 'yellow';
|
|
||||||
|
|
||||||
if (isLatestApprovalRejected) {
|
if (isLatestApprovalRejected) {
|
||||||
realizationStatusPillBadgeColor = 'red';
|
realizationStatusBadgeColor = 'error';
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PillBadge
|
<StatusBadge
|
||||||
content={isLatestApprovalRejected ? 'Ditolak' : realizationStatus}
|
color={realizationStatusBadgeColor}
|
||||||
color={realizationStatusPillBadgeColor}
|
text={isLatestApprovalRejected ? 'Ditolak' : realizationStatus}
|
||||||
className='text-xs'
|
className={{
|
||||||
|
badge: 'w-fit',
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user