import { supabase } from './supabase'; export async function sendEmail(type, to, data) { const { data: result, error } = await supabase.functions.invoke('send-email', { body: { type, to, data }, }); if (error) { console.error('Email invoke error:', error); throw new Error(`Email failed: ${error.message || JSON.stringify(error)}`); } if (result?.error) { console.error('Email send error:', result.error); throw new Error(`Email failed: ${JSON.stringify(result.error)}`); } return result; }