From 6ef50d06aa300ad32dd3cca0200c37267fabd309 Mon Sep 17 00:00:00 2001 From: schn33fuchs Date: Thu, 28 May 2026 18:49:29 +0200 Subject: [PATCH] Error fixes type mismatch in update user and some styling improvements --- backend/src/handlers/auth.rs | 4 ++-- frontend/src/pages/ticket.rs | 2 +- frontend/src/pages/user.rs | 6 +++--- frontend/src/pages/utilities.rs | 34 ++++++++++++++++----------------- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/backend/src/handlers/auth.rs b/backend/src/handlers/auth.rs index 062a8d2..bcfc76a 100644 --- a/backend/src/handlers/auth.rs +++ b/backend/src/handlers/auth.rs @@ -268,7 +268,7 @@ pub async fn get_current_user( /// - `404 Not Found` if user doesn't exist /// - `500 Internal Server Error` if database error occurs pub async fn delete_user( - Path(id): Path, + Path(id): Path, State(data): State>, ) -> Result)> { let query = sqlx::query(r#"DELETE FROM users WHERE id = $1"#) @@ -411,7 +411,7 @@ pub async fn get_user_by_id( /// - This endpoint requires admin privileges (enforced by middleware via /// [`validate_admin`](crate::cookie::validation::validate_admin)). pub async fn update_user( - Path(id): Path, + Path(id): Path, State(data): State>, Json(body): Json, ) -> Result)> { diff --git a/frontend/src/pages/ticket.rs b/frontend/src/pages/ticket.rs index abfbca8..6be9abf 100644 --- a/frontend/src/pages/ticket.rs +++ b/frontend/src/pages/ticket.rs @@ -302,7 +302,7 @@ pub fn submit_ticket_component() -> Html { - + diff --git a/frontend/src/pages/user.rs b/frontend/src/pages/user.rs index 66ecd24..b67e802 100644 --- a/frontend/src/pages/user.rs +++ b/frontend/src/pages/user.rs @@ -771,10 +771,10 @@ pub fn user_by_id_component(props: &UserProps) -> Html { if *save_success { -

{ "Erfolgreich aktualisiert" }

+

{ "Erfolgreich aktualisiert" }

} if let Some(err) = &*save_error { -

{ err.clone() }

+

{ err.clone() }

} @@ -784,7 +784,7 @@ pub fn user_by_id_component(props: &UserProps) -> Html { to={crate::Route::AllUsers} classes="return-to">{ "Zurück zur Benutzerübersicht" }> if let Some(err) = &*delete_error { -

{ err.clone() }

+

{ err.clone() }

} } diff --git a/frontend/src/pages/utilities.rs b/frontend/src/pages/utilities.rs index 25d0e1a..316c354 100644 --- a/frontend/src/pages/utilities.rs +++ b/frontend/src/pages/utilities.rs @@ -285,19 +285,20 @@ pub fn ticket_count_component() -> Html { .send() .await && response.status() == 200 - && let Ok(json) = response.json::().await { - let id = json - .get("data") - .and_then(|d| d.get("id")) - .and_then(|v| v.as_i64()) - .and_then(|n| i16::try_from(n).ok()); - let is_admin = json - .get("data") - .and_then(|d| d.get("is_admin")) - .and_then(|v| v.as_bool()) - .unwrap_or(false); - user.set(ActiveUser { id, is_admin }); - } + && let Ok(json) = response.json::().await + { + let id = json + .get("data") + .and_then(|d| d.get("id")) + .and_then(|v| v.as_i64()) + .and_then(|n| i16::try_from(n).ok()); + let is_admin = json + .get("data") + .and_then(|d| d.get("is_admin")) + .and_then(|v| v.as_bool()) + .unwrap_or(false); + user.set(ActiveUser { id, is_admin }); + } }); || () }); @@ -311,10 +312,7 @@ pub fn ticket_count_component() -> Html { let status_conditions = |t: &Ticket| t.status == "ToDo" || t.status == "InProgress"; let count = tickets .iter() - .filter(|t| { - status_conditions(t) - && (user.is_admin || (user.id == Some(t.user_id))) - }) + .filter(|t| status_conditions(t) && (user.is_admin || (user.id == Some(t.user_id)))) .count(); html! {
@@ -435,7 +433,7 @@ pub fn submit_stats_component() -> Html {

{ "Lade..." }

} if let Some(e) = &*error { -

{ e.clone() }

+

{ e.clone() }

}

{ "Tickets pro Wochentag" }