feat(frontend): nieuwe "cancel" knop bij create assignment

This commit is contained in:
Joyelle Ndagijimana 2025-04-19 15:19:58 +02:00
parent 1d29adaa31
commit 800f6433d6
10 changed files with 44 additions and 238 deletions

View file

@ -4,7 +4,7 @@
* Ensures that the title is not empty.
*/
export const assignmentTitleRules = [
(value: string) => {
(value: string): string | boolean => {
if (value?.length >= 1) return true; // Title must not be empty
return 'Title cannot be empty.';
},
@ -16,7 +16,7 @@ export const assignmentTitleRules = [
* Ensures that a valid learning path is selected.
*/
export const learningPathRules = [
(value: { hruid: string; title: string }) => {
(value: { hruid: string; title: string }): string | boolean => {
if (value && value.hruid) {
return true; // Valid if hruid is present
}
@ -30,7 +30,7 @@ export const learningPathRules = [
* Ensures that at least one class is selected.
*/
export const classRules = [
(value: string) => {
(value: string): string | boolean => {
if (value) return true;
return 'You must select at least one class.';
},
@ -42,7 +42,7 @@ export const classRules = [
* Ensures that a valid deadline is selected and is in the future.
*/
export const deadlineRules = [
(value: string) => {
(value: string): string | boolean => {
if (!value) return "You must set a deadline.";
const selectedDateTime = new Date(value);
@ -57,7 +57,7 @@ export const deadlineRules = [
];
export const descriptionRules = [
(value: string) => {
(value: string): string | boolean => {
if (!value || value.trim() === "") return "Description cannot be empty.";
return true;
},

View file

@ -1,24 +1,24 @@
// TODO : temp data until frontend controllers are ready
type Teacher = {
interface Teacher {
username: string;
firstName: string;
lastName: string;
classes: Array<Class>;
};
classes: Class[];
}
type Student = {
interface Student {
username: string;
firstName: string;
lastName: string;
classes: Array<Class>;
};
classes: Class[];
}
type Class = {
interface Class {
id: string;
displayName: string;
teachers: Array<Teacher>;
students: Array<Student>;
};
teachers: Teacher[];
students: Student[];
}
const student01: Student = {username: "id01", firstName: "Mark", lastName: "Knopfler", classes: []};
const student02: Student = {username: "id02", firstName: "John", lastName: "Hiat", classes: []};
@ -55,11 +55,11 @@ teacher01.classes = [class01];
teacher02.classes = [class02];
teacher03.classes = [class03];
type Assignment = {
interface Assignment {
id: string;
title: string;
description: string;
};
}
export const assignments: Assignment[] = Array.from({length: 4}, (_, i) => ({
@ -100,4 +100,4 @@ export const assignments: Assignment[] = Array.from({length: 4}, (_, i) => ({
}));
export const classes: Array<Class> = [class01, class02, class03];
export const classes: Class[] = [class01, class02, class03];