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:
Claude 2026-05-18 22:57:06 +00:00
parent 68193e31c5
commit 358f476106
No known key found for this signature in database
3 changed files with 11 additions and 10 deletions

View file

@ -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;
}

View file

@ -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." };

View file

@ -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";