Skip to content

Commit

Permalink
Add useLogin hook to Login component
Browse files Browse the repository at this point in the history
  • Loading branch information
PawanAK committed Jan 19, 2024
1 parent 2969ff5 commit 203ffc3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions frontend/src/pages/Login.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { useState } from "react";
import { useLogin } from "../hooks/useLogin";

const Login = () => {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const { login, error, isLoading } = useLogin();

const handleSubmit = async (e) => {
e.preventDefault();

console.log(email, password);
await login(email, password);
};

return (
Expand All @@ -28,7 +30,8 @@ const Login = () => {
value={password}
/>

<button>Login</button>
<button disabled={isLoading}>Login</button>
{error && <div className="error">{error}</div>}
</form>
);
};
Expand Down

0 comments on commit 203ffc3

Please sign in to comment.