import { Meta, StoryObj } from '@storybook/react';
import { Button, withId, type WithIdProps } from '..';

type Story = StoryObj<typeof withId>;

type DescribedButtonProps = { id?: string };
type DescribedButtonWithIdProps = WithIdProps<DescribedButtonProps>;

function CustomButton({ id }: DescribedButtonWithIdProps) {
  return (
    <>
      <Button aria-describedby={id}>Continue</Button>

      <p id={id} className="text-xs-center m-t-2">
        Enter an amount in either GBP or PLN
        <br />
        This paragraph has id of <code>{id}</code>
      </p>
    </>
  );
}
const DescribedButton = withId<DescribedButtonProps>(CustomButton);
DescribedButton.displayName = 'DescribedButton';

export default {
  component: DescribedButton,
  tags: ['docs-only'],
} satisfies Meta<typeof withId>;

export const WithoutId: Story = {};

export const WithCustomId: Story = {
  args: {
    id: 'myId',
  },
};

export const WithEmptyId: Story = {
  args: {
    id: '',
  },
};
