CLASSROOMIO-T-140: Remove teacher & student input

CLASSROOMIO-T-140: Complete Cleanup

CLASSROOMIO-T-140: Remove teacher & student input


Co-authored-by: Tunji Adeyemi <[email protected]>


Merge-request: CLASSROOMIO-MR-72
Merged-by: Best Admin <[email protected]>
This commit is contained in:
tunny17
2023-09-18 17:03:56 +00:00
committed by Space Cloud
parent a6a9b18f4f
commit 5e77f9ca46
2 changed files with 10 additions and 92 deletions
+5 -47
View File
@@ -2,66 +2,24 @@ import { validateEmail } from '$lib/utils/functions/validateEmail';
export function validateForm(fields) {
let hasError = false;
const { students = '', tutors = '', title, description } = fields;
const { title, description } = fields;
const fieldErrors = {
tutors: '',
students: '',
title: '',
description: '',
description: ''
};
const _tutors =
tutors.length < 5
? []
: tutors.split(',').map((_email) => {
const email = _email.trim();
if (!validateEmail(email)) {
hasError = true;
fieldErrors.tutors += !fieldErrors.tutors.length
? `Not valid email: ${email}`
: `, ${email}`;
}
return email;
});
const _students =
students.length < 5
? []
: students.split(',').map((_email) => {
const email = _email.trim();
if (!validateEmail(email)) {
hasError = true;
fieldErrors.students += !fieldErrors.students.length
? `Not valid email: ${email}`
: `, ${email}`;
}
return email;
});
if (!title) {
fieldErrors.title = 'Title is required';
return {
hasError: true,
fieldErrors,
};
hasError = true;
}
if (!description) {
fieldErrors.description = 'Description is required';
return {
hasError: true,
fieldErrors,
};
hasError = true;
}
return {
hasError,
fieldErrors,
tutors: _tutors,
students: _students,
fieldErrors
};
}