tsk-14: Update user profile #15

Merged
phoenix merged 8 commits from tsk-14 into main 2026-11-11 13:13:50 -05:00
Showing only changes of commit 9c591af773 - Show all commits
+27 -20
View File
@@ -508,27 +508,34 @@ pub mod endpoint {
Ok(user) => {
let firstname = payload.firstname;
let lastname = payload.lastname;
match repo::user::update_user_profile(&pool, &user_id, &firstname, &lastname)
if firstname == user.firstname && lastname == user.lastname {
(axum::http::StatusCode::NOT_MODIFIED, axum::Json(response))
} else {
match repo::user::update_user_profile(
&pool, &user_id, &firstname, &lastname,
)
.await
{
Ok(_) => {
let user_profile = simodels::user::UserProfile {
firstname,
lastname,
username: user.username,
email: user.email,
};
response.message = "SUCCESSFUL".to_string();
response.data.push(user_profile);
(axum::http::StatusCode::OK, axum::Json(response))
}
Err(err) => {
eprintln!("Error: {err:?}");
response.message = "ERROR - Updating user profile".to_string();
(
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
axum::Json(response),
)
{
Ok(_) => {
let user_profile = simodels::user::UserProfile {
firstname,
lastname,
username: user.username,
email: user.email,
};
response.message = "SUCCESSFUL".to_string();
response.data.push(user_profile);
(axum::http::StatusCode::OK, axum::Json(response))
}
Err(err) => {
eprintln!("Error: {err:?}");
response.message = "ERROR - Updating user profile".to_string();
(
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
axum::Json(response),
)
}
}
}
}