Error fixes
type mismatch in update user and some styling improvements
This commit is contained in:
@@ -268,7 +268,7 @@ pub async fn get_current_user(
|
|||||||
/// - `404 Not Found` if user doesn't exist
|
/// - `404 Not Found` if user doesn't exist
|
||||||
/// - `500 Internal Server Error` if database error occurs
|
/// - `500 Internal Server Error` if database error occurs
|
||||||
pub async fn delete_user(
|
pub async fn delete_user(
|
||||||
Path(id): Path<i32>,
|
Path(id): Path<i16>,
|
||||||
State(data): State<Arc<AppState>>,
|
State(data): State<Arc<AppState>>,
|
||||||
) -> Result<impl IntoResponse, (StatusCode, Json<serde_json::Value>)> {
|
) -> Result<impl IntoResponse, (StatusCode, Json<serde_json::Value>)> {
|
||||||
let query = sqlx::query(r#"DELETE FROM users WHERE id = $1"#)
|
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
|
/// - This endpoint requires admin privileges (enforced by middleware via
|
||||||
/// [`validate_admin`](crate::cookie::validation::validate_admin)).
|
/// [`validate_admin`](crate::cookie::validation::validate_admin)).
|
||||||
pub async fn update_user(
|
pub async fn update_user(
|
||||||
Path(id): Path<i32>,
|
Path(id): Path<i16>,
|
||||||
State(data): State<Arc<AppState>>,
|
State(data): State<Arc<AppState>>,
|
||||||
Json(body): Json<UserUpdateScheme>,
|
Json(body): Json<UserUpdateScheme>,
|
||||||
) -> Result<impl IntoResponse, (StatusCode, Json<serde_json::Value>)> {
|
) -> Result<impl IntoResponse, (StatusCode, Json<serde_json::Value>)> {
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ pub fn submit_ticket_component() -> Html {
|
|||||||
<option value="Whiteboard Beamer">{ "Whiteboard Beamer" }</option>
|
<option value="Whiteboard Beamer">{ "Whiteboard Beamer" }</option>
|
||||||
<option value="Internet">{ "Internet" }</option>
|
<option value="Internet">{ "Internet" }</option>
|
||||||
<option value="iPad Koffer">{ "iPad Koffer" }</option>
|
<option value="iPad Koffer">{ "iPad Koffer" }</option>
|
||||||
<option value="Apple TV">{ "Apple TV" }</option>
|
<option value="Apple TV" selected=true>{ "Apple TV" }</option>
|
||||||
<option value="Docu Cam">{ "Dokumenten Kamera" }</option>
|
<option value="Docu Cam">{ "Dokumenten Kamera" }</option>
|
||||||
<option value="Sonstiges">{ "Sonstiges" }</option>
|
<option value="Sonstiges">{ "Sonstiges" }</option>
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -771,10 +771,10 @@ pub fn user_by_id_component(props: &UserProps) -> Html {
|
|||||||
|
|
||||||
<button type="submit" disabled={*saving}>{ if *saving { "Speichern..." } else { "Speichern" } }</button>
|
<button type="submit" disabled={*saving}>{ if *saving { "Speichern..." } else { "Speichern" } }</button>
|
||||||
if *save_success {
|
if *save_success {
|
||||||
<p style="color:green">{ "Erfolgreich aktualisiert" }</p>
|
<p class="alert success">{ "Erfolgreich aktualisiert" }</p>
|
||||||
}
|
}
|
||||||
if let Some(err) = &*save_error {
|
if let Some(err) = &*save_error {
|
||||||
<p style="color:red">{ err.clone() }</p>
|
<p class="alert error">{ err.clone() }</p>
|
||||||
}
|
}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@@ -784,7 +784,7 @@ pub fn user_by_id_component(props: &UserProps) -> Html {
|
|||||||
|
|
||||||
<Link<crate::Route> to={crate::Route::AllUsers} classes="return-to">{ "Zurück zur Benutzerübersicht" }</Link<crate::Route>>
|
<Link<crate::Route> to={crate::Route::AllUsers} classes="return-to">{ "Zurück zur Benutzerübersicht" }</Link<crate::Route>>
|
||||||
if let Some(err) = &*delete_error {
|
if let Some(err) = &*delete_error {
|
||||||
<p style="color:red">{ err.clone() }</p>
|
<p class="alert error">{ err.clone() }</p>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -285,7 +285,8 @@ pub fn ticket_count_component() -> Html {
|
|||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
&& response.status() == 200
|
&& response.status() == 200
|
||||||
&& let Ok(json) = response.json::<serde_json::Value>().await {
|
&& let Ok(json) = response.json::<serde_json::Value>().await
|
||||||
|
{
|
||||||
let id = json
|
let id = json
|
||||||
.get("data")
|
.get("data")
|
||||||
.and_then(|d| d.get("id"))
|
.and_then(|d| d.get("id"))
|
||||||
@@ -311,10 +312,7 @@ pub fn ticket_count_component() -> Html {
|
|||||||
let status_conditions = |t: &Ticket| t.status == "ToDo" || t.status == "InProgress";
|
let status_conditions = |t: &Ticket| t.status == "ToDo" || t.status == "InProgress";
|
||||||
let count = tickets
|
let count = tickets
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|t| {
|
.filter(|t| status_conditions(t) && (user.is_admin || (user.id == Some(t.user_id))))
|
||||||
status_conditions(t)
|
|
||||||
&& (user.is_admin || (user.id == Some(t.user_id)))
|
|
||||||
})
|
|
||||||
.count();
|
.count();
|
||||||
html! {
|
html! {
|
||||||
<div class="open-tickets">
|
<div class="open-tickets">
|
||||||
@@ -435,7 +433,7 @@ pub fn submit_stats_component() -> Html {
|
|||||||
<p>{ "Lade..." }</p>
|
<p>{ "Lade..." }</p>
|
||||||
}
|
}
|
||||||
if let Some(e) = &*error {
|
if let Some(e) = &*error {
|
||||||
<p style="color: red;">{ e.clone() }</p>
|
<p class="alert error">{ e.clone() }</p>
|
||||||
}
|
}
|
||||||
<h3>{ "Tickets pro Wochentag" }</h3>
|
<h3>{ "Tickets pro Wochentag" }</h3>
|
||||||
<div class="weekday-chart">
|
<div class="weekday-chart">
|
||||||
|
|||||||
Reference in New Issue
Block a user