brackt/app/components/league/settings/SettingsMessages.tsx
Chris Parsons b1a1a472f5 Refactor league settings into per-section components (#347)
Extract all settings sections from the monolithic 1009-line route file into
individual components under app/components/league/settings/. Route file drops
to ~300 lines. Separates draft-order dirty state from general settings dirty
state, deduplicates section-change handling, and fixes several bugs found
during review (typo in pointsFor5th, wrong mock in tests, lint violations).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 14:00:35 -07:00

55 lines
1.6 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>
);
}
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;
}
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;
}