diff --git a/frontend/src/components/ProjectTeacherComponent.tsx b/frontend/src/components/ProjectTeacherComponent.tsx index 71080837..1cc94cd2 100644 --- a/frontend/src/components/ProjectTeacherComponent.tsx +++ b/frontend/src/components/ProjectTeacherComponent.tsx @@ -3,7 +3,7 @@ import Inputfield from "./Inputfield.tsx"; import {SelectionBox} from "./SelectionBox.tsx"; import 'react-calendar/dist/Calendar.css'; import {FaEraser, FaUpload} from "react-icons/fa"; -import {ProjectTeacher, Value} from "../types/project.ts"; +import {ProjectTeacher} from "../types/project.ts"; import "../assets/styles/teacher_components.css" import SimpleTests from "./SimpleTests/SimpleTests.tsx"; import {TeacherOrStudent} from "./SimpleTests/TeacherOrStudentEnum.tsx"; @@ -35,7 +35,7 @@ export function ProjectTeacherComponent(props: { 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); + const [deadline, setDeadline] = useState(props.project.deadline); const [description, setDescription] = useState(props.project.description); const [max_students, setMaxStudents] = useState(props.project.maxGroupMembers); const [groups, setGroups] = useState(props.project.amount_groups); @@ -78,10 +78,10 @@ export function ProjectTeacherComponent(props: { _.isEqual(groupProject, initialValues.value9) && _.isEqual(dockerString, initialValues.value10) && _.isEqual(visible, initialValues.value11) && - _.isEqual(archived, initialValues.value12) && + _.isEqual(archived, initialValues.value12); _.isEqual(groups, initialValues.value13); - const second_part_1 = (deadline as Date).toDateString(); - const second_part_2 = (initialValues.value5 as Date).toDateString(); + const second_part_1 = deadline; + const second_part_2 = initialValues.value5; const second_part = _.isEqual(second_part_1, second_part_2); const third_part = groupProject && Number.isNaN(max_students); return projectName !== "" && (props.is_new === true || !((first_part && second_part) || third_part)); @@ -172,7 +172,7 @@ export function ProjectTeacherComponent(props: { async function handleSaveClick() { const projectInput: ProjectInput = { name: projectName, - deadline: (deadline as Date).toISOString(), + deadline: deadline, visible: visible, archived: archived, description: description, @@ -296,7 +296,12 @@ export function ProjectTeacherComponent(props: { className="field-body is-flex is-flex-direction-column is-align-items-start is-justify-content-center">
- setDeadline(date)} value={deadline} + { + if (date) { + setDeadline((new Date(date.toLocaleString())).toISOString()) + } + }} + value={new Date(deadline)} locale={t('create_project.deadline.locale')}/>
diff --git a/frontend/src/pages/teacher/CreateProject.tsx b/frontend/src/pages/teacher/CreateProject.tsx index 96db51f2..545d975d 100644 --- a/frontend/src/pages/teacher/CreateProject.tsx +++ b/frontend/src/pages/teacher/CreateProject.tsx @@ -22,7 +22,7 @@ export function CreateProject(): JSX.Element { projectId: -1, courseName: data.courses[0].course_name, all_courses: data.courses, - deadline: new Date(Date.now()), + deadline: (new Date(Date.now())).toISOString(), description: "", groupProject: false, hours: 0, diff --git a/frontend/src/pages/teacher/ProjectViewTeacher.tsx b/frontend/src/pages/teacher/ProjectViewTeacher.tsx index 84f98c2f..1bc5aa51 100644 --- a/frontend/src/pages/teacher/ProjectViewTeacher.tsx +++ b/frontend/src/pages/teacher/ProjectViewTeacher.tsx @@ -33,7 +33,7 @@ export default function ProjectViewTeacher() { courseName: project_data.course_name, hours: deadline_date.getHours(), minutes: deadline_date.getMinutes(), - deadline: deadline_date, + deadline: deadline_date.toISOString(), visible: project_data.project_visible, archived: project_data.project_archived, description: project_data.project_description, diff --git a/frontend/src/types/project.ts b/frontend/src/types/project.ts index 65ee1090..da2a1c5f 100644 --- a/frontend/src/types/project.ts +++ b/frontend/src/types/project.ts @@ -11,7 +11,7 @@ export type ProjectTeacher = { courseName: string, hours: number, minutes: number, - deadline: Value, + deadline: string, visible: boolean, archived: boolean, description: string, diff --git a/frontend/src/utils/helper.ts b/frontend/src/utils/helper.ts index 934b2234..0fd7b11e 100644 --- a/frontend/src/utils/helper.ts +++ b/frontend/src/utils/helper.ts @@ -1,5 +1,8 @@ export function deadline_to_string(deadline: string){ + if (deadline === "-"){ + return "-" + } const deadline_date = new Date(deadline) const hours = String(deadline_date.getHours()).padStart(2, '0'); const minutes = String(deadline_date.getMinutes()).padStart(2, '0');