import { Checkbox, Combobox } from '@mantine/core'; import { useMemo } from 'react'; import type { BoxerItem } from '../Boxer.types'; interface UseBoxerOptionsProps { boxerData: Array; multiSelect?: boolean; onOptionSubmit: (index: number) => void; value?: any | Array; } const useBoxerOptions = (props: UseBoxerOptionsProps) => { const { boxerData, multiSelect, onOptionSubmit, value } = props; const options = useMemo(() => { return boxerData.map((item, index) => { const isSelected = multiSelect ? Array.isArray(value) && value.includes(item.value) : value === item.value; return ( { onOptionSubmit(index); }} value={String(index)} > {multiSelect ? (
{}} tabIndex={-1} /> {item.label}
) : ( item.label )}
); }); }, [boxerData, value, multiSelect, onOptionSubmit]); return { options }; }; export default useBoxerOptions;