fix: change GAME_ROUNDS from strings to numbers

This commit is contained in:
lila 2026-04-28 12:29:46 +02:00
parent 7d3c456efe
commit 02ccc88d24
8 changed files with 181 additions and 14 deletions

View file

@ -24,19 +24,19 @@ const LABELS: Record<string, string> = {
type GameSetupProps = { onStart: (settings: GameRequest) => void };
type SettingGroupProps = {
type SettingGroupProps<T extends string | number> = {
label: string;
options: readonly string[];
selected: string;
onSelect: (value: string) => void;
options: readonly T[];
selected: T;
onSelect: (value: T) => void;
};
const SettingGroup = ({
const SettingGroup = <T extends string | number>({
label,
options,
selected,
onSelect,
}: SettingGroupProps) => (
}: SettingGroupProps<T>) => (
<div className="w-full">
<p className="text-xs font-bold tracking-widest uppercase text-(--color-primary) mb-2">
{label}
@ -52,7 +52,7 @@ const SettingGroup = ({
: "bg-white text-(--color-primary-dark) border-(--color-primary-light) hover:bg-(--color-surface) hover:-translate-y-0.5 active:translate-y-0"
}`}
>
{LABELS[option] ?? option}
{LABELS[String(option)] ?? option}
</button>
))}
</div>
@ -68,7 +68,7 @@ export const GameSetup = ({ onStart }: GameSetupProps) => {
);
const [pos, setPos] = useState<string>(SUPPORTED_POS[0]);
const [difficulty, setDifficulty] = useState<string>(DIFFICULTY_LEVELS[0]);
const [rounds, setRounds] = useState<string>(GAME_ROUNDS[0]);
const [rounds, setRounds] = useState<number>(GAME_ROUNDS[0]);
const handleSourceLanguage = (value: string) => {
if (value === targetLanguage) {