().ok());
+ let new_status = select_element
+ .map(|s| s.value())
+ .unwrap_or_else(|| (*status).clone());
+ status.set(new_status.clone());
+
+ let id = id.clone();
+ let error = error.clone();
+
+ spawn_local(async move {
+ let value = TicketUpdateScheme { status: new_status };
+
+ let url = format!("/api/tickets/{}", id);
+ let request = Request::patch(&url)
+ .json(&value)
+ .expect("Failed to construct request");
+
+ match request.send().await {
+ Ok(response) if response.status() == 200 => error.set(Some("Success".into())),
+ Ok(response) => error.set(Some(format!("Error: {}", response.status()))),
+ Err(err) => error.set(Some(format!("Network error: {}", err))),
+ }
+ });
+ })
+ };
if *loading {
html! {{ "Loading" }
}
@@ -204,7 +256,25 @@ pub fn show_ticket_by_id_component(props: &TicketProps) -> Html {
{ "Beschreibung: " }{ &t.description }
{ "Raum: " }{ t.room }
{ "Datum: " }{ &t.date }
- { "Status: "}{ &t.status }
+ { "Status: "}{ match t.status.as_str() {
+ "ToDo" => "Zu tun",
+ "InProgress" => "In Bearbeitung",
+ "Completed" => "Erledigt",
+ "Archived" => "Archiviert",
+ _ => "Ungültiger Status"
+ }}
+
+
}
} else {
@@ -226,7 +296,7 @@ pub fn all_tickets_component() -> Html {
use_effect_with((), move |_| {
loading.set(true);
spawn_local(async move {
- let url = format!("http://localhost:8001/api/tickets");
+ let url = format!("/api/tickets");
match Request::get(&url).send().await {
Ok(response) if response.status() == 200 => {
match response.json::>().await {