User profile edit page

This commit is contained in:
Greg Burri 2024-12-17 21:28:47 +01:00
parent 38c286e860
commit 4248d11aa9
15 changed files with 450 additions and 175 deletions

View file

@ -23,18 +23,10 @@ pub fn main() -> Result<(), JsValue> {
let window = web_sys::window().expect("no global `window` exists");
let document = window.document().expect("should have a document on window");
// let body = document.body().expect("document should have a body");
let location = window.location().pathname()?;
let path: Vec<&str> = location.split('/').skip(1).collect();
/*
* TODO:
* [ok] get url (/recipe/edit/{id}) and extract the id
* - Add a handle (event?) to the title field (when edited/changed?):
* - Call (as AJAR) /ron-api/set-title and set the body to a serialized RON of the type common::ron_api::SetTitle
* - Display error message if needed
*/
match path[..] {
["recipe", "edit", id] => {
let id = id.parse::<i64>().unwrap(); // TODO: remove unwrap.
@ -43,16 +35,12 @@ pub fn main() -> Result<(), JsValue> {
handles::recipe_edit(document)?;
}
["user", "edit"] => {
handles::user_edit(document)?;
}
// Disable: user editing data are now submitted as classic form data.
// ["user", "edit"] => {
// handles::user_edit(document)?;
// }
_ => (),
}
// TEST
// let val = document.create_element("p")?;
// val.set_inner_html("Hello from Rust!");
// body.append_child(&val)?;
Ok(())
}