import type { Key } from "react-aria-components"; import { useTranslation } from "react-i18next"; import { SendouSelect, SendouSelectItem } from "~/components/elements/Select"; import { StageImage } from "~/components/Image"; import { stageIds } from "~/modules/in-game-lists/stage-ids"; import type { StageId } from "~/modules/in-game-lists/types"; import styles from "./StageSelect.module.css"; interface StageSelectProps { label?: string; value?: StageId | null; initialValue?: StageId; onChange?: ( stageId: StageId | (Clearable extends true ? null : never), ) => void; clearable?: Clearable; testId?: string; isRequired?: boolean; } export function StageSelect({ label, value, initialValue, onChange, clearable, testId = "stage-select", isRequired, }: StageSelectProps) { const { t } = useTranslation(["common", "game-misc"]); const items = useStageItems(); const isControlled = value !== undefined; const handleOnChange = (key: Key | null) => { if (key === null) return onChange?.(null as any); onChange?.(Number(key) as any); }; return ( {({ id, name }) => (
{name}
)}
); } function useStageItems() { const { t } = useTranslation(["game-misc"]); return stageIds.map((id) => ({ id, name: t(`game-misc:STAGE_${id}`), })); }