From 836f556597944c9b5e8d95a9b526d8995921ae8c Mon Sep 17 00:00:00 2001 From: ALBERICLOOS Date: Thu, 23 May 2024 20:45:48 +0200 Subject: [PATCH 1/2] fix bug --- frontend/src/components/ProjectTeacherComponent.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/ProjectTeacherComponent.tsx b/frontend/src/components/ProjectTeacherComponent.tsx index 71080837..45f51202 100644 --- a/frontend/src/components/ProjectTeacherComponent.tsx +++ b/frontend/src/components/ProjectTeacherComponent.tsx @@ -29,10 +29,12 @@ export function ProjectTeacherComponent(props: { updateTitle?: (name: string) => void, is_new?: boolean, }): JSX.Element { + const course_options = props.project.all_courses.filter(course => !course.course_archived).map(course => course.course_name); + const navigate = useNavigate(); const {t} = useTranslation(); const [projectName, setProjectName] = useState(props.project.projectName) - const [courseName, setCourseName] = useState(props.project.courseName) + const [courseName, setCourseName] = useState(course_options[0]) const [hours, setHours] = useState(props.project.hours); const [minutes, setMinutes] = useState(props.project.minutes); const [deadline, setDeadline] = useState(props.project.deadline); @@ -95,7 +97,6 @@ export function ProjectTeacherComponent(props: { } }; - const course_options = props.project.all_courses.filter(course => !course.course_archived).map(course => course.course_name); const hours_array = Array.from({length: 24}, (_, index) => index.toString()); const minutes_array = Array.from({length: 60}, (_, index) => index.toString()); From ac31aa56b1191ed61459df639e90748aec3c2f4f Mon Sep 17 00:00:00 2001 From: ALBERICLOOS Date: Thu, 23 May 2024 20:59:11 +0200 Subject: [PATCH 2/2] fix selection box course bug --- frontend/src/components/ProjectTeacherComponent.tsx | 7 +++---- frontend/src/pages/teacher/CreateProject.tsx | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/ProjectTeacherComponent.tsx b/frontend/src/components/ProjectTeacherComponent.tsx index 5f63a32d..f8395d64 100644 --- a/frontend/src/components/ProjectTeacherComponent.tsx +++ b/frontend/src/components/ProjectTeacherComponent.tsx @@ -29,12 +29,10 @@ export function ProjectTeacherComponent(props: { updateTitle?: (name: string) => void, is_new?: boolean, }): JSX.Element { - const course_options = props.project.all_courses.filter(course => !course.course_archived).map(course => course.course_name); - const navigate = useNavigate(); const {t} = useTranslation(); const [projectName, setProjectName] = useState(props.project.projectName) - const [courseName, setCourseName] = useState(course_options[0]) + const [courseName, setCourseName] = useState(props.project.courseName) const [hours, setHours] = useState(props.project.hours); const [minutes, setMinutes] = useState(props.project.minutes); const [deadline, setDeadline] = useState(props.project.deadline); @@ -81,7 +79,7 @@ export function ProjectTeacherComponent(props: { _.isEqual(dockerString, initialValues.value10) && _.isEqual(visible, initialValues.value11) && _.isEqual(archived, initialValues.value12); - _.isEqual(groups, initialValues.value13); + _.isEqual(groups, initialValues.value13); const second_part_1 = deadline; const second_part_2 = initialValues.value5; const second_part = _.isEqual(second_part_1, second_part_2); @@ -97,6 +95,7 @@ export function ProjectTeacherComponent(props: { } }; + const course_options = props.project.all_courses.filter(course => !course.course_archived).map(course => course.course_name); const hours_array = Array.from({length: 24}, (_, index) => index.toString()); const minutes_array = Array.from({length: 60}, (_, index) => index.toString()); diff --git a/frontend/src/pages/teacher/CreateProject.tsx b/frontend/src/pages/teacher/CreateProject.tsx index 545d975d..2cc6046a 100644 --- a/frontend/src/pages/teacher/CreateProject.tsx +++ b/frontend/src/pages/teacher/CreateProject.tsx @@ -20,7 +20,7 @@ export function CreateProject(): JSX.Element { const emptyProjectTeacher: ProjectTeacher = { projectId: -1, - courseName: data.courses[0].course_name, + courseName: data.courses.filter(course => !course.course_archived)[0].course_name, all_courses: data.courses, deadline: (new Date(Date.now())).toISOString(), description: "",