update
This commit is contained in:
@@ -229,15 +229,6 @@ export default function AppointmentForm({ isEdit, id, currentAppointment }: Prop
|
||||
// Autocomplite unit
|
||||
const [unitOptions, setUnitsOptions] = useState([]);
|
||||
const [selectedUnitsOptions, setSelectedUnitsOptions] = useState({});
|
||||
|
||||
const handleAutocompleteChangeUnit = (newValue, index) => {
|
||||
setSelectedUnitsOptions((prevState) => ({
|
||||
...prevState,
|
||||
[index]: newValue
|
||||
}));
|
||||
setValue(`medicine.${index}.unit_id`, newValue ? newValue.value : '');
|
||||
};
|
||||
|
||||
// Ambil data dari API dan atur opsi rumah sakit
|
||||
useEffect(() => {
|
||||
axios.get('units')
|
||||
@@ -248,6 +239,15 @@ export default function AppointmentForm({ isEdit, id, currentAppointment }: Prop
|
||||
console.error('Error fetching unit options:', error);
|
||||
});
|
||||
}, []); // useEffect dijalankan hanya sekali saat komponen dimount
|
||||
|
||||
|
||||
const handleAutocompleteChangeUnit = (newValue, index) => {
|
||||
setSelectedUnitsOptions((prevState) => ({
|
||||
...prevState,
|
||||
[index]: newValue
|
||||
}));
|
||||
setValue(`medicine.${index}.unit_id`, newValue ? newValue.value : '');
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (defaultValues.medicine.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user