Merge pull request #28 from Nona-Creative/feat/new-json-structure

New JSON structure transform
This commit is contained in:
Wisani 2018-07-20 10:55:10 +02:00 committed by GitHub
commit 6a8ede1cee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6754 additions and 1791 deletions

View File

@ -7,7 +7,7 @@ import TopicsList from '../topicsList';
import ProjectsList from '../projectsList';
import SearchBar from '../searchBar';
import SearchResults from '../searchResults';
import { InterviewsData, Questions } from '../../data/archives/interviews';
import { InterviewData, Questions } from '../../data/archives/interviews';
import './style.scss';
class BrowseArchives extends React.Component {
@ -22,7 +22,7 @@ class BrowseArchives extends React.Component {
isInterviewsListModalOpen: false,
activeSingleInterviewId: 1,
isSearchActive: false,
interviewData: this.transformInterviews(InterviewsData),
interviewData: this.transformInterviews(InterviewData),
matchedCount: 0,
};
@ -112,6 +112,7 @@ class BrowseArchives extends React.Component {
});
}
// used as an intermediary to give us an easy to search through JSON object
transformInterviews = (interviews) => {
const { length } = Object.keys(interviews);
const betterInterviews = [];
@ -121,18 +122,18 @@ class BrowseArchives extends React.Component {
const qKeys = Object.keys(interview);
const interviewFormatted = [];
qKeys.forEach((key, index) => {
if (key !== 'Name' && interview[key] !== null) {
qKeys.forEach((key) => {
if (key !== 'name' && interview[key] !== null && interview[key].answer !== null && interview[key].answer !== '') {
interviewFormatted.push({
question: index,
answer: interview[key],
question: key,
answer: interview[key].answer,
});
}
});
betterInterviews.push({
id: i + 1,
name: interview.Name,
name: interview.name,
matchedIndex: -1,
interview: interviewFormatted,
});

View File

@ -36,7 +36,7 @@ SingleInterview.propTypes = {
}).isRequired,
toggleSingleInterview: PropTypes.func.isRequired,
questions: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.number.isRequired,
id: PropTypes.string.isRequired,
text: PropTypes.string.isRequired,
})).isRequired,
};

File diff suppressed because one or more lines are too long