import React from 'react'
import {withInfo} from '@storybook/addon-info'
import {storiesOf} from '@storybook/react'

import Board from '../src'

const data = {
  lanes: [
    {
      id: 'lane1',
      title: 'Planned Tasks',
      cards: [
        {id: 'Card1', title: 'Card1', description: 'foo card', metadata: {id: 'Card1'}},
        {id: 'Card2', title: 'Card2', description: 'bar card', metadata: {id: 'Card2'}}
      ]
    },
    {
      id: 'lane2',
      title: 'Executing',
      cards: []
    }
  ]
}

storiesOf('React Trello', module).add(
  'Event Handling',
  withInfo('Adding event handlers to cards')(() =>
    <Board
    draggable={true}
      data={data}
      onCardClick={(cardId, metadata, laneId) => alert(`Card with id:${cardId} clicked. Has metadata.id: ${metadata.id}. Card in lane: ${laneId}`)}
      onLaneClick={(laneId) => alert(`Lane with id:${laneId} clicked`)}
    />
  )
)

import React from 'react'
import {withInfo} from '@storybook/addon-info'
import {storiesOf} from '@storybook/react'

import Board from '../src'

const data = {
  lanes: [
    {
      id: 'lane1',
      title: 'Planned Tasks',
      cards: [
        {id: 'Card1', title: 'Card1', description: 'foo card', metadata: {id: 'Card1'}},
        {id: 'Card2', title: 'Card2', description: 'bar card', metadata: {id: 'Card2'}}
      ]
    },
    {
      id: 'lane2',
      title: 'Executing',
      cards: [
        {id: 'Card3', title: 'Card3', description: 'foobar card', metadata: {id: 'Card3'}}
      ]
    }
  ]
}

storiesOf('React Trello', module).add(
  'Event Handling',
  withInfo('Adding event handlers to cards')(() =>
    <Board
    draggable={true}
      data={data}
      onCardClick={(cardId, metadata, laneId) => alert(`Card with id:${cardId} clicked. Has metadata.id: ${metadata.id}. Card in lane: ${laneId}`)}
      onLaneClick={(laneId) => alert(`Lane with id:${laneId} clicked`)}
    />
  )
)

Allow laneId to be passed as param to onCardClick handler
fix: Allow laneId to be passed as param to onCardClick handler

https://github.com/rcdexta/react-trello/issues/34
