Means to reset local state

Resolves #9
This commit is contained in:
Emilia Allison 2023-06-05 14:38:29 -04:00
parent 5153b67fe4
commit 44574db301
Signed by: emilia
GPG Key ID: 7A3F8997BFE894E0
1 changed files with 16 additions and 0 deletions

View File

@ -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 {
<div class="upper_menu">
<div class="dropdown">
<button>{"File"}</button>
<button onclick={new_button_callback}>{"New"}</button>
<button onclick={save_button_callback}>{"Save"}</button>
</div>
</div>