import { uuid } from '@/utils/uuid';
import Button from '@/components/Button';
import message, { MessageProps, MessageTypes } from '@/components/Message';

export default {
  title: 'components',
  argTypes: {
    type: {
      control: {
        type: 'select',
      },
      options: [MessageTypes.Error, MessageTypes.Info, MessageTypes.Success],
    },
  },
  args: {
    type: MessageTypes.Info,
    content: 'hello world',
    id: uuid(),
    i18: true,
    isRichText: true,
    actions: [<Button label="ok" key={uuid()} />],
    duration: 3000,
  },
};

export const Message: React.FC<MessageProps & { duration?: number }> = ({
  content,
  type,
  i18,
  isRichText,
  actions,
  duration,
}) => {
  return (
    <Button
      label="Hello"
      onClick={() => {
        message({
          type,
          content,
          i18,
          isRichText,
          actions,
          duration,
        });
      }}
    />
  );
};
