Merge remote-tracking branch 'origin/staging' into origin/production

This commit is contained in:
Server D3 Linksehat
2024-10-16 08:37:01 +07:00
6 changed files with 159 additions and 103 deletions

View File

@@ -71,8 +71,8 @@ class ApotekController extends Controller
WHEN tx_prescription_orders.sStatus = "order_prepared" THEN "Siap Diambil"
WHEN tx_prescription_orders.sStatus = "ready" THEN "Cari Kurir"
WHEN tx_prescription_orders.sStatus = "failed" THEN "Cari Kurir"
WHEN tx_prescription_orders.sStatus = "waiting_for_courir" THEN "Kurir Sudah Ambil Pesanan"
WHEN tx_prescription_orders.sStatus = "package_picked_up" THEN "Sedang diantar ke Alamat Tujuan"
WHEN tx_prescription_orders.sStatus = "waiting_for_courir" THEN "Pesanan Diambil"
WHEN tx_prescription_orders.sStatus = "package_picked_up" THEN "Sedang Diantar"
WHEN tx_prescription_orders.sStatus = "package_on_delivery" THEN "Selesai"
ELSE ""
END AS button_accept'),
@@ -189,7 +189,7 @@ class ApotekController extends Controller
'),
'tx_prescription_orders.sAddress AS alamat_penerima',
'tx_prescription_orders.sDeliveryMethod AS pengiriman',
'tx_prescription_orders.sDeliveryPrice AS total_kirim',
'tx_prescription_orders.nTotalPrice AS total_kirim',
'tx_prescriptions.sNoRefProvider AS noref_dokter',
DB::raw('DATE_ADD(tx_prescriptions.dTanggalResep, INTERVAL 1 DAY) as valid_tanggal'),
'tx_prescriptions.sNomorPenjamin AS nomor_penjamin',
@@ -479,7 +479,12 @@ class ApotekController extends Controller
$apotek = DB::connection('mysql')->table('organizations')
->leftJoin('addresses', 'addresses.id', '=', 'organizations.main_address_id')
->where('organizations.id', '=', $prescriptions->nIDApotek)
->select('organizations.name as nama_apotek', 'addresses.text as alamat_apotek', 'addresses.lat', 'addresses.lng')
->select('organizations.name as nama_apotek',
'addresses.text as alamat_apotek',
'addresses.lat',
'addresses.lng',
'organizations.phone',
'organizations.email')
->first();
// Fetch patient (pasien) data
@@ -500,6 +505,7 @@ class ApotekController extends Controller
'tm_users.sPhone as phone',
'tm_users_detail.sLatitude as latitude',
'tm_users_detail.sLongitude as longitude',
'tm_users_detail.sAlamatMap',
DB::raw('(SELECT tm_provinsi.sProvinsi FROM tm_provinsi WHERE tm_provinsi.nID = tm_users_detail.nIDProvinsi LIMIT 1) AS provinsi'),
DB::raw('(SELECT tm_kota.sKota FROM tm_kota WHERE tm_kota.nID = tm_users_detail.nIDKota LIMIT 1) AS kota'),
DB::raw('(SELECT tm_kecamatan.sKecamatan FROM tm_kecamatan WHERE tm_kecamatan.nID = tm_users_detail.nIDKecamatan LIMIT 1) AS kecamatan'),
@@ -542,7 +548,7 @@ class ApotekController extends Controller
]
],
"destination" => [
"address" => "{$pasien->provinsi}, {$pasien->kota}, {$pasien->kecamatan}, {$pasien->kelurahan}, {$pasien->kode_pos}",
"address" => $pasien->sAlamatMap,
"coordinates" => [
"latitude" => (float)$pasien->latitude,
"longitude" => (float)$pasien->longitude
@@ -556,10 +562,10 @@ class ApotekController extends Controller
"smsEnabled" => true
],
"sender" => [
"firstName" => env('SENDER_NAME_GRAB'),
"companyName" => env('SENDER_COMPANY_NAME_GRAB'),
"email" => env('SENDER_EMAIL_GRAB'),
"phone" => env('SENDER_PHONE_GRAB'),
"firstName" => $apotek->nama_apotek,
"companyName" => $apotek->nama_apotek,
"email" => $apotek->email,
"phone" => $apotek->phone,
"smsEnabled" => true
],
"schedule" => $grabHelper->getScheduleTimes()

View File

@@ -93,6 +93,8 @@ class PermissionTableSeeder extends Seeder
'file-billing-client-portal',
'file-diagnosis-client-portal',
'file-pendukung-medis-client-portal',
'export-alarm-center-client-portal',
'filter-alarm-center-client-portal',
'benefit-client-portal',
]
],

View File

@@ -19,12 +19,21 @@ import { enqueueSnackbar } from 'notistack';
import Label from '../../components/Label';
import { Stack } from '@mui/material';
import { Download } from '@mui/icons-material';
import useAuth from '../../hooks/useAuth';
/* -------------------------------------------------------------------------- */
export default function List() {
const {user} = useAuth();
const checkIfNameExists = (name) => {
return user.user.permissions.some(item => item.name === name);
};
const exportLog = 'export-alarm-center-client-portal';
const filterLog = 'filter-alarm-center-client-portal';
const navigate = useNavigate();
const viewExportCheck = checkIfNameExists(exportLog);
const viewFilterCheck = checkIfNameExists(filterLog);
const { corporateValue } = useContext(UserCurrentCorporateContext);
const [data, setData] = useState([]);
@@ -168,7 +177,7 @@ export default function List() {
};
const filterStartDate = {
useFilter: true,
useFilter: viewFilterCheck ? true : false,
startDate: startDateValue,
setStartDate: setStartDateValue,
handleStartDateChange: handleStartDateChanges,
@@ -190,7 +199,7 @@ export default function List() {
};
const filterEndDate = {
useFilter: true,
useFilter: viewFilterCheck ? true : false,
endDate: endDateValue,
setEndDate: setEndDateValue,
handleEndDateChange: handleEndDateChanges,
@@ -225,7 +234,7 @@ export default function List() {
);
};
const exportReport = {
useExport: true,
useExport: viewExportCheck ? true : false,
startDate: startDateValue,
endDate: endDateValue,
status: statusValue,

View File

@@ -94,6 +94,8 @@ export default function Table<T>({
selected,
openRowId, // Receive the currently opened row ID
setOpenRowId, // Receive the function to set the opened row ID
dialogIDRow,
setDialogIDRow,
reloadData,
}: TableListProps<T>) {
/* ------------------------------- handle sort ------------------------------ */
@@ -249,7 +251,7 @@ const allowedStatusesForCSLMS = ['waiting_pharmacy', 'order_prepared', 'ready',
const [openDialogStatus, setOpenDialogStatus] = useState(false);
const [dialogIDRow, setDialogIDRow] = useState<number | null>(null);
// const [dialogIDRow, setDialogIDRow] = useState<number | null>(null);
const [dialogIDRowDriver, setDialogIDRowDriver] = useState<number | null>(null);
const [txtStatusDriver, setTxtStatusDriver] = useState('');
const [txtIDDriver, setTxtIDDriver] = useState('');
@@ -269,7 +271,7 @@ const allowedStatusesForCSLMS = ['waiting_pharmacy', 'order_prepared', 'ready',
const handleClickKonfirmasi = (row: any) => {
setTxtStatusDriver('');
setTxtIDDriver('');
if(row.sStatus === 'ready' || row.sStatus === 'failed')
if(row.sStatus === 'order_prepared' || row.sStatus === 'ready' || row.sStatus === 'failed')
{
//close
setDialogIDRow(row.id === dialogIDRow ? null : row.id);
@@ -311,6 +313,8 @@ const allowedStatusesForCSLMS = ['waiting_pharmacy', 'order_prepared', 'ready',
}
}
const putPrescriptionOrders = (row: any) => {
//close
setDialogIDRow(row.id === dialogIDRow ? null : row.id);
setIsDisabled(true); // Disable button after clicking
const updateData = {
sStatus: row.sStatus
@@ -319,7 +323,6 @@ const allowedStatusesForCSLMS = ['waiting_pharmacy', 'order_prepared', 'ready',
.put(`/put-prescription-orders/${row.nID_orders}`, updateData)
.then((response) => {
enqueueSnackbar(response?.data?.meta?.message, { variant: 'success' });
setDialogIDRow(row.id === dialogIDRow ? null : row.id);
setIsDisabled(false); // Re-enable the button after success
// Call reloadData to refresh the table
@@ -565,11 +568,87 @@ const allowedStatusesForCSLMS = ['waiting_pharmacy', 'order_prepared', 'ready',
</TableCell>
))}
</TableRow>
{/* Dialog Update Status */}
<Dialog open={dialogIDRow === row.id} fullWidth={true}>
<DialogTitle sx={{ backgroundColor: '#19BBBB', color: '#FFF', padding: 2 }}>
<Stack direction="row" alignItems="center" justifyContent="space-between">
<Stack direction="row" alignItems='center' spacing={1}>
<Typography variant="h6">{localeData.txtConfirmation}</Typography>
</Stack>
<IconButton sx={{ color: '#FFF' }} onClick={() => setDialogIDRow(row.id === dialogIDRow ? null : row.id)}>
<CloseIcon />
</IconButton>
</Stack>
</DialogTitle>
<DialogContent>
<Stack spacing={2} padding={2}>
<Typography variant='body1'>{localeData.txtDialogConfirmation}</Typography>
<Card sx={{padding:2}} >
<Stack direction='row' spacing={2}>
<Typography variant='subtitle2' sx={{color: '#919EAB', width: '50%'}}>{localeData.txtNomorResep}</Typography>
<Typography variant='subtitle2' sx={{width: '50%'}}>{row.no_resep}</Typography>
</Stack>
<Stack direction='row' spacing={2}>
<Typography variant='subtitle2' sx={{color: '#919EAB', width: '50%'}}>{localeData.txtTanggalTerbitResep}</Typography>
<Typography variant='subtitle2' sx={{width: '50%'}}>{row.tanggal}</Typography>
</Stack>
</Card>
</Stack>
</DialogContent>
<DialogActions>
<Button sx={{backgroundColor: '#19BBBB'}} variant="contained" onClick={() => handleClickKonfirmasi(row)} disabled={isDisabled}>{localeData.txtOK}</Button>
</DialogActions>
</Dialog>
{/* Modal for fullscreen display */}
<Modal open={dialogIDRowDriver === row.id} onClose={() => handleClose(row)}>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
height: '100vh',
// backgroundColor: 'rgba(0, 0, 0, 0.8)', // semi-transparent background
color: '#fff',
textAlign: 'center',
}}
>
{loading ? (
<>
<CircularProgress color="inherit" />
<Typography variant="h6" sx={{ mt: 2 }}>
{localeData.txtFindingDriver}
</Typography>
</>
) : (
<>
<Typography variant="h4">Info!</Typography>
<Typography variant="h6" sx={{ mt: 2 }}>
{txtIDDriver ? (
`${localeData.txtDriverFound} ${txtIDDriver} status ${txtStatusDriver}.`
) : (
// You can add an alternative UI or message here, or leave it empty
`Failed to get driver, please check the message info.`
)}
</Typography>
<Button
sx={{ mt: 4, backgroundColor: '#19BBBB' }}
variant="contained"
onClick={() => handleClose(row)}
>
{localeData.txtOK}
</Button>
</>
)}
</Box>
</Modal>
{/* COLLAPSIBLE ROW */}
<TableRow
sx={{ cursor: 'pointer' }} // Use pointer cursor always, or conditionally based on your preference
>
<TableCell colSpan={6}>
<TableCell colSpan={7}>
<Collapse in={openRowId === row.id} timeout="auto" unmountOnExit>
<Card sx={{padding:2}}>
{/* Icon inside a Box for spacing and alignment */}
@@ -724,12 +803,17 @@ const allowedStatusesForCSLMS = ['waiting_pharmacy', 'order_prepared', 'ready',
<Grid item xs={6}>
<Typography variant="body2"><strong>{row.pengiriman}</strong></Typography>
</Grid>
<Grid item xs={6}>
<Typography variant="body2">{localeData.txtTotal} :</Typography>
</Grid>
<Grid item xs={6}>
<Typography variant="body2"><strong>{row.total_kirim}</strong></Typography>
</Grid>
{formattedRoleName === 'cs-lms' ? (
<>
<Grid item xs={6}>
<Typography variant="body2">{localeData.txtTotal} :</Typography>
</Grid>
<Grid item xs={6}>
<Typography variant="body2"><strong>{row.total_kirim}</strong></Typography>
</Grid>
</>
):''}
</Grid>
</Grid>
@@ -842,7 +926,7 @@ const allowedStatusesForCSLMS = ['waiting_pharmacy', 'order_prepared', 'ready',
{localeData.txtButtonClose}
</Button>
{/* Accept Button on the Right */}
{row.button_accept && formattedRoleName === 'admin-apotek' && allowedStatusesForApotek.includes(row.sStatus) ? (
{/* {row.button_accept && formattedRoleName === 'admin-apotek' && allowedStatusesForApotek.includes(row.sStatus) ? (
<Button variant="contained" color="primary" onClick={() => setDialogIDRow(row.id === dialogIDRow ? null : row.id)}>
{row.button_accept}
</Button>
@@ -851,87 +935,13 @@ const allowedStatusesForCSLMS = ['waiting_pharmacy', 'order_prepared', 'ready',
<Button variant="contained" color="primary" onClick={() => setDialogIDRow(row.id === dialogIDRow ? null : row.id)}>
{row.button_accept}
</Button>
) : ''}
) : ''} */}
</Box>
{/* Dialog Update Status */}
<Dialog open={dialogIDRow === row.id} fullWidth={true}>
<DialogTitle sx={{ backgroundColor: '#19BBBB', color: '#FFF', padding: 2 }}>
<Stack direction="row" alignItems="center" justifyContent="space-between">
<Stack direction="row" alignItems='center' spacing={1}>
<Typography variant="h6">{localeData.txtConfirmation}</Typography>
</Stack>
<IconButton sx={{ color: '#FFF' }} onClick={() => setDialogIDRow(row.id === dialogIDRow ? null : row.id)}>
<CloseIcon />
</IconButton>
</Stack>
</DialogTitle>
<DialogContent>
<Stack spacing={2} padding={2}>
<Typography variant='body1'>{localeData.txtDialogConfirmation}</Typography>
<Card sx={{padding:2}} >
<Stack direction='row' spacing={2}>
<Typography variant='subtitle2' sx={{color: '#919EAB', width: '50%'}}>{localeData.txtNomorResep}</Typography>
<Typography variant='subtitle2' sx={{width: '50%'}}>{row.no_resep}</Typography>
</Stack>
<Stack direction='row' spacing={2}>
<Typography variant='subtitle2' sx={{color: '#919EAB', width: '50%'}}>{localeData.txtTanggalTerbitResep}</Typography>
<Typography variant='subtitle2' sx={{width: '50%'}}>{row.tanggal}</Typography>
</Stack>
</Card>
</Stack>
</DialogContent>
<DialogActions>
<Button sx={{backgroundColor: '#19BBBB'}} variant="contained" onClick={() => handleClickKonfirmasi(row)} disabled={isDisabled}>{localeData.txtOK}</Button>
</DialogActions>
</Dialog>
{/* Modal for fullscreen display */}
<Modal open={dialogIDRowDriver === row.id} onClose={() => handleClose(row)}>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
height: '100vh',
// backgroundColor: 'rgba(0, 0, 0, 0.8)', // semi-transparent background
color: '#fff',
textAlign: 'center',
}}
>
{loading ? (
<>
<CircularProgress color="inherit" />
<Typography variant="h6" sx={{ mt: 2 }}>
{localeData.txtFindingDriver}
</Typography>
</>
) : (
<>
<Typography variant="h4">Info!</Typography>
<Typography variant="h6" sx={{ mt: 2 }}>
{txtIDDriver ? (
`${localeData.txtDriverFound} ${txtIDDriver} status ${txtStatusDriver}.`
) : (
// You can add an alternative UI or message here, or leave it empty
`Failed to get driver, please check the message info.`
)}
{/* Dialog Update Status confirmation */}
</Typography>
<Button
sx={{ mt: 4, backgroundColor: '#19BBBB' }}
variant="contained"
onClick={() => handleClose(row)}
>
{localeData.txtOK}
</Button>
</>
)}
</Box>
</Modal>
</Card>
</Collapse>
</TableCell>

View File

@@ -125,11 +125,11 @@
"txtTinggi" : "Tinggi / Berat",
"txtLabelNew": "Baru",
"txtLabelAccepted": "Diterima Apotek",
"txtLabelReady": "Pesanan Siap Diambil",
"txtLabelReady": "Siap Diambil",
"txtLabelWaitingCourir": "Menunggu Kurir",
"txtLabelPackagePickedUp": "Paket Sudah Diambil",
"txtLabelPackageOnDelivery": "Sedang Diantar ke Alamat Tujuan",
"txtLabelPackageDelivered": "Sudah diterima Pasien",
"txtLabelPackagePickedUp": "Sudah Diambil",
"txtLabelPackageOnDelivery": "Sedang Diantar",
"txtLabelPackageDelivered": "Diterima Pasien",
"txtLabelWaitingForPayment": "Menunggu Pembayaran",
"txtOK": "Ya",
"txtFindingDriver" : "Sedang mencari driver...",

View File

@@ -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', padding: '0px 4px'}}
onClick={() => setDialogIDRow(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}
/>
</>