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