diff --git a/app/components/league/settings/DraftSetupSection.tsx b/app/components/league/settings/DraftSetupSection.tsx index 1eb2c0b..5f44905 100644 --- a/app/components/league/settings/DraftSetupSection.tsx +++ b/app/components/league/settings/DraftSetupSection.tsx @@ -1,5 +1,5 @@ -import { useState, useEffect } from "react"; import { Swords, CalendarIcon } from "lucide-react"; +import { useLocalTimezone } from "~/hooks/useLocalTimezone"; import { format } from "date-fns"; import { Label } from "~/components/ui/label"; import { Input } from "~/components/ui/input"; @@ -65,10 +65,7 @@ export function DraftSetupSection({ onOvernightTimezoneChange: (v: string) => void; commishTimezone: string | null; }) { - const [localTz, setLocalTz] = useState(""); - useEffect(() => { - setLocalTz(Intl.DateTimeFormat().resolvedOptions().timeZone); - }, []); + const localTz = useLocalTimezone(); return ( { const user = userEvent.setup(); render(); - const mlbCheckbox = screen.getByRole("checkbox", { name: /mlb - 2025 season \(2025\)/i }); + const mlbCheckbox = screen.getByRole("checkbox", { name: /2025 mlb season/i }); expect(mlbCheckbox).not.toBeChecked(); - await user.click(screen.getByText("MLB - 2025 Season (2025)")); + await user.click(screen.getByText("2025 MLB Season")); expect(mlbCheckbox).toBeChecked(); }); @@ -95,7 +89,7 @@ describe("SportsSection", () => { const handleSubmit = vi.fn(); render(); - await user.click(screen.getByText("MLB - 2025 Season (2025)")); + await user.click(screen.getByText("2025 MLB Season")); await user.click(screen.getByRole("button", { name: "Save" })); expect(handleSubmit).toHaveBeenCalledWith(["nba-2025", "mlb-2025"]); diff --git a/app/hooks/useLocalTimezone.ts b/app/hooks/useLocalTimezone.ts new file mode 100644 index 0000000..ef1ae10 --- /dev/null +++ b/app/hooks/useLocalTimezone.ts @@ -0,0 +1,10 @@ +import { useState, useEffect } from "react"; + +export function useLocalTimezone() { + const [tz, setTz] = useState(""); + useEffect(() => { + const parts = Intl.DateTimeFormat(undefined, { timeZoneName: "short" }).formatToParts(new Date()); + setTz(parts.find((p) => p.type === "timeZoneName")?.value ?? ""); + }, []); + return tz; +} diff --git a/app/routes/leagues/new.tsx b/app/routes/leagues/new.tsx index ed64ea3..43f7ede 100644 --- a/app/routes/leagues/new.tsx +++ b/app/routes/leagues/new.tsx @@ -25,6 +25,7 @@ import { Checkbox } from "~/components/ui/checkbox"; import { cn } from "~/lib/utils"; import { parseDraftSpeed, formatTime12h } from "~/lib/draft-timer"; import { TIMEZONE_OPTIONS } from "~/components/league/TimezoneSelect"; +import { useLocalTimezone } from "~/hooks/useLocalTimezone"; import { saveWizardState, buildFormDataFromSnapshot } from "~/lib/wizard-state"; import { type ScoringRules, DEFAULT_SCORING_RULES } from "~/lib/scoring-types"; import { SportIcon } from "~/components/league/SportIcon"; @@ -659,10 +660,7 @@ function Step3DraftSettings({ const { draftInitialTime, draftIncrementTime } = parseDraftSpeed(draftSpeed, timerMode); const showOvernightPause = draftInitialTime >= 3600 || draftIncrementTime >= 600; - const [localTz, setLocalTz] = useState(""); - useEffect(() => { - setLocalTz(Intl.DateTimeFormat().resolvedOptions().timeZone); - }, []); + const localTz = useLocalTimezone(); useEffect(() => { if (!showOvernightPause) setOvernightMode("none"); @@ -917,7 +915,7 @@ function StepReview({ {uniqueSportsCount} sport{uniqueSportsCount !== 1 ? "s" : ""}

    - {selectedSeasons.toSorted((a, b) => a.sport.name.localeCompare(b.sport.name)).map((s) => ( + {selectedSeasons.toSorted((a, b) => a.name.localeCompare(b.name)).map((s) => (
  • {s.name}