Fix COMPANY verification snapshot dropping every field but company_name
All checks were successful
build-and-release / build (catering-services) (push) Successful in 13s
build-and-release / build (cron) (push) Successful in 12s
build-and-release / build (customers) (push) Successful in 13s
build-and-release / build (companies) (push) Successful in 16s
build-and-release / build (developers) (push) Successful in 6s
build-and-release / build (fitness-trainers) (push) Successful in 6s
build-and-release / build (employees) (push) Successful in 6s
build-and-release / build (gateway) (push) Successful in 5s
build-and-release / build (graphic-designers) (push) Successful in 6s
build-and-release / build (job-seekers) (push) Successful in 6s
build-and-release / build (jobs) (push) Successful in 6s
build-and-release / build (makeup-artists) (push) Successful in 6s
build-and-release / build (payments) (push) Successful in 5s
build-and-release / build (photographers) (push) Successful in 5s
build-and-release / build (social-media-managers) (push) Successful in 6s
build-and-release / build (tutors) (push) Successful in 5s
build-and-release / build (ugc-content-creators) (push) Successful in 6s
build-and-release / build (video-editors) (push) Successful in 6s
build-and-release / build (users) (push) Successful in 2m49s

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 <noreply@anthropic.com>
This commit is contained in:
Ashwin Kumar Sivakumar 2026-07-29 15:00:25 +05:30
parent fd889efa22
commit 2da1ebc8be

View file

@ -893,7 +893,11 @@ 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"#)
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
@ -901,7 +905,25 @@ async fn fetch_saved_profile(
Ok(Some(r)) => {
use sqlx::Row;
let name: Option<String> = r.try_get("company_name").ok();
serde_json::json!({ "company_name": name })
let email: Option<String> = r.try_get("contact_email").ok();
let phone: Option<String> = r.try_get("contact_phone").ok();
let website: Option<String> = r.try_get("website_url").ok();
let address: Option<String> = r.try_get("address_line1").ok();
let city: Option<String> = r.try_get("city").ok();
let state_val: Option<String> = r.try_get("state").ok();
let postal: Option<String> = r.try_get("postal_code").ok();
let gst: Option<String> = 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()),
};