Skip to content

Commit

Permalink
Noob mistakes for #59
Browse files Browse the repository at this point in the history
  • Loading branch information
gregv committed Dec 2, 2023
1 parent 11b9b1e commit 97ad4f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions app/routes/resources+/event-register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: <RegistrationEmail event={event} role={submission.value.role} />,
}).then(result => {
if (result.status == 'error') {
Expand Down Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion app/utils/email.server.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down

0 comments on commit 97ad4f2

Please sign in to comment.