-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
30 lines (26 loc) · 841 Bytes
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import React, { useState } from 'react'
import { useQuery } from 'react-query'
import QuizBox from './Module/QuizBox/QuizBox'
import StartBox from './Module/StartBox/StartBox'
import { getAllQuiz } from './requests'
import './index.scss'
export default function App() {
const [runningQuiz, setRunningQuiz] = useState()
const { isLoading, error, data: quizzes } = useQuery('repoData', () => getAllQuiz())
if (isLoading)
return (
<div className="error">
<div className="loader"></div>
</div>
)
if (error) return <div className="error">An error has occurred: {error.message}</div>
return (
<>
{runningQuiz ? (
<QuizBox quiz={runningQuiz} restart={() => setRunningQuiz(null)} />
) : (
<StartBox quizzes={quizzes} setRunningQuiz={setRunningQuiz} />
)}
</>
)
}