Admin.js 16.2 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
81
    }
    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>
                <input type="text" class="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
88
        let addQuiz = function () {
            return <a className="nav-link" id="v-pills-settings-tab" data-toggle="pill" href="#Quiz4" role="tab" aria-controls="v-pills-settings" aria-selected="false">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
97
98
99
            <div className="row">
                <div className="col-3">
                    <div className="container-fluid ">
                        <div className="navbar-header p-3">
baesangjune's avatar
admin    
baesangjune committed
100
                            <p className="navbar-brand">관리자 페이지</p>
baesangjune's avatar
baesangjune committed
101
102
                        </div>
                        <div className="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
baesangjune's avatar
admin    
baesangjune committed
103
104
105
106
107
108
109
110
111
112
113
114
115
116

                            <p className="navbar-text">관리자 설정 변경하기</p>

                            <a className="nav-link" id="setting-tab" data-toggle='pill' href="#setting" role="tab" aria-controls="v-pills-home" aria-selected="false">Setting</a>


                            <p className="navbar-text">Quiz 입력하기</p>

                            <a className="nav-link" id="Quiz1-tab" data-toggle="pill" href="#Quiz1" role="tab" aria-controls="v-pills-profile" aria-selected="false">Quiz1</a>
                            <a className="nav-link" id="Quiz2-tab" data-toggle="pill" href="#Quiz2" role="tab" aria-controls="v-pills-messages" aria-selected="false">Quiz2</a>
                            <a className="nav-link" id="Quiz3-tab" data-toggle="pill" href="#Quiz3" role="tab" aria-controls="v-pills-settings" aria-selected="false">Quiz3</a>
                            {addQuiz}
                            <button class="btn btn-danger navbar-btn" onClick={handleClickQuiz} >Quiz 추가</button>

baesangjune's avatar
baesangjune committed
117
118

                        </div>
baesangjune's avatar
baesangjune committed
119
120
                    </div>
                </div>
baesangjune's avatar
baesangjune committed
121
122
                <div className="col-9">
                    <div className="tab-content" id="v-pills-tabContent">
baesangjune's avatar
admin    
baesangjune committed
123
                        <div className="tab-pane fade show active" id="setting" role="tabpanel" aria-labelledby="v-pills-home-tab">
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
159

                        <div className="tab-pane fade show active" id="Quiz1" role="tabpanel" aria-labelledby="v-pills-profile-tab">
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
182
183
184
                                            <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}
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" aria-labelledby="v-pills-messages-tab">
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>
244
                                                    {selectOption}
baesangjune's avatar
baesangjune committed
245

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

248
                                                </div>
baesangjune's avatar
baesangjune committed
249

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

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

259
                                            </div>
baesangjune's avatar
admin    
baesangjune committed
260
                                        </div>
baesangjune's avatar
baesangjune committed
261
262
                                    </div>
                                </div>
baesangjune's avatar
baesangjune committed
263
                            </div>
264
265
266
267
                            <div className="tab-pane fade" id="Quiz3" role="tabpanel" aria-labelledby="v-pills-settings-tab">
                                <div className="container">
                                    <div className="row d-flex justify-content-center">
                                        <div className="col-8">
baesangjune's avatar
baesangjune committed
268

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

271
272
273
274
275
                                            <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
276

277
                                                </div>
baesangjune's avatar
baesangjune committed
278

279
280
281
282
283
284
                                                <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
285
                                                        </div>
286
                                                        <input type="text" class="form-control" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
baesangjune's avatar
admin    
baesangjune committed
287
                                                    </div>
288
                                                    {selectOption}
baesangjune's avatar
baesangjune committed
289

290
                                                    <button className="btn btn-outline-secondary btn-sm" onClick={addSelectOption}>+</button>
Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
291

292
                                                </div>
baesangjune's avatar
baesangjune committed
293

294
295
296
297
                                                <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
298

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

303
                                            </div>
baesangjune's avatar
admin    
baesangjune committed
304
                                        </div>
baesangjune's avatar
baesangjune committed
305
306
307
                                    </div>
                                </div>
                            </div>
baesangjune's avatar
baesangjune committed
308
309
310
311
                        </div>
                    </div>
                </div>
            </div>
baesangjune's avatar
admin    
baesangjune committed
312

baesangjune's avatar
baesangjune committed
313
314
315
316
317
        </>
    )
}

export default Admin