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
|
@ -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 (
|
|
||||||
<div >
|
|
||||||
{subj.Questions.map((question, i) => {
|
|
||||||
return (
|
|
||||||
<Question
|
|
||||||
key={i}
|
|
||||||
question={question}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<div />
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Subject
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
"apiUrl": "https://api.frylabs.net/",
|
"apiUrl": "https://api.frylabs.net/",
|
||||||
"mobileWindowWidth": 700
|
"mobileWindowWidth": 700,
|
||||||
|
"maxQuestionsToRender": 250
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,18 +2,16 @@ import React, { useState, useEffect } from 'react'
|
||||||
import fetch from 'unfetch'
|
import fetch from 'unfetch'
|
||||||
|
|
||||||
import LoadingIndicator from '../components/LoadingIndicator.js'
|
import LoadingIndicator from '../components/LoadingIndicator.js'
|
||||||
import Subject from '../components/Subject.js'
|
import Questions from '../components/Questions.js'
|
||||||
import SubjectSelector from '../components/SubjectSelector.js'
|
|
||||||
|
|
||||||
import constants from '../constants.json'
|
import constants from '../constants.json'
|
||||||
|
|
||||||
export default function AllQuestions (props) {
|
export default function AllQuestions (props) {
|
||||||
|
console.log('AllQuestions module render')
|
||||||
const [data, setData] = useState(null)
|
const [data, setData] = useState(null)
|
||||||
const [activeSubjName, setActiveSubjName] = useState('')
|
|
||||||
const [searchTerm, setSearchTerm] = useState('')
|
const [searchTerm, setSearchTerm] = useState('')
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.info('Fetching data')
|
|
||||||
fetch(`${constants.apiUrl}data.json`)
|
fetch(`${constants.apiUrl}data.json`)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
return resp.json()
|
return resp.json()
|
||||||
|
@ -24,10 +22,6 @@ export default function AllQuestions (props) {
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
let currSubj = data.Subjects.find((subj) => {
|
|
||||||
return subj.Name === activeSubjName
|
|
||||||
})
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
|
@ -39,16 +33,11 @@ export default function AllQuestions (props) {
|
||||||
onChange={(e) => { setSearchTerm(e.target.value) }}
|
onChange={(e) => { setSearchTerm(e.target.value) }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<SubjectSelector
|
|
||||||
data={data}
|
|
||||||
activeSubjName={activeSubjName}
|
|
||||||
searchTerm={searchTerm}
|
|
||||||
onSubjSelect={(subjName) => { setActiveSubjName(subjName) }}
|
|
||||||
/>
|
|
||||||
<hr />
|
<hr />
|
||||||
<div>
|
<div>
|
||||||
<Subject
|
<Questions
|
||||||
subj={currSubj}
|
data={data}
|
||||||
|
searchTerm={searchTerm}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// TODO: css remove unnecesarry stuff
|
// TODO: css remove unnecesarry stuff
|
||||||
// TODO: aludni
|
|
||||||
// TODO: fetch only once
|
// TODO: fetch only once
|
||||||
|
|
||||||
import React, { useState, useEffect } from 'react'
|
import React, { useState, useEffect } from 'react'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue