import { useState } from "react"


function Urlap() {
    let [inputs, setInputs] = useState({})
    let esemenykezeles = (event) => {
        let name = event.target.name
        let value = event.target.value

        setInputs(values => ({...values, [name]: value}))
    }

    return (
        <form onSubmit={() => feldolgozas(inputs.userName, inputs.userAge)}>
            <label htmlFor="name">Add meg a neved:</label><br />
            <input type="text" name="userName" id="name" value={inputs.userName} onChange={esemenykezeles}/><br />
            <label htmlFor="age">Add meg a korodat:</label><br />
            <input type="number" name="userAge" id="age" value={inputs.userAge} onChange={esemenykezeles}/>
            <input type="submit" value="Szia" />
        </form>
    )
}


function feldolgozas(name, age) {
    alert(`A beírt név és kor: ${name} ${age}`)
}


export default Urlap