feat: added profile routing
This commit is contained in:
parent
0d382b6869
commit
b989dc06d7
|
@ -1,3 +1,4 @@
|
|||
pub mod about;
|
||||
pub mod home;
|
||||
pub mod error;
|
||||
pub mod home;
|
||||
pub mod profile;
|
||||
|
|
|
@ -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>
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ mod content;
|
|||
mod topbar;
|
||||
|
||||
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_storage::{SessionStorage, Storage};
|
||||
use std::ops::Deref;
|
||||
|
@ -21,6 +21,8 @@ enum Route {
|
|||
Community,
|
||||
#[at("/about")]
|
||||
About,
|
||||
#[at("/profile/:username")]
|
||||
Profile { username: String },
|
||||
#[not_found]
|
||||
#[at("/404")]
|
||||
NotFound,
|
||||
|
@ -32,6 +34,7 @@ fn switch(routes: Route) -> Html {
|
|||
Route::Services => html! {<h1>{ "Services" }</h1>},
|
||||
Route::Community => html! {<h1>{ "Community" }</h1>},
|
||||
Route::About => html! {<About/>},
|
||||
Route::Profile { username } => html! { <Profile username={username}/> },
|
||||
Route::NotFound => html! { <error::NotFound/> },
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue