Update
This commit is contained in:
@@ -30,11 +30,18 @@ import MuiDialog from '@/components/MuiDialog';
|
||||
import DialogMember from '@/sections/dashboard/DialogMember';
|
||||
import DialogClaimSubmit from '@/sections/dashboard/DialogClaimSubmit';
|
||||
import { fPostFormat } from '@/utils/formatTime';
|
||||
import useAuth from '@/hooks/useAuth';
|
||||
|
||||
export default function TableList() {
|
||||
const navigate = useNavigate();
|
||||
const { localeData }: any = useContext(LanguageContext);
|
||||
|
||||
const {user} = useAuth();
|
||||
const formattedRoleName = user?.role.name;
|
||||
// List of statuses for 'apotek'
|
||||
const allowedStatusesForApotek = ['waiting_pharmacy', 'order_prepared'];
|
||||
const allowedStatusesForCSLMS = ['waiting_pharmacy', 'order_prepared', 'ready', 'waiting_for_courir', 'package_picked_up', 'package_on_delivery', 'failed'];
|
||||
|
||||
const [data, setData] = useState([]);
|
||||
|
||||
// Download Resep
|
||||
@@ -288,6 +295,13 @@ export default function TableList() {
|
||||
label: localeData.txtStatus,
|
||||
isSort: true,
|
||||
},
|
||||
// Conditionally include button_accept if the role is 'admin-apotek'
|
||||
...(formattedRoleName === 'admin-apotek' ? [{
|
||||
id: 'button_accept',
|
||||
align: 'left',
|
||||
label: localeData.txtConfirmation,
|
||||
isSort: false,
|
||||
}] : []),
|
||||
{
|
||||
id: 'action',
|
||||
align: 'right',
|
||||
@@ -301,6 +315,7 @@ export default function TableList() {
|
||||
getData();
|
||||
}, [appliedParams, searchParams, order, orderBy, setSearchParams]);
|
||||
const [openRowId, setOpenRowId] = useState<number | null>(null);
|
||||
const [dialogIDRow, setDialogIDRow] = useState<number | null>(null);
|
||||
function getData()
|
||||
{
|
||||
(async () => {
|
||||
@@ -372,6 +387,18 @@ export default function TableList() {
|
||||
{obj.valid_tanggal ? fDateTime(obj.valid_tanggal) : ''}
|
||||
</Label>
|
||||
,
|
||||
...(formattedRoleName === 'admin-apotek' && obj.button_accept && {
|
||||
button_accept: (
|
||||
<Button
|
||||
variant="contained"
|
||||
color="primary"
|
||||
style={{ width: 'auto' }}
|
||||
onClick={() => setDialogIDRow(obj.id === dialogIDRow ? null : obj.id)}
|
||||
>
|
||||
{obj.button_accept}
|
||||
</Button>
|
||||
),
|
||||
}),
|
||||
action:
|
||||
<TableMoreMenu actions={
|
||||
<>
|
||||
@@ -433,6 +460,8 @@ export default function TableList() {
|
||||
// filterEndDate={filterEndDate}
|
||||
openRowId={openRowId} // Pass the currently opened row ID
|
||||
setOpenRowId={setOpenRowId} // Pass the function to set the opened row ID
|
||||
dialogIDRow={dialogIDRow}
|
||||
setDialogIDRow={setDialogIDRow}
|
||||
reloadData={getData}
|
||||
/>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user