diff --git a/frontend/dashboard/src/pages/EPrescription/Livechat/View.tsx b/frontend/dashboard/src/pages/EPrescription/Livechat/View.tsx index bc9dc607..f18e66d8 100644 --- a/frontend/dashboard/src/pages/EPrescription/Livechat/View.tsx +++ b/frontend/dashboard/src/pages/EPrescription/Livechat/View.tsx @@ -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) {