diff --git a/frontend/dashboard/src/pages/CustomerService/FinalLog/Detail.tsx b/frontend/dashboard/src/pages/CustomerService/FinalLog/Detail.tsx index f6af3b8b..821e9c3d 100644 --- a/frontend/dashboard/src/pages/CustomerService/FinalLog/Detail.tsx +++ b/frontend/dashboard/src/pages/CustomerService/FinalLog/Detail.tsx @@ -86,6 +86,77 @@ import { format } from 'date-fns'; export default function Detail() { + //dari hospital portal + const [dischargeDate, setDischargeDate] = useState(format(new Date(), "yyyy MMM d HH:mm:ss")); + const [serviceOptions, setServiceOptions] = useState([ + { value: '-', label: '-' } +]); +const [specialisOptions, setSpecialisOptions] = useState([ + { value: '-', label: '-' } +]); +useEffect(() => { + axios.get('service-member/'+1) + .then((response) => { + setServiceOptions(response.data); + }).catch((error) => { + console.error('Error fetching ICD options:', error); + }); + + axios.get('specialis') + .then((response) => { + setSpecialisOptions(response.data); + }).catch((error) => { + console.error('Error fetching ICD options:', error); + }); + + }, []); +const [serviceCode, setServiceCode] = useState(""); +const [idSpecialities, setIdSpecialities] = useState(""); +const [inputDppj, setInputDppj] = useState(""); +function submitRequestFinalLog() { + if(dischargeDate == '') + { + enqueueSnackbar('Tanggal Keluar', { variant: 'warning' }); + return false; + } + //cek spesialis + if(!idSpecialities) + { + enqueueSnackbar('Spesialis', { variant: 'warning' }); + return false; + } + //cek dpjp + if(!inputDppj) + { + enqueueSnackbar('DPPJ', { variant: 'warning' }); + return false; + } + setSubmitLoading(true); + const formData = makeFormData({ + // request_logs_id: member.id, + // result_files: fileHasilPenunjangs, + // diagnosa_files: fileDiagnosas, + // kondisi_files: fileKondisis, + discharge_date: fPostFormat(dischargeDate, 'yyyy-MM-dd HH:mm:ss'), + service_code: serviceCode, + spescialis_id: idSpecialities, + dppj: inputDppj, + }); + axios + .post('/request-final-log', formData) + .then((response) => { + enqueueSnackbar(response.data.meta.message ?? 'Berhasil membuat data', { variant: 'success' }); + // handleSubmitSuccess(); + // onClose({ someData: 'example data' }, getData); + }) + .catch(({ response }) => { + enqueueSnackbar(response.data.meta.message ?? 'Something Went Wrong', { variant: 'error' }); + }) + .then(() => { + setSubmitLoading(false); + }); + } +//end dari hospital portal const location = useLocation(); @@ -553,17 +624,17 @@ function submitRequestFinalLog() { Tipe Service o.label} - isOptionEqualToValue={(o, v) => o.value === v.value} - onChange={(_, v) => setServiceCode(v?.value ?? '')} + getOptionLabel={(option) => option.label || ""} + value={serviceOptions.find((opt) => opt.value == serviceCode) || null} + onChange={(event, newValue) => { + setServiceCode(newValue?.value || ""); + }} renderInput={(params) => ( - + )} - /> - - + /> diff --git a/frontend/hospital-portal/src/sections/dashboard/DetailRequestFinalLog.tsx b/frontend/hospital-portal/src/sections/dashboard/DetailRequestFinalLog.tsx index 9647505f..5075a24d 100644 --- a/frontend/hospital-portal/src/sections/dashboard/DetailRequestFinalLog.tsx +++ b/frontend/hospital-portal/src/sections/dashboard/DetailRequestFinalLog.tsx @@ -296,10 +296,10 @@ export default function DetailRequestFinalLog() { >([]) useEffect(() => { - if (!requestLog?.id_member) return + if (!requestLog?.id && !Log_id) return axios - .get('service-member/' + (requestLog?.id_member ?? null)) + .get('service-member/' + (requestLog?.id ?? Log_id)) .then((res) => setServiceOptions(res.data)) .catch(console.error) @@ -307,7 +307,7 @@ export default function DetailRequestFinalLog() { .get('specialis') .then((res) => setSpecialisOptions(res.data)) .catch(console.error) - }, [requestLog?.id_member]) + }, [requestLog?.id, Log_id]) const [serviceCode, setServiceCode] = useState('')