CLASSROOMIO-T-140: Remove teacher & student input

CLASSROOMIO-T-140: Complete Cleanup

CLASSROOMIO-T-140: Remove teacher & student input


Co-authored-by: Tunji Adeyemi <tunji@digdippa.com>


Merge-request: CLASSROOMIO-MR-72
Merged-by: Best Admin <best@digdippa.com>
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
@@ -12,11 +12,12 @@
import { currentOrg } from '$lib/utils/store/org'; import { currentOrg } from '$lib/utils/store/org';
let errors = { let errors = {
emails: '' title: '',
description: ''
}; };
async function createCourse(e) { async function createCourse(e) {
const { hasError, fieldErrors, students, tutors } = validateForm($createCourseModal); const { hasError, fieldErrors } = validateForm($createCourseModal);
errors = fieldErrors; errors = fieldErrors;
if (hasError) return; if (hasError) return;
@@ -54,29 +55,7 @@
role_id: ROLE.TUTOR role_id: ROLE.TUTOR
}); });
let membersStack = []; $createCourseModal.open = false;
// Create groupmemebers from group_id and add teachers and students
for (const student of students) {
membersStack.push({
email: student,
group_id,
role_id: ROLE.STUDENT
});
}
for (const tutor of tutors) {
membersStack.push({
email: tutor,
group_id,
role_id: ROLE.TUTOR
});
}
addGroupMember(membersStack).then((membersAdded) => {
console.log(`membersAdded`, membersAdded);
$createCourseModal.open = false;
});
} }
</script> </script>
@@ -101,26 +80,6 @@
errorMessage={errors.title} errorMessage={errors.title}
autoComplete={false} autoComplete={false}
/> />
<TextArea
label="Invite Tutors"
bind:value={$createCourseModal.tutors}
rows="2"
maxRows="3"
placeholder="tutor@company.com, john@gmail.com"
helperMessage="To invite people, add their emails separated by a comma"
errorMessage={errors.tutors}
className="mb-4"
/>
<TextArea
label="Invite Students"
bind:value={$createCourseModal.students}
rows="2"
maxRows="3"
placeholder="student@gmail.com, john@gmail.com"
helperMessage="To invite people, add their emails separated by a comma"
errorMessage={errors.students}
className="mb-4"
/>
<TextArea <TextArea
label="Short description" label="Short description"
bind:value={$createCourseModal.description} bind:value={$createCourseModal.description}
@@ -129,6 +88,7 @@
placeholder="A little description about this course" placeholder="A little description about this course"
className="mb-4" className="mb-4"
isRequired={true} isRequired={true}
errorMessage={errors.description}
/> />
<div class="mt-5 flex items-center"> <div class="mt-5 flex items-center">
+5 -47
View File
@@ -2,66 +2,24 @@ import { validateEmail } from '$lib/utils/functions/validateEmail';
export function validateForm(fields) { export function validateForm(fields) {
let hasError = false; let hasError = false;
const { students = '', tutors = '', title, description } = fields; const { title, description } = fields;
const fieldErrors = { const fieldErrors = {
tutors: '',
students: '',
title: '', 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) { if (!title) {
fieldErrors.title = 'Title is required'; fieldErrors.title = 'Title is required';
return { hasError = true;
hasError: true,
fieldErrors,
};
} }
if (!description) { if (!description) {
fieldErrors.description = 'Description is required'; fieldErrors.description = 'Description is required';
return { hasError = true;
hasError: true,
fieldErrors,
};
} }
return { return {
hasError, hasError,
fieldErrors, fieldErrors
tutors: _tutors,
students: _students,
}; };
} }