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