From e430c446fd85d62a7af1ae8196f498f65ff25f7b Mon Sep 17 00:00:00 2001 From: ivan-sim Date: Tue, 15 Oct 2024 08:30:27 +0700 Subject: [PATCH] Update --- .../Http/Controllers/ApotekController.php | 24 ++- .../hospital-portal/src/components/Table.tsx | 180 +++++++++--------- frontend/hospital-portal/src/lang/id-ID.json | 8 +- .../sections/dashboardApotek/TableList.tsx | 29 +++ 4 files changed, 143 insertions(+), 98 deletions(-) diff --git a/Modules/HospitalPortal/Http/Controllers/ApotekController.php b/Modules/HospitalPortal/Http/Controllers/ApotekController.php index ae464599..822d178d 100644 --- a/Modules/HospitalPortal/Http/Controllers/ApotekController.php +++ b/Modules/HospitalPortal/Http/Controllers/ApotekController.php @@ -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() diff --git a/frontend/hospital-portal/src/components/Table.tsx b/frontend/hospital-portal/src/components/Table.tsx index 99aa7d91..b6f3875a 100755 --- a/frontend/hospital-portal/src/components/Table.tsx +++ b/frontend/hospital-portal/src/components/Table.tsx @@ -94,6 +94,8 @@ export default function Table({ selected, openRowId, // Receive the currently opened row ID setOpenRowId, // Receive the function to set the opened row ID + dialogIDRow, + setDialogIDRow, reloadData, }: TableListProps) { /* ------------------------------- handle sort ------------------------------ */ @@ -249,7 +251,8 @@ const allowedStatusesForCSLMS = ['waiting_pharmacy', 'order_prepared', 'ready', const [openDialogStatus, setOpenDialogStatus] = useState(false); - const [dialogIDRow, setDialogIDRow] = useState(null); +// const [dialogIDRow, setDialogIDRow] = useState(null); +console.log(dialogIDRow); const [dialogIDRowDriver, setDialogIDRowDriver] = useState(null); const [txtStatusDriver, setTxtStatusDriver] = useState(''); const [txtIDDriver, setTxtIDDriver] = useState(''); @@ -565,11 +568,87 @@ const allowedStatusesForCSLMS = ['waiting_pharmacy', 'order_prepared', 'ready', ))} + {/* Dialog Update Status */} + + + + + {localeData.txtConfirmation} + + setDialogIDRow(row.id === dialogIDRow ? null : row.id)}> + + + + + + + {localeData.txtDialogConfirmation} + + + {localeData.txtNomorResep} + {row.no_resep} + + + {localeData.txtTanggalTerbitResep} + {row.tanggal} + + + + + + + + + {/* Modal for fullscreen display */} + handleClose(row)}> + + {loading ? ( + <> + + + {localeData.txtFindingDriver} + + + ) : ( + <> + Info! + + {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.` + )} + + + + + + )} + + {/* COLLAPSIBLE ROW */} - + {/* Icon inside a Box for spacing and alignment */} @@ -724,12 +803,17 @@ const allowedStatusesForCSLMS = ['waiting_pharmacy', 'order_prepared', 'ready', {row.pengiriman} - - {localeData.txtTotal} : - - - {row.total_kirim} - + {formattedRoleName === 'cs-lms' ? ( + <> + + {localeData.txtTotal} : + + + {row.total_kirim} + + + ):''} + @@ -842,7 +926,7 @@ const allowedStatusesForCSLMS = ['waiting_pharmacy', 'order_prepared', 'ready', {localeData.txtButtonClose} {/* 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) ? ( @@ -851,87 +935,13 @@ const allowedStatusesForCSLMS = ['waiting_pharmacy', 'order_prepared', 'ready', - ) : ''} + ) : ''} */} - {/* Dialog Update Status */} - - - - - {localeData.txtConfirmation} - - setDialogIDRow(row.id === dialogIDRow ? null : row.id)}> - - - - - - - {localeData.txtDialogConfirmation} - - - {localeData.txtNomorResep} - {row.no_resep} - - - {localeData.txtTanggalTerbitResep} - {row.tanggal} - - - - - - - - - {/* Modal for fullscreen display */} - handleClose(row)}> - - {loading ? ( - <> - - - {localeData.txtFindingDriver} - - - ) : ( - <> - Info! - - {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 */} - - - - - )} - - diff --git a/frontend/hospital-portal/src/lang/id-ID.json b/frontend/hospital-portal/src/lang/id-ID.json index 956c82fa..7db6d659 100755 --- a/frontend/hospital-portal/src/lang/id-ID.json +++ b/frontend/hospital-portal/src/lang/id-ID.json @@ -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...", diff --git a/frontend/hospital-portal/src/sections/dashboardApotek/TableList.tsx b/frontend/hospital-portal/src/sections/dashboardApotek/TableList.tsx index 87027d83..328c76c9 100644 --- a/frontend/hospital-portal/src/sections/dashboardApotek/TableList.tsx +++ b/frontend/hospital-portal/src/sections/dashboardApotek/TableList.tsx @@ -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(null); + const [dialogIDRow, setDialogIDRow] = useState(null); function getData() { (async () => { @@ -372,6 +387,18 @@ export default function TableList() { {obj.valid_tanggal ? fDateTime(obj.valid_tanggal) : ''} , + ...(formattedRoleName === 'admin-apotek' && obj.button_accept && { + button_accept: ( + + ), + }), action: @@ -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} />