diff --git a/backend/scss/main.scss b/backend/scss/main.scss index 1f7cb68..0469b94 100644 --- a/backend/scss/main.scss +++ b/backend/scss/main.scss @@ -68,6 +68,10 @@ body { .header-menu { .user-menu { margin: consts.$margin; + + .user-edit-link { + margin-left: consts.$margin; + } } #select-website-language { diff --git a/backend/templates/message.html b/backend/templates/message.html index 4bfa738..247206b 100644 --- a/backend/templates/message.html +++ b/backend/templates/message.html @@ -12,8 +12,6 @@ {% if as_code %} {% endif %} - - Go to home {% endblock %} \ No newline at end of file diff --git a/frontend/src/pages/recipe_edit.rs b/frontend/src/pages/recipe_edit.rs index 1bb6f91..6ba50bc 100644 --- a/frontend/src/pages/recipe_edit.rs +++ b/frontend/src/pages/recipe_edit.rs @@ -22,7 +22,13 @@ use crate::{ pub fn setup_page(recipe_id: i64) { // Title. { - let title: HtmlInputElement = by_id("input-title"); + // Here we check if the first element exists, + // if not, the recipe edit page hasn't been loaded + // and we return from the function without panicking. + let title = match document().get_element_by_id("input-title") { + Some(e) => e.dyn_into::().unwrap(), + None => return, + }; // Check if the recipe has been loaded. diff --git a/frontend/src/pages/recipe_view.rs b/frontend/src/pages/recipe_view.rs index 069e3a9..27a3152 100644 --- a/frontend/src/pages/recipe_view.rs +++ b/frontend/src/pages/recipe_view.rs @@ -1,6 +1,6 @@ use chrono::Weekday; use common::utils::substitute_with_names; -use gloo::events::EventListener; +use gloo::{events::EventListener, utils::document}; use wasm_bindgen_futures::spawn_local; use web_sys::{Element, HtmlInputElement}; @@ -14,7 +14,13 @@ use crate::{ pub fn setup_page(recipe_id: i64, is_user_logged: bool, first_day_of_the_week: Weekday) { let recipe_scheduler = RecipeScheduler::new(!is_user_logged); - let add_to_planner: Element = selector("#recipe-view .add-to-planner"); + // Here we check if the first element exists, + // if not, the recipe view page hasn't been loaded + // and we return from the function without panicking. + let add_to_planner = match document().query_selector("#recipe-view .add-to-planner") { + Ok(Some(e)) => e, + _ => return, + }; EventListener::new(&add_to_planner, "click", move |_event| { spawn_local(async move {