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

6
7

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

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

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

JeongYeonwoo's avatar
updated    
JeongYeonwoo committed
36
37
    }

38
39
    return (
        <>
JeongYeonwoo's avatar
JeongYeonwoo committed
40

JeongYeonwoo's avatar
updated    
JeongYeonwoo committed
41
            {done ? <Redirect to='/quiz' /> : ''}
JeongYeonwoo's avatar
JeongYeonwoo committed
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
            {/* <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> */}

            <h1 className="h-3 mb-5 mx-3 text-center bg-danger py-2">
                KOREA UNIVERSITY
            </h1>
            
            <form className="d-flex justify-content-center">

                <div className="table table-bordered" style={{width: "400px" }}>

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

                        <label for="inputPassword">
                            비밀번호<input type='password' className="ml-3 inputBox" onChange={handleChangepassword} placeholder="Password"/>
                        </label>
                        <div className="form-group for login">
                            <label for="inputLogin" className="d-flex justify-content-center">
                                <button className="mt-4 btn btn-dark" onClick={handleClick}>Login</button>
                            </label>
                        </div>
                    </div>
                </div>
            </form>

{/* 
            <div className="container">
                <div className="row justify-content-center mb-5 mt-5">
                    <div className="col-md-4"></div>
                    <div className="col-md-4"> </div>
                    <div className="col-md-4"></div>
                </div>
                <div className="row text-center p-3">
                    <div className="col-md-4"></div>
                    <div className="col-md-4">이름입력<input className="ml-2 inputBox" onChange={handleChangename} /></div>
                    <div className="col-md-4"></div>
                </div>

                <div className="row text-center">
                    <div className="col-md-4"></div>
                    <div className="col-md-4">비밀번호<input type='password' className="ml-2 inputBox" onChange={handleChangepassword} /></div>
                    <div className="col-md-4"></div>
                </div>
                <div className="row text-center">
                    <div className="col-md-4"></div>
                    <div className="col-md-4"><button className="mt-4 btn btn-dark" onClick={handleClick}>Login</button></div>
                    <div className="col-md-4"></div>
                </div>


JeongYeonwoo's avatar
JeongYeonwoo committed
103
            </div>
JeongYeonwoo's avatar
JeongYeonwoo committed
104
105
106
 */}


JeongYeonwoo's avatar
JeongYeonwoo committed
107
            {/* 
JeongYeonwoo's avatar
JeongYeonwoo committed
108
            <div className="d-flex justify-content-center ">
JeongYeonwoo's avatar
updated    
JeongYeonwoo committed
109

JeongYeonwoo's avatar
JeongYeonwoo committed
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
136
137
138
139
140
141
142
143
144
145
                <table className="table table-bordered dark-table" style={{ width: "400px" }}>
                    <thead className="text-center">
                        <tr style={{ height: "0 px" }}>정보 입력</tr>
                    </thead>
                    <tbody className="text-center">
                        <tr>
                            <td>이름 입력<input className="ml-2 inputBox" onChange={handleChangename} /></td>
                        </tr>
                        <tr>
                            <td>비밀번호<input type='password' className="ml-2 inputBox" onChange={handleChangepassword} /></td>
                        </tr>
                        <tr>
                            <td><button className="mt-4 btn btn-dark" onClick={handleClick}>Login</button></td>
                        </tr>
                    </tbody>
                </table>
            </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>
                </div> */}

            {/* localStorage를 사용해야는지 localstorage를 사용해야하는지 */}
            {/* </div> */}


            {/* </div> */}
146
        </>
JeongYeonwoo's avatar
JeongYeonwoo committed
147

JeongYeonwoo's avatar
updated    
JeongYeonwoo committed
148
149
    )
}
JeongYeonwoo's avatar
JeongYeonwoo committed
150

151
export default Home;
JeongYeonwoo's avatar
JeongYeonwoo committed
152