import React from 'react'

import EventBets from '../templates/event-bets'
import EventHeading from '../templates/event-heading'

import styles from './index.module.styl'

export default ({ data }) => (
  <ol className={styles['events-list']}>
    {
      data.allMongodbPlacardDevEvents.edges.map(({ node }, idx) => (
        <li key={idx} className={styles['event-item']}>
          <EventHeading event={node} />
          <EventBets betTypes={node.betTypes} />
        </li>
      ))
    }
  </ol>
)

export const query = graphql`
  query EventsListQuery($sport: String, $country: String, $skip: Int = 0, $limit: Int = 20) {
    allMongodbPlacardDevEvents(
      filter: { sport: { eq: $sport }, country: { eq: $country } },
      sort: { fields: [date], order: ASC },
      skip: $skip,
      limit: $limit
    ) {
      edges {
        node {
          code
          home
          away
          date
          sport
          country
          competition
          betTypes {
            name
            options {
              name
              value
            }
          }
        }
      }
    }
  }
`

import React from 'react'

import EventBets from '../templates/event-bets'
import EventHeading from '../templates/event-heading'

import styles from './index.module.styl'

export default ({ data }) => (
  <ol className={styles['events-list']}>
    {
      data.allMongodbPlacardDevEvents.edges.map(({ node }, idx) => (
        <li key={idx} className={styles['event-item']}>
          <EventHeading event={node} />
          <EventBets betTypes={node.betTypes} />
        </li>
      ))
    }
  </ol>
)

export const query = graphql`
  query EventsListQuery($sport: String, $country: String, $skip: Int = 0, $limit: Int = 10) {
    allMongodbPlacardDevEvents(
      filter: { sport: { eq: $sport }, country: { eq: $country } },
      sort: { fields: [date], order: ASC },
      skip: $skip,
      limit: $limit
    ) {
      edges {
        node {
          code
          home
          away
          date
          sport
          country
          competition
          betTypes {
            name
            options {
              name
              value
            }
          }
        }
      }
    }
  }
`

Set default page size to 10 events.
Set default page size to 10 events.
