mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
Snow rendering changes, allquestions page fixes and improvements
This commit is contained in:
parent
d15e79e6ac
commit
5a1bd258bc
3 changed files with 34 additions and 28 deletions
|
@ -11,6 +11,10 @@ import styles from './allQuestions.module.css'
|
|||
|
||||
import constants from '../constants.json'
|
||||
|
||||
const countReducer = (acc, subj) => {
|
||||
return acc + subj.Questions.length
|
||||
}
|
||||
|
||||
function mergeData(data) {
|
||||
return data.reduce((acc, db) => {
|
||||
return [
|
||||
|
@ -60,7 +64,6 @@ function fetchDbs() {
|
|||
return resp.json()
|
||||
})
|
||||
.then((data) => {
|
||||
console.log(data)
|
||||
resolve(data)
|
||||
})
|
||||
})
|
||||
|
@ -72,6 +75,8 @@ export default function AllQuestions({ router }) {
|
|||
const [dbs, setDbs] = useState(null)
|
||||
const [searchTerm, setSearchTerm] = useState('')
|
||||
const [activeSubjName, setActiveSubjName] = useState('')
|
||||
const subjectCount = data ? data.length : 0
|
||||
const questionCount = data ? data.reduce(countReducer, 0) : 0
|
||||
|
||||
useEffect(() => {
|
||||
router.replace(`${router.asPath.replace('.html', '')}`, undefined, {
|
||||
|
@ -97,9 +102,7 @@ export default function AllQuestions({ router }) {
|
|||
defaultValue={-1}
|
||||
onChange={(event) => {
|
||||
const key = event.target.value
|
||||
if (key === 'none') {
|
||||
console.log(key)
|
||||
} else if (key === 'all') {
|
||||
if (key === 'all') {
|
||||
fetchAllData(dbs).then((res) => {
|
||||
setData(mergeData(res))
|
||||
console.log(res)
|
||||
|
@ -182,9 +185,7 @@ export default function AllQuestions({ router }) {
|
|||
<Subject subj={currSubj} />
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<LoadingIndicator />
|
||||
)}
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
@ -236,6 +237,7 @@ export default function AllQuestions({ router }) {
|
|||
return (
|
||||
<div>
|
||||
{dbs && renderDbSelector()}
|
||||
{data && `${questionCount} kérdés, ${subjectCount} tárgy`}
|
||||
<div className={styles.typeSelector}>
|
||||
<div
|
||||
className={!asd ? styles.activeTypeSelector : ''}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue