From 563e8d7b2bc49a296c8182012bf548635e9da3c1 Mon Sep 17 00:00:00 2001 From: TkymHrt <23.h.takayama.nutfes@gmail.com> Date: Tue, 5 Mar 2024 15:55:37 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20=E7=99=BB=E9=8C=B2=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=9F=E3=83=87=E3=83=BC=E3=82=BF=E3=81=8C=E7=B7=A8=E9=9B=86?= =?UTF-8?q?=E3=83=A2=E3=83=BC=E3=83=80=E3=83=AB=E3=81=AB=E5=8F=8D=E6=98=A0?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/fund_information/EditModal.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/view/next-project/src/components/fund_information/EditModal.tsx b/view/next-project/src/components/fund_information/EditModal.tsx index 651e00355..ed2d596f3 100644 --- a/view/next-project/src/components/fund_information/EditModal.tsx +++ b/view/next-project/src/components/fund_information/EditModal.tsx @@ -34,10 +34,19 @@ export default function EditModal(props: ModalProps) { useEffect(() => { const teacher = props.teachers.find((teacher) => teacher.departmentID === departmentID); if (teacher && teacher.id) { - setFormData({ ...formData, teacherID: teacher.id }); + setFormData({ ...formData, teacherID: props.fundInformation.teacherID }); } }, [departmentID]); + useEffect(() => { + const selectedTeacher = props.teachers.find( + (teacher) => teacher.id === props.fundInformation.teacherID, + ); + if (selectedTeacher) { + setDepartmentID(selectedTeacher.departmentID); + } + }, [props.teachers, props.fundInformation.teacherID]); + const handler = (input: string) => ( @@ -69,7 +78,7 @@ export default function EditModal(props: ModalProps) { .filter((user, index, self) => { return self.findIndex((u) => u.name === user.name) === index; }); - if (res.length !== 0) setFormData({ ...formData, userID: res[0].id }); + if (res.length !== 0) setFormData({ ...formData, userID: props.fundInformation.userID }); return res; }, [bureauId]);