diff --git a/frontend/src/components/ProjectTeacherComponent.tsx b/frontend/src/components/ProjectTeacherComponent.tsx index eee80263..0b73abb7 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"; @@ -34,7 +34,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 [requiredFiles, setRequiredFiles] = useState(props.project.requiredFiles); @@ -78,8 +78,8 @@ export function ProjectTeacherComponent(props: { _.isEqual(dockerString, initialValues.value10) && _.isEqual(visible, initialValues.value11) && _.isEqual(archived, initialValues.value12); - 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)); @@ -154,7 +154,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, @@ -275,7 +275,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 128430ef..05a134d6 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 7c823d50..83dd92bb 100644 --- a/frontend/src/pages/teacher/ProjectViewTeacher.tsx +++ b/frontend/src/pages/teacher/ProjectViewTeacher.tsx @@ -32,7 +32,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 8971fc05..39103e0a 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');