-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: removed email.js, now entirely using resend
- Loading branch information
Showing
8 changed files
with
170 additions
and
125 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
RESEND_API_KEY= | ||
NEXT_PUBLIC_SERVICE_ID= | ||
NEXT_PUBLIC_TEMPLATE_ID_BUSINESS= | ||
NEXT_PUBLIC_PUBLIC_KEY= | ||
RESEND_FROM_DOMAIN_EMAIL= | ||
RESEND_REPLY_TO_EMAIL= | ||
RESEND_TO_EMAIL= |
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ import { Resend } from "resend"; | |
import { basePartnerSchema } from "@/lib/schema"; | ||
import PartnerEmail from "@/emails/partners"; | ||
import { FormInputType } from "@/components/shared/partners/type"; | ||
import PartnerMessage from "@/emails/partner-message"; | ||
|
||
const resend = new Resend(process.env.RESEND_API_KEY) | ||
|
||
|
@@ -13,10 +14,9 @@ export async function sendEmail(data: FormInputType) { | |
const { name, email } = result.data | ||
try { | ||
const data = await resend.emails.send({ | ||
// from: `Sahil <${process.env.RESEND_FROM_EMAIL}>`, | ||
from: 'Sahil <[email protected]>', | ||
// to: [email], | ||
to: ['[email protected]'], | ||
from: `Sahil <${process.env.RESEND_FROM_DOMAIN_EMAIL}>`, | ||
to: [email], | ||
replyTo: `${process.env.RESEND_REPLY_TO_EMAIL}`, | ||
subject: 'Partnering with Sahil', | ||
text: `Name: ${name}\nEmail: ${email}`, | ||
react: PartnerEmail({ name }) | ||
|
@@ -31,3 +31,40 @@ export async function sendEmail(data: FormInputType) { | |
return { success: false, error: result.error.format() } | ||
} | ||
} | ||
|
||
export async function storeUserDetails(data: FormInputType) { | ||
const result = basePartnerSchema.safeParse(data) | ||
|
||
if (result.success) { | ||
const { | ||
name, | ||
email, | ||
phoneNumber, | ||
companyName, | ||
supplyDetails, | ||
vehicleDetails | ||
} = result.data | ||
|
||
try { | ||
const data = await resend.emails.send({ | ||
from: `Sahil <${process.env.RESEND_FROM_DOMAIN_EMAIL}>`, | ||
to: `${process.env.RESEND_TO_EMAIL}`, | ||
subject: `New Partner Submission from ${name}`, | ||
react: PartnerMessage({ | ||
name, | ||
email, | ||
phoneNumber, | ||
companyName, | ||
supplyDetails, | ||
vehicleDetails | ||
}) | ||
}) | ||
return { success: true, data } | ||
} catch (error) { | ||
return { success: false, error } | ||
} | ||
} | ||
if (result.error) { | ||
return { success: false, error: result.error.format() } | ||
} | ||
} |
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
Oops, something went wrong.