New JSON structure transform
This commit is contained in:
parent
122ef68de9
commit
adde5e0a0e
|
@ -7,7 +7,7 @@ import TopicsList from '../topicsList';
|
||||||
import ProjectsList from '../projectsList';
|
import ProjectsList from '../projectsList';
|
||||||
import SearchBar from '../searchBar';
|
import SearchBar from '../searchBar';
|
||||||
import SearchResults from '../searchResults';
|
import SearchResults from '../searchResults';
|
||||||
import { InterviewsData, Questions } from '../../data/archives/interviews';
|
import { InterviewData, Questions } from '../../data/archives/interviews';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
class BrowseArchives extends React.Component {
|
class BrowseArchives extends React.Component {
|
||||||
|
@ -22,7 +22,7 @@ class BrowseArchives extends React.Component {
|
||||||
isInterviewsListModalOpen: false,
|
isInterviewsListModalOpen: false,
|
||||||
activeSingleInterviewId: 1,
|
activeSingleInterviewId: 1,
|
||||||
isSearchActive: false,
|
isSearchActive: false,
|
||||||
interviewData: this.transformInterviews(InterviewsData),
|
interviewData: this.transformInterviews(InterviewData),
|
||||||
matchedCount: 0,
|
matchedCount: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -118,21 +118,21 @@ class BrowseArchives extends React.Component {
|
||||||
|
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
const interview = interviews[i];
|
const interview = interviews[i];
|
||||||
const qKeys = Object.keys(interview);
|
const qKeys = Object.keys(interview); // name, who_what->question
|
||||||
const interviewFormatted = [];
|
const interviewFormatted = [];
|
||||||
|
|
||||||
qKeys.forEach((key, index) => {
|
qKeys.forEach((key) => {
|
||||||
if (key !== 'Name' && interview[key] !== null) {
|
if (key !== 'name' && interview[key] !== null && interview[key].answer !== null && interview[key].answer !== '') {
|
||||||
interviewFormatted.push({
|
interviewFormatted.push({
|
||||||
question: index,
|
question: key,
|
||||||
answer: interview[key],
|
answer: interview[key].answer,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
betterInterviews.push({
|
betterInterviews.push({
|
||||||
id: i + 1,
|
id: i + 1,
|
||||||
name: interview.Name,
|
name: interview.name,
|
||||||
matchedIndex: -1,
|
matchedIndex: -1,
|
||||||
interview: interviewFormatted,
|
interview: interviewFormatted,
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,7 +36,7 @@ SingleInterview.propTypes = {
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
toggleSingleInterview: PropTypes.func.isRequired,
|
toggleSingleInterview: PropTypes.func.isRequired,
|
||||||
questions: PropTypes.arrayOf(PropTypes.shape({
|
questions: PropTypes.arrayOf(PropTypes.shape({
|
||||||
id: PropTypes.number.isRequired,
|
id: PropTypes.string.isRequired,
|
||||||
text: PropTypes.string.isRequired,
|
text: PropTypes.string.isRequired,
|
||||||
})).isRequired,
|
})).isRequired,
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue