diff --git a/frontend/Cargo.toml b/frontend/Cargo.toml index 5f5a179..78fbfc2 100644 --- a/frontend/Cargo.toml +++ b/frontend/Cargo.toml @@ -26,8 +26,6 @@ thiserror = "2" futures = "0.3" -scanf = "1.2" - web-sys = { version = "0.3", features = [ "console", "Document", diff --git a/frontend/src/calendar.rs b/frontend/src/calendar.rs index 37ff1e3..dd77168 100644 --- a/frontend/src/calendar.rs +++ b/frontend/src/calendar.rs @@ -6,7 +6,6 @@ use gloo::{ events::EventListener, utils::{document, window}, }; -use scanf::sscanf; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::spawn_local; use web_sys::{Element, HtmlInputElement}; @@ -133,15 +132,11 @@ pub fn setup( ); } else if target.class_name().contains("remove-scheduled-recipe") { spawn_local(async move { - let mut recipe_id: i64 = 0; - let mut date: NaiveDate = NaiveDate::default(); - sscanf!( - &target.parent_element().unwrap().id(), - "scheduled-recipe-{}-{}", - recipe_id, - date - ) - .unwrap(); + // Element id format example: "scheduled-recipe-1-2025-05-15". + let element_id = target.parent_element().unwrap().id(); + let element_id_splitted: Vec<&str> = element_id.splitn(4, '-').collect(); + let recipe_id: i64 = element_id_splitted[2].parse().unwrap(); + let date: NaiveDate = element_id_splitted[3].parse().unwrap(); let title = target.previous_element_sibling().unwrap().inner_html();