Simple Fix Popup

There is a popup that tells the user simple ways to fix things and also
increments a counter if it worked
This commit is contained in:
2026-05-13 22:57:43 +02:00
parent f8a89d820b
commit a23fe9be7c
2 changed files with 65 additions and 2 deletions

View File

@@ -170,10 +170,25 @@ pub fn submit_ticket_component() -> Html {
let valid_rooms: HashSet<i16> = VALID_ROOMS.iter().copied().collect(); let valid_rooms: HashSet<i16> = VALID_ROOMS.iter().copied().collect();
{ {
let message = "Bevor sie zum Support weitergeleitet werden prüfen sie ob: \r\n - Ob das Problem durch Neustarten gelößt wird \r\n - Ob sie die richtigen Anmeldedaten genutzt habem \r\n - Alle notwendigen Kabel eingesteckt sind".to_string(); let message = "Bevor sie zum Support weitergeleitet werden prüfen sie ob:
- Ob das Problem durch Neustarten gelößt wird
- Ob sie die richtigen Anmeldedaten genutzt habem
- Alle notwendigen Kabel eingesteckt sind
Wenn es funktioniert hat klicken sie bitte \"Abbrechen\""
.to_string();
use_effect(move || { use_effect(move || {
if let Some(win) = web_sys::window() { if let Some(win) = web_sys::window() {
let _ = win.alert_with_message(&message); let _ = if win.confirm_with_message(&message).unwrap() {
} else {
spawn_local(async move {
let _ = Request::post("/api/count")
.credentials(web_sys::RequestCredentials::Include)
.send()
.await;
});
let _ = win.location().set_href("/");
};
} }
|| () || ()
}); });

View File

@@ -17,6 +17,11 @@ use crate::pages::ticket::{ActiveUser, Ticket};
/// # Fields /// # Fields
/// - `date`: The creation date and time of the ticket in UTC. /// - `date`: The creation date and time of the ticket in UTC.
/// - `room`: The room number associated with the ticket. /// - `room`: The room number associated with the ticket.
#[derive(Deserialize)]
struct CountResponse {
value: i64,
}
#[derive(Debug, Deserialize, Clone, PartialEq)] #[derive(Debug, Deserialize, Clone, PartialEq)]
struct TicketPartial { struct TicketPartial {
date: DateTime<Utc>, date: DateTime<Utc>,
@@ -186,6 +191,7 @@ pub fn diagnostics_component() -> Html {
html! { html! {
<div> <div>
<TicketCount/> <TicketCount/>
<EasyFixCount/>
<SubmitStats/> <SubmitStats/>
</div> </div>
} }
@@ -575,3 +581,45 @@ fn user_total_component(props: &UserTotalProps) -> Html {
</div> </div>
} }
} }
#[component(EasyFixCount)]
fn easy_fix_component() -> Html {
let count = use_state(|| 0);
let error = use_state(|| None::<String>);
{
let count = count.clone();
let error = error.clone();
use_effect_with((), move |_| {
spawn_local(async move {
match Request::get("/api/count").send().await {
Ok(resp) if resp.status() == 200 => match resp.json::<CountResponse>().await {
Ok(r) => count.set(r.value),
Err(e) => error.set(Some(format!("parse error: {}", e))),
},
Ok(resp) => error.set(Some(
resp.text()
.await
.unwrap_or_else(|_| format!("status {}", resp.status())),
)),
Err(e) => error.set(Some(format!("Network error: {}", e))),
}
});
|| ()
});
}
html! {
<div>
<h2>{ "Probleme ohne Ticket gelößt" }</h2>
<h4>{ *count }</h4>
{
if let Some(e) = &*error {
html!{ <p style="color: red;">{ e.clone() }</p> }
} else {
html!{}
}
}
</div>
}
}