// supabase/functions/send-interview-email/index.ts import { serve } from "https://deno.land/std@0.168.0/http/server.ts"; import { Resend } from "npm:resend"; const resend = new Resend(Deno.env.get("RESEND_API_KEY")); const corsHeaders = { "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Headers": "authorization, x-client-info, apikey, content-type", }; serve(async (req) => { if (req.method === "OPTIONS") return new Response("ok", { headers: corsHeaders }); try { const { candidateName, candidateEmail, date, time, meetingLink, role } = await req.json(); const { data, error } = await resend.emails.send({ from: "Acme HR ", // Change this to your verified domain if you have one to: [candidateEmail], subject: `Interview Invitation: ${role}`, html: `

Hi ${candidateName},

We are pleased to invite you to a Technical Interview for the ${role} position.

📅 Date: ${date}

⏰ Time: ${time}

🔗 Link: ${meetingLink}

Please join 5 minutes early.

Best,
Hiring Team

`, }); if (error) throw error; return new Response(JSON.stringify(data), { headers: { ...corsHeaders, "Content-Type": "application/json" }, status: 200, }); } catch (error) { return new Response(JSON.stringify({ error: error.message }), { headers: { ...corsHeaders, "Content-Type": "application/json" }, status: 500, }); } });