import { Resend } from "resend"; import { env } from "@/env.mjs"; export const resend = new Resend(env.RESEND_API_KEY || "re_key"); export function getVerificationEmailHtml({ url, appName, }: { url: string; appName: string; }): string { return ` Email Verification - ${appName}

Welcome to ${appName}

Your journey starts here 🎉

Verify Your Email

Hello there,
Thank you for joining ${appName}! To complete your login and get started, please verify your email address by clicking the button below:

Or copy and paste the link below into your browser:
${url}

If you didn’t request this email or believe this was sent in error, you can safely ignore it. This link will expire in 24 hours for security reasons.

`; } // TODO: Update sendVerificationRequest for use react-email with resend magic-link // Email({ // sendVerificationRequest: async ({ identifier, url, provider }) => { // const user = await getUserByEmail(identifier); // if (!user || !user.name) return null; // const userVerified = user?.emailVerified ? true : false; // const authSubject = userVerified ? `Sign-in link for ${siteConfig.name}` : "Activate your account"; // try { // const { data, error } = await resend.emails.send({ // from: 'WR.DO App ', // to: process.env.NODE_ENV === "development" ? 'delivered@resend.dev' : identifier, // subject: authSubject, // react: MagicLinkEmail({ // firstName: user?.name as string, // actionUrl: url, // mailType: userVerified ? "login" : "register", // siteName: siteConfig.name // }), // // Set this to prevent Gmail from threading emails. // // More info: https://resend.com/changelog/custom-email-headers // headers: { // 'X-Entity-Ref-ID': new Date().getTime() + "", // }, // }); // if (error || !data) { // throw new Error(error?.message) // } // // console.log(data) // } catch (error) { // throw new Error("Failed to send verification email.") // } // }, // }),