fix: remove infinite loop in submit_action effects
This commit is contained in:
1 parent
9ebab0689a
commit
95b69a36a8
7 files changed
+54
-52
No files matched your search
@@ -41,19 +41,16 @@ pub fn DashboardButton(
|
||||
<button
|
||||
type="button"
|
||||
class="dashboard-button flex items-start gap-3 rounded-lg bg-white border-grey-300 p-6
|
||||
hover:bg-gray-100 transition cursor-pointer w-full text-left
|
||||
shadow-[inset_0_0_6px_rgba(0,0,0,0.12)]"
|
||||
on:click=on_click>
|
||||
hover:bg-gray-100 transition cursor-pointer w-full text-left
|
||||
shadow-[inset_0_0_6px_rgba(0,0,0,0.12)]"
|
||||
on:click=on_click
|
||||
>
|
||||
|
||||
<div class="flex flex-col">
|
||||
<img src={icon.clone()} class="h-8 w-8" alt="icon"/>
|
||||
<h3 class="font-semibold text-base">
|
||||
{title.clone()}
|
||||
</h3>
|
||||
<img src=icon.clone() class="h-8 w-8" alt="icon" />
|
||||
<h3 class="font-semibold text-base">{title.clone()}</h3>
|
||||
|
||||
<p class="text-sm text-gray-600 pt-6">
|
||||
{description.clone()}
|
||||
</p>
|
||||
<p class="text-sm text-gray-600 pt-6">{description.clone()}</p>
|
||||
|
||||
</div>
|
||||
</button>
|
||||
|
||||
@@ -24,7 +24,5 @@ pub fn ProviderLoginContext() -> impl IntoView {
|
||||
"/providers/callback"
|
||||
);
|
||||
|
||||
view! {
|
||||
<Outlet />
|
||||
}
|
||||
view! { <Outlet /> }
|
||||
}
|
||||
@@ -24,7 +24,5 @@ pub fn StudentLoginContext() -> impl IntoView {
|
||||
"/students/callback"
|
||||
);
|
||||
|
||||
view! {
|
||||
<Outlet />
|
||||
}
|
||||
view! { <Outlet /> }
|
||||
}
|
||||
@@ -119,27 +119,34 @@ pub fn ProviderContactPage() -> impl IntoView {
|
||||
});
|
||||
|
||||
let mut toasts_context = expect_context::<ToastContext>();
|
||||
Effect::new(move || {
|
||||
match submit_action.value().get() {
|
||||
Some(Ok(_)) => toasts_context.toast(
|
||||
Toast::new()
|
||||
Effect::watch(
|
||||
move || submit_action.value().get(),
|
||||
move |value, _, _| {
|
||||
log!("Running submit_action effect");
|
||||
let Some(result) = value else {
|
||||
return;
|
||||
};
|
||||
|
||||
let toast = match result {
|
||||
Ok(_) => 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()
|
||||
.msg("You can go back or continue editing your responses."),
|
||||
Err(err) => Toast::new()
|
||||
.id(uuid::Uuid::new_v4())
|
||||
.header("Submission Failed")
|
||||
.msg(err.to_string())
|
||||
),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
submit_action.clear();
|
||||
});
|
||||
|
||||
// Display contact form.
|
||||
};
|
||||
|
||||
untrack(move || {
|
||||
submit_action.clear();
|
||||
toasts_context.toast(toast);
|
||||
});
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
// Display contact form.
|
||||
view! {
|
||||
<Banner title="R15 Scholarships" logo="/PHS_Stacked_Acronym.png" path="/" />
|
||||
<AuthLoaded fallback=Loading>
|
||||
|
||||
@@ -20,11 +20,7 @@ pub fn ProviderPortal() -> impl IntoView {
|
||||
});
|
||||
|
||||
view! {
|
||||
<Banner
|
||||
title="Provider Dashboard"
|
||||
logo="PHS_Stacked_Acronym.png"
|
||||
path="/"
|
||||
/>
|
||||
<Banner title="Provider Dashboard" logo="PHS_Stacked_Acronym.png" path="/" />
|
||||
<AuthLoaded fallback=Loading>
|
||||
<Authenticated unauthenticated=UnauthenticatedPage>
|
||||
<div class="mx-auto px-6">
|
||||
|
||||
@@ -490,25 +490,32 @@ fn ScholarshipForm(
|
||||
});
|
||||
};
|
||||
|
||||
Effect::new(move || {
|
||||
match submit_action.value().get() {
|
||||
Some(Ok(_)) => toasts.toast(
|
||||
Toast::new()
|
||||
Effect::watch(
|
||||
move || submit_action.value().get(),
|
||||
move |value, _, _| {
|
||||
log!("Running submit_action effect");
|
||||
let Some(result) = value else {
|
||||
return;
|
||||
};
|
||||
|
||||
let toast = match result {
|
||||
Ok(_) => 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()
|
||||
.msg("You can go back or continue editing your responses."),
|
||||
Err(err) => Toast::new()
|
||||
.id(uuid::Uuid::new_v4())
|
||||
.header("Submission Failed")
|
||||
.msg(err.to_string())
|
||||
),
|
||||
_ => {}
|
||||
}
|
||||
};
|
||||
|
||||
submit_action.clear();
|
||||
});
|
||||
untrack(move || {
|
||||
submit_action.clear();
|
||||
toasts.toast(toast);
|
||||
});
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
//#endregion
|
||||
|
||||
|
||||
@@ -33,8 +33,7 @@ pub fn TestPage() -> impl IntoView {
|
||||
<h3 class="text-white font-bold">Important Dates</h3>
|
||||
</div>
|
||||
<div class="p-2">
|
||||
<div class="flex flex-col p-3 gap-3">
|
||||
</div>
|
||||
<div class="flex flex-col p-3 gap-3"></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
Reference in new issue
Block a user