From 97ad4f22d6e465ee591c11de7eb50f1a4191acfb Mon Sep 17 00:00:00 2001 From: Greg V Date: Sat, 2 Dec 2023 16:27:19 -0700 Subject: [PATCH] Noob mistakes for #59 --- app/routes/resources+/event-register.tsx | 14 +++++++++----- app/utils/email.server.ts | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/routes/resources+/event-register.tsx b/app/routes/resources+/event-register.tsx index 1f82e74..ae53092 100644 --- a/app/routes/resources+/event-register.tsx +++ b/app/routes/resources+/event-register.tsx @@ -124,14 +124,11 @@ export async function action({ request }: DataFunctionArgs) { ) } - // Transform invite to be sent as an attachment - const inviteAttachment = new Blob([invite], { type: 'text/calendar' }) - sendEmail({ to: user.email, subject: `Event Registration Notification`, - attachments: [{ filename: 'invite.ics', content: inviteAttachment }], + attachments: [{ filename: 'invite.ics', content: invite }], react: , }).then(result => { if (result.status == 'error') { @@ -187,7 +184,14 @@ function generateInvite(event: Event) { // Log the event as a string console.log("Calendar invite: " + invite.value); - return invite + // Check if invite.value is a string + if (typeof invite.value === 'string') { + // Convert to a buffer + const inviteBuffer = Buffer.from(invite.value); + return inviteBuffer + } + + return ""; } async function notifyAdmins({ diff --git a/app/utils/email.server.ts b/app/utils/email.server.ts index a74f488..f6c7392 100644 --- a/app/utils/email.server.ts +++ b/app/utils/email.server.ts @@ -1,7 +1,7 @@ import { type ReactElement } from 'react' import { renderAsync } from '@react-email/components' import { z } from 'zod' -import { siteEmailAddress, siteEmailAddressWithName } from '~/data.ts' +import { siteEmailAddressWithName } from '~/data.ts' const resendErrorSchema = z.union([ z.object({