import { MyProEnumItemProps } from '@/common/typings';
import { Radio } from 'antd';

export default function MyEnumRadioGroup(props: {
  enums: MyProEnumItemProps;
  value: string | number | undefined;
  onChange: (value: string | number | undefined) => void;
}) {
  const options = Object.entries(props.enums).map(([, value]) => {
    return { label: value.text, value: value.value };
  });
  return (
    <Radio.Group
      options={options}
      onChange={(e) => props?.onChange(e.target.value)}
      value={props.value || options[0].value}
      optionType="button"
      buttonStyle="solid"
    />
  );
}
