Vendor profile email: add where-to-send-invoices block

Below the Submit vendor profile button, instruct vendors to email bills to
ap@avriacam.com or mail them to the association's mailing address, c/o Avria
Community Management, LLC. The address is resolved from the vendor's
association (association_id, falling back to association_ids[0]).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-16 12:20:12 -04:00
parent fe6893b367
commit 393268dd04
2 changed files with 38 additions and 2 deletions
@@ -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,
},
}),
})