Admin.js 2.21 KB
Newer Older
baesangjune's avatar
baesangjune committed
1
import React, { useState } from 'react';
Jiwon Yoon's avatar
a    
Jiwon Yoon committed
2
import AdminQuiz from './AdminQuiz'
Jiwon Yoon's avatar
Jiwon Yoon committed
3
import AdminSetting from './AdminSetting'
baesangjune's avatar
baesangjune committed
4

Jiwon Yoon's avatar
h    
Jiwon Yoon committed
5

Jiwon Yoon's avatar
A    
Jiwon Yoon committed
6
let QuizBtn = []
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
7

baesangjune's avatar
baesangjune committed
8
function Admin() {
baesangjune's avatar
baesangjune committed
9

Jiwon Yoon's avatar
A    
Jiwon Yoon committed
10
11
    const [result, setresult] = useState('')
    const [QuizBtnCount, setQuizBtnCount] = useState(4)
baesangjune's avatar
baesangjune committed
12

Jiwon Yoon's avatar
A    
Jiwon Yoon committed
13
14
15

    function handleClickSetting() {
        setresult(<AdminSetting />)
baesangjune's avatar
baesangjune committed
16
    }
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
17

Jiwon Yoon's avatar
A    
Jiwon Yoon committed
18
    function handleClickQuiz(e) {
Jiwon Yoon's avatar
ha..    
Jiwon Yoon committed
19
        setresult(<AdminQuiz QuizNum={e.target.id} data={JSON.parse(localStorage.getItem('QnA'))} />)
baesangjune's avatar
baesangjune committed
20
    }
Jiwon Yoon's avatar
A    
Jiwon Yoon committed
21
22
23

    function handleClickAddQuiz() {
        QuizBtn.push(
Jiwon Yoon's avatar
a    
Jiwon Yoon committed
24
            <button type='button' className='btn btn-outline-primary' id={QuizBtnCount} onClick={handleClickQuiz}>Quiz {QuizBtnCount}</button>
Jiwon Yoon's avatar
d    
Jiwon Yoon committed
25
        )
Jiwon Yoon's avatar
A    
Jiwon Yoon committed
26
        setQuizBtnCount(QuizBtnCount + 1)
Jiwon Yoon's avatar
d    
Jiwon Yoon committed
27
28
    }

baesangjune's avatar
baesangjune committed
29
30
    return (
        <>
Jiwon Yoon's avatar
A    
Jiwon Yoon committed
31
            <div className="container-fluid">
Jiwon Yoon's avatar
ha..    
Jiwon Yoon committed
32
                <div className="row justify-content-md-center mt-5">
Jiwon Yoon's avatar
ㅠㅠ    
Jiwon Yoon committed
33
34
35
                    <div className="col-2 text-center border py-5 bg-white">
                        <div className="py-3 border-top border-bottom">
                            <h5 className="font-weight-bold">ADMIN</h5>
Jiwon Yoon's avatar
A    
Jiwon Yoon committed
36
                        </div>
Jiwon Yoon's avatar
ㅠㅠ    
Jiwon Yoon committed
37
38
                        <div className="border-bottom py-4">
                            <button type="button" className="btn btn-info" onClick={handleClickSetting}>Setting</button>
Jiwon Yoon's avatar
A    
Jiwon Yoon committed
39
                        </div>
Jiwon Yoon's avatar
ㅠㅠ    
Jiwon Yoon committed
40
                        <div className="btn-group-vertical py-4">
Jiwon Yoon's avatar
A    
Jiwon Yoon committed
41
42
43
44
45
                            <button type="button" className="btn btn-outline-primary" id="1" onClick={handleClickQuiz}>Quiz 1</button>
                            <button type="button" className="btn btn-outline-primary" id="2" onClick={handleClickQuiz}>Quiz 2</button>
                            <button type="button" className="btn btn-outline-primary" id="3" onClick={handleClickQuiz}>Quiz 3</button>
                            {QuizBtn.map((element) => element)}
                            <button type="button" className="btn btn-outline-primary" onClick={handleClickAddQuiz}>+</button>
baesangjune's avatar
baesangjune committed
46

Jiwon Yoon's avatar
A    
Jiwon Yoon committed
47
                        </div>
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
48
                    </div>
Jiwon Yoon's avatar
d    
Jiwon Yoon committed
49

Jiwon Yoon's avatar
ha..    
Jiwon Yoon committed
50
                    <div className="col-8 ">
Jiwon Yoon's avatar
a    
Jiwon Yoon committed
51
                        {result}
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
52
53
54
55
                    </div>
                </div>
            </div>

baesangjune's avatar
admin    
baesangjune committed
56

Jiwon Yoon's avatar
A    
Jiwon Yoon committed
57
        </>
baesangjune's avatar
baesangjune committed
58
59
60
61
    )
}

export default Admin