mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
Changed all questions search. Now searchers for questions instead of subjects
This commit is contained in:
parent
e67042e90a
commit
201c64504a
4 changed files with 7 additions and 48 deletions
|
@ -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 (
|
||||
<div>
|
||||
<div>
|
||||
|
@ -39,16 +33,11 @@ export default function AllQuestions (props) {
|
|||
onChange={(e) => { setSearchTerm(e.target.value) }}
|
||||
/>
|
||||
</div>
|
||||
<SubjectSelector
|
||||
data={data}
|
||||
activeSubjName={activeSubjName}
|
||||
searchTerm={searchTerm}
|
||||
onSubjSelect={(subjName) => { setActiveSubjName(subjName) }}
|
||||
/>
|
||||
<hr />
|
||||
<div>
|
||||
<Subject
|
||||
subj={currSubj}
|
||||
<Questions
|
||||
data={data}
|
||||
searchTerm={searchTerm}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue