"use client" import { FORMATS, FORMAT_MAP, isScrambleVsSolo, isTwoSided } from "@/lib/ny-runde/formats" import type { StatLevel } from "@/lib/ny-runde/types" import { cn } from "@/lib/utils" import { ChevronDown } from "lucide-react" import { useState } from "react" import { ChoiceCard, Field, Panel, Segmented, Stepper, TextInput, Toggle, ToggleButton } from "./primitives" import { useWizard } from "./wizard-context" const STAT_OPTIONS: { value: StatLevel; title: string; description: string }[] = [ { value: "score", title: "Kun slag", description: "Registrer bare score per hull." }, { value: "score_putts", title: "Slag og putter", description: "Score pluss antall putter." }, { value: "full", title: "All statistikk", description: "Kølle, retning, chip, bunker, straff m.m." }, ] export function Step2Format() { const { state, patch } = useWizard() const format = state.format const selectedDef = FORMAT_MAP[format] const svs = isScrambleVsSolo(format) return (

Spilleform

Velg statistikknivå og hvordan runden spilles.

{/* Stat level for owner */}

Statistikk for deg selv

{STAT_OPTIONS.map((o) => ( patch({ statLevel: o.value })} title={o.title} description={o.description} /> ))}
{/* Antall hull -- et grunnleggende oppsettsvalg, derfor FØR det store formatrutenettet, ikke etter (2026-08-11, brukertilbakemelding: ble tidligere lett oversett fordi den lå sist, bak et 18-knappers rutenett man må skrolle forbi først). */}

Antall hull

patch({ numHoles: v === "9" ? 9 : 18 })} options={[ { value: "9", label: "9 hull" }, { value: "18", label: "18 hull" }, ]} />
{/* Avanserte HCP-innstillinger (skjult for scramble mot solo) -- fortsatt kollapset som standard, KUN rekkefølgen flyttet opp, samme grunn som Antall hull over. */} {!svs ? : null} {/* Format grid */}

Spilleform

{FORMATS.map((f) => ( patch({ format: f.id })}> {f.label} ))}

{selectedDef.label}.{" "} {selectedDef.description}

{/* Format-specific config */} {/* Solo allowance (scramble vs solo only) */} {svs ? (

Individualspillerens handicap-andel

patch({ soloAllowance: v })} min={0} max={100} step={5} snap suffix="%" />

Andel av enkeltspillerens handicap som teller (0–100 %).

) : null}
) } function FormatConfig() { const { state, patch } = useWizard() const f = state.format if (f === "match") { return ( patch({ matchExcludeHcp: v })} label="Ekskluder denne runden fra mitt faktiske HCP" /> ) } if (f === "skins") { return ( patch({ skinsScoring: v })} options={[ { value: "net", label: "Netto (m/HCP)" }, { value: "gross", label: "Brutto" }, ]} /> patch({ skinsTie: v })} options={[ { value: "carry", label: "Rullerer over" }, { value: "split", label: "Deles likt" }, ]} />

Skins krever minst 3 spillere.

) } if (f === "bbb") { return ( patch({ bbbSweep: v })} label="Bonuspoeng ved «sveip»" /> ) } if (f === "shamble") { return (
{[1, 2, 3, 4].map((n) => ( patch({ shambleBestN: n })} className="flex-1" > {n} ))}
) } if (f === "moneyball") { return (

Rotasjonen for «money ball» settes opp i neste steg.

) } if (f === "copenhagen") { return (

Nøyaktig 3 spillere.

) } if (isScrambleVsSolo(f)) { return null // handled by the dedicated allowance stepper } if (isTwoSided(f)) { return (

Du setter opp lagene i neste steg.

) } return null } function AdvancedHcp() { const { state, patch } = useWizard() const [open, setOpen] = useState(false) const f = state.format const isSlagOrStable = f === "slagspill" || f === "stableford" return (
{open ? (
patch({ useHandicap: v })} label="Bruk handicap" /> {state.useHandicap && !isSlagOrStable ? ( patch({ useCourseHcpAdj: v })} label="Bruk course handicap-justering" /> ) : null} {state.useHandicap && isTwoSided(f) ? ( patch({ useMatchplayHcp: v })} label="Bruk matchplay-handicap" /> ) : null} {state.useHandicap ? ( patch({ hcpPercent: e.target.value })} placeholder="F.eks. 95" className="max-w-[10rem]" /> ) : null}
) : null}
) } function ConfigCard({ children }: { children: React.ReactNode }) { return (
{children}
) } function CheckboxRow({ checked, onChange, label, }: { checked: boolean onChange: (v: boolean) => void label: string }) { return ( ) }