Add example protected route to project
This commit is contained in:
parent
1e83393ad6
commit
fb5aa5ee5a
9 changed files with 161 additions and 36 deletions
|
@ -6,7 +6,7 @@ extern crate web_logger;
|
|||
mod component;
|
||||
pub mod utils;
|
||||
|
||||
use component::login::LoginComponent;
|
||||
use component::{login::LoginComponent, protected::ProtectedComponent};
|
||||
use yew::prelude::*;
|
||||
use yew::virtual_dom::VNode;
|
||||
use yew_router::{prelude::*, switch::Permissive, Switch};
|
||||
|
@ -37,6 +37,10 @@ impl Component for App {
|
|||
fn view(&self) -> VNode {
|
||||
html! {
|
||||
<div>
|
||||
<nav class="menu",>
|
||||
<RouterButton<AppRoute> route=AppRoute::Login> {"Kirjautuminen"} </RouterButton<AppRoute>>
|
||||
<RouterButton<AppRoute> route=AppRoute::Root> {"Suojattu data"} </RouterButton<AppRoute>>
|
||||
</nav>
|
||||
<Router<AppRoute>
|
||||
render = Router::render(|switch: AppRoute| {
|
||||
match switch {
|
||||
|
@ -44,7 +48,7 @@ impl Component for App {
|
|||
AppRoute::PageNotFound(Permissive(None)) => html!{"Page not found"},
|
||||
AppRoute::PageNotFound(Permissive(Some(missed_route))) => html!{format!("Page '{}' not found", missed_route)},
|
||||
AppRoute::Root => {
|
||||
html!{"hello there!"}
|
||||
html!{<ProtectedComponent />}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue