mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
Handling multiple data files in subjectBrowser and allQuestions
This commit is contained in:
parent
4a7ad2d6c8
commit
309436b227
4 changed files with 85 additions and 47 deletions
|
@ -1,35 +1,26 @@
|
|||
import React, { useState, useEffect } from 'react'
|
||||
import Link from 'next/link'
|
||||
import fetch from 'unfetch'
|
||||
|
||||
import LoadingIndicator from '../components/LoadingIndicator.js'
|
||||
import QuestionSearchResult from '../components/QuestionSearchResult.js'
|
||||
|
||||
import styles from './allQuestions.module.css'
|
||||
import constants from '../constants.json'
|
||||
|
||||
export default function AllQuestions({ router }) {
|
||||
export default function AllQuestions({ router, getData }) {
|
||||
const [data, setData] = useState(null)
|
||||
const [searchTerm, setSearchTerm] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
fetch(`${constants.apiUrl}data.json`, {
|
||||
credentials: 'include',
|
||||
})
|
||||
.then((resp) => {
|
||||
return resp.json()
|
||||
})
|
||||
.then((data) => {
|
||||
setData(data)
|
||||
getData().then((result) => {
|
||||
setData(result)
|
||||
|
||||
router.replace(`${router.asPath.replace('.html', '')}`, undefined, {
|
||||
shallow: true,
|
||||
})
|
||||
const querySearch = router.query.question
|
||||
? decodeURIComponent(router.query.question)
|
||||
: ''
|
||||
setSearchTerm(querySearch)
|
||||
router.replace(`${router.asPath.replace('.html', '')}`, undefined, {
|
||||
shallow: true,
|
||||
})
|
||||
const querySearch = router.query.question
|
||||
? decodeURIComponent(router.query.question)
|
||||
: ''
|
||||
setSearchTerm(querySearch)
|
||||
})
|
||||
}, [])
|
||||
|
||||
if (data) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue