import React from "react"
import { useNavigate } from "react-router-dom"
/**
* Challenge: Pass a message from the requireAuth function
* that says "You must log in first." and display that message
* in an <h2> BELOW the <h1>. Give it a classname of "red" for
* some quick styling - (I added the CSS already).
*/
export default function Login() {
const [loginFormData, setLoginFormData] = React.useState({ email: "", password: "" })
function handleSubmit(e) {
e.preventDefault()
console.log(loginFormData)
}
function handleChange(e) {
const { name, value } = e.target
setLoginFormData(prev => ({
...prev,
[name]: value
}))
}
return (
<div className="login-container">
<h1>Sign in to your account</h1>
{/* Warning goes here. Give it a classname="red" */}
<form onSubmit={handleSubmit} className="login-form">
<input
name="email"
onChange={handleChange}
type="email"
placeholder="Email address"
value={loginFormData.email}
/>
<input
name="password"
onChange={handleChange}
type="password"
placeholder="Password"
value={loginFormData.password}
/>
<button>Log in</button>
</form>
</div>
)
}