Skip to content

Commit

Permalink
[fix] 登録されたデータが編集モーダルに反映されるよう修正
Browse files Browse the repository at this point in the history
  • Loading branch information
TkymHrt committed Mar 5, 2024
1 parent 74f7d51 commit 563e8d7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions view/next-project/src/components/fund_information/EditModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
(
Expand Down Expand Up @@ -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]);

Expand Down

0 comments on commit 563e8d7

Please sign in to comment.