import RadioGroup, { RadioGroupProps } from './RadioGroup';
import { Field } from '../field/Field';
import { Meta, StoryObj } from '@storybook/react-webpack5';
import { fn } from 'storybook/test';

const meta = {
  component: RadioGroup,
  title: 'Forms/RadioGroup/Tests',
  tags: ['!autodocs', '!manifest'],
  args: {
    selectedValue: 'radio-2',
    name: 'radio-group',
    radios: [
      {
        value: 'radio-1',
        label: 'Radio1',
      },
      {
        value: 'radio-2',
        label: 'Radio2',
      },
    ],
    onChange: fn(),
  },
} satisfies Meta<typeof RadioGroup>;

export default meta;
type Story<T extends string | number = string> = StoryObj<RadioGroupProps<T>>;

export const FieldsWithPrompt = {
  render: function Render(args) {
    return (
      <>
        {['i1', 'i2'].map((id) => (
          <Field
            key={id}
            label="Field label"
            description="Field description"
            message="Something went great"
            sentiment="positive"
          >
            <RadioGroup {...args} selectedValue="radio-2" />
          </Field>
        ))}
      </>
    );
  },
} satisfies Story;

export const FieldsWithoutPrompt = {
  render: function Render(args) {
    return (
      <>
        {['i1', 'i2'].map((id) => (
          <Field key={id} label="Field label" sentiment="positive">
            <RadioGroup {...args} selectedValue="radio-2" />
          </Field>
        ))}
      </>
    );
  },
} satisfies Story;
