// components/form/RadioInput.tsx
import React from 'react';
import { Radio } from 'antd';
import type { RadioChangeEvent } from 'antd/es/radio';

interface RadioOption {
    label: string
    value: number | string
}

interface RadioInputProps {
    options: RadioOption[]
    onChange: (value: number | string) => void
    value: number | string
    [key: string]: unknown // Allow any additional props
}

const RadioInput: React.FC<RadioInputProps> = ({ options, onChange, value, ...rest }) => {
  const handleChange = (e: RadioChangeEvent): void => {
    onChange(e.target.value);
  };

  return (
    <Radio.Group onChange={handleChange} value={value} {...rest}>
      {options.map((option) => (
        <Radio key={option?.value} value={option.value}>
          {option.label}
        </Radio>
      ))}
    </Radio.Group>
  );
};

export default RadioInput;
