import React from 'react'; import { PropTypes } from 'prop-types'; import Parser from 'html-react-parser'; import Modal from '../../modal'; import getConfig from 'next/config'; import './style.scss'; const { publicRuntimeConfig } = getConfig(); class InterviewsList extends React.Component { constructor(props) { super(props); this.state = { activeLetter: 'A', }; } render() { const { activeLetter } = this.state; // Sort interviews alphabetically const sortedInterviews = this.props.data.sort((a, b) => a.name.localeCompare(b.name)); const interviews = {}; // Build up interviews object with letter key sortedInterviews.forEach((interview) => { const firstLetter = interview.name.charAt(0); if (typeof interviews[firstLetter] === 'undefined') { interviews[firstLetter] = []; } interviews[firstLetter].push(interview); }); return (

Interviews

{ Object.keys(interviews).map(firstLetter => (
{ firstLetter }
    { interviews[firstLetter].map(interview => (
  • )) }
)) }
{ Object.keys(interviews).map(firstLetter => ( )) }
); } } InterviewsList.propTypes = { isInterviewsListModalOpen: PropTypes.bool.isRequired, data: PropTypes.arrayOf(PropTypes.shape({})).isRequired, toggleSingleInterview: PropTypes.func.isRequired, /* eslint-disable-line */ toggleInterviewsListModal: PropTypes.func.isRequired, }; export default InterviewsList;