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>
69 lines
2 KiB
TypeScript
69 lines
2 KiB
TypeScript
import type { Blocker } from "react-router";
|
|
import {
|
|
AlertDialog,
|
|
AlertDialogAction,
|
|
AlertDialogCancel,
|
|
AlertDialogContent,
|
|
AlertDialogDescription,
|
|
AlertDialogFooter,
|
|
AlertDialogHeader,
|
|
AlertDialogTitle,
|
|
} from "~/components/ui/alert-dialog";
|
|
|
|
export function LeaveSettingsDialog({ blocker }: { blocker: Blocker }) {
|
|
if (blocker.state !== "blocked") return null;
|
|
|
|
return (
|
|
<AlertDialog open>
|
|
<AlertDialogContent>
|
|
<AlertDialogHeader>
|
|
<AlertDialogTitle>Leave without saving?</AlertDialogTitle>
|
|
<AlertDialogDescription>
|
|
You have unsaved settings changes. If you leave this page, those changes will be lost.
|
|
</AlertDialogDescription>
|
|
</AlertDialogHeader>
|
|
<AlertDialogFooter>
|
|
<AlertDialogCancel onClick={() => blocker.reset?.()}>
|
|
Stay
|
|
</AlertDialogCancel>
|
|
<AlertDialogAction onClick={() => blocker.proceed?.()}>
|
|
Leave without saving
|
|
</AlertDialogAction>
|
|
</AlertDialogFooter>
|
|
</AlertDialogContent>
|
|
</AlertDialog>
|
|
);
|
|
}
|
|
|
|
export function SwitchSettingsSectionDialog({
|
|
open,
|
|
onOpenChange,
|
|
onStay,
|
|
onDiscard,
|
|
}: {
|
|
open: boolean;
|
|
onOpenChange: (open: boolean) => void;
|
|
onStay: () => void;
|
|
onDiscard: () => void;
|
|
}) {
|
|
return (
|
|
<AlertDialog open={open} onOpenChange={onOpenChange}>
|
|
<AlertDialogContent>
|
|
<AlertDialogHeader>
|
|
<AlertDialogTitle>Switch sections without saving?</AlertDialogTitle>
|
|
<AlertDialogDescription>
|
|
You have unsaved settings changes. Save before switching sections, or discard your edits to continue.
|
|
</AlertDialogDescription>
|
|
</AlertDialogHeader>
|
|
<AlertDialogFooter>
|
|
<AlertDialogCancel onClick={onStay}>
|
|
Stay
|
|
</AlertDialogCancel>
|
|
<AlertDialogAction onClick={onDiscard}>
|
|
Discard changes
|
|
</AlertDialogAction>
|
|
</AlertDialogFooter>
|
|
</AlertDialogContent>
|
|
</AlertDialog>
|
|
);
|
|
}
|