Home.js 4.32 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
import React, { useState} from 'react'
baesangjune's avatar
baesangjune committed
4
import { Redirect } from 'react-router-dom';
Jiwon Yoon's avatar
Jiwon Yoon committed
5

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

baesangjune's avatar
baesangjune committed
11
12
    const [admin, setAdmin] = useState(false);

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

baesangjune's avatar
baesangjune committed
20
    function checking() {
baesangjune's avatar
baesangjune committed
21
22
23
        if (!name) {
            alert('이름을 입력하세요')
        }
baesangjune's avatar
baesangjune committed
24
25
26
        else if (!password) {
            alert('비밀번호를 입력하세요')
        }
baesangjune's avatar
baesangjune committed
27
28
29
30
31
32
33
        else if (name === 'admin' && password === '0001') {
            console.log('done')

            return (setAdmin(true)

            )
        }
baesangjune's avatar
baesangjune committed
34
35
36
        else if (password !== '0319') {
            alert('유효한 비밀번호를 입력하세요')
        }
baesangjune's avatar
baesangjune committed
37
        else {
baesangjune's avatar
baesangjune committed
38
            alert('입력하신 이름은 ' + name + '입니다.')
baesangjune's avatar
baesangjune committed
39
            localStorage.setItem('name', name)
baesangjune's avatar
baesangjune committed
40
            localStorage.setItem('password', password)
baesangjune's avatar
baesangjune committed
41
42
            setDone(true)
        }
baesangjune's avatar
baesangjune committed
43

baesangjune's avatar
baesangjune committed
44
45
    }

baesangjune's avatar
baesangjune committed
46
47
48



Jiwon Yoon's avatar
Jiwon Yoon committed
49
    return (
baesangjune's avatar
baesangjune committed
50
        <>
baesangjune's avatar
baesangjune committed
51
            {admin ? <Redirect to='/admin' /> : ''}
baesangjune's avatar
baesangjune committed
52

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

baesangjune's avatar
baesangjune committed
61

baesangjune's avatar
end    
baesangjune committed
62
63
64
65
66
67
68
69
70
71
72
73
74
75
            <div className="d-flex justify-content-center ">

                <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>
baesangjune's avatar
baesangjune committed
76
77
                            <td>
                                <button className="mt-4 btn btn-dark" onClick={checking}>Login</button></td>
baesangjune's avatar
end    
baesangjune committed
78
                        </tr>
baesangjune's avatar
baesangjune committed
79
                    
baesangjune's avatar
end    
baesangjune committed
80
81
82
83
                    </tbody>
                </table>
            </div>

baesangjune's avatar
baesangjune committed
84
            {/* <div className="Box" style={{ border: 'solid', position: 'absolute', top: "300px", left: "68%"}} > */}
baesangjune's avatar
end    
baesangjune committed
85
            {/* <div className="Name" style={{boxShadow: '5px 5px 5px 5px gray', border: 'solid', fontSize: '30px', position: "absolute", top: "300px", left: "68%" }}>
baesangjune's avatar
baesangjune committed
86
87
88
89
90
91
92
93
94
                    이름(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
end    
baesangjune committed
95
                </div> */}
baesangjune's avatar
home    
baesangjune committed
96

baesangjune's avatar
end    
baesangjune committed
97
            {/* localStorage를 사용해야는지 localstorage를 사용해야하는지 */}
baesangjune's avatar
baesangjune committed
98
            {/* </div> */}
baesangjune's avatar
0    
baesangjune committed
99

baesangjune's avatar
baesangjune committed
100
101

            {/* </div> */}
baesangjune's avatar
baesangjune committed
102
        </>
baesangjune's avatar
home    
baesangjune committed
103

Jiwon Yoon's avatar
Jiwon Yoon committed
104
105
    )
}
baesangjune's avatar
baesangjune committed
106

baesangjune's avatar
baesangjune committed
107
export default Home;
Jiwon Yoon's avatar
Jiwon Yoon committed
108