Pages link to each other
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use gloo_net::http::Request;
|
||||
use wasm_bindgen_futures::spawn_local;
|
||||
use yew::prelude::*;
|
||||
use yew_router::prelude::*;
|
||||
|
||||
#[component(Home)]
|
||||
pub fn home_component() -> Html {
|
||||
@@ -31,7 +32,7 @@ pub fn home_component() -> Html {
|
||||
match *is_admin {
|
||||
None => html! { <div>{ "Loading..." }</div> },
|
||||
Some(true) => html! { <div>{ "You are admin" }</div> },
|
||||
Some(false) => html! { <div>{ "You are a normal user" }</div> },
|
||||
Some(false) => html! { <Redirect<crate::Route> to={crate::Route::Ticket}/> },
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen_futures::spawn_local;
|
||||
use web_sys::HtmlSelectElement;
|
||||
use yew::prelude::*;
|
||||
use yew_router::prelude::*;
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||
pub struct TicketCreateScheme {
|
||||
@@ -155,6 +156,8 @@ pub fn submit_ticket_component() -> Html {
|
||||
<br/>
|
||||
<button type="submit">{ "Send" }</button>
|
||||
|
||||
<Link<crate::Route> to={crate::Route::AllTickets}>{ "Tickets ansehen" }</Link<crate::Route>>
|
||||
|
||||
{
|
||||
if let Some(s) = &*status {
|
||||
html!{ <p>{ s }</p> }
|
||||
@@ -338,6 +341,8 @@ pub fn ticket_by_id_component(props: &TicketProps) -> Html {
|
||||
<button onclick={ondelete} disabled={*deleting}>
|
||||
{if *deleting {"Löschen..."} else {"Löschen"}}
|
||||
</button>
|
||||
|
||||
<Link<crate::Route> to={crate::Route::AllTickets}>{ "Zurück zur Ticketübersicht" }</Link<crate::Route>>
|
||||
if let Some(err) = &*delete_error {
|
||||
<p style="color:red">{ err.clone() }</p>
|
||||
}
|
||||
@@ -428,8 +433,9 @@ pub fn all_tickets_component() -> Html {
|
||||
html! {
|
||||
<ul>
|
||||
{ for tickets.iter().filter(|t| if user.is_admin { true } else if let Some(uid) = user.id { t.user_id == uid } else { false }).map(|t| html! {
|
||||
<div>
|
||||
<li key={t.id.to_string()}>
|
||||
<h3>{ format!("{} - #{}", t.betreff, t.id) }</h3>
|
||||
<Link<crate::Route> to={crate::Route::TicketById{id: t.id}}><h3>{ format!("{} - #{}", t.betreff, t.id) }</h3></Link<crate::Route>>
|
||||
<p>{ &t.description }</p>
|
||||
<p>{ match t.status.as_str() {
|
||||
"ToDo" => "Zu tun",
|
||||
@@ -439,6 +445,9 @@ pub fn all_tickets_component() -> Html {
|
||||
_ => "Ungültiger Status"
|
||||
}}</p>
|
||||
</li>
|
||||
|
||||
<Link<crate::Route> to={crate::Route::Ticket}>{ "Zurück zur Startseite" }</Link<crate::Route>>
|
||||
</div>
|
||||
})}
|
||||
</ul>
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use gloo_net::http::Request;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use wasm_bindgen_futures::spawn_local;
|
||||
use yew::prelude::*;
|
||||
use yew_router::prelude::use_navigator;
|
||||
use yew_router::prelude::*;
|
||||
|
||||
// #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
// pub struct User {
|
||||
@@ -298,7 +298,7 @@ pub fn all_users_component() -> Html {
|
||||
<ul>
|
||||
{ for users.iter().map(|t| html! {
|
||||
<li key={t.id.to_string()}>
|
||||
<h3>{ format!("{} {}- #{}", t.first_name, t.last_name, t.id) }</h3>
|
||||
<Link<crate::Route> to={crate::Route::UserByID{id: t.id}}><h3>{ format!("{} {}- #{}", t.first_name, t.last_name, t.id) }</h3></Link<crate::Route>>
|
||||
</li>
|
||||
})}
|
||||
</ul>
|
||||
@@ -576,6 +576,8 @@ pub fn user_by_id_component(props: &UserProps) -> Html {
|
||||
<button onclick={ondelete} disabled={*deleting}>
|
||||
{if *deleting {"Löschen..."} else {"Löschen"}}
|
||||
</button>
|
||||
|
||||
<Link<crate::Route> to={crate::Route::AllUsers}>{ "Zurück zur Benutzerübersicht" }</Link<crate::Route>>
|
||||
if let Some(err) = &*delete_error {
|
||||
<p style="color:red">{ err.clone() }</p>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user