diff --git a/src/components/Subject.js b/src/components/Subject.js deleted file mode 100644 index 8235b5e..0000000 --- a/src/components/Subject.js +++ /dev/null @@ -1,30 +0,0 @@ -import React, { PureComponent } from 'react' - -import Question from './Question.js' - -class Subject extends PureComponent { - render () { - const { subj } = this.props - - if (subj) { - return ( -
- {subj.Questions.map((question, i) => { - return ( - - ) - })} -
- ) - } else { - return ( -
- ) - } - } -} - -export default Subject diff --git a/src/constants.json b/src/constants.json index dd76684..afc85f3 100644 --- a/src/constants.json +++ b/src/constants.json @@ -1,4 +1,5 @@ { "apiUrl": "https://api.frylabs.net/", - "mobileWindowWidth": 700 + "mobileWindowWidth": 700, + "maxQuestionsToRender": 250 } diff --git a/src/pages/allQuestions.js b/src/pages/allQuestions.js index 59d7351..ad86b98 100644 --- a/src/pages/allQuestions.js +++ b/src/pages/allQuestions.js @@ -2,18 +2,16 @@ import React, { useState, useEffect } from 'react' import fetch from 'unfetch' import LoadingIndicator from '../components/LoadingIndicator.js' -import Subject from '../components/Subject.js' -import SubjectSelector from '../components/SubjectSelector.js' +import Questions from '../components/Questions.js' import constants from '../constants.json' export default function AllQuestions (props) { + console.log('AllQuestions module render') const [data, setData] = useState(null) - const [activeSubjName, setActiveSubjName] = useState('') const [searchTerm, setSearchTerm] = useState('') useEffect(() => { - console.info('Fetching data') fetch(`${constants.apiUrl}data.json`) .then((resp) => { return resp.json() @@ -24,10 +22,6 @@ export default function AllQuestions (props) { }, []) if (data) { - let currSubj = data.Subjects.find((subj) => { - return subj.Name === activeSubjName - }) - return (
@@ -39,16 +33,11 @@ export default function AllQuestions (props) { onChange={(e) => { setSearchTerm(e.target.value) }} />
- { setActiveSubjName(subjName) }} - />
-
diff --git a/src/pages/index.js b/src/pages/index.js index 390b739..6e9fae3 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -1,5 +1,4 @@ // TODO: css remove unnecesarry stuff -// TODO: aludni // TODO: fetch only once import React, { useState, useEffect } from 'react'