cek all spesialis

This commit is contained in:
2023-11-15 14:18:05 +07:00
parent 643fd2b6cd
commit 0dc10587a8
4 changed files with 156 additions and 11 deletions

View File

@@ -230,9 +230,46 @@ export default function Divisions() {
}
};
const handleToggleSpecialityAll = (
event: ChangeEvent<HTMLInputElement>,
service: any,
specialityAll: boolean
) => {
console.log('Changing Service ', service, 'and', specialityAll);
try {
axios
.post(`/corporates/${corporate_id}/services/${service_code}/specialities-all`, {
active: specialityAll,
})
.then((res) => {
setService({
...service,
selected_specialities: res.data?.selected_specialities,
exclusions: res.data?.service?.exclusions,
});
// let newConfigurations = service.configurations
// newConfigurations[res.data.name] = res.data.value == true
// setService({
// ...service,
// configurations: { ...newConfigurations }
// })
enqueueSnackbar('Speciality Updated', {
variant: 'success',
});
});
} catch (error) {
console.log(error);
enqueueSnackbar('Speciality Update Failed', {
variant: 'error',
});
}
};
const [minAge, setMinAge] = useState('');
const [maxAge, setMaxAge] = useState('');
const [valuePlan, setValuePlan] = useState([]);
const [checkAll, setCheckAll] = useState(false);
const [exclusion, setExclusion] = useState([
{
@@ -263,6 +300,11 @@ export default function Divisions() {
}
};
const handleCheckAll = (event, checkAll) => {
setCheckAll(!checkAll); // Membalik nilai checkAll saat checkbox di klik
handleToggleSpecialityAll(event, service, !checkAll)
};
// const handleSubmit = (event: any, service: any, row: any) => {
// const allData = exclusion.find((item: any) => item.speciality_id === row.id);
@@ -494,7 +536,7 @@ export default function Divisions() {
<FormControlLabel
control={
<Checkbox
checked={service?.configurations?.sp_external_doctor_online == '1'}
checked={ service?.configurations?.sp_external_doctor_online == '1'}
onChange={(event) => {
handleConfigChange(event, service);
}}
@@ -662,7 +704,7 @@ export default function Divisions() {
alignItems="center"
>
<Typography id="modal-modal-title" variant="h6" color={'#FFF'} component="h2">
Specialities
Specialities Exclusion
</Typography>
<Button
sx={{ color: '#FFF' }}
@@ -680,10 +722,11 @@ export default function Divisions() {
<TableHead>
<TableRow>
<TableCell>
<Checkbox
/>
<Checkbox
onClick={(event) => handleCheckAll(event, checkAll)}
checked={checkAll} // Ini penting untuk memastikan status checkbox sesuai dengan state checkAll
content='test'
/>
</TableCell>
<TableCell sx={{ width: 10 }}>Specialitation</TableCell>
<TableCell>MSC</TableCell>
@@ -708,6 +751,7 @@ export default function Divisions() {
checked={Object.keys(service.selected_specialities).includes(
String(row.id)
)}
// checked={checkAll}
onChange={(event) => {
handleToggleSpeciality(event, service, row);
}}
@@ -725,6 +769,7 @@ export default function Divisions() {
(item: { speciality_id: any; msc: { m: string } }) =>
item.speciality_id == row.id && item.msc?.m == '1'
)}
// checked={true}
onChange={(event) => {
handleConfigExclusion(event, service, row, 'm', 'msc');
}}
@@ -739,6 +784,7 @@ export default function Divisions() {
(item: { speciality_id: any; msc: { s: string } }) =>
item.speciality_id == row.id && item.msc?.s == '1'
)}
// checked={true}
onChange={(event) => {
handleConfigExclusion(event, service, row, 's', 'msc');
}}
@@ -775,6 +821,7 @@ export default function Divisions() {
item.speciality_id == row.id &&
item.gender?.male == '1'
)}
// checked={true}
onChange={(event) => {
handleConfigExclusion(
event,