Home.js 3.08 KB
Newer Older
baesangjune's avatar
baesangjune committed
1
2
// import bg from './img_study.jpg'
// import korea from './img_korea.jpg'
baesangjune's avatar
baesangjune committed
3
4
import React, { useState } from 'react'
import { Redirect } from 'react-router-dom';
Jiwon Yoon's avatar
Jiwon Yoon committed
5
6


baesangjune's avatar
baesangjune committed
7
function Home() {
baesangjune's avatar
baesangjune committed
8
    const [name, setName] = useState('')
baesangjune's avatar
baesangjune committed
9
    const [password, SetPassword] = useState('')
baesangjune's avatar
baesangjune committed
10
11
    const [done, setDone] = useState(false)

baesangjune's avatar
baesangjune committed
12
    const handleChangename = (event) => {
baesangjune's avatar
baesangjune committed
13
14
        setName(event.target.value)
    }
baesangjune's avatar
baesangjune committed
15
16
17
    const handleChangepassword = (event) => {
        SetPassword(event.target.value)
    }
baesangjune's avatar
baesangjune committed
18

baesangjune's avatar
baesangjune committed
19
    function checking() {
baesangjune's avatar
baesangjune committed
20
21
22
        if (!name) {
            alert('이름을 입력하세요')
        }
baesangjune's avatar
baesangjune committed
23
24
25
26
27
28
        else if (!password) {
            alert('비밀번호를 입력하세요')
        }
        else if (password !== '0319') {
            alert('유효한 비밀번호를 입력하세요')
        }
baesangjune's avatar
baesangjune committed
29
        else {
baesangjune's avatar
baesangjune committed
30
            alert('입력하신 이름은 ' + name + '입니다.')
baesangjune's avatar
baesangjune committed
31
            localStorage.setItem('name', name)
baesangjune's avatar
baesangjune committed
32
            localStorage.setItem('password', password)
baesangjune's avatar
baesangjune committed
33
34
            setDone(true)
        }
baesangjune's avatar
baesangjune committed
35

baesangjune's avatar
baesangjune committed
36
37
    }

Jiwon Yoon's avatar
Jiwon Yoon committed
38
    return (
baesangjune's avatar
baesangjune committed
39
        <>
baesangjune's avatar
baesangjune committed
40

baesangjune's avatar
baesangjune committed
41
            {done ? <Redirect to='/quiz' /> : ''}
baesangjune's avatar
baesangjune committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
            {/* <div style={{ backgroundImage: 'url(' + bg + ')', backgroundColor: "grey", backgroundSize: "100%", width: "100%", height: "880px", backgroundRepeat: 'no-repeat' }}>
                <div className="Main"></div> */}
            <div style={{ fontSize: '70px', marginBottom: '100px', textAlign: 'center', backgroundColor: '#AE0E36' }}>
                {/* <img alt='korea' src={korea} width='10%'/> */}
                KOREA UNIVERSITY
            </div>

            {/* <div className="Box" style={{ border: 'solid', position: 'absolute', top: "300px", left: "68%"}} > */}
                <div className="Name" style={{boxShadow: '5px 5px 5px 5px gray', border: 'solid', fontSize: '30px', position: "absolute", top: "300px", left: "68%" }}>
                    이름(Name)
                        <input style={{ padding: '5px', border: 'solid', borderRight: 'none', borderBottom: 'none', borderTop: 'none', marginLeft: '105px', inlineSize: '160px', blockSize: '40px', fontSize: '40px' }} onChange={handleChangename} />
                </div>
                <div className="Name" style={{ boxShadow: '5px 5px 5px 5px gray',border: 'solid', fontSize: '30px', position: "absolute", top: "360px", left: "68%" }}>
                    비밀번호(Password)
                        <input type='password' style={{ padding: '5px', border: 'solid', borderRight: 'none', borderBottom: 'none', borderTop: 'none', marginLeft: '0px', inlineSize: '160px', blockSize: '40px', fontSize: '40px' }} onChange={handleChangepassword} />
                </div>
                <div className='Box2'>
                    <button style={{boxShadow: '5px 5px 5px 5px gray', marginLeft: '82%', marginTop: '10%', blockSize: '50px', inlineSize: '175px', fontSize: '35px' }} className="QuizStart" onClick={checking}>Start !</button>
baesangjune's avatar
baesangjune committed
60
                </div>
baesangjune's avatar
home    
baesangjune committed
61

baesangjune's avatar
baesangjune committed
62
63
                {/* localStorage를 사용해야는지 localstorage를 사용해야하는지 */}
            {/* </div> */}
baesangjune's avatar
0    
baesangjune committed
64

baesangjune's avatar
baesangjune committed
65
66

            {/* </div> */}
baesangjune's avatar
baesangjune committed
67
        </>
baesangjune's avatar
home    
baesangjune committed
68

Jiwon Yoon's avatar
Jiwon Yoon committed
69
70
    )
}
baesangjune's avatar
baesangjune committed
71

baesangjune's avatar
baesangjune committed
72
export default Home;
Jiwon Yoon's avatar
Jiwon Yoon committed
73