feat: added profile routing

This commit is contained in:
antifallobst 2023-10-13 18:20:18 +02:00
parent 0d382b6869
commit b989dc06d7
Signed by: antifallobst
GPG Key ID: 2B4F402172791BAF
3 changed files with 19 additions and 2 deletions

View File

@ -1,3 +1,4 @@
pub mod about; pub mod about;
pub mod error;
pub mod home; pub mod home;
pub mod error; pub mod profile;

View File

@ -0,0 +1,13 @@
use yew::prelude::*;
#[derive(PartialEq, Properties)]
pub struct Props {
pub username: AttrValue,
}
#[function_component]
pub fn Profile(props: &Props) -> Html {
html! {
<h1>{"User profile: "}{props.username.clone()}</h1>
}
}

View File

@ -3,7 +3,7 @@ mod content;
mod topbar; mod topbar;
use backend::Session; use backend::Session;
use content::{about::About, error, home::Home}; use content::{about::About, error, home::Home, profile::Profile};
use gloo::dialogs::alert; use gloo::dialogs::alert;
use gloo_storage::{SessionStorage, Storage}; use gloo_storage::{SessionStorage, Storage};
use std::ops::Deref; use std::ops::Deref;
@ -21,6 +21,8 @@ enum Route {
Community, Community,
#[at("/about")] #[at("/about")]
About, About,
#[at("/profile/:username")]
Profile { username: String },
#[not_found] #[not_found]
#[at("/404")] #[at("/404")]
NotFound, NotFound,
@ -32,6 +34,7 @@ fn switch(routes: Route) -> Html {
Route::Services => html! {<h1>{ "Services" }</h1>}, Route::Services => html! {<h1>{ "Services" }</h1>},
Route::Community => html! {<h1>{ "Community" }</h1>}, Route::Community => html! {<h1>{ "Community" }</h1>},
Route::About => html! {<About/>}, Route::About => html! {<About/>},
Route::Profile { username } => html! { <Profile username={username}/> },
Route::NotFound => html! { <error::NotFound/> }, Route::NotFound => html! { <error::NotFound/> },
} }
} }