import React from 'react'; import { PropTypes } from 'prop-types'; import Modal from '../../modal'; import './style.scss'; const InterviewsList = (props) => { // Sort interviews alphabetically const sortedInterviews = 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 (
{/* eslint-disable-next-line */} Interviews ({props.data.length}) {/* eslint-disable-next-line */} View

Interviews ({ props.data.length })

{ Object.keys(interviews).map(firstLetter => (
{ firstLetter }
    { interviews[firstLetter].map(interview => (
  • )) }
)) }
{ Object.keys(interviews).map(firstLetter => ( // eslint-disable-next-line { document.querySelector(`#${firstLetter}`).scrollIntoView({ behavior: 'smooth' }); }} > { 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;