diff --git a/project/backend/.env b/project/backend/.env index c6a3c6e..b52d5be 100644 --- a/project/backend/.env +++ b/project/backend/.env @@ -1,5 +1,5 @@ APP_NAME=thesis -BIND=127.0.0.1 +BIND=0.0.0.0 PORT=3880 DOMAIN=localhost DATABASE_URL=mysql://diesel:fuel@localhost/thesis diff --git a/project/frontend/src/main.rs b/project/frontend/src/main.rs index 71aa90e..6f01484 100644 --- a/project/frontend/src/main.rs +++ b/project/frontend/src/main.rs @@ -1,44 +1,60 @@ +#![recursion_limit = "256"] + mod component; use component::login::LoginComponent; use yew::prelude::*; +use yew::virtual_dom::VNode; +use yew_router::{prelude::*, switch::Permissive, Switch}; -struct App { - clicked: bool, - onclick: Callback, -} +struct App {} -enum Msg { - Click, +#[derive(Debug, Switch, Clone)] +enum AppRoute { + #[to = "/"] + Root, + #[to = "/login"] + Login, + PageNotFound(Permissive), } impl Component for App { - type Message = Msg; + type Message = (); type Properties = (); - fn create(_: Self::Properties, link: ComponentLink) -> Self { - App { - clicked: false, - onclick: link.callback(|_| Msg::Click), - } + fn create(_: Self::Properties, _link: ComponentLink) -> Self { + App {} } - fn update(&mut self, msg: Self::Message) -> ShouldRender { - match msg { - Msg::Click => { - if self.clicked { - self.clicked = false; - } else { - self.clicked = true - } - true - } - } + fn update(&mut self, _msg: Self::Message) -> ShouldRender { + true } - fn view(&self) -> Html { + fn view(&self) -> VNode { html! { - +
+ +
+ + render = Router::render(|switch: AppRoute| { + match switch { + AppRoute::Login => html!{}, + AppRoute::Root => { + html!{"hello there!"} + }, + AppRoute::PageNotFound(Permissive(None)) => html!{"Page not found"}, + AppRoute::PageNotFound(Permissive(Some(missed_route))) => html!{format!("Page '{}' not found", missed_route)} + } + }) + redirect = Router::redirect(|route: Route| { + AppRoute::PageNotFound(Permissive(Some(route.route))) + }) + /> +
+
} } }