diff --git a/frontend/src/dataloaders/loader_helpers/SharedFunctions.ts b/frontend/src/dataloaders/loader_helpers/SharedFunctions.ts index 4c3add76..9f4b6cda 100644 --- a/frontend/src/dataloaders/loader_helpers/SharedFunctions.ts +++ b/frontend/src/dataloaders/loader_helpers/SharedFunctions.ts @@ -54,7 +54,7 @@ export async function coursesLoader(role: teacherStudentRole, course_id?: number if (courseProjects.length === 0) { return { active_projects: 0, - first_deadline: null, + first_deadline: "-", project_archived: false, project_visible: false, all_projects: [], @@ -63,7 +63,7 @@ export async function coursesLoader(role: teacherStudentRole, course_id?: number course_archived: course.course_archived, course_id: course.course_id, course_name: course.course_name - }; + } as properCourse; } const firstDeadline = getFirstUpcomingDeadline(courseProjects); @@ -96,10 +96,10 @@ function getSmallProjectInfo(project: Project): SmallProjectInfo { } -function getFirstUpcomingDeadline(courseProjects: Project[]): string | Date { +function getFirstUpcomingDeadline(courseProjects: Project[]): string { const filtered = courseProjects.filter(course => course.project_visible && !course.project_archived); if (filtered.length === 0) { - return ""; + return "-"; } const first_deadline = filtered.reduce((minProject, project) => { if (project.project_deadline < minProject.project_deadline) { diff --git a/frontend/src/pages/student/CoursesViewStudent.tsx b/frontend/src/pages/student/CoursesViewStudent.tsx index add7b240..03ebb676 100644 --- a/frontend/src/pages/student/CoursesViewStudent.tsx +++ b/frontend/src/pages/student/CoursesViewStudent.tsx @@ -23,13 +23,9 @@ export default function CoursesViewStudent(): JSX.Element { const tableCoursesActive: TableRowCourses[] = active_courses.map((course: properCourse) => { - const deadline_date = course.first_deadline ? new Date(course.first_deadline) : null - - let deadline = null - if (deadline_date !== null) { - deadline = deadline_to_string(deadline_date) - } else { - deadline = "-" + let deadline = "-" + if (course.first_deadline) { + deadline = deadline_to_string(course.first_deadline) } return { diff --git a/frontend/src/pages/teacher/CoursesViewTeacher.tsx b/frontend/src/pages/teacher/CoursesViewTeacher.tsx index 5bb81e08..948aaf6c 100644 --- a/frontend/src/pages/teacher/CoursesViewTeacher.tsx +++ b/frontend/src/pages/teacher/CoursesViewTeacher.tsx @@ -19,11 +19,9 @@ export default function CoursesViewTeacher(): JSX.Element { const archived_courses = data.courses.filter(course => course.course_archived); const tableCoursesActive: TableRowCourses[] = active_courses.map(course => { - const deadline_date = course.first_deadline ? new Date(course.first_deadline) : "-" - - let deadline = deadline_date + let deadline = "-" if (course.first_deadline) { - deadline = deadline_to_string(deadline_date) + deadline = deadline_to_string(course.first_deadline) } return { diff --git a/frontend/src/utils/ApiInterfaces.ts b/frontend/src/utils/ApiInterfaces.ts index 026d7606..6d7e4fad 100644 --- a/frontend/src/utils/ApiInterfaces.ts +++ b/frontend/src/utils/ApiInterfaces.ts @@ -9,7 +9,7 @@ export interface Course { export interface Project { project_id: number, project_name: string, - project_deadline: string | Date, + project_deadline: string, project_archived: boolean, project_description: string, project_requirements: string, @@ -63,14 +63,14 @@ export interface CompleteProjectTeacher extends CompleteProject { export interface SmallProjectInfo { project_id: number, project_name: string, - project_deadline: Date | string, + project_deadline: string, project_archived: boolean, project_visible: boolean, } export interface properCourse extends Course { active_projects: number, - first_deadline: Date | null | string, + first_deadline: string, all_projects: SmallProjectInfo[] | null, teachers: SmallUserInfo[], students: SmallUserInfo[] diff --git a/frontend/src/utils/BackendInterfaces.ts b/frontend/src/utils/BackendInterfaces.ts index d69a081d..e753e76e 100644 --- a/frontend/src/utils/BackendInterfaces.ts +++ b/frontend/src/utils/BackendInterfaces.ts @@ -9,7 +9,7 @@ export interface Backend_Course { export interface Backend_Project { id: number, name: string, - deadline: string | Date, + deadline: string, archived: boolean, description: string, requirements: string, diff --git a/frontend/src/utils/helper.ts b/frontend/src/utils/helper.ts index 3398f217..934b2234 100644 --- a/frontend/src/utils/helper.ts +++ b/frontend/src/utils/helper.ts @@ -1,10 +1,10 @@ -export function deadline_to_string(deadline: Date | string){ +export function deadline_to_string(deadline: string){ const deadline_date = new Date(deadline) const hours = String(deadline_date.getHours()).padStart(2, '0'); const minutes = String(deadline_date.getMinutes()).padStart(2, '0'); const day = String(deadline_date.getDate()).padStart(2, '0'); - const month = String(deadline_date.getMonth()).padStart(2, '0'); + const month = String(deadline_date.getMonth() + 1).padStart(2, '0'); return `${hours}:${minutes} - ${day}/${month}/${deadline_date.getFullYear()}`;