diff --git a/supabase/functions/_shared/transactional-email-templates/vendor-profile-request.tsx b/supabase/functions/_shared/transactional-email-templates/vendor-profile-request.tsx index bd0cbb6..6188174 100644 --- a/supabase/functions/_shared/transactional-email-templates/vendor-profile-request.tsx +++ b/supabase/functions/_shared/transactional-email-templates/vendor-profile-request.tsx @@ -7,11 +7,14 @@ interface VendorProfileRequestProps { requesterName?: string link?: string expiresAt?: string + associationName?: string + billingAddress?: string } const SITE_NAME = 'Avria Community Management' +const AP_EMAIL = 'ap@avriacam.com' -const VendorProfileRequestEmail = ({ vendorName, requesterName, link, expiresAt }: VendorProfileRequestProps) => ( +const VendorProfileRequestEmail = ({ vendorName, requesterName, link, expiresAt, associationName, billingAddress }: VendorProfileRequestProps) => ( Vendor profile information requested for {vendorName || 'your account'} @@ -27,6 +30,18 @@ const VendorProfileRequestEmail = ({ vendorName, requesterName, link, expiresAt {link && } {expiresAt && This secure link expires on {expiresAt}.} +
+ Where to send your invoices + + Please email all invoices and bills to{' '} + {AP_EMAIL}, or mail them to: + + + {[associationName, 'c/o Avria Community Management, LLC', billingAddress] + .filter(Boolean) + .join('\n')} + +
This request was sent by {SITE_NAME}. If you weren't expecting it, you can ignore this email. @@ -45,6 +60,8 @@ export const template = { requesterName: 'Avria Community Management', link: 'https://avria.cloud/vendor-profile/sample-token', expiresAt: 'June 1, 2026', + associationName: 'Village Woods of La Cita Homeowners Association, Inc.', + billingAddress: 'P.O. Box 560099\nRockledge, FL 32956', }, } satisfies TemplateEntry @@ -56,3 +73,8 @@ const text = { color: '#374151', fontSize: '15px', lineHeight: '24px', margin: ' const meta = { color: '#6b7280', fontSize: '13px', lineHeight: '20px', margin: '14px 0 0' } const button = { backgroundColor: '#2563eb', color: '#ffffff', borderRadius: '6px', fontSize: '14px', fontWeight: '600', textDecoration: 'none', padding: '12px 18px' } const footer = { color: '#6b7280', fontSize: '12px', lineHeight: '18px', margin: '28px 0 0' } +const billingBox = { backgroundColor: '#f9fafb', border: '1px solid #e5e7eb', borderRadius: '8px', padding: '16px 18px', margin: '26px 0 0' } +const billingHeading = { color: '#111827', fontSize: '15px', lineHeight: '22px', fontWeight: '700', margin: '0 0 8px' } +const billingText = { color: '#374151', fontSize: '14px', lineHeight: '22px', margin: '0 0 10px' } +const emailLink = { color: '#2563eb', textDecoration: 'underline' } +const addressText = { color: '#111827', fontSize: '14px', lineHeight: '22px', margin: '0', whiteSpace: 'pre-line' as const, fontWeight: '600' } diff --git a/supabase/functions/send-vendor-profile-request/index.ts b/supabase/functions/send-vendor-profile-request/index.ts index 8e56831..392f47d 100644 --- a/supabase/functions/send-vendor-profile-request/index.ts +++ b/supabase/functions/send-vendor-profile-request/index.ts @@ -46,7 +46,7 @@ Deno.serve(async (req) => { } const { data: vendor, error: vErr } = await admin - .from('vendors').select('id, name, email').eq('id', vendor_id).single() + .from('vendors').select('id, name, email, association_id, association_ids').eq('id', vendor_id).single() if (vErr || !vendor) { return new Response(JSON.stringify({ error: 'Vendor not found' }), { status: 404, headers: { ...corsHeaders, 'Content-Type': 'application/json' }, @@ -61,6 +61,18 @@ Deno.serve(async (req) => { const { data: profile } = await admin .from('profiles').select('full_name').eq('user_id', userId).maybeSingle() + // Resolve the vendor's association for the "where to send invoices" block. + const assocId = vendor.association_id + || (Array.isArray(vendor.association_ids) ? vendor.association_ids[0] : null) + let associationName: string | undefined + let billingAddress: string | undefined + if (assocId) { + const { data: assoc } = await admin + .from('associations').select('name, mailing_address').eq('id', assocId).maybeSingle() + associationName = assoc?.name || undefined + billingAddress = assoc?.mailing_address || undefined + } + const { data: reqRow, error: reqErr } = await admin .from('vendor_profile_requests') .insert({ vendor_id, sent_to_email: vendor.email, created_by: userId }) @@ -99,6 +111,8 @@ Deno.serve(async (req) => { requesterName: profile?.full_name || 'Avria Community Management', link, expiresAt, + associationName, + billingAddress, }, }), })