import React from 'react' import { hashToCollection } from '../../libs/hashToCollection' import { LinkListItem } from './linkListItem' class QuestionListByConcept extends React.Component { constructor(props) { super(props) this.renderQuestionLinks = this.renderQuestionLinks.bind(this) this.mapConceptsToList = this.mapConceptsToList.bind(this) } renderLabel(concept) { return (

{concept.name}

); } renderQuestionLinks(questions) { let filtered; if (!this.props.showOnlyArchived) { filtered = questions.filter((question) => question.flag !== "archived" ) } else { filtered = questions.filter((question) => question.flag === "archived" ) } return filtered.map((question) => { if (question.prompt) { const formattedPrompt = question.prompt.replace(/(<([^>]+)>)/ig, "").replace(/ /ig, "") return ( ); } }); } renderConceptWithQuestions(questions, label) { if (questions.length === 0) { return; } const listItems = this.renderQuestionLinks(questions); return [ label, () ]; } mapConceptsToList() { const concepts = hashToCollection(this.props.concepts.data['0']); const questions = hashToCollection(this.props.questions); return concepts.map((concept) => { const label = this.renderLabel(concept); const questionsForConcept = questions.filter(q => q.conceptID === concept.uid) return this.renderConceptWithQuestions(questionsForConcept, label); }) } render() { return ( ); } } export { QuestionListByConcept }