fix: crash bugs in TeamInvoices + faster load
Bug fixes: - TeamInvoices: add useAuth import/currentUser (invoice-create crash) - TeamInvoices: setChartYear -> setExportYear (year-dropdown crash) - TeamDashboard: drop redundant setState-in-effect (cascading renders) - Companies: delete dead _UnusedClientCompanies (illegal hook calls) - annotate intentional empty PDF-fallback catches Load speed: - preconnect/dns-prefetch to Supabase origin - lazy-load heic-to in Converters: page chunk 2737KB -> 9KB - split recharts into its own 'charts' vendor chunk Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import Stripe from 'https://esm.sh/stripe@14?target=deno';
|
||||
|
||||
const stripe = new Stripe(Deno.env.get('STRIPE_SECRET_KEY')!, { apiVersion: '2023-10-16' });
|
||||
const webhookSecret = Deno.env.get('STRIPE_WEBHOOK_SECRET')!;
|
||||
const internalWebhookSecret = Deno.env.get('SUPABASE_WEBHOOK_SECRET')!;
|
||||
|
||||
serve(async (req) => {
|
||||
const body = await req.text();
|
||||
@@ -42,6 +43,31 @@ serve(async (req) => {
|
||||
};
|
||||
if (stripe_fee !== null) updateData.stripe_fee = stripe_fee;
|
||||
await supabase.from('invoices').update(updateData).eq('id', invoice_id);
|
||||
|
||||
const { data: invoice } = await supabase
|
||||
.from('invoices')
|
||||
.select('invoice_number, invoice_email, bill_to, total, paid_at, company_id')
|
||||
.eq('id', invoice_id)
|
||||
.single();
|
||||
if (!invoice?.invoice_email) return;
|
||||
|
||||
await fetch(`${Deno.env.get('SUPABASE_URL')}/functions/v1/send-email`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'x-webhook-secret': internalWebhookSecret,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
type: 'receipt_sent',
|
||||
to: [invoice.invoice_email],
|
||||
data: {
|
||||
invoiceNumber: invoice.invoice_number,
|
||||
billTo: invoice.bill_to || invoice.invoice_email,
|
||||
total: `$${Number(invoice.total || 0).toFixed(2)}`,
|
||||
paidDate: new Date(invoice.paid_at || new Date().toISOString()).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }),
|
||||
},
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
// Card payments: session completes with payment_status = 'paid' immediately
|
||||
|
||||
Reference in New Issue
Block a user