-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
115 changed files
with
3,097 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
'use server'; | ||
|
||
import { z } from 'zod'; | ||
|
||
import mailchimp from '@/lib/mailchimp'; | ||
|
||
import { NewsletterSchema } from '@/containers/newsletter/index'; | ||
|
||
export const contactFormActions = async ( | ||
email: z.infer<typeof NewsletterSchema>['email'], | ||
mergeFields: { | ||
FNAME: string; | ||
LNAME: string; | ||
ORG_TYPE?: string | undefined; | ||
ORG_TYPE_O?: string | undefined; | ||
} | ||
) => { | ||
try { | ||
await mailchimp.lists.addListMember('77ab6984cf', { | ||
status: 'subscribed', | ||
email_address: email, | ||
merge_fields: { | ||
...mergeFields, | ||
}, | ||
}); | ||
|
||
return { | ||
ok: true, | ||
}; | ||
} catch (err) { | ||
if (err instanceof Error) { | ||
return { | ||
ok: false, | ||
message: err.message, | ||
}; | ||
} | ||
|
||
return { | ||
ok: false, | ||
message: 'Error sending contact form', | ||
}; | ||
} | ||
}; | ||
|
||
export default contactFormActions; | ||
|
||
import { Resend } from 'resend'; | ||
import * as React from 'react'; | ||
import { ContactUsEmail } from 'components/contact/email-template'; | ||
|
||
const resend = new Resend(process.env.RESEND_API_KEY); | ||
|
||
export async function POST(req: Request) { | ||
const payload = await req.json(); | ||
|
||
try { | ||
const { data, error } = await resend.emails.send({ | ||
from: '[email protected]', | ||
to: payload.email, | ||
subject: `Thank you for contacting us, ${payload.name}`, | ||
react: ContactUsEmail(payload), | ||
}); | ||
|
||
if (error) { | ||
return Response.json({ error }); | ||
} | ||
|
||
return Response.json({ data }); | ||
} catch (error) { | ||
return Response.json({ error }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Body, Container, Head, Html, Markdown, Preview, Text } from '@react-email/components'; | ||
import { CSSProperties } from 'react'; | ||
|
||
interface ContactUsEmailProps { | ||
name: string; | ||
email: string; | ||
message: string; | ||
} | ||
|
||
export const ContactUsEmail = ({ name, email, message }: ContactUsEmailProps) => ( | ||
<Html> | ||
<Head /> | ||
<Preview>Thanks for contacting us {name}!</Preview> | ||
<Body style={main}> | ||
<Container style={container}> | ||
<Text style={paragraph}>Hi {name},</Text> | ||
<Text style={paragraph}>We have received your message</Text> | ||
<Markdown | ||
markdownContainerStyles={{ | ||
boxShadow: '0 0 10px rgba(0, 0, 0, 0.05)', | ||
borderRadius: '8px', | ||
padding: '20px', | ||
backgroundColor: '#f3f4f6', | ||
border: '1px solid #e5e7eb', | ||
}} | ||
> | ||
{message} | ||
</Markdown> | ||
<Text style={paragraph}>We will get back to you as soon as possible at {email}.</Text> | ||
</Container> | ||
</Body> | ||
</Html> | ||
); | ||
|
||
const main: CSSProperties = { | ||
backgroundColor: '#ffffff', | ||
borderRadius: '8px', | ||
border: '1px solid #e5e7eb', | ||
boxShadow: '0 0 10px rgba(0, 0, 0, 0.05)', | ||
fontFamily: | ||
'-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif', | ||
}; | ||
|
||
const container: CSSProperties = { | ||
margin: '0 auto', | ||
padding: '20px 0 48px', | ||
}; | ||
|
||
const paragraph: CSSProperties = { | ||
fontSize: '16px', | ||
lineHeight: '26px', | ||
}; |
Oops, something went wrong.