feat: teacher email should include student details

This commit is contained in:
Rotimi Best
2024-07-23 11:02:06 +01:00
parent 72b58ed2c7
commit 32e7073cc5
2 changed files with 7 additions and 6 deletions
@@ -5,11 +5,11 @@ import sendEmail from '$mail/sendEmail';
const supabase = getSupabase();
export async function POST({ request }) {
const { to, courseName } = await request.json();
const { to, courseName, studentName, studentEmail } = await request.json();
const accessToken = request.headers.get('Authorization') || '';
console.log('/POST api/email/course/teacher_student_joined', to, courseName);
if (!to || !courseName) {
if (!to || !courseName || !studentName || !studentEmail) {
return json({ success: false, message: 'Missing required fields' }, { status: 400 });
}
@@ -32,10 +32,9 @@ export async function POST({ request }) {
subject: `[${courseName}] You've got a new student 🎉!`,
content: `
<p>Hi amazing tutor,</p>
<p>Congratulations 🎉, a new student has joined a course you are teaching: ${courseName}</p>
<p>Congratulations 🎉, a new student: <strong>${studentName} (${studentEmail})</strong> has joined a course you are teaching: ${courseName}</p>
<p>We hope they have a great experience learning from the best (YOU).</p>
<p>If you run into any issues, please don’t fail to reach out to us, we’d love to make your teaching
experience as easy as possible.</p>
<p>If you run into any issues, please don’t fail to reach out to us, we’d love to make your teaching experience as easy as possible.</p>
`
}
];
@@ -95,7 +95,9 @@
// Send notification to teacher(s) that a student has joined the course.
triggerSendEmail(NOTIFICATION_NAME.TEACHER_STUDENT_JOINED, {
to: teachers[0],
courseName: data.name
courseName: data.name,
studentName: $profile.fullname,
studentEmail: $profile.email
});
// go to lms