45 lines
1.4 KiB
JavaScript
Raw Normal View History

import React from 'react';
import { PropTypes } from 'prop-types';
import Parser from 'html-react-parser';
import Modal from '../../modal';
import './style.scss';
const SingleInterview = props => (
<Modal
2018-07-06 14:36:22 +02:00
isModalOpen
closeModal={props.toggleSingleInterview}
>
<div className="single-interview">
2018-07-17 15:07:27 +02:00
<div className="number">{ props.activeSingleInterviewId.toString().padStart(3, '0') }</div>
<div className="name"> { Parser(props.selectedInterview.name) } </div>
2018-07-13 11:11:32 +02:00
{ props.selectedInterview.interview.filter(interview => interview.answer !== null)
.map((interview, index) => {
2018-07-13 11:55:26 +02:00
const question = props.questions.find(q => q.id === interview.question);
2018-07-13 11:11:32 +02:00
return (
2018-07-17 15:07:27 +02:00
<div className="qa-block" key={`question-${question.id}`}>
2018-07-16 09:22:42 +02:00
<p className="question">{index + 1}) { question.text }</p>
<p className="answer">{ Parser(interview.answer) }</p>
2018-07-13 11:11:32 +02:00
</div>
);
})
}
</div>
</Modal>
);
SingleInterview.propTypes = {
activeSingleInterviewId: PropTypes.number.isRequired,
2018-07-06 14:36:22 +02:00
selectedInterview: PropTypes.shape({
2018-07-13 11:11:32 +02:00
name: PropTypes.string.isRequired,
interview: PropTypes.array.isRequired,
2018-07-06 14:36:22 +02:00
}).isRequired,
toggleSingleInterview: PropTypes.func.isRequired,
2018-07-13 11:47:52 +02:00
questions: PropTypes.arrayOf(PropTypes.shape({
2018-07-13 11:11:32 +02:00
id: PropTypes.number.isRequired,
text: PropTypes.string.isRequired,
2018-07-13 11:47:52 +02:00
})).isRequired,
};
export default SingleInterview;