Admin.js 14.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
    const [done, setDone] = useState(false)

baesangjune's avatar
admin    
baesangjune committed
25
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)
baesangjune's avatar
baesangjune committed
51
52
53
54
55
        localStorage.setItem('Answer', answer)
        localStorage.setItem('P', password)
        localStorage.setItem('AP', adminpassword)
        localStorage.setItem('T', time * 1000)

baesangjune's avatar
baesangjune committed
56
57
58
        setDone(true)


baesangjune's avatar
admin    
baesangjune committed
59
60
61
62
63
64
65
66
67
    }
    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
68
                <input type="text" className="form-control" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
baesangjune's avatar
admin    
baesangjune committed
69
70
71
            </div>
        }
        setselectOption(list)
baesangjune's avatar
baesangjune committed
72
    }
baesangjune's avatar
baesangjune committed
73
    function handleClickQuiz() {
baesangjune's avatar
admin    
baesangjune committed
74
        let addQuiz = function () {
baesangjune's avatar
.    
baesangjune committed
75
            return <a className="nav-link" id="Quiz4-tab" data-toggle="pill" href="#Quiz4" role="tab" >Quiz4</a>
baesangjune's avatar
baesangjune committed
76
77
78
        }
        setaddQuiz(addQuiz)
    }
baesangjune's avatar
baesangjune committed
79

baesangjune's avatar
baesangjune committed
80
81
    return (
        <>
baesangjune's avatar
baesangjune committed
82
            {done ? alert('모두 입력되었습니다.') : ''}
baesangjune's avatar
css    
baesangjune committed
83
84
            <div className="row justify-content-md-center">
                <div className="col-2 text-center border">
baesangjune's avatar
baesangjune committed
85
                    <div className="container-fluid ">
baesangjune's avatar
css    
baesangjune committed
86
87
                        <div className="navbar-header p-3 ">
                            <p className="navbar-brand border-bottom ">관리자 페이지</p>
baesangjune's avatar
baesangjune committed
88
                        </div>
baesangjune's avatar
.    
baesangjune committed
89
                        <div className="nav flex-column nav-pills" id="v-pills-tab" role="tablist">
baesangjune's avatar
admin    
baesangjune committed
90

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

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


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

baesangjune's avatar
.    
baesangjune committed
98
99
100
                            <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
101
                            {addQuiz}
baesangjune's avatar
css    
baesangjune committed
102
                            <button className="btn btn-danger navbar-btn" onClick={handleClickQuiz} >Quiz 추가</button>
baesangjune's avatar
admin    
baesangjune committed
103

baesangjune's avatar
baesangjune committed
104
105

                        </div>
baesangjune's avatar
baesangjune committed
106
107
                    </div>
                </div>
baesangjune's avatar
css    
baesangjune committed
108
                <div className="col-8">
baesangjune's avatar
baesangjune committed
109
                    <div className="tab-content" id="v-pills-tabContent">
baesangjune's avatar
css    
baesangjune committed
110
                        <div className="tab-pane fade show active" id="setting" role="tabpanel" >
baesangjune's avatar
baesangjune committed
111
112
113
114
                            <div>
                                <div className="container">
                                    <div className="row d-flex justify-content-center">
                                        <div className="col-8">
baesangjune's avatar
baesangjune committed
115

baesangjune's avatar
baesangjune committed
116
117
118
119
                                            <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
120

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

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

baesangjune's avatar
baesangjune committed
131
132
133
134
135
136
137
138
139
140
                                            </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
141

baesangjune's avatar
baesangjune committed
142
                            </div>
baesangjune's avatar
baesangjune committed
143

baesangjune's avatar
baesangjune committed
144
                        </div>
baesangjune's avatar
admin    
baesangjune committed
145

baesangjune's avatar
css    
baesangjune committed
146
                        <div className="tab-pane fade" id="Quiz1" role="tabpanel" >
baesangjune's avatar
baesangjune committed
147
148
149
150
151

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

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

baesangjune's avatar
admin    
baesangjune committed
154
155
156
157
158
                                        <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
159

baesangjune's avatar
admin    
baesangjune committed
160
                                            </div>
baesangjune's avatar
baesangjune committed
161

baesangjune's avatar
admin    
baesangjune committed
162
163
164
165
166
167
168
                                            <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
169
                                                    <input type="text" className="form-control" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
baesangjune's avatar
admin    
baesangjune committed
170
171
                                                </div>
                                                {selectOption}
baesangjune's avatar
baesangjune committed
172

baesangjune's avatar
admin    
baesangjune committed
173
174
175
                                                <button className="btn btn-outline-secondary btn-sm" onClick={addSelectOption}>+</button>

                                            </div>
baesangjune's avatar
baesangjune committed
176

baesangjune's avatar
admin    
baesangjune committed
177
178
179
180
                                            <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
181

baesangjune's avatar
admin    
baesangjune committed
182
183
184
185
186
                                            <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
187
188
                                    </div>
                                </div>
baesangjune's avatar
baesangjune committed
189

baesangjune's avatar
admin    
baesangjune committed
190
                            </div>
baesangjune's avatar
baesangjune committed
191
                        </div>
baesangjune's avatar
admin    
baesangjune committed
192

baesangjune's avatar
css    
baesangjune committed
193
                        <div className="tab-pane fade" id="Quiz2" role="tabpanel">
baesangjune's avatar
baesangjune committed
194
195
196
197
198

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

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

baesangjune's avatar
admin    
baesangjune committed
201
202
203
204
205
                                        <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
206

baesangjune's avatar
admin    
baesangjune committed
207
                                            </div>
baesangjune's avatar
baesangjune committed
208

baesangjune's avatar
admin    
baesangjune committed
209
210
211
212
213
214
215
                                            <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
216
                                                    <input type="text" className="form-control" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
baesangjune's avatar
admin    
baesangjune committed
217
218
                                                </div>
                                                {selectOption}
baesangjune's avatar
baesangjune committed
219

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

baesangjune's avatar
admin    
baesangjune committed
222
                                            </div>
baesangjune's avatar
baesangjune committed
223

baesangjune's avatar
admin    
baesangjune committed
224
225
226
227
228
229
230
231
232
233
                                            <div className="p-3 ">
                                                <span className="font-weight-bold mr-2 h3">정답:</span>
                                                <input type="text" onChange={handleChangeanswer} placeholder="정답을 입력하세요" />
                                            </div>

                                            <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
234
235
236
237
                                    </div>
                                </div>
                            </div>
                        </div>
baesangjune's avatar
css    
baesangjune committed
238
                        <div className="tab-pane fade" id="Quiz3" role="tabpanel">
baesangjune's avatar
baesangjune committed
239
240
241
242
                            <div className="container">
                                <div className="row d-flex justify-content-center">
                                    <div className="col-8">

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

baesangjune's avatar
admin    
baesangjune committed
245
246
247
248
249
                                        <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
250

baesangjune's avatar
admin    
baesangjune committed
251
                                            </div>
baesangjune's avatar
baesangjune committed
252

baesangjune's avatar
admin    
baesangjune committed
253
254
255
256
257
258
259
                                            <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
260
                                                    <input type="text" className="form-control" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
baesangjune's avatar
admin    
baesangjune committed
261
262
                                                </div>
                                                {selectOption}
baesangjune's avatar
baesangjune committed
263

baesangjune's avatar
admin    
baesangjune committed
264
265
266
                                                <button className="btn btn-outline-secondary btn-sm" onClick={addSelectOption}>+</button>

                                            </div>
baesangjune's avatar
baesangjune committed
267

baesangjune's avatar
admin    
baesangjune committed
268
269
270
271
                                            <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
272

baesangjune's avatar
admin    
baesangjune committed
273
274
275
276
277
                                            <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
278
279
280
                                    </div>
                                </div>
                            </div>
baesangjune's avatar
baesangjune committed
281
282
283
284
                        </div>
                    </div>
                </div>
            </div>
baesangjune's avatar
admin    
baesangjune committed
285

baesangjune's avatar
baesangjune committed
286
287
288
289
290
        </>
    )
}

export default Admin