import React from 'react';
import {Meta, StoryObj} from '@storybook/react';

import {Alert, AlertProps} from './index';

type StoryComponent = AlertProps & {actionLabel: string};

const meta: Meta<StoryComponent> = {
  title: 'HuGo/Alert',
  component: Alert,
  argTypes: {
    variant: {
      control: 'radio',
      options: ['error', 'success', 'warning', 'info', 'highLight'],
    },
    title: {control: 'text'},
    description: {control: 'text'},
    withClose: {control: 'boolean'},
    actionLabel: {control: 'text'},
  },
};

export const AlertComponent: StoryObj<StoryComponent> = {
  args: {
    variant: 'info',
    title: 'Title',
    description: 'This is a description',
    actionLabel: 'Action',
    withClose: true,
  },
  render: ({actionLabel, ...args}) => (
    <Alert
      action={
        actionLabel ? {text: actionLabel, onPress: () => null} : undefined
      }
      {...args}
    />
  ),
};

export default meta;
