Admin.js 7.99 KB
Newer Older
baesangjune's avatar
baesangjune committed
1
import React, { useState } from 'react';
Jiwon Yoon's avatar
d    
Jiwon Yoon committed
2
import Quiz from './Quiz';
baesangjune's avatar
baesangjune committed
3
4
// import { Link } from 'react-router-dom';

Jiwon Yoon's avatar
h    
Jiwon Yoon committed
5
6

let list = []
Jiwon Yoon's avatar
d    
Jiwon Yoon committed
7
let QuizBtn = []
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
8

baesangjune's avatar
baesangjune committed
9
function Admin() {
baesangjune's avatar
baesangjune committed
10
11
12
13
14
15
16


    // let QnAadmin = []
    // let Q = []
    // let choose = []
    // let N = []

baesangjune's avatar
admin    
baesangjune committed
17

baesangjune's avatar
baesangjune committed
18
19
20
    const [question, setQuestion] = useState('')
    const [choose, setChoose] = useState('')
    const [answer, setAnswer] = useState('')
baesangjune's avatar
baesangjune committed
21
22
23
    const [password, setPassword] = useState('')
    const [adminpassword, setAdminPassword] = useState('')
    const [time, setTime] = useState('')
baesangjune's avatar
admin    
baesangjune committed
24
    const [addQuiz, setaddQuiz] = useState('')
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
25
    const [selectOption, setselectOption] = useState(1)
Jiwon Yoon's avatar
d    
Jiwon Yoon committed
26
    const [QuizBtnCount, setQuizBtnCount] = useState(4)
baesangjune's avatar
baesangjune committed
27

baesangjune's avatar
baesangjune committed
28
29


Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
30
    const handleChangeQuestion = (event) => {
baesangjune's avatar
baesangjune committed
31
32
        setQuestion(event.target.value)
    }
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
33
    const handleChangeChoose = (event) => {
baesangjune's avatar
baesangjune committed
34
35
36
37
38
        setChoose(event.target.value)
    }
    const handleChangeanswer = (event) => {
        setAnswer(event.target.value)
    }
baesangjune's avatar
baesangjune committed
39
40
41
42
43
44
45
46
47
48
    const handleChangePassword = (event) => {
        setPassword(event.target.value)
    }
    const handleChangeAdminPassword = (event) => {
        setAdminPassword(event.target.value)
    }
    const handleChangeTime = (event) => {
        setTime(event.target.value)
    }

Jiwon Yoon's avatar
d    
Jiwon Yoon committed
49
50
51
    function handleClickSetting(){
        
    }
baesangjune's avatar
baesangjune committed
52
53
54
55
56
57

    function handleClick() {

        alert('입력이 완료되었습니다')
        localStorage.setItem('Q', question)
        localStorage.setItem('Choose', choose)
Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
58
        localStorage.setItem('Answer', answer)
baesangjune's avatar
baesangjune committed
59
60
61
62
        localStorage.setItem('P', password)
        localStorage.setItem('AP', adminpassword)
        localStorage.setItem('T', time * 1000)

Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
63
    }
baesangjune's avatar
baesangjune committed
64
65


Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
66
    function addSelectOption() {
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
67
68
        list.push(
            <div className="input-group">
baesangjune's avatar
admin    
baesangjune committed
69
70
                <div className="input-group-prepend">
                    <div className="input-group-text">
Jiwon Yoon's avatar
d    
Jiwon Yoon committed
71
                        <input type="radio" id={selectOption + 1} name="answer" />
baesangjune's avatar
admin    
baesangjune committed
72
73
                    </div>
                </div>
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
74
                <input type="text" class="form-control" placeholder="보기를 입력하세요" onChange={handleChangeChoose} />
Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
75
            </div>
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
76
77
        )
        setselectOption(selectOption + 1)
baesangjune's avatar
baesangjune committed
78
    }
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
79

baesangjune's avatar
baesangjune committed
80
    function handleClickQuiz() {
baesangjune's avatar
admin    
baesangjune committed
81
        let addQuiz = function () {
baesangjune's avatar
.    
baesangjune committed
82
            return <a className="nav-link" id="Quiz4-tab" data-toggle="pill" href="#Quiz4" role="tab" >Quiz4</a>
baesangjune's avatar
baesangjune committed
83
84
85
        }
        setaddQuiz(addQuiz)
    }
baesangjune's avatar
baesangjune committed
86

Jiwon Yoon's avatar
d    
Jiwon Yoon committed
87
88
89
90
91
92
93
    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
baesangjune committed
94
95
    return (
        <>
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
96
97
98
            <div className="container-fluid">
                <div className="row justify-content-md-center mt-5 ">
                    <div className="col-2 text-center border">
Jiwon Yoon's avatar
d    
Jiwon Yoon committed
99
100
                        <div className="my-5">
                            <h4>관리자페이지</h4>
baesangjune's avatar
baesangjune committed
101
                        </div>
Jiwon Yoon's avatar
d    
Jiwon Yoon committed
102
103
                        <div>
                            <button type="button" className="btn btn-outline-info mb-5" onClick={handleClickSetting}>Setting</button>
baesangjune's avatar
baesangjune committed
104
                        </div>
Jiwon Yoon's avatar
d    
Jiwon Yoon committed
105
106
107
108
109
110
                        <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
111

Jiwon Yoon's avatar
d    
Jiwon Yoon committed
112
                        </div>
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
113
                    </div>
Jiwon Yoon's avatar
d    
Jiwon Yoon committed
114

Jiwon Yoon's avatar
h    
Jiwon Yoon committed
115
                    <div className="col-8">
Jiwon Yoon's avatar
d    
Jiwon Yoon committed
116

Jiwon Yoon's avatar
h    
Jiwon Yoon committed
117
118
                        <div className="tab-content" id="v-pills-tabContent">
                            <div className="tab-pane fade show active" id="setting" role="tabpanel" >
baesangjune's avatar
baesangjune committed
119
120
                                <div className="row d-flex justify-content-center">
                                    <div className="col-8">
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
121
122
123
124
                                        <h1 className="p-3 border">관리자 설정 변경 </h1>
                                        <div className="p-3 border">
                                            <h2>변경할 비밀번호를 입력하세요</h2>
                                            <input type="text" onChange={handleChangePassword} placeholder="New Password" />
baesangjune's avatar
baesangjune committed
125

Jiwon Yoon's avatar
h    
Jiwon Yoon committed
126
127
128
129
                                        </div>
                                        <div className="p-3 border">
                                            <h2>변경할 관리자 비밀번호를 입력하세요</h2>
                                            <input type="text" onChange={handleChangeAdminPassword} placeholder="New Admin Password" />
baesangjune's avatar
admin    
baesangjune committed
130

Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
131
                                        </div>
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
132
133
134
                                        <div className="p-3 border">
                                            <h2>타이머를 설정하세요(초단위)</h2>
                                            <input type="text" onChange={handleChangeTime} placeholder="Set Time" />
Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
135

136
                                        </div>
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
137
138
139
                                        <label for="inputLogin" className="d-flex justify-content-center">
                                            <button className="mt-4 btn btn-dark" onClick={handleClick}>작성완료</button>
                                        </label>
140
141
                                    </div>
                                </div>
baesangjune's avatar
baesangjune committed
142
                            </div>
baesangjune's avatar
baesangjune committed
143

baesangjune's avatar
baesangjune committed
144

Jiwon Yoon's avatar
h    
Jiwon Yoon committed
145
                            <div className="" id="Quiz1">
Jiwon Yoon's avatar
d    
Jiwon Yoon committed
146
147
148
149
150
151
152
153
154
155
156
                                <h2 className="p-3 border text-center">문제만들기</h2>
                                <div className="p-3 borber">
                                    <div className="p-3 ">
                                        <span className="font-weight-bold mr-2 h3">1.</span>
                                        <input type="text" className="form-control" onChange={handleChangeQuestion} placeholder="문제를 입력하세요" />
                                    </div>
                                    <div className="p-3 ">
                                        <div className="input-group">
                                            <div className="input-group-prepend">
                                                <div className="input-group-text">
                                                    <input type="radio" id={selectOption} name="answer" />
Jiwon Yoon's avatar
l    
Jiwon Yoon committed
157
158
                                                </div>
                                            </div>
Jiwon Yoon's avatar
d    
Jiwon Yoon committed
159
                                            <input type="text" className="form-control" placeholder="보기를 입력하세요" onChange={handleChangeChoose} />
Jiwon Yoon's avatar
l    
Jiwon Yoon committed
160
                                        </div>
Jiwon Yoon's avatar
d    
Jiwon Yoon committed
161
162
163
                                        {list.map((element) => element)}
                                        <button className="btn btn-outline-secondary btn-sm" onClick={addSelectOption}>+</button>
                                    </div>
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
164

Jiwon Yoon's avatar
d    
Jiwon Yoon committed
165
166
167
                                    <div className="p-3 ">
                                        <span className="font-weight-bold mr-2 h3">정답:</span>
                                        <input type="text" onChange={handleChangeanswer} placeholder="정답을 입력하세요" />
Jiwon Yoon's avatar
l    
Jiwon Yoon committed
168
                                    </div>
Jiwon Yoon's avatar
d    
Jiwon Yoon committed
169
170
171
172

                                    <label for="inputLogin" className="d-flex justify-content-center">
                                        <button className="mt-4 btn btn-dark" onClick={handleClick}>작성완료</button>
                                    </label>
baesangjune's avatar
baesangjune committed
173
174
                                </div>
                            </div>
baesangjune's avatar
baesangjune committed
175
                        </div>
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
176
177
178
179
                    </div>
                </div>
            </div>

baesangjune's avatar
admin    
baesangjune committed
180

baesangjune's avatar
baesangjune committed
181
182
183
184
185
        </>
    )
}

export default Admin