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