Admin.js 16.2 KB
Newer Older
김민수's avatar
김민수 committed
1
import React, { useState } from 'react';
김민수's avatar
0810    
김민수 committed
2

김민수's avatar
김민수 committed
3
4
5
6
7
8
9
10
11
12
// import { Link } from 'react-router-dom';

function Admin() {


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

김민수's avatar
0810    
김민수 committed
13

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

김민수's avatar
김민수 committed
23
24
    const [done, setDone] = useState(false)

김민수's avatar
0810    
김민수 committed
25
26

    const handleChangeQuestion = (event) => {
김민수's avatar
김민수 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)
    }
김민수's avatar
0810    
김민수 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)
    }

김민수's avatar
김민수 committed
45
46
47
48
49
50
51

    function handleClick() {

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

김민수's avatar
김민수 committed
56
        setDone(true)
김민수's avatar
김민수 committed
57
    }
김민수's avatar
김민수 committed
58
59


김민수's avatar
0810    
김민수 committed
60
61
62
63
64
65
66
67
68
69
70
71
    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} />
            </div>
        }
        setselectOption(list)
김민수's avatar
김민수 committed
72
    }
김민수's avatar
김민수 committed
73
74
75
76
77
78
79
80
81
82
83
84
85
    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" className="form-control" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
            </div>
        }
        setselectOption(list)
    }
김민수's avatar
0810    
김민수 committed
86
    function handleClickQuiz() {
김민수's avatar
0810    
김민수 committed
87
        let addQuiz = function () {
김민수's avatar
김민수 committed
88
            return <a className="nav-link" id="Quiz4-tab" data-toggle="pill" href="#Quiz4" role="tab" >Quiz4</a>
김민수's avatar
0810    
김민수 committed
89
90
91
        }
        setaddQuiz(addQuiz)
    }
김민수's avatar
김민수 committed
92
93
94
95

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

김민수's avatar
김민수 committed
104
                            <p className="navbar-text border-bottom">관리자 설정 변경하기</p>
김민수's avatar
0810    
김민수 committed
105

김민수's avatar
김민수 committed
106
                            <a className="nav-link" id="setting-tab" data-toggle='pill' href="#setting" role="tab">Setting</a>
김민수's avatar
0810    
김민수 committed
107
108


김민수's avatar
김민수 committed
109
                            <p className="navbar-text border-bottom">Quiz 입력하기</p>
김민수's avatar
0810    
김민수 committed
110

김민수's avatar
김민수 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>
김민수's avatar
0810    
김민수 committed
114
                            {addQuiz}
김민수's avatar
김민수 committed
115
                            <button className="btn btn-danger navbar-btn" onClick={handleClickQuiz} >Quiz 추가</button>
김민수's avatar
0810    
김민수 committed
116

김민수's avatar
김민수 committed
117

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

김민수's avatar
0810    
김민수 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" />
김민수's avatar
김민수 committed
133

김민수's avatar
0810    
김민수 committed
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
                                            </div>
                                            <div className="p-3 border">
                                                <h2>변경할 관리자 비밀번호를 입력하세요</h2>
                                                <input type="text" onChange={handleChangeAdminPassword} placeholder="New Admin Password" />

                                            </div>
                                            <div className="p-3 border">
                                                <h2>타이머를 설정하세요(초단위)</h2>
                                                <input type="text" onChange={handleChangeTime} placeholder="Set Time" />

                                            </div>


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

                                        </div>
                                    </div>
                                </div>
김민수's avatar
김민수 committed
154
155
156

                            </div>

김민수's avatar
0810    
김민수 committed
157
                        </div>
김민수's avatar
0810    
김민수 committed
158

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

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

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

김민수's avatar
0810    
김민수 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="문제를 입력하세요" />
김민수's avatar
김민수 committed
172

김민수's avatar
0810    
김민수 committed
173
                                            </div>
김민수's avatar
0810    
김민수 committed
174

김민수's avatar
0810    
김민수 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>
김민수's avatar
김민수 committed
182
                                                    <input type="text" className="form-control" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
김민수's avatar
0810    
김민수 committed
183
184
                                                </div>
                                                {selectOption}
김민수's avatar
0810    
김민수 committed
185

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

                                            </div>
김민수's avatar
0810    
김민수 committed
189

김민수's avatar
0810    
김민수 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>
김민수's avatar
0810    
김민수 committed
194

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

                                        </div>
김민수's avatar
0810    
김민수 committed
200
201
                                    </div>
                                </div>
김민수's avatar
김민수 committed
202

김민수's avatar
김민수 committed
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>
김민수's avatar
0810    
김민수 committed
217
218
                            </div>

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

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

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

김민수's avatar
김민수 committed
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="문제를 입력하세요" />
김민수's avatar
0810    
김민수 committed
232

김민수's avatar
김민수 committed
233
                                                </div>
김민수's avatar
0810    
김민수 committed
234

김민수's avatar
김민수 committed
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>
김민수's avatar
0810    
김민수 committed
241
                                                        </div>
김민수's avatar
김민수 committed
242
                                                        <input type="text" class="form-control" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
김민수's avatar
0810    
김민수 committed
243
                                                    </div>
김민수's avatar
김민수 committed
244
                                                    <input type="text" className="form-control" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
김민수's avatar
0810    
김민수 committed
245
246
                                                </div>
                                                {selectOption}
김민수's avatar
0810    
김민수 committed
247

김민수's avatar
김민수 committed
248
                                                    <button className="btn btn-outline-secondary btn-sm" onClick={addSelectOption}>+</button>
김민수's avatar
0810    
김민수 committed
249

김민수's avatar
김민수 committed
250
                                                </div>
김민수's avatar
0810    
김민수 committed
251

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

김민수's avatar
김민수 committed
257
258
259
                                                <label for="inputLogin" className="d-flex justify-content-center">
                                                    <button className="mt-4 btn btn-dark" onClick={handleClick}>작성완료</button>
                                                </label>
김민수's avatar
0810    
김민수 committed
260

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

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

김민수's avatar
김민수 committed
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="문제를 입력하세요" />
김민수's avatar
0810    
김민수 committed
279

김민수's avatar
김민수 committed
280
                                                </div>
김민수's avatar
0810    
김민수 committed
281

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

김민수's avatar
김민수 committed
295
296
                                                    <button className="btn btn-outline-secondary btn-sm" onClick={addSelectOption}>+</button>
                                                </div>
김민수's avatar
0810    
김민수 committed
297

김민수's avatar
김민수 committed
298
299
300
301
                                                <div className="p-3 ">
                                                    <span className="font-weight-bold mr-2 h3">정답:</span>
                                                    <input type="text" onChange={handleChangeanswer} placeholder="정답을 입력하세요" />
                                                </div>
김민수's avatar
0810    
김민수 committed
302

김민수's avatar
김민수 committed
303
304
305
                                                <label for="inputLogin" className="d-flex justify-content-center">
                                                    <button className="mt-4 btn btn-dark" onClick={handleClick}>작성완료</button>
                                                </label>
김민수's avatar
0810    
김민수 committed
306

김민수's avatar
김민수 committed
307
                                            </div>
김민수's avatar
0810    
김민수 committed
308
                                        </div>
김민수's avatar
0810    
김민수 committed
309
310
311
312
                                    </div>
                                </div>
                            </div>
                        </div>
김민수's avatar
0810    
김민수 committed
313

김민수's avatar
김민수 committed
314
315
316
317
318
        </>
    )
}

export default Admin