import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';

import CardTable from './cardTable';
import CardItem from './cardItems/cardItem';
import CardItemHeader from './cardItems/cardItemHeader';
import AccountInfoItem, {
  AccountInfoHeader,
} from './cardItems/templates/accountInfoItem';
import CarrierItem, { CarrierHeader } from './cardItems/templates/carrierItem';
import PremiumItem, { PremiumHeader } from './cardItems/templates/premiumItem';
import PremiumCarrierItem, {
  PremiumCarrierHeader,
} from './cardItems/templates/premiumCarrierItem';
import EffectivePeriodItem from './cardItems/templates/effectivePeriodItem';
import LobItem from './cardItems/templates/lobItem';
import AgentItem from './cardItems/templates/agentItem';
import LastActivityItem from './cardItems/templates/lastActivityItem';

const cardActionsShort = [
  {
    label: 'Main Action',
    onClick: action('click on Main Action'),
  },
  {
    label: 'Action 2',
    onClick: action('click on Action 2'),
  },
  {
    label: 'Action 3',
    onClick: action('click on Action 3'),
  },
];

const cardActions = [
  ...cardActionsShort,
  {
    label: 'Action 4',
    onClick: action('click on Action 4'),
  },
  {
    label: 'Action 5',
    onClick: action('click on Action 5'),
  },
  {
    label: 'Action 6',
    onClick: action('click on Action 6'),
  },
];

const cards = [
  {
    accountInfo: {
      businessName: 'A & S Transportation',
      name: 'Raymond Bell',
      contactEmail: 'raubell815@gmail.com',
      contactPhone: '(815) 995 23 47',
    },
    insuranceType: 'Business Owner Policy (BOP)',
    carrier: {
      name: 'Ohio Security Insurance Company',
      logo: 'https://cdn.filestackcontent.com/sJEJWELwS7Gg9VbadZtT',
    },
    premium: 595.8,
    premiumCarrier: {
      premium: 595.8,
      carrier: {
        name: 'Ohio Security Insurance Company',
        logo: 'https://cdn.filestackcontent.com/sJEJWELwS7Gg9VbadZtT',
      },
    },
    effectivePeriod: {
      startDate: 'Jun 9, 2019',
      endDate: 'Jun 9, 2020',
    },
    agent: {
      name: 'Gabe McNaughton',
      phone: '(646) 760-8440',
      email: 'gabemcn@coverwallet.com',
    },
    status: {
      type: 'success',
      label: 'Active',
    },
    actions: cardActions,
  },
  {
    accountInfo: {
      businessName: 'A & S Transportation',
      name: 'Raymond Bell',
      contactEmail: 'raubell815@gmail.com',
      contactPhone: '(815) 995 23 47',
    },
    insuranceType: 'Business Owner Policy (BOP)',
    carrier: {
      name: 'Ohio Security Insurance Company',
      logo: 'https://cdn.filestackcontent.com/sJEJWELwS7Gg9VbadZtT',
    },
    premium: 1595.8,
    premiumCarrier: {
      premium: 1595.8,
      carrier: {
        name: 'Ohio Security Insurance Company',
        logo: 'https://cdn.filestackcontent.com/sJEJWELwS7Gg9VbadZtT',
      },
    },
    effectivePeriod: {
      startDate: 'Jun 9, 2019',
      endDate: 'Jun 9, 2020',
    },
    agent: {
      name: 'Gabe McNaughton',
      phone: '(646) 760-8440',
      email: 'gabemcn@coverwallet.com',
    },
    status: {
      type: 'warning',
      label: 'Expiring',
    },
    actions: cardActionsShort,
  },
  {
    accountInfo: {
      businessName: 'A & S Transportation',
      name: 'Raymond Bell',
      contactEmail: 'raubell815@gmail.com',
      contactPhone: '(815) 995 23 47',
    },
    insuranceType: 'Business Owner Policy (BOP)',
    carrier: {
      name: 'Ohio Security Insurance Company',
      logo: 'https://cdn.filestackcontent.com/sJEJWELwS7Gg9VbadZtT',
    },
    premium: 595.8,
    premiumCarrier: {
      premium: 595.8,
      carrier: {
        name: 'Ohio Security Insurance Company',
        logo: 'https://cdn.filestackcontent.com/sJEJWELwS7Gg9VbadZtT',
      },
    },
    effectivePeriod: {
      startDate: 'Jun 9, 2019',
      endDate: 'Jun 9, 2020',
    },
    agent: {
      name: 'Gabe McNaughton',
      phone: '(646) 760-8440',
      email: 'gabemcn@coverwallet.com',
    },
    status: {
      type: 'error',
      label: 'Expired',
    },
    actions: cardActions,
  },
];

storiesOf('Composites|Card Table', module).add('Cards for Policies', () => {
  CardItem.addTemplates({
    accountInfo: AccountInfoItem,
    carrier: CarrierItem,
    premium: PremiumItem,
    premiumCarrier: PremiumCarrierItem,
    effectivePeriod: EffectivePeriodItem,
    insuranceType: LobItem,
    agent: AgentItem,
    lastActivity: LastActivityItem,
  });

  CardItemHeader.addTemplates({
    accountInfo: AccountInfoHeader,
    carrier: CarrierHeader,
    premium: PremiumHeader,
    premiumCarrier: PremiumCarrierHeader,
  });

  return (
    <CardTable
      sections={[
        { label: 'INSURANCE TYPE', type: 'insuranceType' },
        { label: 'CARRIER', type: 'carrier' },
        { label: 'PREMIUM', type: 'premium' },
        { label: 'PREMIUM', type: 'premiumCarrier' },
        { label: 'EFFECTIVE PERIOD', type: 'effectivePeriod' },
        { label: 'BROKER', type: 'agent' },
      ]}
      cards={cards}
    />
  );
});
