Mark component props as Readonly<> across 15 component files and simplify edit-player-character field access with optional chaining and nullish coalescing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
import type { Encounter } from "@initiative/domain";
|
|
import { StepBack, StepForward, Trash2 } from "lucide-react";
|
|
import { Button } from "./ui/button";
|
|
import { ConfirmButton } from "./ui/confirm-button";
|
|
|
|
interface TurnNavigationProps {
|
|
encounter: Encounter;
|
|
onAdvanceTurn: () => void;
|
|
onRetreatTurn: () => void;
|
|
onClearEncounter: () => void;
|
|
}
|
|
|
|
export function TurnNavigation({
|
|
encounter,
|
|
onAdvanceTurn,
|
|
onRetreatTurn,
|
|
onClearEncounter,
|
|
}: Readonly<TurnNavigationProps>) {
|
|
const hasCombatants = encounter.combatants.length > 0;
|
|
const isAtStart = encounter.roundNumber === 1 && encounter.activeIndex === 0;
|
|
const activeCombatant = encounter.combatants[encounter.activeIndex];
|
|
|
|
return (
|
|
<div className="flex items-center gap-3 rounded-md border border-border bg-card px-4 py-3">
|
|
<Button
|
|
variant="outline"
|
|
size="icon"
|
|
onClick={onRetreatTurn}
|
|
disabled={!hasCombatants || isAtStart}
|
|
title="Previous turn"
|
|
aria-label="Previous turn"
|
|
>
|
|
<StepBack className="h-5 w-5" />
|
|
</Button>
|
|
|
|
<div className="flex min-w-0 flex-1 items-center justify-center gap-2 text-sm">
|
|
<span className="shrink-0 rounded-full bg-muted px-2 py-0.5 font-semibold text-foreground text-sm">
|
|
R{encounter.roundNumber}
|
|
</span>
|
|
{activeCombatant ? (
|
|
<span className="truncate font-medium">{activeCombatant.name}</span>
|
|
) : (
|
|
<span className="text-muted-foreground">No combatants</span>
|
|
)}
|
|
</div>
|
|
|
|
<div className="flex flex-shrink-0 items-center gap-3">
|
|
<ConfirmButton
|
|
icon={<Trash2 className="h-5 w-5" />}
|
|
label="Clear encounter"
|
|
onConfirm={onClearEncounter}
|
|
disabled={!hasCombatants}
|
|
className="text-muted-foreground"
|
|
/>
|
|
<Button
|
|
variant="outline"
|
|
size="icon"
|
|
onClick={onAdvanceTurn}
|
|
disabled={!hasCombatants}
|
|
title="Next turn"
|
|
aria-label="Next turn"
|
|
>
|
|
<StepForward className="h-5 w-5" />
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|