diff --git a/app/routes/resources+/event-register.tsx b/app/routes/resources+/event-register.tsx index ae53092..b258990 100644 --- a/app/routes/resources+/event-register.tsx +++ b/app/routes/resources+/event-register.tsx @@ -5,6 +5,7 @@ import { json, type DataFunctionArgs } from '~/remix.ts' import { prisma } from '~/utils/db.server.ts' import { sendEmail } from '~/utils/email.server.ts' import { RegistrationEmail, RegistrationNoticeForAdmins } from './registration-emails.server.tsx' +import { UnregistrationEmail } from './unregistration-emails.server.tsx' import { createEvent, type DateArray } from 'ics' import type { User, Event } from '@prisma/client' import { differenceInMinutes } from 'date-fns' @@ -64,6 +65,22 @@ export async function action({ request }: DataFunctionArgs) { }, }, }) + + sendEmail({ + to: user.email, + subject: `Event Unregistration Notification`, + attachments: [], + react: , + }).then(result => { + if (result.status == 'error') { + // TODO: think through this case and how to handle it properly + console.error( + 'There was an error sending an event registration email: ', + JSON.stringify(result.error), + ) + } + }) + notifyAdmins({ user: user, event: event, diff --git a/app/routes/resources+/unregistration-emails.server.tsx b/app/routes/resources+/unregistration-emails.server.tsx new file mode 100644 index 0000000..18e0ede --- /dev/null +++ b/app/routes/resources+/unregistration-emails.server.tsx @@ -0,0 +1,44 @@ +import type { Event } from '@prisma/client' +import { Container, Html, Tailwind, Text } from '@react-email/components' +import tailwindConfig from '~/../tailwind.config.ts' +import { format } from 'date-fns' +import { volunteerTypes } from '~/data.ts' + +export function UnregistrationEmail({ + event, + role, +}: { + event: Event + role: 'cleaningCrew' | 'lessonAssistants' | 'sideWalkers' | 'horseLeaders' +}) { + let roleName + for (let v of volunteerTypes) { + if (v.field == role) { + roleName = v.displayName + } + } + + return ( + + + +

+ Thanks for considering volunteering! We hope to see you again! +

+

+ + You've unregistered to volunteer{' '} + {roleName ? `as one of the ${roleName}` : ''} to help with the + following event: + + {event.title} + On: {format(event.start, 'MMMM do, y')} + + From: {format(event.start, 'p')} - {format(event.end, 'p')} + +

+
+ +
+ ) +} \ No newline at end of file