Calendar is now displayed on home page and recipes can be scheduled without being logged
This commit is contained in:
parent
ccb1248da3
commit
37721ac3ea
22 changed files with 538 additions and 166 deletions
|
|
@ -3,12 +3,16 @@ use gloo::{console::log, events::EventListener, utils::window};
|
|||
use utils::by_id;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen_futures::spawn_local;
|
||||
use web_sys::HtmlSelectElement;
|
||||
use web_sys::{HtmlElement, HtmlSelectElement};
|
||||
|
||||
use crate::utils::selector;
|
||||
|
||||
mod calendar;
|
||||
mod home;
|
||||
mod modal_dialog;
|
||||
mod on_click;
|
||||
mod recipe_edit;
|
||||
mod recipe_scheduler;
|
||||
mod recipe_view;
|
||||
mod request;
|
||||
mod toast;
|
||||
|
|
@ -21,6 +25,12 @@ pub fn main() -> Result<(), JsValue> {
|
|||
let location = window().location().pathname()?;
|
||||
let path: Vec<&str> = location.split('/').skip(1).collect();
|
||||
|
||||
let is_user_logged = selector::<HtmlElement>("html")
|
||||
.dataset()
|
||||
.get("userLogged")
|
||||
.map(|v| v == "true")
|
||||
.unwrap_or_default();
|
||||
|
||||
// if let ["recipe", "edit", id] = path[..] {
|
||||
match path[..] {
|
||||
["recipe", "edit", id] => {
|
||||
|
|
@ -31,7 +41,13 @@ pub fn main() -> Result<(), JsValue> {
|
|||
}
|
||||
["recipe", "view", id] => {
|
||||
let id = id.parse::<i64>().unwrap(); // TODO: remove unwrap.
|
||||
if let Err(error) = recipe_view::setup_page(id) {
|
||||
if let Err(error) = recipe_view::setup_page(id, is_user_logged) {
|
||||
log!(error);
|
||||
}
|
||||
}
|
||||
// Home.
|
||||
[""] => {
|
||||
if let Err(error) = home::setup_page(is_user_logged) {
|
||||
log!(error);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue