brackt/app/components/league/settings/ScoringSection.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

46 lines
1.6 KiB
TypeScript

import { TrendingUp } from "lucide-react";
import { type ScoringRules } from "~/lib/scoring-types";
import { ScoringPresetPicker } from "~/components/league/ScoringPresetPicker";
import { SettingsSection, SettingsStatusPill } from "./SettingsSection";
export function ScoringSection({
active,
canEditSports,
season,
scoringPreset,
onScoringPresetChange,
scoringRules,
onScoringRulesChange,
}: {
active: boolean;
canEditSports: boolean;
season: { status: string } | null;
scoringPreset: "brackt" | "omnifantasy" | "custom";
onScoringPresetChange: (v: "brackt" | "omnifantasy" | "custom") => void;
scoringRules: ScoringRules;
onScoringRulesChange: (v: ScoringRules) => void;
}) {
return (
<SettingsSection
id="scoring"
icon={TrendingUp}
title="Scoring"
description="Configure placement scoring for drafted sports. Scoring locks when the draft starts."
status={<SettingsStatusPill tone={canEditSports ? "success" : "locked"}>{canEditSports ? "Editable" : "Locked"}</SettingsStatusPill>}
className={active ? undefined : "hidden"}
>
<div className="rounded-lg border p-5 sm:p-6">
<ScoringPresetPicker
preset={scoringPreset}
onPresetChange={onScoringPresetChange}
rules={scoringRules}
onRulesChange={onScoringRulesChange}
disabled={!season || season.status !== "pre_draft"}
/>
{(Object.entries(scoringRules) as [string, number][]).map(([k, v]) => (
<input key={k} type="hidden" name={k} value={v} />
))}
</div>
</SettingsSection>
);
}