compare.js 2.13 KB
Newer Older
baesangjune's avatar
.    
baesangjune committed
1
2
3
import React, { useState } from 'react';
import AdminQuiz from './AdminQuiz'
import AdminSetting from './AdminSetting'
baesangjune's avatar
admin    
baesangjune committed
4

baesangjune's avatar
.    
baesangjune committed
5
let QuizBtn=[]
baesangjune's avatar
choose    
baesangjune committed
6

baesangjune's avatar
.    
baesangjune committed
7
function Admin() {
baesangjune's avatar
choose    
baesangjune committed
8

baesangjune's avatar
.    
baesangjune committed
9
10
    const [result, setresult] = useState('')
    const [QuizBtnCount, setQuizBtnCount] = useState(4)
baesangjune's avatar
admin    
baesangjune committed
11

baesangjune's avatar
.    
baesangjune committed
12
13
    function handleClickSetting() {
        setresult(<AdminSetting />)
baesangjune's avatar
admin    
baesangjune committed
14
15
    }

baesangjune's avatar
.    
baesangjune committed
16
17
    function handleClickQuiz(e) {
        setresult(<AdminQuiz QuizNum={e.target.id} data={JSON.parse(localStorage.getItem('QnA'))} />)
baesangjune's avatar
admin    
baesangjune committed
18
19
    }

baesangjune's avatar
.    
baesangjune committed
20
21
22
23
24
    function handleClickAddQuiz() {
        QuizBtn.push(
            <button type='button' className='btn btn-outline-primary' id={QuizBtnCount} onClick={handleClickQuiz}>Quiz {QuizBtnCount}</button>
        )
        setQuizBtnCount(QuizBtnCount + 1)
baesangjune's avatar
choose    
baesangjune committed
25
    }
baesangjune's avatar
admin    
baesangjune committed
26

baesangjune's avatar
choose    
baesangjune committed
27
    return (
baesangjune's avatar
.    
baesangjune committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
        <>
            <div className="container-fluid">
                <div className="row justify-content-md-center mt-5">
                    <div className="col-2 text-center border py-5">
                        <div className="mb-5">
                            <h4>관리자페이지</h4>
                        </div>
                        <div>
                            <button type="button" className="btn btn-outline-info mb-5" onClick={handleClickSetting}>Setting</button>
                        </div>
                        <div class="btn-group-vertical">
                            <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
admin    
baesangjune committed
45
46
                        </div>
                    </div>
baesangjune's avatar
choose    
baesangjune committed
47

baesangjune's avatar
.    
baesangjune committed
48
49
50
                    <div className="col-8 ">
                        {result}
                    </div>
baesangjune's avatar
admin    
baesangjune committed
51
52
                </div>
            </div>
baesangjune's avatar
.    
baesangjune committed
53
54
55


        </>
baesangjune's avatar
admin    
baesangjune committed
56
57
58
    )
}

baesangjune's avatar
.    
baesangjune committed
59
export default Admin