Home.js 4.19 KB
Newer Older
김민수's avatar
수정2    
김민수 committed
1
2
// import bg from './img_study.jpg'
// import korea from './img_korea.jpg'
김민수's avatar
김민수 committed
3
4
5
import React, { useState } from 'react'
import { Redirect } from 'react-router-dom';

김민수's avatar
김민수 committed
6

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

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

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

김민수's avatar
김민수 committed
36
37
38
39
    }

    return (
        <>
김민수's avatar
수정2    
김민수 committed
40

김민수's avatar
김민수 committed
41
            {done ? <Redirect to='/quiz' /> : ''}
김민수's avatar
수정2    
김민수 committed
42
43
44
45
46
47
48
            {/* <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>

김민수's avatar
김민수 committed
49
            <form className="d-flex justify-content-center">
김민수's avatar
김민수 committed
50

김민수's avatar
김민수 committed
51
                <div className="table table-bordered " style={{width: "400px" }}>
김민수's avatar
김민수 committed
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

                    <label for="inputId" className="d-flex justify-content-center" >
                        정보 입력
                    </label>
                    <div className="form-group">
                        <label for="inputName">
                            이름입력<input className="ml-3 inputBox" onChange={handleChangename} />
                        </label>

                        <label for="inputPassword">
                            비밀번호<input type='password' className="ml-3 inputBox" onChange={handleChangepassword} />
                        </label>
                        <div className="form-group for login">
                            <label for="inputLogin" className="d-flex justify-content-center">
                                <button className="mt-4 btn btn-dark" onClick={checking}>Login</button>
                            </label>
                        </div>
                    </div>
                </div>
            </form>
김민수's avatar
김민수 committed
72

김민수's avatar
수정2    
김민수 committed
73
            {/* <div className="Box" style={{ border: 'solid', position: 'absolute', top: "300px", left: "68%"}} > */}
김민수's avatar
김민수 committed
74
            {/* <div className="Name" style={{boxShadow: '5px 5px 5px 5px gray', border: 'solid', fontSize: '30px', position: "absolute", top: "300px", left: "68%" }}>
김민수's avatar
수정2    
김민수 committed
75
76
77
78
79
80
81
82
83
                    이름(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>
김민수's avatar
김민수 committed
84
                </div> */}
김민수's avatar
김민수 committed
85

김민수's avatar
김민수 committed
86
            {/* localStorage를 사용해야는지 localstorage를 사용해야하는지 */}
김민수's avatar
수정2    
김민수 committed
87
            {/* </div> */}
김민수's avatar
김민수 committed
88
89


김민수's avatar
수정2    
김민수 committed
90
            {/* </div> */}
김민수's avatar
김민수 committed
91
92
93
94
95
96
97
        </>

    )
}

export default Home;