Show toast instead of redirecting after league settings save
Commishes now stay on the settings page when saving, with a Sonner toast confirming the save rather than being navigated to the league homepage. https://claude.ai/code/session_01PewdKxVfAbqasJbmk2UGw4
This commit is contained in:
parent
68193e31c5
commit
358f476106
3 changed files with 11 additions and 10 deletions
|
|
@ -25,13 +25,6 @@ export function SettingsMessage({ actionData }: { actionData: SettingsActionData
|
|||
</div>
|
||||
);
|
||||
}
|
||||
if (actionData.success) {
|
||||
return (
|
||||
<div className="rounded-md bg-emerald-500/15 px-4 py-3 text-sm text-emerald-700 dark:text-emerald-300">
|
||||
{actionData.message ?? "Settings updated successfully."}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -776,7 +776,7 @@ export async function action(args: Route.ActionArgs) {
|
|||
}
|
||||
}
|
||||
|
||||
return redirect(`/leagues/${leagueId}?updated=true`);
|
||||
return { success: true, message: "Settings saved successfully." };
|
||||
} catch (error) {
|
||||
logger.error("Error updating season settings:", error);
|
||||
return { error: "Failed to update season settings. Please try again." };
|
||||
|
|
|
|||
|
|
@ -179,8 +179,8 @@ export default function LeagueSettings({ loaderData, actionData }: Route.Compone
|
|||
setHasDraftOrderChanges(false);
|
||||
}, [draftSlots, teams]);
|
||||
|
||||
// Re-mark dirty if the settings save returned an error (success path redirects away, so no cleanup
|
||||
// needed there). Guard against non-settings errors (e.g. draft-order) which carry a `section` field.
|
||||
// Re-mark dirty if the settings save returned an error. Guard against non-settings errors
|
||||
// (e.g. draft-order) which carry a `section` field.
|
||||
useEffect(() => {
|
||||
if (navigation.state !== "idle") return;
|
||||
if (actionData && "error" in actionData && !("section" in actionData)) {
|
||||
|
|
@ -188,6 +188,14 @@ export default function LeagueSettings({ loaderData, actionData }: Route.Compone
|
|||
}
|
||||
}, [actionData, navigation.state]);
|
||||
|
||||
useEffect(() => {
|
||||
if (navigation.state !== "idle") return;
|
||||
if (actionData && "success" in actionData && actionData.success && !("section" in actionData)) {
|
||||
toast.success("Settings saved!");
|
||||
setHasUnsavedSettingsChanges(false);
|
||||
}
|
||||
}, [actionData, navigation.state]);
|
||||
|
||||
const canEditSports = season?.status === "pre_draft";
|
||||
const canEditTeamCount = season?.status === "pre_draft";
|
||||
const canEditDraftOrder = season?.status === "pre_draft";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue