feat(inquiries): website_submissions tracking + display columns; capture populates contact name/email
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,6 +25,7 @@ import {
|
||||
autoPromoteWebsiteBerthInquiry,
|
||||
isWebsiteBerthAutopromoteEnabled,
|
||||
} from '@/lib/services/website-intake-promote.service';
|
||||
import { extractInquiryFields } from '@/lib/services/website-intake-fields';
|
||||
|
||||
/**
|
||||
* POST /api/public/website-inquiries
|
||||
@@ -149,6 +150,10 @@ export async function POST(req: NextRequest) {
|
||||
// hits, `returning()` yields zero rows and we look up the existing row to
|
||||
// return its id, mirroring the first-delivery shape so the website never
|
||||
// sees a difference between fresh and dup.
|
||||
// Extract contact name/email into real columns so the inquiry list can
|
||||
// search/sort/display without digging into the JSONB payload per row.
|
||||
const fields = extractInquiryFields(parsed.payload);
|
||||
|
||||
const insertResult = await db
|
||||
.insert(websiteSubmissions)
|
||||
.values({
|
||||
@@ -157,6 +162,8 @@ export async function POST(req: NextRequest) {
|
||||
kind: parsed.kind,
|
||||
payload: parsed.payload,
|
||||
legacyNocodbId: parsed.legacy_nocodb_id ?? null,
|
||||
contactName: fields.fullName || null,
|
||||
contactEmail: fields.email || null,
|
||||
sourceIp: ip,
|
||||
userAgent: req.headers.get('user-agent') ?? null,
|
||||
utmSource: parsed.utm_source ?? null,
|
||||
|
||||
Reference in New Issue
Block a user