Admin.js 5.85 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
baesangjune committed
6
7
// let QnAadmins = []
// let QnAadmin = {}
baesangjune's avatar
baesangjune committed
8

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

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

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

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

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

baesangjune's avatar
baesangjune committed
33

baesangjune's avatar
.    
baesangjune committed
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
135
    // 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
136

baesangjune's avatar
baesangjune committed
137
138
    return (
        <>
baesangjune's avatar
baesangjune committed
139
        <div className="container-fluid">
baesangjune's avatar
.    
baesangjune committed
140
            <div className="row justify-content-md-center mt-5 ">
baesangjune's avatar
css    
baesangjune committed
141
                <div className="col-2 text-center border">
baesangjune's avatar
baesangjune committed
142
143
144
145
146
147
148
149
150
151
152
153
                    <div className="my-5">
                        <h4>관리자페이지</h4>
                    </div>
                    <div>
                        <button type="button" className="btn btn-outline-info mb-5" onClick={handleClickSetting}>Setting</button>
                    </div>
                    <div class="btn-group-vertical">
                        <button type="button" className="btn btn-outline-primary" id="1" onClick={handleClickQuiz}>Quiz 1</button>
                        <button type="button" className="btn btn-outline-primary" id="2" onClick={handleClickQuiz}>Quiz 2</button>
                        <button type="button" className="btn btn-outline-primary" id="3" onClick={handleClickQuiz}>Quiz 3</button>
                        {QuizBtn.map((element) => element)}
                        <button type="button" className="btn btn-outline-primary" onClick={handleClickAddQuiz}>+</button>
baesangjune's avatar
baesangjune committed
154

baesangjune's avatar
baesangjune committed
155
156
                    </div>
                </div>
baesangjune's avatar
baesangjune committed
157

baesangjune's avatar
css    
baesangjune committed
158
                <div className="col-8">
baesangjune's avatar
baesangjune committed
159
                    <div className="tab-content" id="v-pills-tabContent">
baesangjune's avatar
css    
baesangjune committed
160
                        <div className="tab-pane fade show active" id="setting" role="tabpanel" >
baesangjune's avatar
baesangjune committed
161
                            <div className="row d-flex justify-content-center">
baesangjune's avatar
baesangjune committed
162
                            </div>
baesangjune's avatar
baesangjune committed
163
                        </div>
baesangjune's avatar
baesangjune committed
164
165
            
                        {result}
baesangjune's avatar
admin    
baesangjune committed
166

baesangjune's avatar
baesangjune committed
167
168
169
                    </div>
                </div>
            </div>
baesangjune's avatar
baesangjune committed
170
171
        </div>

baesangjune's avatar
admin    
baesangjune committed
172

baesangjune's avatar
baesangjune committed
173
    </>
baesangjune's avatar
baesangjune committed
174
175
176
177
    )
}

export default Admin