import { SwitchMiiInstructions } from "@/types"; import { useState } from "react"; import ColorPicker from "../color-picker"; import TypeSelector from "../type-selector"; import NumberInputs from "../number-inputs"; interface Props { instructions: React.RefObject; } const TABS: { name: keyof SwitchMiiInstructions["other"]; length: number; colorsDisabled?: number[] }[] = [ { name: "wrinkles1", length: 50 }, { name: "wrinkles2", length: 40 }, { name: "beard", length: 20 }, { name: "moustache", length: 10 }, { name: "goatee", length: 5 }, { name: "mole", length: 15 }, { name: "eyeShadow", length: 3 }, { name: "blush", length: 8, colorsDisabled: [6] }, ]; export default function OtherTab({ instructions }: Props) { const [tab, setTab] = useState(0); // One type/color state per tab const [types, setTypes] = useState(Array(TABS.length).fill(0)); const [colors, setColors] = useState(Array(TABS.length).fill(0)); const currentTab = TABS[tab]; const isColorPickerDisabled = currentTab.colorsDisabled ? currentTab.colorsDisabled.includes(types[tab]) : false; const setType = (value: number) => { setTypes((prev) => { const copy = [...prev]; copy[tab] = value; return copy; }); instructions.current.other[currentTab.name].type = value; }; const setColor = (value: number) => { setColors((prev) => { const copy = [...prev]; copy[tab] = value; return copy; }); instructions.current.other[currentTab.name].color = value; }; return (

Other

{TABS.map((_, i) => ( ))}
); }