From bba72364ab0b0e01b0a9b24a342a184ebadffd1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stef=20Oss=C3=A9?= Date: Thu, 23 May 2024 18:07:24 +0200 Subject: [PATCH 1/2] deadline fout weergegeven --- frontend/src/utils/ApiInterfaces.ts | 2 +- frontend/src/utils/BackendInterfaces.ts | 2 +- frontend/src/utils/helper.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/utils/ApiInterfaces.ts b/frontend/src/utils/ApiInterfaces.ts index 157b8767..cbe0def0 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, 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()}`; From 9ae345be7e9c909927c85d600f342341f1117abb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stef=20Oss=C3=A9?= Date: Thu, 23 May 2024 18:28:02 +0200 Subject: [PATCH 2/2] lint --- .../src/dataloaders/loader_helpers/SharedFunctions.ts | 8 ++++---- frontend/src/pages/student/CoursesViewStudent.tsx | 10 +++------- frontend/src/pages/teacher/CoursesViewTeacher.tsx | 6 ++---- frontend/src/utils/ApiInterfaces.ts | 4 ++-- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/frontend/src/dataloaders/loader_helpers/SharedFunctions.ts b/frontend/src/dataloaders/loader_helpers/SharedFunctions.ts index 16d71334..4851e406 100644 --- a/frontend/src/dataloaders/loader_helpers/SharedFunctions.ts +++ b/frontend/src/dataloaders/loader_helpers/SharedFunctions.ts @@ -53,7 +53,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: [], @@ -62,7 +62,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); @@ -95,10 +95,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 cbe0def0..6a4a2cf6 100644 --- a/frontend/src/utils/ApiInterfaces.ts +++ b/frontend/src/utils/ApiInterfaces.ts @@ -62,14 +62,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[]