text: import React, { Component } from 'react';
  import * as PropTypes from 'prop-types';
  import { graphql, createPaginationContainer } from 'react-relay';
  import { pathOr } from 'ramda';
  import ListLinesContent from '../../../../components/list_lines/ListLinesContent';
  import { IndividualLine, IndividualLineDummy } from './IndividualLine';
  import { setNumberOfElements } from '../../../../utils/Number';
  
  const nbOfRowsToLoad = 50;
  
  class IndividualsLines extends Component {
    componentDidUpdate(prevProps) {
      setNumberOfElements(
        prevProps,
        this.props,
        'individuals',
        this.props.setNumberOfElements.bind(this),
      );
    }
  
    render() {
      const {
        initialLoading,
        dataColumns,
        relay,
        paginationOptions,
        onLabelClick,
      } = this.props;
      return (
        <ListLinesContent
          initialLoading={initialLoading}
          loadMore={relay.loadMore.bind(this)}
          hasMore={relay.hasMore.bind(this)}
          isLoading={relay.isLoading.bind(this)}
          dataList={pathOr([], ['individuals', 'edges'], this.props.data)}
          globalCount={pathOr(
            nbOfRowsToLoad,
            ['individuals', 'pageInfo', 'globalCount'],
            this.props.data,
          )}
          LineComponent={<IndividualLine />}
          DummyLineComponent={<IndividualLineDummy />}
          dataColumns={dataColumns}
          nbOfRowsToLoad={nbOfRowsToLoad}
          paginationOptions={paginationOptions}
          onLabelClick={onLabelClick.bind(this)}
        />
      );
    }
  }
  
  IndividualsLines.propTypes = {
    classes: PropTypes.object,
    paginationOptions: PropTypes.object,
    dataColumns: PropTypes.object.isRequired,
    data: PropTypes.object,
    relay: PropTypes.object,
    initialLoading: PropTypes.bool,
    onLabelClick: PropTypes.func,
    setNumberOfElements: PropTypes.func,
  };
  
  export const individualsLinesQuery = graphql`
    query IndividualsLinesPaginationQuery(
      $search: String
      $count: Int!
      $cursor: ID
      $orderBy: IndividualsOrdering
      $orderMode: OrderingMode
      $filters: [IndividualsFiltering]
    ) {
      ...IndividualsLines_data
        @arguments(
          search: $search
          count: $count
          cursor: $cursor
          orderBy: $orderBy
          orderMode: $orderMode
          filters: $filters
        )
    }
  `;
  
  export default createPaginationContainer(
    IndividualsLines,
    {
      data: graphql`
        fragment IndividualsLines_data on Query
        @argumentDefinitions(
          search: { type: "String" }
          count: { type: "Int", defaultValue: 25 }
          cursor: { type: "ID" }
          orderBy: { type: "IndividualsOrdering", defaultValue: name }
          orderMode: { type: "OrderingMode", defaultValue: asc }
          filters: { type: "[IndividualsFiltering]" }
        ) {
          individuals(
            search: $search
            first: $count
            after: $cursor
            orderBy: $orderBy
            orderMode: $orderMode
            filters: $filters
          ) @connection(key: "Pagination_individuals") {
            edges {
              node {
                id
                name
                description
                ...IndividualLine_node
              }
            }
            pageInfo {
              endCursor
              hasNextPage
              globalCount
            }
          }
        }
      `,
    },
    {
      direction: 'forward',
      getConnectionFromProps(props) {
        return props.data && props.data.individuals;
      },
      getFragmentVariables(prevVars, totalCount) {
        return {
          ...prevVars,
          count: totalCount,
        };
      },
      getVariables(props, { count, cursor }, fragmentVariables) {
        return {
          search: fragmentVariables.search,
          count,
          cursor,
          orderBy: fragmentVariables.orderBy,
          orderMode: fragmentVariables.orderMode,
          filters: fragmentVariables.filters,
        };
      },
      query: individualsLinesQuery,
    },
  );
  