`;
}
async function respondOffer(offerId, response) {
const confirmMsg = response === 'accepted'
? 'Confirm you wish to accept this offer. The desk will follow up to coordinate next steps.'
: 'Confirm you wish to decline this offer. The desk will be notified.';
if (!confirm(confirmMsg)) return;
await fetch(`${SUPABASE_URL}/rest/v1/offers?id=eq.${offerId}`, {
method: 'PATCH',
headers: { apikey: SUPABASE_KEY, Authorization: `Bearer ${SUPABASE_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ status: response, responded_at: new Date().toISOString() }),
});
const card = document.getElementById('offer-card-' + offerId);
if (card) {
const el = card.querySelector('.offer-card-actions, .offer-responded-msg');
if (response === 'accepted') {
el.outerHTML = '
✓ You accepted this offer — the desk will be in touch shortly.