add edit provider prime center
This commit is contained in:
@@ -49,6 +49,8 @@ import { LoadingButton } from '@mui/lab';
|
||||
import { makeFormData } from '@/utils/jsonToFormData';
|
||||
import TextField from '@mui/material/TextField';
|
||||
import { fPostFormat } from '@/utils/formatTime';
|
||||
import { parse } from 'date-fns';
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -86,16 +88,29 @@ import { format } from 'date-fns';
|
||||
|
||||
export default function Detail() {
|
||||
//dari hospital portal
|
||||
const [dischargeDate, setDischargeDate] = useState<string>(format(new Date(), "yyyy MMM d HH:mm:ss"));
|
||||
const [serviceOptions, setServiceOptions] = useState([
|
||||
{ value: '-', label: '-' }
|
||||
]);
|
||||
const [specialisOptions, setSpecialisOptions] = useState([
|
||||
{ value: '-', label: '-' }
|
||||
]);
|
||||
// const [dischargeDate, setDischargeDate] = useState<string>(format(new Date(), "yyyy MMM d HH:mm:ss"));
|
||||
const [dischargeDate, setDischargeDate] = useState<Date | null>(null)
|
||||
|
||||
|
||||
// const [serviceOptions, setServiceOptions] = useState([
|
||||
// { value: '-', label: '-' }
|
||||
// ]);
|
||||
// const [specialisOptions, setSpecialisOptions] = useState([
|
||||
// { value: '-', label: '-' }
|
||||
// ]);
|
||||
|
||||
const [serviceOptions, setServiceOptions] = useState<
|
||||
{ value: string; label: string }[]
|
||||
>([])
|
||||
|
||||
const [specialisOptions, setSpecialisOptions] = useState<
|
||||
{ value: number; label: string }[]
|
||||
>([])
|
||||
const [serviceCode, setServiceCode] = useState<string>("");
|
||||
const [idSpecialities, setIdSpecialities] = useState("");
|
||||
const [idSpecialities, setIdSpecialities] = useState<number | null>(null)
|
||||
|
||||
const [inputDppj, setInputDppj] = useState("");
|
||||
const [requestLog, setRequestLog] = useState<DetailFinalLogType>();
|
||||
function submitRequestFinalLog() {
|
||||
if(dischargeDate == '')
|
||||
{
|
||||
@@ -120,6 +135,7 @@ function submitRequestFinalLog() {
|
||||
// result_files: fileHasilPenunjangs,
|
||||
// diagnosa_files: fileDiagnosas,
|
||||
// kondisi_files: fileKondisis,
|
||||
request_logs_id: requestLog?.id,
|
||||
discharge_date: fPostFormat(dischargeDate, 'yyyy-MM-dd HH:mm:ss'),
|
||||
service_code: serviceCode,
|
||||
spescialis_id: idSpecialities,
|
||||
@@ -147,7 +163,7 @@ function submitRequestFinalLog() {
|
||||
|
||||
const navigate = useNavigate();
|
||||
const { themeStretch } = useSettings();
|
||||
const [requestLog, setRequestLog] = useState<DetailFinalLogType>();
|
||||
|
||||
const [isReversal, setIsReversal] = useState(false);
|
||||
const [submitLoading, setSubmitLoading] = useState(false);
|
||||
|
||||
@@ -337,6 +353,40 @@ function submitRequestFinalLog() {
|
||||
);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (requestLog?.discharge_date) {
|
||||
setDischargeDate(
|
||||
parse(
|
||||
requestLog.discharge_date,
|
||||
'yyyy-MM-dd HH:mm:ss',
|
||||
new Date()
|
||||
)
|
||||
)
|
||||
}
|
||||
}, [requestLog?.discharge_date])
|
||||
useEffect(() => {
|
||||
if (!requestLog) return
|
||||
setServiceCode(requestLog.service_code ?? '')
|
||||
setIdSpecialities(requestLog.specialitiesID ?? null)
|
||||
setInputDppj(requestLog.dppj ?? '')
|
||||
}, [requestLog])
|
||||
const selectedService = useMemo(
|
||||
() =>
|
||||
serviceOptions.find(
|
||||
(o) => String(o.value) === String(serviceCode)
|
||||
) || null,
|
||||
[serviceOptions, serviceCode]
|
||||
)
|
||||
console.log(serviceOptions);
|
||||
console.log(serviceCode);
|
||||
const selectedSpecialis = useMemo(
|
||||
() =>
|
||||
specialisOptions.find(
|
||||
(o) => Number(o.value) === Number(idSpecialities)
|
||||
) || null,
|
||||
[specialisOptions, idSpecialities]
|
||||
)
|
||||
|
||||
return (
|
||||
<Page title='Detail'>
|
||||
<Container maxWidth={themeStretch ? false : 'xl'}>
|
||||
@@ -354,7 +404,7 @@ function submitRequestFinalLog() {
|
||||
Detail
|
||||
</Typography>
|
||||
</Grid>
|
||||
{requestLog?.status_final_log != 'requested' ? (
|
||||
{requestLog?.status_final_log != 'approved' ? (
|
||||
<Grid item xs={6} sx={{ display: 'flex', placeContent: 'end' }}>
|
||||
<MoreMenu
|
||||
actions={
|
||||
@@ -531,7 +581,7 @@ function submitRequestFinalLog() {
|
||||
{/* Kolom Service Type */}
|
||||
<Stack spacing={2} sx={{ flex: 1 }}>
|
||||
<Typography variant="subtitle1">Tipe Service </Typography>
|
||||
<Autocomplete
|
||||
{/* <Autocomplete
|
||||
id="service_type"
|
||||
options={serviceOptions}
|
||||
getOptionLabel={(option) => option.label || ""}
|
||||
@@ -542,7 +592,17 @@ function submitRequestFinalLog() {
|
||||
renderInput={(params) => (
|
||||
<TextField {...params} label='Tipe Service' fullWidth />
|
||||
)}
|
||||
/>
|
||||
/> */}
|
||||
<Autocomplete
|
||||
options={serviceOptions}
|
||||
value={selectedService}
|
||||
getOptionLabel={(o) => o.label}
|
||||
isOptionEqualToValue={(o, v) => o.value === v.value}
|
||||
onChange={(_, v) => setServiceCode(v?.value ?? '')}
|
||||
renderInput={(params) => (
|
||||
<TextField {...params} label="Tipe Service" fullWidth />
|
||||
)}
|
||||
/>
|
||||
<FormHelperText style={{ color: "red" }}></FormHelperText>
|
||||
</Stack>
|
||||
</Stack>
|
||||
@@ -551,7 +611,7 @@ function submitRequestFinalLog() {
|
||||
<Stack direction="row" spacing={2}>
|
||||
<Stack spacing={2} sx={{ width: '100%' }}>
|
||||
<Typography variant='subtitle1'>Spesialis </Typography>
|
||||
<Autocomplete
|
||||
{/* <Autocomplete
|
||||
id='specialities'
|
||||
options={specialisOptions}
|
||||
getOptionLabel={(option) => option.label || ''}
|
||||
@@ -562,6 +622,16 @@ function submitRequestFinalLog() {
|
||||
renderInput={(params) => (
|
||||
<TextField {...params} label="Spesialis" fullWidth />
|
||||
)}
|
||||
/> */}
|
||||
<Autocomplete
|
||||
options={specialisOptions}
|
||||
value={selectedSpecialis}
|
||||
getOptionLabel={(o) => o.label}
|
||||
isOptionEqualToValue={(o, v) => o.value === v.value}
|
||||
onChange={(_, v) => setIdSpecialities(v?.value ?? null)}
|
||||
renderInput={(params) => (
|
||||
<TextField {...params} label="Spesialis" fullWidth />
|
||||
)}
|
||||
/>
|
||||
<FormHelperText style={{ color: 'red' }}></FormHelperText>
|
||||
</Stack>
|
||||
|
||||
Reference in New Issue
Block a user