From 00923681ecfc2eb5e9227da404d355304c1b8f06 Mon Sep 17 00:00:00 2001 From: Ashwin Kumar Sivakumar Date: Sun, 19 Jul 2026 22:03:36 +0530 Subject: [PATCH] fix: company profile submission stored wrapper object as verification payload submit_with_documents parsed the multipart 'profile' field (shaped {roleKey, profile_data: {...}} per the frontend wizard) but read fields like company_name directly off the outer wrapper instead of unwrapping profile_data first - every company_profiles field ended up blank, and the double-wrapped object got stored as the verification's payload, breaking admin-side rendering of company name/details. Co-Authored-By: Claude Sonnet 5 --- apps/companies/src/handlers/mod.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/companies/src/handlers/mod.rs b/apps/companies/src/handlers/mod.rs index f188431..5dafc80 100644 --- a/apps/companies/src/handlers/mod.rs +++ b/apps/companies/src/handlers/mod.rs @@ -902,7 +902,7 @@ async fn submit_with_documents( } }; - let profile_obj: serde_json::Value = match serde_json::from_str(&profile_str) { + let profile_wrapper: serde_json::Value = match serde_json::from_str(&profile_str) { Ok(v) => v, Err(e) => { return ( @@ -913,6 +913,18 @@ async fn submit_with_documents( } }; + // The frontend sends `{ roleKey, profile_data: {...actual fields} }` (see + // submitCompanyProfileWithDocuments in nxtgauge-frontend-solid/src/lib/api.ts). + // Unwrap `profile_data` here so every field lookup below and the verification + // payload we store operate on the actual company fields, not the outer wrapper - + // reading e.g. `company_name` directly off the wrapper always came back empty, + // and storing the wrapper itself as the verification payload made admin-side + // rendering of company name/details break for every submission through this path. + let profile_obj: serde_json::Value = profile_wrapper + .get("profile_data") + .cloned() + .unwrap_or(profile_wrapper); + // ---- 2. Save profile to `company_profiles` (DRAFT upsert). ---- // SQL mapping copied verbatim from apps/users/src/handlers/profile.rs:236-335 (COMPANY branch). let name = profile_obj