add detailuser file

This commit is contained in:
2025-10-09 22:53:06 +07:00
parent 25e31c58bd
commit 823492a381
2 changed files with 543 additions and 56 deletions

View File

@@ -13,6 +13,7 @@ import { NotifAlert, NotifOk, NotifConfirmDialog } from '../../../components/Glo
import { useNavigate } from 'react-router-dom';
import { deleteUser, getAllUser, approveUser } from '../../../api/user';
import TableList from '../../../components/Global/TableList';
import Swal from 'sweetalert2';
const columns = (showPreviewModal, showEditModal, showDeleteDialog, showApproveDialog) => [
{
@@ -42,71 +43,74 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog, showApproveD
},
{
title: 'Level',
dataIndex: 'level',
key: 'level',
dataIndex: 'role_level',
key: 'role_level',
width: '8%',
align: 'center',
render: (role_level) => role_level || '-',
},
{
title: 'Nama Role',
dataIndex: 'role_name',
key: 'role_name',
width: '12%',
render: (_, { role_name }) => (
<>
{role_name === 'administrator' && (
<Tag color={'purple'} key={'role'}>
Administrator
</Tag>
)}
{role_name === 'operator' && (
<Tag color={'blue'} key={'role'}>
Operator
</Tag>
)}
{role_name === 'engineer' && (
<Tag color={'cyan'} key={'role'}>
Engineer
</Tag>
)}
{role_name === 'guest' && (
<Tag color={'default'} key={'role'}>
Guest
</Tag>
)}
</>
),
render: (_, { role_name }) => {
if (!role_name) return <Tag color={'default'}>Belum Ada Role</Tag>;
return (
<>
{role_name === 'administrator' && (
<Tag color={'purple'} key={'role'}>
Administrator
</Tag>
)}
{role_name === 'operator' && (
<Tag color={'blue'} key={'role'}>
Operator
</Tag>
)}
{role_name === 'engineer' && (
<Tag color={'cyan'} key={'role'}>
Engineer
</Tag>
)}
{role_name === 'guest' && (
<Tag color={'default'} key={'role'}>
Guest
</Tag>
)}
</>
);
},
},
{
title: 'Status',
dataIndex: 'status',
key: 'status',
title: 'Status Approval',
dataIndex: 'is_approve',
key: 'is_approve',
width: '10%',
align: 'center',
render: (_, { status }) => (
<>
{status === 'active' && (
render: (_, { is_approve, is_active }) => {
// Status approval
if (is_approve === false || is_approve === 0) {
return (
<Tag color={'orange'} key={'status'}>
Pending Approval
</Tag>
);
}
// Jika sudah approve, cek active/inactive
if (is_active === true || is_active === 1) {
return (
<Tag color={'green'} key={'status'}>
Active
</Tag>
)}
{status === 'pending' && (
<Tag color={'orange'} key={'status'}>
Pending
</Tag>
)}
{status === 'inactive' && (
<Tag color={'default'} key={'status'}>
Inactive
</Tag>
)}
{status === 'rejected' && (
<Tag color={'red'} key={'status'}>
Rejected
</Tag>
)}
</>
),
);
}
return (
<Tag color={'default'} key={'status'}>
Inactive
</Tag>
);
},
},
{
title: 'Aksi',
@@ -121,7 +125,7 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog, showApproveD
icon={<EyeOutlined style={{ color: '#1890ff' }} />}
onClick={() => showPreviewModal(record)}
/>
{record.status === 'pending' && (
{(record.is_approve === false || record.is_approve === 0) && (
<Button
type="text"
style={{ borderColor: '#52c41a' }}
@@ -203,12 +207,22 @@ const ListUser = memo(function ListUser(props) {
};
const showApproveDialog = (param) => {
NotifConfirmDialog({
Swal.fire({
icon: 'question',
title: 'Konfirmasi Approve User',
message: 'Apakah anda yakin approve user "' + param.fullname + '" ?',
onConfirm: () => handleApprove(param.user_id),
onCancel: () => props.setSelectedData(null),
text: 'Apakah anda yakin approve user "' + param.user_fullname + '" ?',
showCancelButton: true,
cancelButtonColor: '#d33',
cancelButtonText: 'Batal',
confirmButtonColor: '#23A55A',
confirmButtonText: 'Approve',
reverseButtons: true,
}).then((result) => {
if (result.isConfirmed) {
handleApprove(param.user_id);
} else if (result.dismiss) {
props.setSelectedData(null);
}
});
};
@@ -216,7 +230,7 @@ const ListUser = memo(function ListUser(props) {
NotifConfirmDialog({
icon: 'question',
title: 'Konfirmasi',
message: 'Apakah anda yakin hapus user "' + param.fullname + '" ?',
message: 'Apakah anda yakin hapus user "' + param.user_fullname + '" ?',
onConfirm: () => handleDelete(param.user_id),
onCancel: () => props.setSelectedData(null),
});
@@ -340,6 +354,7 @@ const ListUser = memo(function ListUser(props) {
</Col>
</Row>
</Card>
</React.Fragment>
);
});