Files
M-CTF-2025/dollhouse/crates/dollhouse-frontend/src/routes.rs

51 lines
1.1 KiB
Rust
Raw Normal View History

2025-12-14 10:39:18 +03:00
use yew::prelude::*;
use yew_router::prelude::*;
use crate::pages::{CorpPage, LoginPage, NotFound, RegisterPage, ReplicantDetail, ReplicantsPage};
use crate::Layout;
use uuid::Uuid;
#[derive(Clone, Routable, PartialEq)]
pub enum Route {
#[at("/")]
Replicants,
#[at("/replicants/:id")]
ReplicantDetail { id: Uuid },
#[not_found]
#[at("/404")]
NotFound,
#[at("/login")]
Login,
#[at("/register")]
Register,
#[at("/corp")]
Corp,
}
pub fn switch(routes: Route) -> Html {
match routes {
Route::Login => html! { <LoginPage /> },
Route::Register => html! { <RegisterPage /> },
Route::Replicants => html! {
<Layout>
<ReplicantsPage />
</Layout>
},
Route::ReplicantDetail { id } => {
html! {
<Layout>
<ReplicantDetail replicant_id={id} />
</Layout>
}
}
Route::NotFound => html! {
<NotFound />
},
Route::Corp => html! {
<Layout>
<CorpPage />
</Layout>
},
}
}