Commit 1f81448a authored by Jiwon Yoon's avatar Jiwon Yoon
Browse files

choose

parent c6d01df3
...@@ -5,6 +5,8 @@ let list = [] ...@@ -5,6 +5,8 @@ let list = []
let QnAadmins = [] let QnAadmins = []
let QnAadmin = {} let QnAadmin = {}
let c = {}
function AdminQuiz() { function AdminQuiz() {
...@@ -21,8 +23,9 @@ function AdminQuiz() { ...@@ -21,8 +23,9 @@ function AdminQuiz() {
setQuestion(event.target.value) setQuestion(event.target.value)
} }
const handleChangeChoose = (event) => { const handleChangeChoose = (event) => {
c[event.target.id] = event.target.value
QnAadmin['Choose'] = event.target.value // QnAadmin['Choose'] = event.target.value
setChoose(event.target.value) setChoose(event.target.value)
} }
...@@ -40,10 +43,10 @@ function AdminQuiz() { ...@@ -40,10 +43,10 @@ function AdminQuiz() {
<div className="input-group"> <div className="input-group">
<div className="input-group-prepend"> <div className="input-group-prepend">
<div className="input-group-text"> <div className="input-group-text">
<input type="radio" id={selectOption + 1} name="answer" /> <input type="radio" name="answer" />
</div> </div>
</div> </div>
<input type="text" class="form-control" placeholder="보기를 입력하세요" onChange={handleChangeChoose} /> <input type="text" class="form-control" id={String(selectOption + 1)} placeholder="보기를 입력하세요" onChange={handleChangeChoose} />
</div> </div>
) )
setselectOption(selectOption + 1) setselectOption(selectOption + 1)
...@@ -62,6 +65,8 @@ function AdminQuiz() { ...@@ -62,6 +65,8 @@ function AdminQuiz() {
} }
else { else {
console.log(QnAadmin) console.log(QnAadmin)
QnAadmin['Choose']=Object.values(c)
QnAadmins.push(QnAadmin) QnAadmins.push(QnAadmin)
localStorage.setItem('QnA', JSON.stringify(QnAadmins)) localStorage.setItem('QnA', JSON.stringify(QnAadmins))
console.log(QnAadmins) console.log(QnAadmins)
...@@ -88,7 +93,7 @@ function AdminQuiz() { ...@@ -88,7 +93,7 @@ function AdminQuiz() {
<input type="radio" id={selectOption} name="answer" /> <input type="radio" id={selectOption} name="answer" />
</div> </div>
</div> </div>
<input type="text" className="form-control" placeholder="보기를 입력하세요" onChange={handleChangeChoose} /> <input type="text" className="form-control" id='1' placeholder="보기를 입력하세요" onChange={handleChangeChoose} />
</div> </div>
{list.map((element) => element)} {list.map((element) => element)}
<button className="btn btn-outline-secondary btn-sm" onClick={addSelectOption}>+</button> <button className="btn btn-outline-secondary btn-sm" onClick={addSelectOption}>+</button>
......
import React,{ useState } from 'react' import React,{ useState } from 'react'
let Setadmins = []
let Setadmin = {}
function AdminSetting() { function AdminSetting() {
...@@ -8,21 +10,41 @@ function AdminSetting() { ...@@ -8,21 +10,41 @@ function AdminSetting() {
const [adminpassword, setAdminPassword] = useState('') const [adminpassword, setAdminPassword] = useState('')
const [time, setTime] = useState('') const [time, setTime] = useState('')
const handleChangePassword = (event) => { const handleChangePassword = (event) => {
Setadmin['password'] = event.target.value
setPassword(event.target.value) setPassword(event.target.value)
} }
const handleChangeAdminPassword = (event) => { const handleChangeAdminPassword = (event) => {
Setadmin['AdminPassword'] = event.target.value
setAdminPassword(event.target.value) setAdminPassword(event.target.value)
} }
const handleChangeTime = (event) => { const handleChangeTime = (event) => {
Setadmin['Time'] = event.target.value
setTime(event.target.value) setTime(event.target.value)
} }
function handleClick() { function handleClick() {
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)
alert('입력이 완료되었습니다') // setDoneset(true)
}
} }
return ( return (
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment