import { Resend } from 'resend'; const resend = new Resend(process.env.RESEND_API_KEY); const FROM = process.env.RESEND_FROM_EMAIL ?? 'noreply@pawlink.pt'; export interface SendEmailOptions { to: string; subject: string; html: string; } export async function sendEmail({ to, subject, html }: SendEmailOptions) { const { data, error } = await resend.emails.send({ from: `PawLink <${FROM}>`, to, subject, html, }); if (error) { console.error('[email] Falha ao enviar:', error); throw new Error(`Falha ao enviar email: ${error.message}`); } return data; } export function buildReservationConfirmationHtml(opts: { userName: string; animalName: string; shelterName: string; date: string; }): string { return ` Confirmação de Reserva — PawLink
PawLink

Reserva confirmada! 🐾

Olá ${opts.userName}, a tua reserva para conhecer ${opts.animalName} foi confirmada.

Animal

${opts.animalName}

Canil

${opts.shelterName}

Data

${opts.date}

Lembra-te de levar um documento de identificação. Se precisares de alterar ou cancelar, acede à tua área de conta em pawlink.pt.

© 2025 PawLink · Portugal · Privacidade

`; } export function buildWelcomeHtml(opts: { userName: string }): string { return ` Bem-vindo ao PawLink
PawLink

Bem-vindo, ${opts.userName}! 🐾

A tua conta PawLink está pronta. Começa a explorar animais à espera de uma família como a tua.

Explorar animais

© 2025 PawLink · Portugal

`; }