use crate::cookies::get_cookie; use crate::login::LoginForm; use crate::logout::LogoutButton; use crate::user_table::UserTable; use yew::prelude::*; use yew::services::ConsoleService; pub struct App { link: ComponentLink, user_name: Option, } pub enum Msg { Login(String), Logout, } impl Component for App { type Message = Msg; type Properties = (); fn create(_: Self::Properties, link: ComponentLink) -> Self { App { link: link.clone(), user_name: get_cookie("user_id").unwrap_or_else(|e| { ConsoleService::error(&e.to_string()); None }), } } fn update(&mut self, msg: Self::Message) -> ShouldRender { match msg { Msg::Login(user_name) => { self.user_name = Some(user_name); } Msg::Logout => { self.user_name = None; } } true } fn change(&mut self, _: Self::Properties) -> ShouldRender { false } fn view(&self) -> Html { html! {

{ "LLDAP" }

{if self.user_name.is_some() { html! {
} } else { html! {} }}
} } }