Skip to content

Commit

Permalink
feat: feedback changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AuraAlba committed Jul 15, 2024
1 parent aa686af commit 073c144
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
27 changes: 10 additions & 17 deletions src/features/Classes/EnrollStudent/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ const EnrollStudent = ({ isOpen, onClose, queryClassId }) => {
const response = await handleEnrollments(formData, queryClassId);
const validationEmailList = response?.data?.results;
const messages = await getMessages();
let validEmails = [];
let invalidEmails = [];
const validEmails = [];
const invalidEmails = [];
let textToast = '';

/**
Expand All @@ -65,26 +65,19 @@ const EnrollStudent = ({ isOpen, onClose, queryClassId }) => {
return onClose();
}

validationEmailList.map(email => {
if (email?.invalidIdentifier) {
invalidEmails = [
...invalidEmails,
email.identifier,
];
return invalidEmails;
}
validEmails = [
...validEmails,
email.identifier,
];
return validEmails;
validationEmailList.forEach(({ invalidIdentifier, identifier }) => {
(invalidIdentifier ? invalidEmails : validEmails).push(identifier);
});

if (invalidEmails.length > 0) {
textToast = `The following email adresses are invalid: ${invalidEmails.join(' ')}\n`;
textToast = `The following email ${invalidEmails.length === 1
? 'adress is invalid'
: 'adresses are invalid'}:\n${invalidEmails.join('\n')}\n`;
}
if (validEmails.length > 0) {
textToast += `Successfully enrolled and sent email to the following users: ${validEmails.join(' ')}`;
textToast += `Successfully enrolled and sent email to the following ${validEmails.length === 1
? 'user'
: 'users'}:\n${validEmails.join('\n')}`;
}

setToastMessage(textToast);
Expand Down
4 changes: 4 additions & 0 deletions src/features/Classes/EnrollStudent/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
.student-email .pgn__form-control-floating-label {
display: block;
}

.student-email .form-control {
height: 44px;
}
}

.toast-message {
Expand Down

0 comments on commit 073c144

Please sign in to comment.