import { Box, Button, Flex, useColorMode } from "@chakra-ui/react"; import { useId, useState } from "react"; import { colors } from "src/styles/Theme/colors"; interface LabelRadioGroupProps { labelIDs: Array; onChange: (sliderValues: number[]) => unknown; isEditable?: boolean; } export const LabelRadioGroup = (props: LabelRadioGroupProps) => { const [labelValues, setLabelValues] = useState(Array.from({ length: props.labelIDs.length }).map(() => 0)); const [interactionFlag, setInteractionFlag] = useState(false); return ( {props.labelIDs.map((labelId, idx) => ( { const newState = labelValues.slice(); newState[idx] = newValue; props.onChange(newState); setLabelValues(newState); if (!interactionFlag) setInteractionFlag(true); }} states={[ { text: "No", value: 0 }, { text: "Yes", value: 1 }, ]} isEditable={props.isEditable} interactionFlag={interactionFlag} /> ))} ); }; interface ButtonState { text: string; value: number; colorScheme?: string; } interface LabelRadioItemProps { labelId: string; labelValue: number; clickHandler: (newVal: number) => unknown; states: ButtonState[]; isEditable: boolean; interactionFlag: boolean; } const LabelRadioItem = (props: LabelRadioItemProps) => { const id = useId(); const { colorMode } = useColorMode(); const labelTextClass = colorMode === "light" ? `text-${colors.light.text}` : `text-${colors.dark.text}`; return ( {props.states.map((item, idx) => ( ))} ); };