Admin.js 15.8 KB
Newer Older
baesangjune's avatar
baesangjune committed
1
import React, { useState } from 'react';
baesangjune's avatar
baesangjune committed
2

baesangjune's avatar
baesangjune committed
3
4
5
// import { Link } from 'react-router-dom';

function Admin() {
baesangjune's avatar
baesangjune committed
6
7
8
9
10
11
12


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

baesangjune's avatar
admin    
baesangjune committed
13

baesangjune's avatar
baesangjune committed
14
15
16
    const [question, setQuestion] = useState('')
    const [choose, setChoose] = useState('')
    const [answer, setAnswer] = useState('')
baesangjune's avatar
baesangjune committed
17
18
19
    const [password, setPassword] = useState('')
    const [adminpassword, setAdminPassword] = useState('')
    const [time, setTime] = useState('')
baesangjune's avatar
admin    
baesangjune committed
20
21
    const [addQuiz, setaddQuiz] = useState('')
    const [selectOption, setselectOption] = useState('')
baesangjune's avatar
baesangjune committed
22

baesangjune's avatar
baesangjune committed
23
24
25
    const [done, setDone] = useState(false)


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

baesangjune's avatar
baesangjune committed
45
46
47
48
49
50

    function handleClick() {

        alert('입력이 완료되었습니다')
        localStorage.setItem('Q', question)
        localStorage.setItem('Choose', choose)
Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
51
        localStorage.setItem('Answer', answer)
baesangjune's avatar
baesangjune committed
52
53
54
55
        localStorage.setItem('P', password)
        localStorage.setItem('AP', adminpassword)
        localStorage.setItem('T', time * 1000)

baesangjune's avatar
baesangjune committed
56
        setDone(true)
Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
57
    }
baesangjune's avatar
baesangjune committed
58
59


Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
60
    function addSelectOption() {
61
        let list = function () {
Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
62
            return <div className="input-group">
63
64
65
66
                <div className="input-group-prepend">
                    <div className="input-group-text">
                        <input type="radio" id="option" />
                    </div>
Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
67
                </div>
68
                <input type="text" class="form-control" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
69
            </div>
70
71
        }
        setselectOption(list)
baesangjune's avatar
admin    
baesangjune committed
72
73
74
75
76
77
78
79
80
    }
    function addSelectOption() {
        let list = function () {
            return <div className="input-group">
                <div className="input-group-prepend">
                    <div className="input-group-text">
                        <input type="radio" id="option" />
                    </div>
                </div>
baesangjune's avatar
css    
baesangjune committed
81
                <input type="text" className="form-control" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
82
83
84
            </div>
        }
        setselectOption(list)
baesangjune's avatar
baesangjune committed
85
    }
baesangjune's avatar
baesangjune committed
86
    function handleClickQuiz() {
baesangjune's avatar
admin    
baesangjune committed
87
        let addQuiz = function () {
baesangjune's avatar
.    
baesangjune committed
88
            return <a className="nav-link" id="Quiz4-tab" data-toggle="pill" href="#Quiz4" role="tab" >Quiz4</a>
baesangjune's avatar
baesangjune committed
89
90
91
        }
        setaddQuiz(addQuiz)
    }
baesangjune's avatar
baesangjune committed
92

baesangjune's avatar
baesangjune committed
93
94
    return (
        <>
baesangjune's avatar
baesangjune committed
95
            {done ? alert('모두 입력되었습니다.') : ''}
baesangjune's avatar
.    
baesangjune committed
96
            <div className="row justify-content-md-center mt-5 ">
baesangjune's avatar
css    
baesangjune committed
97
                <div className="col-2 text-center border">
baesangjune's avatar
baesangjune committed
98
                    <div className="container-fluid ">
baesangjune's avatar
css    
baesangjune committed
99
100
                        <div className="navbar-header p-3 ">
                            <p className="navbar-brand border-bottom ">관리자 페이지</p>
baesangjune's avatar
baesangjune committed
101
                        </div>
baesangjune's avatar
.    
baesangjune committed
102
                        <div className="nav flex-column nav-pills" id="v-pills-tab" role="tablist">
baesangjune's avatar
admin    
baesangjune committed
103

baesangjune's avatar
css    
baesangjune committed
104
                            <p className="navbar-text border-bottom">관리자 설정 변경하기</p>
baesangjune's avatar
admin    
baesangjune committed
105

baesangjune's avatar
.    
baesangjune committed
106
                            <a className="nav-link" id="setting-tab" data-toggle='pill' href="#setting" role="tab">Setting</a>
baesangjune's avatar
admin    
baesangjune committed
107
108


baesangjune's avatar
css    
baesangjune committed
109
                            <p className="navbar-text border-bottom">Quiz 입력하기</p>
baesangjune's avatar
admin    
baesangjune committed
110

baesangjune's avatar
.    
baesangjune committed
111
112
113
                            <a className="nav-link" id="Quiz1-tab" data-toggle="pill" href="#Quiz1" role="tab" >Quiz1</a>
                            <a className="nav-link" id="Quiz2-tab" data-toggle="pill" href="#Quiz2" role="tab" >Quiz2</a>
                            <a className="nav-link" id="Quiz3-tab" data-toggle="pill" href="#Quiz3" role="tab" >Quiz3</a>
baesangjune's avatar
admin    
baesangjune committed
114
                            {addQuiz}
baesangjune's avatar
css    
baesangjune committed
115
                            <button className="btn btn-danger navbar-btn" onClick={handleClickQuiz} >Quiz 추가</button>
baesangjune's avatar
admin    
baesangjune committed
116

baesangjune's avatar
baesangjune committed
117
118

                        </div>
baesangjune's avatar
baesangjune committed
119
120
                    </div>
                </div>
baesangjune's avatar
css    
baesangjune committed
121
                <div className="col-8">
baesangjune's avatar
baesangjune committed
122
                    <div className="tab-content" id="v-pills-tabContent">
baesangjune's avatar
css    
baesangjune committed
123
                        <div className="tab-pane fade show active" id="setting" role="tabpanel" >
baesangjune's avatar
baesangjune committed
124
125
126
127
                            <div>
                                <div className="container">
                                    <div className="row d-flex justify-content-center">
                                        <div className="col-8">
baesangjune's avatar
baesangjune committed
128

baesangjune's avatar
baesangjune committed
129
130
131
132
                                            <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
133

baesangjune's avatar
baesangjune committed
134
135
136
137
                                            </div>
                                            <div className="p-3 border">
                                                <h2>변경할 관리자 비밀번호를 입력하세요</h2>
                                                <input type="text" onChange={handleChangeAdminPassword} placeholder="New Admin Password" />
baesangjune's avatar
baesangjune committed
138

baesangjune's avatar
baesangjune committed
139
140
141
142
                                            </div>
                                            <div className="p-3 border">
                                                <h2>타이머를 설정하세요(초단위)</h2>
                                                <input type="text" onChange={handleChangeTime} placeholder="Set Time" />
baesangjune's avatar
baesangjune committed
143

baesangjune's avatar
baesangjune committed
144
145
146
147
148
149
150
151
152
153
                                            </div>


                                            <label for="inputLogin" className="d-flex justify-content-center">
                                                <button className="mt-4 btn btn-dark" onClick={handleClick}>작성완료</button>
                                            </label>

                                        </div>
                                    </div>
                                </div>
baesangjune's avatar
baesangjune committed
154

baesangjune's avatar
baesangjune committed
155
                            </div>
baesangjune's avatar
baesangjune committed
156

baesangjune's avatar
baesangjune committed
157
                        </div>
baesangjune's avatar
admin    
baesangjune committed
158

baesangjune's avatar
css    
baesangjune committed
159
                        <div className="tab-pane fade" id="Quiz1" role="tabpanel" >
baesangjune's avatar
baesangjune committed
160
161
162
163
164

                            <div className="container">
                                <div className="row d-flex justify-content-center">
                                    <div className="col-8">

baesangjune's avatar
admin    
baesangjune committed
165
                                        <h2 className="p-3 border text-center">문제만들기</h2>
baesangjune's avatar
baesangjune committed
166

baesangjune's avatar
admin    
baesangjune committed
167
168
169
170
171
                                        <div className="p-3 borber">
                                            <div className="p-3 ">
                                                <span className="font-weight-bold mr-2 h3">1.</span>
                                                {/* <input type="text" onChange={handleChangenumber} placeholder="Number" /> */}
                                                <input type="text" onChange={handleChangeQuestion} placeholder="문제를 입력하세요" />
baesangjune's avatar
baesangjune committed
172

baesangjune's avatar
admin    
baesangjune committed
173
                                            </div>
baesangjune's avatar
baesangjune committed
174

baesangjune's avatar
admin    
baesangjune committed
175
176
177
178
179
180
181
                                            <div className="p-3 ">
                                                <div className="input-group">
                                                    <div className="input-group-prepend">
                                                        <div className="input-group-text">
                                                            <input type="radio" id="option" />
                                                        </div>
                                                    </div>
baesangjune's avatar
css    
baesangjune committed
182
                                                    <input type="text" className="form-control" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
baesangjune's avatar
admin    
baesangjune committed
183
184
                                                </div>
                                                {selectOption}
baesangjune's avatar
baesangjune committed
185

baesangjune's avatar
admin    
baesangjune committed
186
187
188
                                                <button className="btn btn-outline-secondary btn-sm" onClick={addSelectOption}>+</button>

                                            </div>
baesangjune's avatar
baesangjune committed
189

baesangjune's avatar
admin    
baesangjune committed
190
191
192
193
                                            <div className="p-3 ">
                                                <span className="font-weight-bold mr-2 h3">정답:</span>
                                                <input type="text" onChange={handleChangeanswer} placeholder="정답을 입력하세요" />
                                            </div>
baesangjune's avatar
baesangjune committed
194

baesangjune's avatar
admin    
baesangjune committed
195
196
197
198
                                            <label for="inputLogin" className="d-flex justify-content-center">
                                                <button className="mt-4 btn btn-dark" onClick={handleClick}>작성완료</button>
                                            </label>

Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
199
200
201
202
                                        </div>
                                    </div>
                                </div>

203
204
205
206
207
208
209
210
211
212
213
214
215
216
                                <div className="p-3 ">
                                    <div className="input-group">
                                        <div className="input-group-prepend">
                                            <div className="input-group-text">
                                                <input type="radio" id="option" />
                                            </div>
                                        </div>
                                        <input type="text" class="form-control" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
                                    </div>
                                    {selectOption}

                                    <button className="btn btn-outline-secondary btn-sm" onClick={addSelectOption}>+</button>

                                </div>
baesangjune's avatar
baesangjune committed
217
                            </div>
baesangjune's avatar
baesangjune committed
218

219
                            <div className="tab-pane fade" id="Quiz2" role="tabpanel">
baesangjune's avatar
baesangjune committed
220

221
222
223
                                <div className="container">
                                    <div className="row d-flex justify-content-center">
                                        <div className="col-8">
baesangjune's avatar
baesangjune committed
224

225
                                            <h2 className="p-3 border text-center">문제만들기</h2>
baesangjune's avatar
baesangjune committed
226

227
228
229
230
231
                                            <div className="p-3 borber">
                                                <div className="p-3 ">
                                                    <span className="font-weight-bold mr-2 h3">1.</span>
                                                    {/* <input type="text" onChange={handleChangenumber} placeholder="Number" /> */}
                                                    <input type="text" onChange={handleChangeQuestion} placeholder="문제를 입력하세요" />
baesangjune's avatar
baesangjune committed
232

233
                                                </div>
baesangjune's avatar
baesangjune committed
234

235
236
237
238
239
240
                                                <div className="p-3 ">
                                                    <div className="input-group">
                                                        <div className="input-group-prepend">
                                                            <div className="input-group-text">
                                                                <input type="radio" id="option" />
                                                            </div>
baesangjune's avatar
admin    
baesangjune committed
241
                                                        </div>
242
                                                        <input type="text" class="form-control" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
baesangjune's avatar
admin    
baesangjune committed
243
                                                    </div>
baesangjune's avatar
css    
baesangjune committed
244
                                                    <input type="text" className="form-control" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
245
                                                </div>
baesangjune's avatar
admin    
baesangjune committed
246
                                                {selectOption}
baesangjune's avatar
baesangjune committed
247

baesangjune's avatar
admin    
baesangjune committed
248
249
250
251
252
253
254
                                                <button className="btn btn-outline-secondary btn-sm" onClick={addSelectOption}>+</button>

                                            </div>

                                            <div className="p-3 ">
                                                <span className="font-weight-bold mr-2 h3">정답:</span>
                                                <input type="text" onChange={handleChangeanswer} placeholder="정답을 입력하세요" />
255
                                            </div>
baesangjune's avatar
admin    
baesangjune committed
256
257
258
259
260
261

                                            <label for="inputLogin" className="d-flex justify-content-center">
                                                <button className="mt-4 btn btn-dark" onClick={handleClick}>작성완료</button>
                                            </label>

                                        </div>
baesangjune's avatar
baesangjune committed
262
263
                                    </div>
                                </div>
baesangjune's avatar
baesangjune committed
264
                            </div>
baesangjune's avatar
baesangjune committed
265
                        </div>
266
267
268
269
270
                    </div>
                    <div className="tab-pane fade" id="Quiz3" role="tabpanel">
                        <div className="container">
                            <div className="row d-flex justify-content-center">
                                <div className="col-8">
baesangjune's avatar
baesangjune committed
271

272
                                    <h2 className="p-3 border text-center">문제만들기</h2>
baesangjune's avatar
baesangjune committed
273

274
275
276
277
278
                                    <div className="p-3 borber">
                                        <div className="p-3 ">
                                            <span className="font-weight-bold mr-2 h3">1.</span>
                                            {/* <input type="text" onChange={handleChangenumber} placeholder="Number" /> */}
                                            <input type="text" onChange={handleChangeQuestion} placeholder="문제를 입력하세요" />
baesangjune's avatar
baesangjune committed
279

280
                                        </div>
baesangjune's avatar
baesangjune committed
281

282
283
284
285
286
                                        <div className="p-3 ">
                                            <div className="input-group">
                                                <div className="input-group-prepend">
                                                    <div className="input-group-text">
                                                        <input type="radio" id="option" />
baesangjune's avatar
admin    
baesangjune committed
287
                                                    </div>
288
                                                </div>
289
                                                <input type="text" class="form-control" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
baesangjune's avatar
admin    
baesangjune committed
290
                                            </div>
291
292
293
                                            <input type="text" className="form-control" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
                                        </div>
                                        {selectOption}
baesangjune's avatar
baesangjune committed
294

295
                                        <button className="btn btn-outline-secondary btn-sm" onClick={addSelectOption}>+</button>
baesangjune's avatar
baesangjune committed
296

297
                                    </div>
baesangjune's avatar
admin    
baesangjune committed
298

299
300
301
                                    <div className="p-3 ">
                                        <span className="font-weight-bold mr-2 h3">정답:</span>
                                        <input type="text" onChange={handleChangeanswer} placeholder="정답을 입력하세요" />
baesangjune's avatar
baesangjune committed
302
                                    </div>
303
304
305
306
307

                                    <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
308
309
                                </div>
                            </div>
baesangjune's avatar
baesangjune committed
310
311
312
313
                        </div>
                    </div>
                </div>
            </div>
baesangjune's avatar
admin    
baesangjune committed
314

baesangjune's avatar
baesangjune committed
315
316
317
318
319
        </>
    )
}

export default Admin