Show error toasts on failed submissions #49

Merged
BobdaFett merged 1 commits from fix/toast-display-error into main 2026-01-14 16:05:08 +00:00
2 changed files with 34 additions and 22 deletions

No files matched your search

+17 -11
View File
@@ -121,17 +121,23 @@ pub fn ProviderContactPage() -> impl IntoView {
let mut toasts_context = expect_context::<ToastContext>();
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.
+17 -11
View File
@@ -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::<CreateTestComparisons>::new();