Files
ticketsystem/frontend/src/lib.rs
schn33fuchs 63af32c4af Show user by ID implemented
At /users/{id},
Also minor bugfixes and improvements
2026-04-29 20:54:14 +02:00

51 lines
1.2 KiB
Rust

mod pages;
use crate::pages::*;
use yew::prelude::*;
use yew_router::prelude::*;
#[derive(Clone, PartialEq, Routable)]
enum Route {
#[at("/")]
Home,
#[at("/ticket")]
Ticket,
#[at("/tickets/:id")]
TicketById { id: i32 },
#[at("/tickets")]
AllTickets,
#[at("/register")]
Register,
#[at("/login")]
Login,
#[at("/users")]
AllUsers,
#[at("/users/:id")]
UserByID { id: i16 },
#[not_found]
#[at("/404")]
NotFound,
}
fn switch(route: Route) -> Html {
match route {
Route::Home => html! { <basic_pages::Home/>},
Route::NotFound => html! { <basic_pages::NotFound/> },
Route::Ticket => html! { <ticket::SubmitTicket/> },
Route::TicketById { id } => html! { <ticket::TicketByID id={id}/> },
Route::AllTickets => html! { <ticket::AllTickets/> },
Route::Register => html! { <user::Register/> },
Route::Login => html! { <user::Login/> },
Route::AllUsers => html! {<user::AllUsers/>},
Route::UserByID { id } => html! { <user::UserByID id={id}/> },
}
}
#[component(App)]
pub fn app() -> Html {
html! {
<BrowserRouter>
<Switch<Route> render={switch} />
</BrowserRouter>
}
}