Skip to content

Commit

Permalink
feat: add signup page
Browse files Browse the repository at this point in the history
  • Loading branch information
giuseppemilicia committed Dec 17, 2022
1 parent c5e279b commit d5f8a9c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function App() {
<Routes>
<Route element={<Layout />}>
<Route index element={<Login />} />
<Route path="/signup" element={<Signup />} />
<Route path="*" element={<Error404 />} />
</Route>
</Routes>
Expand Down
51 changes: 51 additions & 0 deletions src/pages/Signup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import bgLogin from "../assets/bg-login.svg";
import TopBar from "../components/TopBar";
import {NavLink, useNavigate} from "react-router-dom";
import {useDispatch} from "react-redux";
import {useForm} from "react-hook-form";
import {signup} from "../slice/userSlice";

function Signup() {

const dispatch = useDispatch();
const { register, handleSubmit } = useForm();
const navigate = useNavigate();

const onSubmit = (data) => {
dispatch(signup(data));
navigate("/");
};

return (
<div>
<img className="position-absolute top-0 end-0 w-25" src={bgLogin} alt="Background" />
<TopBar title="Create an account"/>
<div className="d-flex justify-content-center w-100">
<form
className="d-flex flex-column col-12 col-md-8 col-lg-6 col-xl-5"
onSubmit={handleSubmit(onSubmit)}
>
<div className="form-group mb-3">
<label htmlFor="fullName">Full name</label>
<input {...register("name")} type="text" className="form-control" id="fullName" placeholder="Enter name" required/>
</div>
<div className="form-group mb-3">
<label htmlFor="email">Email address</label>
<input {...register("email")} type="email" className="form-control" id="email" placeholder="Enter email" required/>
</div>
<div className="form-group mb-3">
<div className="d-flex justify-content-between">
<label htmlFor="password">New Password</label>
<span style={{color: "#46B13D"}}>Strong</span>
</div>
<input {...register("password")} type="password" className="form-control" id="password" placeholder="Enter password" required/>
</div>
<button type="submit" className="btn btn-success align-self-center">Signup</button>
<div className="align-self-center mt-5">Already user? <NavLink to="/">Login</NavLink></div>
</form>
</div>
</div>
);
}

export default Signup;

0 comments on commit d5f8a9c

Please sign in to comment.