mentorenwahl/frontend/src/layouts/main.rs

44 lines
1,009 B
Rust
Raw Normal View History

2022-11-04 20:23:36 +00:00
use yew::prelude::*;
2022-11-05 20:27:49 +00:00
use crate::components;
2022-11-04 20:23:36 +00:00
2022-11-05 20:27:49 +00:00
pub enum Msg {
2022-11-21 18:48:53 +00:00
LogOutClicked,
LogOut(Option<Vec<String>>),
2022-11-05 20:27:49 +00:00
}
2022-11-04 20:23:36 +00:00
#[derive(Properties, PartialEq)]
pub struct MainProps {
2022-11-21 18:48:53 +00:00
pub token: Option<String>,
2022-11-05 20:27:49 +00:00
pub logged_in: bool,
2022-11-04 20:23:36 +00:00
#[prop_or_default]
pub children: Children,
}
2022-11-27 13:29:31 +00:00
pub struct Main;
2022-11-05 20:27:49 +00:00
impl Component for Main {
type Message = Msg;
type Properties = MainProps;
2022-11-27 13:29:31 +00:00
fn create(_ctx: &Context<Self>) -> Self {
Self
2022-11-05 20:27:49 +00:00
}
fn view(&self, ctx: &Context<Self>) -> Html {
html! {
2022-11-21 18:48:53 +00:00
<>
2022-11-27 13:29:31 +00:00
<components::logged_in_handler::LoggedInHandler logged_in={ctx.props().logged_in} />
2022-11-25 22:21:21 +00:00
<div id="wrapper">
2022-11-27 13:29:31 +00:00
<components::navbar::Navbar token={ctx.props().token.to_owned()} logged_in={ctx.props().logged_in} />
2022-11-25 22:21:21 +00:00
<main>
{ for ctx.props().children.iter() }
</main>
</div>
<components::footer::Footer />
2022-11-21 18:48:53 +00:00
</>
2022-11-05 20:27:49 +00:00
}
2022-11-04 20:23:36 +00:00
}
}