From 82b8b447dcddf8c0ad94dbc11b23cfe6031b1f9a Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Mon, 9 Dec 2024 19:20:18 +0300 Subject: [PATCH] fix(item-form): update tag handling to support key-value pairs - Changed `tags` signal type from `Vec` to `Vec<(String, String)>` for richer data representation. - Updated `on_submit` callback to align with the new `tags` structure. - Modified form submission logic to accommodate changes in tag handling. --- src/components/item_form.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/components/item_form.rs b/src/components/item_form.rs index c82a1d7..ed98fff 100644 --- a/src/components/item_form.rs +++ b/src/components/item_form.rs @@ -1,15 +1,14 @@ use leptos::*; -use leptos_dom::ev::SubmitEvent; // Import the correct event type +use leptos_dom::ev::SubmitEvent; #[component] -pub fn ItemForm(on_submit: Box)>) -> impl IntoView { +pub fn ItemForm(on_submit: Box)>) -> impl IntoView { let (name, set_name) = create_signal(String::new()); let (description, set_description) = create_signal(String::new()); - let (tags, set_tags) = create_signal(Vec::::new()); + let (tags, set_tags) = create_signal(Vec::<(String, String)>::new()); - // Use SubmitEvent for the form submission handler let handle_submit = move |ev: SubmitEvent| { - ev.prevent_default(); // Prevent form submission from reloading the page + ev.prevent_default(); on_submit(name.get(), description.get(), tags.get().clone()); // Reset values after submission @@ -34,4 +33,4 @@ pub fn ItemForm(on_submit: Box)>) -> impl Int } -} +} \ No newline at end of file