brackt/app/components/league/settings/SportsSection.tsx
Chris Parsons 6df4f86920
Improve flag config validation and remove settings completion tracking (#390)
* Fix mobile league settings: prevent sports scroll and remove completion checkmarks

- Add overflow-hidden to sport label text span so flex truncation is properly contained
- Add min-w-0 to SettingsSection header inner flex item to prevent title/description overflow
- Remove completion check marks from mobile grid nav buttons (league settings has no completion concept)
- Remove "X of Y set" counter from mobile nav header
- Remove isComplete field from SettingsGridSection type and all data

https://claude.ai/code/session_01T7iTb9YZLuWJFtKV753tdB

* Fix race window in user creation and restore FlagSvg safety fallback

auth.server.ts: switch generateId to application-generated UUIDs so the
ID is known before the insert, then move flagConfig assignment from
create.after (a separate UPDATE) to create.before so it lands in the
initial INSERT with no race window.

FlagSvg.tsx: validate the config with parseFlagConfig before rendering;
corrupt or missing data falls back to a neutral gray triband flag rather
than silently rendering blank SVG shapes.

https://claude.ai/code/session_01T7iTb9YZLuWJFtKV753tdB

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-05-07 10:09:45 -07:00

91 lines
3.3 KiB
TypeScript

import { ClipboardList } from "lucide-react";
import { Label } from "~/components/ui/label";
import { Button } from "~/components/ui/button";
import { Checkbox } from "~/components/ui/checkbox";
import { cn } from "~/lib/utils";
import { SportIcon } from "~/components/league/SportIcon";
import { SettingsSection, SettingsStatusPill } from "./SettingsSection";
type SportsSeason = {
id: string;
name: string;
year: number;
scoringType: string;
sport: { id: string; name: string; slug: string; type: string; iconUrl: string | null };
};
const BRACKT_SLUG = "brackt";
export function SportsSection({
active,
canEditSports,
selectedSports,
displaySportsSeasons,
onSportToggle,
onClearAll,
}: {
active: boolean;
canEditSports: boolean;
selectedSports: Set<string>;
displaySportsSeasons: SportsSeason[];
onSportToggle: (id: string) => void;
onClearAll: () => void;
}) {
return (
<SettingsSection
id="sports"
icon={ClipboardList}
title="Sports"
description="Manage draftable sports seasons for this league. Sports lock when the draft starts."
status={<SettingsStatusPill tone={canEditSports ? "success" : "locked"}>{canEditSports ? "Editable" : "Locked"}</SettingsStatusPill>}
className={active ? undefined : "hidden"}
>
<div className="space-y-4">
<div className="flex items-center justify-between gap-3">
<Label>{selectedSports.size} selected</Label>
{canEditSports && selectedSports.size > 0 && (
<Button type="button" variant="ghost" size="sm" onClick={onClearAll}>
Clear all
</Button>
)}
</div>
<div className="space-y-2">
{displaySportsSeasons.length > 0 ? (
displaySportsSeasons.map((ss) => {
const selected = selectedSports.has(ss.id);
return (
<label
key={ss.id}
htmlFor={`sport-${ss.id}`}
className={cn(
"mb-2 flex cursor-pointer items-center gap-3 rounded-md border p-3 text-sm transition-colors last:mb-0",
selected ? "border-primary bg-primary/10 text-primary" : "border-border bg-background hover:border-primary/50",
!canEditSports && "cursor-not-allowed opacity-65"
)}
>
<Checkbox
id={`sport-${ss.id}`}
name="sportsSeasons"
value={ss.id}
checked={selected}
onCheckedChange={() => onSportToggle(ss.id)}
disabled={!canEditSports}
/>
<SportIcon sport={ss.sport} />
<span className="min-w-0 flex-1 overflow-hidden">
<span className="block truncate font-medium">
{ss.sport.slug === BRACKT_SLUG ? "Brackt" : `${ss.sport.name} - ${ss.name} (${ss.year})`}
</span>
<span className="text-xs text-muted-foreground">{ss.scoringType.replace("_", " ")}</span>
</span>
</label>
);
})
) : (
<p className="p-3 text-sm text-muted-foreground">No sports seasons available.</p>
)}
</div>
</div>
</SettingsSection>
);
}