diff --git a/notification/sendMail.feature b/notification/sendMail.feature new file mode 100644 index 000000000..38ea7f55a --- /dev/null +++ b/notification/sendMail.feature @@ -0,0 +1,37 @@ + + +Scenario: Editing grade + +Given The student "Marcos Almeida" has achieved "MPA, MPA, -" for the evaluated learning goals +And I’m at the "Editing grades" page +When I confirm grades to the system +Then I go to "grades" page +And I see the new grade to "Marcos Almeida" +and the student "Marcos Almeida" receive a email from the system + +Scenario: + +Given The student "Valeria Almeida" has achieved "MANA, MANA, -" for the evaluated learning goals +And I’m at the "Editing grades" page +When I confirm grades to the system +Then I go to "grades" page +And I see the new grade to "Valeria Almeida" +and the student "Valeria Almeida" receive a email from the system + +Scenario: Editing grade for the second time + +Given The student "Marcos Almeida" has achieved "MPA, MPA, -" for the evaluated learning goals +And I’m at the "Editing grades" page +When I confirm grades to the system +Then I go to "grades" page +And I see the new grade to "Marcos Almeida" a +and the student "Marcos Almeida" don't receive a email from the system because he alredy received once today + +Scenario: Editing grade for the second time + +Given The student "Valeria Almeida" has achieved "MPA, MPA, -" for the evaluated learning goals +And I’m at the "Editing grades" page +When I confirm grades to the system +Then I go to "grades" page +And I see the new grade to "Valeria Almeida" a +and the student "Valeria Almeida" don't receive a email from the sgiystem because he alredy received once today diff --git a/server/mailService.js b/server/mailService.js new file mode 100644 index 000000000..3f3243ecf --- /dev/null +++ b/server/mailService.js @@ -0,0 +1,31 @@ +/** + * Função para enviar e-mail ao aluno. + * @param {string} studentName - Nome do aluno. + * @param {string} email - Endereço de e-mail do aluno. + * @param {string} message - Mensagem a ser enviada. + * @returns {Promise} + */ +export async function sendEmail(studentName, email, message) { + try { + const response = await fetch('/api/send-email', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + studentName, + email, + message, + }), + }); + + if (!response.ok) { + throw new Error('Falha ao enviar o e-mail'); + } + + console.log(`E-mail enviado com sucesso para ${studentName}`); + } catch (error) { + console.error('Erro ao enviar e-mail:', error); + throw error; + } + } \ No newline at end of file