Skip to content

Commit

Permalink
Implemented sendEmail for every single unregistered student for given…
Browse files Browse the repository at this point in the history
… event
  • Loading branch information
imnotrafa committed Sep 25, 2024
1 parent 6d5e9e2 commit 75db792
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions packages/core/src/modules/event/use-cases/event-reminder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { db } from '@oyster/db';
import { type Event } from '@oyster/types';
import { listEventAttendees } from '@/member-profile.server';
import { sendEmail } from '@/modules/notification/use-cases/send-email';
import { Email } from '../../../../../types/src/domain/types';
import { send } from 'process';

import { StudentActivatedEmail } from '@oyster/email-templates';
export async function eventReminder(input: Event) {
//selects students who are undergrad
let RegisteredStudentIDs: string[] = [];
Expand All @@ -20,16 +18,23 @@ export async function eventReminder(input: Event) {
RegisteredStudentIDs.push(attendee.studentId);
}
});
// filter down to just the undergrads that are not register for the event
//filter down to just the undergrads that are not register for the event
const unregisteredStudents = await db
.selectFrom('students')
.select(['students.email'])
.select(['students.email', 'students.firstName'])
.where('educationLevel', '=', 'undergraduate')
.where('id', 'not in', RegisteredStudentIDs)
.execute();
const unregisteredStudentsEmailList = unregisteredStudents.map(
(studentEmail) => studentEmail.email
);
//list of unregistered student emails
return unregisteredStudentsEmailList;

//Must change the name of the email template being used based on the prupose of the function
//TODO: create an email tenplate for event reminders
unregisteredStudents.forEach((student) => {
sendEmail({
name: 'application-accepted',
to: student.email,
data: {
firstName: student.firstName,
},
});
});
}

0 comments on commit 75db792

Please sign in to comment.