().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 });
+ }
+ }
+ }
+ });
+ || ()
+ });
+ }
+
+ if *loading {
+ html! {{ "Loading" }
}
+ } else if let Some(e) = &*error {
+ html! { { format!("Error: {}", e) }
}
+ } else {
+ 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.map_or(false, |uid| t.user_id == uid))
+ })
+ .count();
+ html! {
+
+
{ "Offene Tickets" }
+ { count }
+
+ }
+ }
+}
+
+// #[component(SubmitStats)]
+// pub fn submit_stats_component() -> Html {}