Fix toast firing for unrelated intents after settings save

Tag update responses with intent: "update" so the success useEffect
only fires for the main settings form, not for owner/commissioner/
reset-draft actions which also return { success: true }. Also replaces
the remaining ?updated=true redirect (no-season edge case) with the
same response shape for consistency.

https://claude.ai/code/session_01PewdKxVfAbqasJbmk2UGw4
This commit is contained in:
Claude 2026-05-18 22:59:53 +00:00
parent 358f476106
commit 57d7064c41
No known key found for this signature in database
2 changed files with 4 additions and 4 deletions

View file

@ -268,7 +268,7 @@ export async function action(args: Route.ActionArgs) {
const season = await findCurrentSeasonWithSports(leagueId);
if (!season) {
if (intent === "update") {
return redirect(`/leagues/${leagueId}?updated=true`);
return { success: true, message: "Settings saved successfully.", intent: "update" as const };
}
return { error: "No active season found" };
}
@ -776,7 +776,7 @@ export async function action(args: Route.ActionArgs) {
}
}
return { success: true, message: "Settings saved successfully." };
return { success: true, message: "Settings saved successfully.", intent: "update" as const };
} catch (error) {
logger.error("Error updating season settings:", error);
return { error: "Failed to update season settings. Please try again." };

View file

@ -190,8 +190,8 @@ export default function LeagueSettings({ loaderData, actionData }: Route.Compone
useEffect(() => {
if (navigation.state !== "idle") return;
if (actionData && "success" in actionData && actionData.success && !("section" in actionData)) {
toast.success("Settings saved!");
if (actionData && "intent" in actionData && actionData.intent === "update" && actionData.success) {
toast.success(actionData.message ?? "Settings saved!");
setHasUnsavedSettingsChanges(false);
}
}, [actionData, navigation.state]);