Recipe edit (WIP): add API to set some recipe values

This commit is contained in:
Greg Burri 2024-12-23 01:37:01 +01:00
parent c6dfff065c
commit dd05a673d9
20 changed files with 690 additions and 2189 deletions

View file

@ -2,7 +2,7 @@ mod handles;
mod toast;
mod utils;
use gloo::{console::log, events::EventListener};
use gloo::{console::log, events::EventListener, utils::window};
use wasm_bindgen::prelude::*;
use web_sys::console;
@ -21,18 +21,16 @@ use web_sys::console;
pub fn main() -> Result<(), JsValue> {
console_error_panic_hook::set_once();
let window = web_sys::window().expect("no global `window` exists");
let document = window.document().expect("should have a document on window");
// let window = web_sys::window().expect("no global `window` exists");
// let document = window.document().expect("should have a document on window");
let location = window.location().pathname()?;
let location = window().location().pathname()?;
let path: Vec<&str> = location.split('/').skip(1).collect();
match path[..] {
["recipe", "edit", id] => {
let id = id.parse::<i64>().unwrap(); // TODO: remove unwrap.
log!("recipe edit ID: {}", id);
handles::recipe_edit(document)?;
handles::recipe_edit(id)?;
}
// Disable: user editing data are now submitted as classic form data.