From 2da1ebc8be967af67197c7c8ab808ec982de0d17 Mon Sep 17 00:00:00 2001 From: Ashwin Kumar Sivakumar Date: Wed, 29 Jul 2026 15:00:25 +0530 Subject: [PATCH] Fix COMPANY verification snapshot dropping every field but company_name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fetch_saved_profile() is the fallback used by submit-for-verification when the caller doesn't send profile_data (e.g. VerificationStatusPage's resubmit-after-revision-request flow, which only sends {roleKey}). It's a separate implementation from GET /api/profile and still had the same stale COMPANY query that was already fixed there — SELECT company_name only, discarding email/phone/website/address/city/state/pin/GST. The admin verification sidebar renders exactly this snapshot, so a resubmit made every other field vanish from the admin's review view. Select and return the full column set, matching get_profile. Co-Authored-By: Claude Sonnet 5 --- apps/users/src/handlers/profile.rs | 32 +++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/apps/users/src/handlers/profile.rs b/apps/users/src/handlers/profile.rs index 609ee18..970da9b 100644 --- a/apps/users/src/handlers/profile.rs +++ b/apps/users/src/handlers/profile.rs @@ -893,15 +893,37 @@ async fn fetch_saved_profile( role_key: &str, ) -> serde_json::Value { if role_key == "COMPANY" { - return match sqlx::query(r#"SELECT company_name FROM company_profiles WHERE user_id = $1"#) - .bind(user_id) - .fetch_optional(&state.pool) - .await + return match sqlx::query( + r#"SELECT company_name, contact_email, contact_phone, website_url, + address_line1, city, state, postal_code, gst_number + FROM company_profiles WHERE user_id = $1"#, + ) + .bind(user_id) + .fetch_optional(&state.pool) + .await { Ok(Some(r)) => { use sqlx::Row; let name: Option = r.try_get("company_name").ok(); - serde_json::json!({ "company_name": name }) + let email: Option = r.try_get("contact_email").ok(); + let phone: Option = r.try_get("contact_phone").ok(); + let website: Option = r.try_get("website_url").ok(); + let address: Option = r.try_get("address_line1").ok(); + let city: Option = r.try_get("city").ok(); + let state_val: Option = r.try_get("state").ok(); + let postal: Option = r.try_get("postal_code").ok(); + let gst: Option = r.try_get("gst_number").ok(); + serde_json::json!({ + "company_name": name, + "company_email": email, + "company_phone": phone, + "website": website, + "address": address, + "location": city, + "state": state_val, + "pin_code": postal, + "gst_number": gst, + }) } _ => serde_json::Value::Object(Default::default()), };