-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make the signin route handler working and improved routing of the app
- Loading branch information
1 parent
da24051
commit a68b7d9
Showing
3 changed files
with
35 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,23 +3,50 @@ import { Button } from "../components/Button"; | |
import { Heading } from "../components/Heading"; | ||
import { InputBox } from "../components/InputBox"; | ||
import { SubHeading } from "../components/SubHeading"; | ||
import axios from "axios"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { useState } from "react"; | ||
|
||
const Signin = () => { | ||
const [username, setUsername] = useState(""); | ||
const [password, setPassword] = useState(""); | ||
const navigate = useNavigate(); | ||
return ( | ||
<div className="bg-slate-300 h-screen flex justify-center"> | ||
<div className="flex flex-col justify-center"> | ||
<div className="rounded-lg bg-white w-80 text-center p-2 h-max px-4"> | ||
<Heading label={"Sign in"} /> | ||
<SubHeading label={"Enter your credentials to access your account"} /> | ||
<InputBox placeholder="[email protected]" label={"Email"} /> | ||
<InputBox placeholder="123456" label={"Password"} /> | ||
<InputBox | ||
placeholder="[email protected]" | ||
label={"Email"} | ||
Change={(e) => setUsername(e.target.value)} | ||
/> | ||
<InputBox | ||
placeholder="123456" | ||
label={"Password"} | ||
Change={(e) => setPassword(e.target.value)} | ||
/> | ||
<div className="pt-4"> | ||
<Button label={"Sign in"} /> | ||
<Button | ||
label={"Sign in"} | ||
Click={async () => { | ||
const response = await axios.post( | ||
"http://localhost:3000/api/v1/user/signin", | ||
{ | ||
username: username, | ||
password: password, | ||
} | ||
); | ||
localStorage.setItem("token", response.data.token); | ||
navigate("/dashboard"); | ||
}} | ||
></Button> | ||
</div> | ||
<BottomWarning | ||
label={"Don't have an account?"} | ||
buttonText={"Sign up"} | ||
to={"/signup"} | ||
to={"/"} | ||
/> | ||
</div> | ||
</div> | ||
|
a68b7d9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make the signin route handler working and improved the routing of the app