import bg from './img_study.jpg'
import React, { useState } from 'react'
import { Redirect } from 'react-router-dom';
import './Home.css'

function Home() {
    const [name, setName] = useState('')
    const [done, setDone] = useState(false)

    const handleChange = (event) => {
        setName(event.target.value)
    }

    function checking(event) {
        if (!name) {
            alert('이름을 입력하세요')
        }
        else {
            alert('입력하신 이름은' + name + '입니다.')
            localStorage.setItem('name', name)
            setDone(true)
        }
    }

    return (
        <>
            {done ? <Redirect to='/quiz' /> : ''}
            <div style={{ backgroundImage: 'url(' + bg + ')', backgroundColor: "grey", backgroundSize: "100%", width: "100%", height: "880px", backgroundRepeat: 'no-repeat' }}>
                {/* <div className="Main"></div> */}

                <div className="container">
                    <div className="text-center">
                        이름을 입력하세요
                        <input className="inputBox" onChange={handleChange} />
                        <div className='Box2'>
                            <button className="btn btn-dark" onClick={checking}>Quiz Start !</button>
                        </div>
                    </div>
                    {/* localStorage를 사용해야는지 localstorage를 사용해야하는지 */}
                </div>

                <div>계산수학</div>


            </div>
        </>



    )

}
export default Home;

