import { useState } from "react"
import { createProfile } from "../endpoints/endpoints";
export default function CreateProfile() {
const [user, setUser] = useState({})
const handleChange = (e) => {
setUser({...user, [e.target.name]: e.target.value});
}
const handleSubmit = (e) => {
e.preventDefault();
createProfile(user)
.then(res => {
window.location.href="/login";
})
.catch(e => console.log(e))
}
return (
<>
<h1>Create Profile</h1>
<form>
<label>Enter name:</label>
<input type="text" name="name" onChange={handleChange} />
<br/>
<label>Enter role:</label>
<input type="text" name="role" onChange={handleChange} />
<br/>
<label>Enter username:</label>
<input type="text" name="username" onChange={handleChange} />
<br/>
<label>Enter password:</label>
<input type="password" name="password" onChange={handleChange} />
<br/>
<button onClick={handleSubmit}>Create</button>
</form>
</>
)
}