update handle reject & is_active

This commit is contained in:
2025-10-16 11:30:00 +07:00
parent 77a89489cd
commit 172e14e77d
3 changed files with 84 additions and 27 deletions

View File

@@ -115,18 +115,10 @@ const columns = (
align: 'center',
render: (_, record) => {
// is_approve: 0 = Rejected, 1 = Pending, 2 = Approved
if (record.is_approve === 1) {
if (record.is_approve === 1 || record.is_approve === '1') {
// Pending - show both Approve and Reject buttons
return (
<Space size="small">
<Button
danger
size="small"
icon={<CloseOutlined />}
onClick={() => showRejectDialog(record)}
>
Reject
</Button>
<Space size="small" direction="vertical">
<Button
type="primary"
size="small"
@@ -135,35 +127,38 @@ const columns = (
style={{
backgroundColor: '#52c41a',
borderColor: '#52c41a',
width: '100%',
}}
>
Approve
</Button>
<Button
danger
size="small"
icon={<CloseOutlined />}
onClick={() => showRejectDialog(record)}
style={{ width: '100%' }}
>
Reject
</Button>
</Space>
);
} else if (record.is_approve === 0) {
} else if (record.is_approve === 0 || record.is_approve === '0') {
// Rejected
return (
<Tag color={'red'} key={'status'}>
Rejected
</Tag>
);
} else if (record.is_approve === 2) {
// Approved - check active/inactive status
if (record.is_active === true || record.is_active === 1) {
return (
<Tag color={'green'} key={'status'}>
Active
</Tag>
);
}
} else if (record.is_approve === 2 || record.is_approve === '2' || record.is_approve === true) {
// Approved
return (
<Tag color={'default'} key={'status'}>
Inactive
<Tag color={'green'} key={'status'}>
Approved
</Tag>
);
}
// Default fallback
// Default fallback (for false/null which means pending in old system)
return (
<Tag color={'orange'} key={'status'}>
Pending
@@ -171,6 +166,31 @@ const columns = (
);
},
},
{
title: 'Status Active',
dataIndex: 'is_active',
key: 'is_active',
width: '10%',
align: 'center',
render: (_, record) => {
// Only show active status if user is approved
if (record.is_approve === 2 || record.is_approve === '2' || record.is_approve === true) {
if (record.is_active === true || record.is_active === 1) {
return (
<Tag color={'green'} key={'active'}>
Active
</Tag>
);
}
return (
<Tag color={'default'} key={'inactive'}>
Inactive
</Tag>
);
}
return <span>-</span>;
},
},
{
title: 'Aksi',
key: 'aksi',
@@ -325,6 +345,24 @@ const ListUser = memo(function ListUser(props) {
}
};
const handleReject = async (user_id) => {
const response = await rejectUser(user_id);
if (response.statusCode == 200) {
NotifAlert({
icon: 'success',
title: 'Berhasil',
message: 'User berhasil direject.',
});
doFilter();
} else {
NotifOk({
icon: 'error',
title: 'Gagal',
message: 'Gagal Reject User',
});
}
};
const handleDelete = async (user_id, user_fullname) => {
const response = await deleteUser(user_id);
@@ -418,7 +456,8 @@ const ListUser = memo(function ListUser(props) {
showPreviewModal,
showEditModal,
showDeleteDialog,
showApproveDialog
showApproveDialog,
showRejectDialog
)}
triger={trigerFilter}
/>