"use client" import { isScrambleVsSolo, isTwoSided } from "@/lib/ny-runde/formats" import type { Player } from "@/lib/ny-runde/types" import { cn } from "@/lib/utils" import { ArrowLeftRight, Check, UserMinus } from "lucide-react" import { Avatar, NativeSelect, Panel, Pill, TextInput } from "./primitives" import { useWizard } from "./wizard-context" function fullName(p: Player) { return `${p.firstName}${p.lastName ? ` ${p.lastName}` : ""}`.trim() || "Spiller" } export function Step4Teams() { const { state } = useWizard() const f = state.format return (

Lag og rekkefølge

Sett opp lagene for denne spilleformen.

{isTwoSided(f) ? : f === "moneyball" ? : isScrambleVsSolo(f) ? : null}
) } /* ------------------------------------------------------------------ */ /* Two-sided A/B */ /* ------------------------------------------------------------------ */ function TwoSided() { const { state, patch } = useWizard() const assign = state.sideAssign const unassigned = state.players.filter((p) => !assign[p.key]) const sideA = state.players.filter((p) => assign[p.key] === "A") const sideB = state.players.filter((p) => assign[p.key] === "B") function set(key: string, side: "A" | "B" | undefined) { patch({ sideAssign: { ...assign, [key]: side } }) } return (
{unassigned.length > 0 ? (

Ikke tildelt

) : null}
patch({ sideALabel: v })} players={sideA} otherSideLabel={state.sideBLabel || "Side B"} onMoveOther={(k) => set(k, "B")} onRemove={(k) => set(k, undefined)} /> patch({ sideBLabel: v })} players={sideB} otherSideLabel={state.sideALabel || "Side A"} onMoveOther={(k) => set(k, "A")} onRemove={(k) => set(k, undefined)} />
) } function SideColumn({ label, placeholder, suggestion, onLabel, players, otherSideLabel, onMoveOther, onRemove, }: { label: string placeholder: string suggestion: string onLabel: (v: string) => void players: Player[] otherSideLabel: string onMoveOther: (key: string) => void onRemove: (key: string) => void }) { return (
onLabel(e.target.value)} placeholder={placeholder} className="h-10 font-medium" /> {!label ? ( ) : null} {players.length === 0 ? (

Ingen spillere ennå.

) : ( )}
) } function AssignBtn({ onClick, children }: { onClick: () => void; children: React.ReactNode }) { return ( ) } /* ------------------------------------------------------------------ */ /* Money Ball */ /* ------------------------------------------------------------------ */ function MoneyBall() { const { state, patch } = useWizard() return (

Gi hver spiller en plass i rotasjonen (0–3).

) } /* ------------------------------------------------------------------ */ /* Scramble vs solo (asymmetric) */ /* ------------------------------------------------------------------ */ function ScrambleVsSolo() { const { state, patch } = useWizard() const assign = state.scrambleAssign const team = state.players.filter((p) => assign[p.key] === "team") const opponent = state.players.find((p) => assign[p.key] === "opponent") const unplaced = state.players.filter((p) => !assign[p.key]) const teamReady = team.length >= 2 const opponentFilled = !!opponent function set(key: string, slot: "team" | "opponent" | undefined) { patch({ scrambleAssign: { ...assign, [key]: slot } }) } return (
{/* The team — open-ended, emphasized */}

Laget

{teamReady ? : null} {teamReady ? "Minst 2 spillere lagt til" : "Minst 2 spillere"}
{team.length === 0 ? (

Legg til spillere fra listen under.

) : ( )}
{/* Individual opponent — capped at 1, visually distinct single slot */}

Individuell motstander

{opponent ? (
{fullName(opponent)} 1 av 1
) : (

Én spiller. Velg «Som motstander» på en spiller under.

)}
{/* Unplaced */} {unplaced.length > 0 ? (

Ikke plassert

) : null}
) }