Admin.js 8.19 KB
Newer Older
baesangjune's avatar
baesangjune committed
1
import React, { useState } from 'react';
baesangjune's avatar
baesangjune committed
2
3
// import { Link } from 'react-router-dom';

Jiwon Yoon's avatar
h    
Jiwon Yoon committed
4
5
6

let list = []

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


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

baesangjune's avatar
admin    
baesangjune committed
15

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

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


Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
28
    const handleChangeQuestion = (event) => {
baesangjune's avatar
baesangjune committed
29
30
        setQuestion(event.target.value)
    }
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
31
    const handleChangeChoose = (event) => {
baesangjune's avatar
baesangjune committed
32
33
34
35
36
        setChoose(event.target.value)
    }
    const handleChangeanswer = (event) => {
        setAnswer(event.target.value)
    }
baesangjune's avatar
baesangjune committed
37
38
39
40
41
42
43
44
45
46
    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
47
48
49
50
51
52

    function handleClick() {

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

baesangjune's avatar
baesangjune committed
58
        setDone(true)
Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
59
    }
baesangjune's avatar
baesangjune committed
60
61


Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
62
    function addSelectOption() {
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
63
64
        list.push(
            <div className="input-group">
baesangjune's avatar
admin    
baesangjune committed
65
66
                <div className="input-group-prepend">
                    <div className="input-group-text">
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
67
                        <input type="radio" id={selectOption+1} name="answer" />
baesangjune's avatar
admin    
baesangjune committed
68
69
                    </div>
                </div>
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
70
                <input type="text" class="form-control" placeholder="보기를 입력하세요" onChange={handleChangeChoose} />
Jiwon Yoon's avatar
addQuiz    
Jiwon Yoon committed
71
            </div>
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
72
73
        )
        setselectOption(selectOption + 1)
baesangjune's avatar
baesangjune committed
74
    }
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
75

baesangjune's avatar
baesangjune committed
76
    function handleClickQuiz() {
baesangjune's avatar
admin    
baesangjune committed
77
        let addQuiz = function () {
baesangjune's avatar
.    
baesangjune committed
78
            return <a className="nav-link" id="Quiz4-tab" data-toggle="pill" href="#Quiz4" role="tab" >Quiz4</a>
baesangjune's avatar
baesangjune committed
79
80
81
        }
        setaddQuiz(addQuiz)
    }
baesangjune's avatar
baesangjune committed
82

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

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

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


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

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

baesangjune's avatar
baesangjune committed
107
108

                        </div>
baesangjune's avatar
baesangjune committed
109

Jiwon Yoon's avatar
h    
Jiwon Yoon committed
110
111
112
113
                    </div>
                    <div className="col-8">
                        <div className="tab-content" id="v-pills-tabContent">
                            <div className="tab-pane fade show active" id="setting" role="tabpanel" >
baesangjune's avatar
baesangjune committed
114
115
                                <div className="row d-flex justify-content-center">
                                    <div className="col-8">
Jiwon Yoon's avatar
h    
Jiwon Yoon 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

Jiwon Yoon's avatar
h    
Jiwon Yoon 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
admin    
baesangjune committed
125

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

131
                                        </div>
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
132
133
134
                                        <label for="inputLogin" className="d-flex justify-content-center">
                                            <button className="mt-4 btn btn-dark" onClick={handleClick}>작성완료</button>
                                        </label>
135
136
                                    </div>
                                </div>
baesangjune's avatar
baesangjune committed
137
                            </div>
baesangjune's avatar
baesangjune committed
138

baesangjune's avatar
baesangjune committed
139

Jiwon Yoon's avatar
h    
Jiwon Yoon committed
140
                            <div className="" id="Quiz1">
141
                                <div className="container">
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
142
143
144
145
146
147
148
149
150
151
152
153
                                    <h2 className="p-3 border text-center">문제만들기</h2>
                                    <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" className="form-control" onChange={handleChangeQuestion} placeholder="문제를 입력하세요" />
                                        </div>
                                        <div className="p-3 ">
                                            <div className="input-group">
                                                <div className="input-group-prepend">
                                                    <div className="input-group-text">
                                                        <input type="radio" id={selectOption} name="answer" />
baesangjune's avatar
admin    
baesangjune committed
154
                                                    </div>
Jiwon Yoon's avatar
l    
Jiwon Yoon committed
155
                                                </div>
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
156
                                                <input type="text" className="form-control" placeholder="보기를 입력하세요" onChange={handleChangeChoose} />
Jiwon Yoon's avatar
l    
Jiwon Yoon committed
157
                                            </div>
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
158
159
                                            {list.map((element)=>element)}
                                            <button className="btn btn-outline-secondary btn-sm" onClick={addSelectOption}>+</button>
baesangjune's avatar
admin    
baesangjune committed
160
                                        </div>
baesangjune's avatar
baesangjune committed
161

Jiwon Yoon's avatar
h    
Jiwon Yoon committed
162
163
164
                                        <div className="p-3 ">
                                            <span className="font-weight-bold mr-2 h3">정답:</span>
                                            <input type="text" onChange={handleChangeanswer} placeholder="정답을 입력하세요" />
Jiwon Yoon's avatar
l    
Jiwon Yoon committed
165
                                        </div>
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
166
167
168
169

                                        <label for="inputLogin" className="d-flex justify-content-center">
                                            <button className="mt-4 btn btn-dark" onClick={handleClick}>작성완료</button>
                                        </label>
Jiwon Yoon's avatar
l    
Jiwon Yoon committed
170
                                    </div>
baesangjune's avatar
baesangjune committed
171
172
                                </div>
                            </div>
baesangjune's avatar
baesangjune committed
173
                        </div>
Jiwon Yoon's avatar
h    
Jiwon Yoon committed
174
175
176
177
                    </div>
                </div>
            </div>

baesangjune's avatar
admin    
baesangjune committed
178

baesangjune's avatar
baesangjune committed
179
180
181
182
183
        </>
    )
}

export default Admin