2018-07-06 11:45:36 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { PropTypes } from 'prop-types';
|
|
|
|
import Modal from '../../modal';
|
|
|
|
import './style.scss';
|
|
|
|
|
2018-07-10 11:43:11 +00:00
|
|
|
const InterviewsList = props => {
|
|
|
|
|
|
|
|
// Sort interviews alphabetically
|
|
|
|
const sortedInterviews = props.data.sort((a, b) => { return 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 (
|
|
|
|
<div className="interviews-wrap">
|
|
|
|
<div className="mob-interviews-link">
|
|
|
|
{/* eslint-disable-next-line */}
|
|
|
|
<span
|
|
|
|
role="button"
|
|
|
|
tabIndex="0"
|
|
|
|
onClick={props.toggleInterviewsListModal}
|
|
|
|
>
|
|
|
|
Interviews ({props.data.length})
|
|
|
|
</span>
|
|
|
|
{/* eslint-disable-next-line */}
|
|
|
|
<span
|
|
|
|
role="button"
|
|
|
|
tabIndex="0"
|
|
|
|
onClick={props.toggleInterviewsListModal}
|
|
|
|
>
|
|
|
|
View
|
|
|
|
</span>
|
2018-07-06 11:45:36 +00:00
|
|
|
</div>
|
2018-07-10 11:43:11 +00:00
|
|
|
<Modal
|
|
|
|
isModalOpen={props.isInterviewsListModalOpen}
|
|
|
|
closeModal={props.toggleInterviewsListModal}
|
|
|
|
modalOnMobileOnly
|
|
|
|
>
|
|
|
|
<React.Fragment>
|
|
|
|
<h4>Interviews ({ props.data.length })</h4>
|
|
|
|
<div className="interviews-nav-wrap">
|
|
|
|
<div className="interviews-list">
|
|
|
|
{
|
|
|
|
Object.keys(interviews).map(firstLetter => (
|
|
|
|
<div className="letter-block" key={firstLetter}>
|
|
|
|
<div id={firstLetter}>{ firstLetter }</div>
|
|
|
|
<ul>
|
|
|
|
{interviews[firstLetter].map(interview => (
|
|
|
|
// eslint-disable-next-line
|
|
|
|
<li
|
|
|
|
id={interview.id}
|
|
|
|
key={interview.id}
|
|
|
|
onClick={props.toggleSingleInterview}
|
|
|
|
>
|
|
|
|
{interview.name}
|
|
|
|
</li>
|
|
|
|
)
|
|
|
|
)}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
<div className="letters-nav">
|
|
|
|
{
|
|
|
|
Object.keys(interviews).map(firstLetter => (
|
|
|
|
<span
|
|
|
|
key={firstLetter}
|
|
|
|
onClick={() => { document.querySelector(`#${firstLetter}`).scrollIntoView({ behavior: 'smooth' }); }}
|
|
|
|
>
|
|
|
|
{ firstLetter }
|
|
|
|
</span>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</React.Fragment>
|
|
|
|
</Modal>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2018-07-06 11:45:36 +00:00
|
|
|
|
|
|
|
InterviewsList.propTypes = {
|
|
|
|
isInterviewsListModalOpen: PropTypes.bool.isRequired,
|
2018-07-09 14:29:38 +00:00
|
|
|
data: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
|
2018-07-06 11:45:36 +00:00
|
|
|
toggleSingleInterview: PropTypes.func.isRequired,
|
|
|
|
toggleInterviewsListModal: PropTypes.func.isRequired,
|
2018-07-06 12:36:22 +00:00
|
|
|
};
|
2018-07-06 11:45:36 +00:00
|
|
|
|
|
|
|
export default InterviewsList;
|