refactor(FE): Add Status Approval column to PurchaseTable

This commit is contained in:
rstubryan
2026-01-26 13:37:06 +07:00
parent 2a03eae8a2
commit afb0c40fd2
@@ -16,6 +16,7 @@ import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import Badge from '@/components/Badge';
import { cn, formatDate } from '@/lib/helper';
import { isResponseSuccess } from '@/lib/api-helper';
@@ -153,6 +154,57 @@ const PurchaseTable = () => {
return `${diffDays} hari`;
},
},
{
header: 'Status Approval',
cell: (props) => {
const approval = props.row.original.latest_approval;
if (!approval) return '-';
const isRejected = approval.action === 'REJECTED';
let statusColor:
| 'warning'
| 'success'
| 'neutral'
| 'error'
| 'primary'
| 'info' = 'neutral';
switch (approval.step_number) {
case 1:
statusColor = 'neutral';
break;
case 2:
statusColor = 'primary';
break;
case 3:
statusColor = 'info';
break;
case 4:
statusColor = 'warning';
break;
case 5:
statusColor = 'success';
break;
}
if (isRejected) {
statusColor = 'error';
}
return (
<Badge
variant='soft'
color={statusColor}
className={{
badge: 'whitespace-nowrap',
}}
>
{isRejected ? 'Ditolak' : approval.step_name}
</Badge>
);
},
},
{
header: 'Aksi',
cell: (props) => {