import { Controller } from 'react-hook-form';

import { type IconInterface } from '@src/types/icons';

import { type FormIconPickerProps } from './types';
import IconPicker from '.';

const FormIconPicker = ({ name, inputProps, rules }: FormIconPickerProps) => {
  return (
    <Controller
      name={name}
      rules={rules}
      render={({ field }) => (
        <IconPicker
          {...inputProps}
          value={field.value as IconInterface | null}
          onChange={field.onChange}
        />
      )}
    />
  );
};

export default FormIconPicker;
