Removed .Subjects to work with new data structure

This commit is contained in:
MrFry 2020-10-21 16:29:14 +02:00
parent 7ac65348e4
commit d523d50fa1
4 changed files with 15 additions and 9 deletions

View file

@ -17,7 +17,7 @@ class QuestionSearchResult extends PureComponent {
}
if (searchTerm) {
subjs = data.Subjects.reduce((acc, subj) => {
subjs = data.reduce((acc, subj) => {
const resultQuestions = subj.Questions.reduce((qacc, question) => {
const keys = [ 'Q', 'A', 'data' ]
keys.some((key) => {
@ -41,14 +41,14 @@ class QuestionSearchResult extends PureComponent {
}, [])
results = subjs.reduce(countReducer, 0)
} else {
results = data.Subjects.reduce(countReducer, 0)
results = data.reduce(countReducer, 0)
}
const renderCount = () => {
return (
<div>
<div>
{searchTerm ? '' : 'Kezdj el írni kereséshez!'} {results} {searchTerm ? 'találat' : 'kérdés' } {searchTerm ? subjs.length : data.Subjects.length} tárgy
{searchTerm ? '' : 'Kezdj el írni kereséshez!'} {results} {searchTerm ? 'találat' : 'kérdés' } {searchTerm ? subjs.length : data.length} tárgy
</div>
<Sleep />
</div>