From 44574db301e3dff45725208f9fb428d7b5214211 Mon Sep 17 00:00:00 2001 From: Emilia Date: Mon, 5 Jun 2023 14:38:29 -0400 Subject: [PATCH] Means to reset local state Resolves #9 --- src/components/main_window.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/components/main_window.rs b/src/components/main_window.rs index 2a9cfaf..bcf6c54 100644 --- a/src/components/main_window.rs +++ b/src/components/main_window.rs @@ -54,6 +54,21 @@ pub fn MainWindow() -> Html { }) }; + let new_button_callback = { + let main_dispatch = main_dispatch.clone(); + let ct_dispatch = ct_dispatch.clone(); + Callback::from(move |_| { + let window = web_sys::window().unwrap(); + let confirm = window.confirm_with_message("This will reset all plates and transfers. Proceed?"); + if let Ok(confirm) = confirm { + if confirm { + main_dispatch.set(MainState::default()); + ct_dispatch.set(CurrentTransfer::default()); + } + } + }) + }; + let save_button_callback = { let main_state = main_state.clone(); Callback::from(move |_| { @@ -81,6 +96,7 @@ pub fn MainWindow() -> Html {