Admin.js 10.8 KB
Newer Older
baesangjune's avatar
baesangjune committed
1
import React, { useState } from 'react';
baesangjune's avatar
.    
baesangjune committed
2
3
import AdminQuiz from './AdminQuiz'
import AdminSetting from './AdminSetting'
baesangjune's avatar
baesangjune committed
4

baesangjune's avatar
baesangjune committed
5

baesangjune's avatar
push    
baesangjune committed
6
7
let QnAadmins = []
let QnAadmin = {}
baesangjune's avatar
baesangjune committed
8

baesangjune's avatar
push    
baesangjune committed
9
10
let Setadmins = []
let Setadmin = {}
baesangjune's avatar
baesangjune committed
11

baesangjune's avatar
push    
baesangjune committed
12
function Admin() {
baesangjune's avatar
admin    
baesangjune committed
13

baesangjune's avatar
.    
baesangjune committed
14
15
    const[result, setresult] = useState('')
    const[QuizBtnCount, setQuizBtnCount] = useState(4)
baesangjune's avatar
push    
baesangjune committed
16

baesangjune's avatar
.    
baesangjune committed
17
18
    function handleClickSetting(){
        setresult(<AdminSetting/>)
baesangjune's avatar
baesangjune committed
19
    }
baesangjune's avatar
push    
baesangjune committed
20

baesangjune's avatar
.    
baesangjune committed
21
22
    function handleClickQuiz(){
        setresult(<AdminQuiz/>)
baesangjune's avatar
baesangjune committed
23
    }
baesangjune's avatar
.    
baesangjune committed
24
25
26
27
28
29
    
    function handleClickAddQuiz(){
        QuizBtnCount.push(
            <button type='button' className='btn btn-outline-primary' id={QuizBtnCount} onClick={handleClickQuiz}>Quiz {QuizBtnCount}</button>
        )
        setQuizBtnCount(QuizBtnCount+1)
baesangjune's avatar
baesangjune committed
30
31
    }

baesangjune's avatar
baesangjune committed
32

baesangjune's avatar
.    
baesangjune committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
    // const [question, setQuestion] = useState('')
    // const [choose, setChoose] = useState('')
    // const [answer, setAnswer] = useState('')
    // const [password, setPassword] = useState('')
    // const [adminpassword, setAdminPassword] = useState('')
    // const [time, setTime] = useState('')
    // const [addQuiz, setaddQuiz] = useState('')
    // const [selectOption, setselectOption] = useState('')


    // const handleChangeQuestion = (event) => {

    //     QnAadmin['Q'] = event.target.value

    //     setQuestion(event.target.value)
    // }
    // const handleChangechoose = (event) => {

    //     QnAadmin['Choose'] = event.target.value

    //     setChoose(event.target.value)
    // }
    // const handleChangeanswer = (event) => {

    //     QnAadmin['A'] = event.target.value

    //     setAnswer(event.target.value)
    // }
    // const handleChangePassword = (event) => {
    //     Setadmin['password'] = event.target.value
    //     setPassword(event.target.value)

    // }
    // const handleChangeAdminPassword = (event) => {
    //     Setadmin['AdminPassword'] = event.target.value
    //     setAdminPassword(event.target.value)
    // }
    // const handleChangeTime = (event) => {
    //     Setadmin['Time'] = event.target.value
    //     setTime(event.target.value)
    // }


    // function handleClickQnA() {
    //     if (!question) {
    //         alert('문제가 입력되지 않았습니다.')
    //     }
    //     else if (!choose) {
    //         alert('보기가 입력되지 않았습니다.')
    //     }
    //     else if (!answer) {
    //         alert('정답이 입력되지 않았습니다.')
    //     }
    //     else {
    //         console.log(QnAadmin)
    //         QnAadmins.push(QnAadmin)
    //         localStorage.setItem('QnA', JSON.stringify(QnAadmins))
    //         console.log(QnAadmins)
    //         alert('입력이 완료되었습니다.')
    //     }

    // }
    // function handleClicksetting() {
    //     if (!password) {
    //         alert('비밀번호가 입력되지 않았습니다.')
    //     }
    //     else if (!adminpassword) {
    //         alert('관리자 비밀번호가 입력되지 않았습니다.')
    //     }
    //     else if (!time) {
    //         alert('제한시간이 입력되지 않았습니다.') //타임은 조건은 빼도 될 듯
    //     }
    //     else {
    //         Setadmins.push(Setadmin)
    //         localStorage.setItem('Set', JSON.stringify(Setadmins))
    //         console.log(Setadmins)
    //         alert('저장이 완료되었습니다.')
    //         console.log(Setadmin)

    //         // setDoneset(true)
    //     }

    // }
    // 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)
    // // }
    // function handleClickQuiz() {
    //     let addQuiz = function () {
    //         return <a className="nav-link" id="Quiz4-tab" data-toggle="pill" href="#Quiz" role="tab" >Quiz4</a>
    //     }
    //     setaddQuiz(addQuiz)
    // }
baesangjune's avatar
baesangjune committed
135

baesangjune's avatar
baesangjune committed
136
137
    return (
        <>
baesangjune's avatar
push    
baesangjune committed
138
139
140
            {/* {doneQnA ? alert('모두 입력되었습니다.') : ''}
            {doneset ? alert('모두 입력되었습니다.') : ''} */}

baesangjune's avatar
.    
baesangjune committed
141
            <div className="row justify-content-md-center mt-5 ">
baesangjune's avatar
css    
baesangjune committed
142
                <div className="col-2 text-center border">
baesangjune's avatar
baesangjune committed
143
                    <div className="container-fluid ">
baesangjune's avatar
css    
baesangjune committed
144
145
                        <div className="navbar-header p-3 ">
                            <p className="navbar-brand border-bottom ">관리자 페이지</p>
baesangjune's avatar
baesangjune committed
146
                        </div>
baesangjune's avatar
.    
baesangjune committed
147
                        <div className="nav flex-column nav-pills" id="v-pills-tab" role="tablist">
baesangjune's avatar
admin    
baesangjune committed
148

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

baesangjune's avatar
.    
baesangjune committed
151
                            <a className="nav-link" id="setting-tab" data-toggle='pill' href="#setting">Setting</a>
baesangjune's avatar
admin    
baesangjune committed
152
153


baesangjune's avatar
push    
baesangjune committed
154
                            <p className="navbar-text border-bottom">Quiz 입력하기</p> {/*Quiz1 버튼에 무언갈 쓰고 Quiz2를 누르면 초기화되도록하기*/}
baesangjune's avatar
admin    
baesangjune committed
155

baesangjune's avatar
push    
baesangjune committed
156
157
158
                            <a className="nav-link" id="Quiz-tab" data-toggle="pill" href="#Quiz" >Quiz1</a>
                            <a className="nav-link" id="Quiz-tab" data-toggle="pill" href="#Quiz" >Quiz2</a>
                            <a className="nav-link" id="Quiz-tab" data-toggle="pill" href="#Quiz" >Quiz3</a>
baesangjune's avatar
admin    
baesangjune committed
159
                            {addQuiz}
baesangjune's avatar
css    
baesangjune committed
160
                            <button className="btn btn-danger navbar-btn" onClick={handleClickQuiz} >Quiz 추가</button>
baesangjune's avatar
admin    
baesangjune committed
161

baesangjune's avatar
baesangjune committed
162
163

                        </div>
baesangjune's avatar
baesangjune committed
164
165
                    </div>
                </div>
baesangjune's avatar
css    
baesangjune committed
166
                <div className="col-8">
baesangjune's avatar
baesangjune committed
167
                    <div className="tab-content" id="v-pills-tabContent">
baesangjune's avatar
css    
baesangjune committed
168
                        <div className="tab-pane fade show active" id="setting" role="tabpanel" >
baesangjune's avatar
baesangjune committed
169
170
171
172
                            <div>
                                <div className="container">
                                    <div className="row d-flex justify-content-center">
                                        <div className="col-8">
baesangjune's avatar
baesangjune committed
173

baesangjune's avatar
.    
baesangjune committed
174
                                            <h2 className="p-3 border text-center bg-danger">관리자 설정변경</h2>
baesangjune's avatar
baesangjune committed
175
                                            <div className="p-3 border">
baesangjune's avatar
.    
baesangjune committed
176
177
                                                <h3>변경할 비밀번호를 입력하세요</h3>
                                                <input className='p-2' type="text" onChange={handleChangePassword} placeholder="New Password" />
baesangjune's avatar
baesangjune committed
178

baesangjune's avatar
baesangjune committed
179
180
                                            </div>
                                            <div className="p-3 border">
baesangjune's avatar
.    
baesangjune committed
181
182
                                                <h3>변경할 관리자 비밀번호를 입력하세요</h3>
                                                <input className='p-2' type="text" onChange={handleChangeAdminPassword} placeholder="New Admin Password" />
baesangjune's avatar
baesangjune committed
183

baesangjune's avatar
baesangjune committed
184
185
                                            </div>
                                            <div className="p-3 border">
baesangjune's avatar
.    
baesangjune committed
186
187
                                                <h3>타이머를 설정하세요(초단위)</h3>
                                                <input className='p-2' type="text" onChange={handleChangeTime} placeholder="Set Time" />
baesangjune's avatar
baesangjune committed
188

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


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

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

baesangjune's avatar
baesangjune committed
200
                            </div>
baesangjune's avatar
baesangjune committed
201

baesangjune's avatar
baesangjune committed
202
                        </div>
baesangjune's avatar
admin    
baesangjune committed
203

baesangjune's avatar
push    
baesangjune committed
204
                        <div className="tab-pane fade" id="Quiz" role="tabpanel">
baesangjune's avatar
baesangjune committed
205
206
207
208
                            <div className="container">
                                <div className="row d-flex justify-content-center">
                                    <div className="col-8">

baesangjune's avatar
.    
baesangjune committed
209
                                        <h2 className="p-3 border text-center bg-danger">문제만들기</h2>
baesangjune's avatar
baesangjune committed
210

baesangjune's avatar
admin    
baesangjune committed
211
212
213
214
                                        <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" /> */}
baesangjune's avatar
.    
baesangjune committed
215
                                                <input className='p-2' type="text" onChange={handleChangeQuestion} placeholder="문제를 입력하세요" />
baesangjune's avatar
baesangjune committed
216

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

baesangjune's avatar
admin    
baesangjune committed
219
220
221
                                            <div className="p-3 ">
                                                <div className="input-group">
                                                    <div className="input-group-prepend">
baesangjune's avatar
.    
baesangjune committed
222
                                                        <div className="input-group-text p-3">
baesangjune's avatar
admin    
baesangjune committed
223
224
225
                                                            <input type="radio" id="option" />
                                                        </div>
                                                    </div>
baesangjune's avatar
.    
baesangjune committed
226
                                                    <input type="text" className="form-control p-4" placeholder="보기를 입력하세요" onChange={handleChangechoose} />
baesangjune's avatar
admin    
baesangjune committed
227
228
                                                </div>
                                                {selectOption}
baesangjune's avatar
baesangjune committed
229

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

                                            </div>
baesangjune's avatar
baesangjune committed
233

baesangjune's avatar
admin    
baesangjune committed
234
235
                                            <div className="p-3 ">
                                                <span className="font-weight-bold mr-2 h3">정답:</span>
baesangjune's avatar
.    
baesangjune committed
236
                                                <input className='p-2' type="text" onChange={handleChangeanswer} placeholder="정답을 입력하세요" />
baesangjune's avatar
admin    
baesangjune committed
237
                                            </div>
baesangjune's avatar
baesangjune committed
238

baesangjune's avatar
admin    
baesangjune committed
239
                                            <label for="inputLogin" className="d-flex justify-content-center">
baesangjune's avatar
push    
baesangjune committed
240
                                                <button className="mt-4 btn btn-dark" onClick={handleClickQnA}>작성완료</button>
baesangjune's avatar
admin    
baesangjune committed
241
242
243
                                            </label>

                                        </div>
baesangjune's avatar
baesangjune committed
244
245
246
                                    </div>
                                </div>
                            </div>
baesangjune's avatar
baesangjune committed
247
248
249
250
                        </div>
                    </div>
                </div>
            </div>
baesangjune's avatar
admin    
baesangjune committed
251

baesangjune's avatar
baesangjune committed
252
253
254
255
256
        </>
    )
}

export default Admin