Skip to content

Commit

Permalink
make the signin route handler working and improved routing of the app
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishsingla51 committed May 13, 2024
1 parent da24051 commit a68b7d9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
4 changes: 3 additions & 1 deletion backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ app.use(express.json());

app.use("/api/v1", mainRouter);

app.listen(3000);
app.listen(3000, () => {
console.log("Server is running on port 3000");
});
2 changes: 1 addition & 1 deletion frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function App() {
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/send" element={<SendMoney />} />
<Route path="/signin" element={<Signin />} />
<Route path="/signup" element={<Signup />} />
<Route path="/" element={<Signup />} />
</Routes>
</BrowserRouter>
</>
Expand Down
35 changes: 31 additions & 4 deletions frontend/src/pages/Signin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

1 comment on commit a68b7d9

@tanishsingla51
Copy link
Author

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

Please sign in to comment.