fix(checkout): pull company from intake_data (compliance has no customer_company col)
compliance_orders stores company in intake_data JSON, not a column; read it from there (company/legal_name/entity_name) with graceful fallback. Fix e2e test seed accordingly.
This commit is contained in:
parent
9987b1e30d
commit
3c65dd8748
2 changed files with 15 additions and 3 deletions
|
|
@ -188,7 +188,18 @@ async function ensureCompliancePortalUser(
|
|||
if (!first) return;
|
||||
const email = ((first.customer_email as string) || "").toLowerCase().trim();
|
||||
const name = (first.customer_name as string) || email.split("@")[0] || "Customer";
|
||||
const company = (first.customer_company as string) || null;
|
||||
// Company: compliance_orders has no customer_company column; it lives in
|
||||
// intake_data. Fall back gracefully across order types.
|
||||
let company: string | null = (first.customer_company as string) || null;
|
||||
if (!company && first.intake_data) {
|
||||
try {
|
||||
const intake = typeof first.intake_data === "string"
|
||||
? JSON.parse(first.intake_data as string)
|
||||
: (first.intake_data as Record<string, unknown>);
|
||||
company = (intake.company as string) || (intake.legal_name as string)
|
||||
|| (intake.entity_name as string) || null;
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
if (!email) return;
|
||||
|
||||
// Skip only the genuine FMCSA-census placeholder, never a real customer who
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue