fix(profile): persist all COMPANY profile fields, not just company_name
All checks were successful
build-and-release / build (developers) (push) Successful in 7s
build-and-release / build (video-editors) (push) Successful in 4s
build-and-release / build (companies) (push) Successful in 10s
build-and-release / build (fitness-trainers) (push) Successful in 3s
build-and-release / build (users) (push) Successful in 7m44s
build-and-release / build (cron) (push) Successful in 15s
build-and-release / build (customers) (push) Successful in 13s
build-and-release / build (employees) (push) Successful in 12s
build-and-release / build (gateway) (push) Successful in 3s
build-and-release / build (catering-services) (push) Successful in 16s
build-and-release / build (graphic-designers) (push) Successful in 4s
build-and-release / build (job-seekers) (push) Successful in 4s
build-and-release / build (jobs) (push) Successful in 5s
build-and-release / build (makeup-artists) (push) Successful in 4s
build-and-release / build (leads) (push) Successful in 4s
build-and-release / build (payments) (push) Successful in 5s
build-and-release / build (photographers) (push) Successful in 4s
build-and-release / build (social-media-managers) (push) Successful in 4s
build-and-release / build (tutors) (push) Successful in 3s
build-and-release / build (ugc-content-creators) (push) Successful in 4s

This commit is contained in:
Ashwin Kumar Sivakumar 2026-07-10 14:27:15 +05:30
parent 9d475858ab
commit 5fa1f8f74c

View file

@ -240,18 +240,85 @@ async fn save_profile(
.and_then(|v| v.as_str())
.unwrap_or_default()
.to_string();
let email = input
.profile_data
.get("company_email")
.and_then(|v| v.as_str())
.unwrap_or_default()
.to_string();
let phone = input
.profile_data
.get("company_phone")
.and_then(|v| v.as_str())
.unwrap_or_default()
.to_string();
let website = input
.profile_data
.get("website")
.and_then(|v| v.as_str())
.unwrap_or_default()
.to_string();
let city = input
.profile_data
.get("location")
.and_then(|v| v.as_str())
.unwrap_or_default()
.to_string();
let state_val = input
.profile_data
.get("state")
.and_then(|v| v.as_str())
.unwrap_or_default()
.to_string();
let postal = input
.profile_data
.get("pin_code")
.and_then(|v| v.as_str())
.unwrap_or_default()
.to_string();
let address = input
.profile_data
.get("address")
.and_then(|v| v.as_str())
.unwrap_or_default()
.to_string();
let gst = input
.profile_data
.get("gst_number")
.and_then(|v| v.as_str())
.unwrap_or_default()
.to_string();
return match sqlx::query(
r#"
INSERT INTO company_profiles (user_id, company_name, status, updated_at)
VALUES ($1, $2, 'DRAFT', NOW())
INSERT INTO company_profiles (
user_id, company_name, contact_email, contact_phone, website_url,
address_line1, city, state, postal_code, gst_number, status, updated_at
)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, 'DRAFT', NOW())
ON CONFLICT (user_id) DO UPDATE SET
company_name = EXCLUDED.company_name,
contact_email = EXCLUDED.contact_email,
contact_phone = EXCLUDED.contact_phone,
website_url = EXCLUDED.website_url,
address_line1 = EXCLUDED.address_line1,
city = EXCLUDED.city,
state = EXCLUDED.state,
postal_code = EXCLUDED.postal_code,
gst_number = EXCLUDED.gst_number,
updated_at = NOW()
"#,
)
.bind(auth.user_id)
.bind(&name)
.bind(&email)
.bind(&phone)
.bind(&website)
.bind(&address)
.bind(&city)
.bind(&state_val)
.bind(&postal)
.bind(&gst)
.execute(&state.pool)
.await
{
@ -260,7 +327,10 @@ async fn save_profile(
Json(serde_json::json!({ "saved": true, "role_key": role_key })),
)
.into_response(),
Err(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(),
Err(e) => {
tracing::error!("save_profile(COMPANY) failed for user {}: {}", auth.user_id, e);
(StatusCode::INTERNAL_SERVER_ERROR, format!("Database error: {}", e)).into_response()
}
};
}