* 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 * 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 --------- Co-authored-by: Claude <noreply@anthropic.com>
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
export type SettingsActionData =
|
|
| {
|
|
section?: string;
|
|
error?: string;
|
|
testSuccess?: boolean;
|
|
success?: boolean;
|
|
message?: string;
|
|
}
|
|
| undefined;
|
|
|
|
export function SettingsMessage({ actionData }: { actionData: SettingsActionData }) {
|
|
if (!actionData) return null;
|
|
if (actionData.section === "draft-order") return null;
|
|
if (actionData.error) {
|
|
return (
|
|
<div className="rounded-md bg-destructive/15 px-4 py-3 text-sm text-destructive">
|
|
{actionData.error}
|
|
</div>
|
|
);
|
|
}
|
|
if (actionData.testSuccess) {
|
|
return (
|
|
<div className="rounded-md bg-emerald-500/15 px-4 py-3 text-sm text-emerald-700 dark:text-emerald-300">
|
|
Test notification sent to Discord.
|
|
</div>
|
|
);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
export function DraftOrderMessage({ actionData }: { actionData: SettingsActionData }) {
|
|
if (!actionData || actionData.section !== "draft-order") return null;
|
|
if (actionData.error) {
|
|
return (
|
|
<div className="rounded-md bg-destructive/15 px-4 py-3 text-sm text-destructive">
|
|
{actionData.error}
|
|
</div>
|
|
);
|
|
}
|
|
if (actionData.success && actionData.message) {
|
|
return (
|
|
<div className="rounded-md bg-emerald-500/15 px-4 py-3 text-sm text-emerald-700 dark:text-emerald-300">
|
|
{actionData.message}
|
|
</div>
|
|
);
|
|
}
|
|
return null;
|
|
}
|