Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #382 from SELab-2/bugfix
Browse files Browse the repository at this point in the history
Deadline fout weergegeven
  • Loading branch information
cstefc authored May 23, 2024
2 parents 69655f9 + 9ae345b commit 7b36f10
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 21 deletions.
8 changes: 4 additions & 4 deletions frontend/src/dataloaders/loader_helpers/SharedFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 3 additions & 7 deletions frontend/src/pages/student/CoursesViewStudent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 2 additions & 4 deletions frontend/src/pages/teacher/CoursesViewTeacher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/utils/ApiInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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[]
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utils/BackendInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/utils/helper.ts
Original file line number Diff line number Diff line change
@@ -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()}`;

Expand Down

0 comments on commit 7b36f10

Please sign in to comment.