Admin.js 2.08 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
a    
Jiwon Yoon committed
19
        setresult(<AdminQuiz QuizNum={e.target.id} />)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
            <div className="container-fluid">
                <div className="row justify-content-md-center mt-5 ">
                    <div className="col-2 text-center border">
                        <div className="my-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
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
A    
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