{"size": 2247, "ext": "js", "max_stars_repo_path": "app/containers/Front/Front.js", "max_stars_repo_name": "nodexchange/quartile-aws", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/containers/Front/Front.js", "max_issues_repo_name": "nodexchange/quartile-aws", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/containers/Front/Front.js", "max_forks_repo_name": "nodexchange/quartile-aws", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.6478873239, "max_line_length": 114, "alphanum_fraction": 0.6533155318}
/* eslint-disable react/no-unescaped-entities */
import React, { PureComponent } from 'react';
import Helmet from 'react-helmet';
import PropTypes from 'prop-types';
import { ArrowNav, Clients, SectionItem } from 'components';
import throttle from '../../helpers/Throttle';
import './Front.scss';
import data from './front-data.json';

export default class Front extends PureComponent {
  constructor(props) {
    super(props);
    this.currentPanel = this.props.offsetRatio || 0;
    // this.localeCopy = this.props.localeCopy || 'pending';
  }

  componentDidMount() {
    // window.addEventListener('resize', throttle(this.props.mainImageResizeAction, 100));
    window.addEventListener('scroll', throttle(this.props.mainWindowScrollAction, 100));
    this.props.mainWindowScrollAction();
    // this.props.mainImageResizeAction();
  }

  componentWillReceiveProps(nextProps) {
    // console.log('PROPS HERE ' + nextProps);
    const panelValue = Math.round(nextProps.offsetRatio) + 0.2;
    if (panelValue !== this.currentPanel) {
      this.currentPanel = Math.round(nextProps.offsetRatio);
    }
  }

  componentWillUnmount() {
    window.removeEventListener('scroll', throttle(this.props.mainWindowScrollAction, 100));
    // this.props.updateMaxPages(1);
  }

  render() {
    const frontPanelsCopy = data.data;
    const rows = [];
    for (let i = 0; i < frontPanelsCopy.length; i++) {
      if (this.currentPanel === i) {
        rows.push(
          <SectionItem inView key={i} order={i} {...frontPanelsCopy[i]} offset={this.props.offsetRatio} />
        );
      } else {
        rows.push(
          <SectionItem inView={false} key={i} order={i} {...frontPanelsCopy[i]} offset={this.props.offsetRatio} />
        );
      }
    }
    // console.log(this.props);
    return (
      <section className="content">
        <div className={'front'}>
          <Helmet title="Home" />
          {rows}
          <Clients />
          <ArrowNav offsetRatio={this.props.offsetRatio} maxPages={6} />
        </div>
      </section>
    );
  }
}

Front.propTypes = {
  mainWindowScrollAction: PropTypes.func.isRequired,
  mainImageResizeAction: PropTypes.func,
  updateMaxPages: PropTypes.func.isRequired,
  offsetRatio: PropTypes.number,
};
