From ed0a9a0fff254a37b78cbb96e01ee39678993796 Mon Sep 17 00:00:00 2001 From: Lucas Vas Date: Wed, 14 Jan 2026 09:42:02 -0500 Subject: [PATCH] fix: show error toasts on failed submissions --- src/pages/provider_contact.rs | 28 +++++++++++++++++----------- src/pages/scholarship_info.rs | 28 +++++++++++++++++----------- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/src/pages/provider_contact.rs b/src/pages/provider_contact.rs index 94b8cf7..355dc69 100644 --- a/src/pages/provider_contact.rs +++ b/src/pages/provider_contact.rs @@ -121,17 +121,23 @@ pub fn ProviderContactPage() -> impl IntoView { let mut toasts_context = expect_context::(); Effect::new(move || { - submit_action.value().get().is_some() - .then(|| { - toasts_context.toast( - Toast::new() - .id(uuid::Uuid::new_v4()) - .header("Submission Successful") - .msg("You can go back or continue editing your responses.") - ); - - submit_action.clear(); - }); + match submit_action.value().get() { + Some(Ok(_)) => toasts_context.toast( + Toast::new() + .id(uuid::Uuid::new_v4()) + .header("Submission Successful") + .msg("You can go back or continue editing your responses.") + ), + Some(Err(err)) => toasts_context.toast( + Toast::new() + .id(uuid::Uuid::new_v4()) + .header("Submission Failed") + .msg(err.to_string()) + ), + _ => {} + } + + submit_action.clear(); }); // Display contact form. diff --git a/src/pages/scholarship_info.rs b/src/pages/scholarship_info.rs index df41afd..eb31f77 100644 --- a/src/pages/scholarship_info.rs +++ b/src/pages/scholarship_info.rs @@ -483,17 +483,23 @@ fn ScholarshipForm( }; Effect::new(move || { - submit_action.value().get().is_some() - .then(|| { - log!("Displaying toasts!"); - toasts.toast( - Toast::new() - .id(uuid::Uuid::new_v4()) - .msg("Succesfully submitted.") - ); - - submit_action.clear(); - }); + match submit_action.value().get() { + Some(Ok(_)) => toasts.toast( + Toast::new() + .id(uuid::Uuid::new_v4()) + .header("Submission Successful") + .msg("You can go back or continue editing your responses.") + ), + Some(Err(err)) => toasts.toast( + Toast::new() + .id(uuid::Uuid::new_v4()) + .header("Submission Failed") + .msg(err.to_string()) + ), + _ => {} + } + + submit_action.clear(); }); let create_comps = ServerAction::::new(); -- 2.54.0