From 002867850d6ad134e8d9a93f3d022ba0fbac17b6 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 25 May 2026 13:28:56 +0200 Subject: [PATCH] Phase6c: Optional Company contact name --- src/app/api/onboarding/route.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/app/api/onboarding/route.ts b/src/app/api/onboarding/route.ts index b7efcd6..799e7ec 100644 --- a/src/app/api/onboarding/route.ts +++ b/src/app/api/onboarding/route.ts @@ -252,11 +252,24 @@ export async function POST(request: Request) { } } - // For follow-up instances, prefer the on-file company name and contact - // details; the user can't change those by re-typing them in the wizard. + // The audit copy of company name on this request stays inherited + // from the first request in the org — it's a historical snapshot + // of the company name at the time the request was created, and + // org_billing is now the canonical source for current values. + // + // Phase 6 fix4: contactName and contactEmail are NOT inherited. + // They identify whoever submitted THIS specific request (drives + // admin display, support ticket routing, and email greetings). + // The previous "prior?.contactName ?? user.name" pattern locked + // the contact to whoever first onboarded the org, which broke for + // any subsequent submission by a different user — admin saw the + // wrong name, support emails went to the wrong person, and the + // actual submitter had no way to correct it because the wizard + // doesn't expose a contact-name input. The fix is simply to use + // the current session user every time. const companyName = prior?.companyName ?? user.orgName; - const contactName = prior?.contactName ?? user.name; - const contactEmail = prior?.contactEmail ?? user.email; + const contactName = user.name; + const contactEmail = user.email; // Bug 35: org-scoped billing. //