Skip to content

Commit

Permalink
create login form and dispatch contact data to login auth operation
Browse files Browse the repository at this point in the history
  • Loading branch information
konstantin-it-lysenko committed Jan 2, 2024
1 parent 9cdd11b commit 330b0f7
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/components/LoginForm/LoginForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { useDispatch } from 'react-redux';
import { logIn } from '../../redux/auth/authOperations';

const LoginForm = () => {
const dispatch = useDispatch();

const handleSubmit = e => {
e.preventDefault();
const form = e.currentTarget;

dispatch(
logIn({
email: form.elements.email.value,
password: form.elements.password.value,
})
);

form.reset();
};

return (
<form onSubmit={handleSubmit} autoComplete="off">
<label>
Email
<input type="text" name="email" />
</label>
<label>
Password
<input type="text" name="password" />
</label>
<button type="submit">Log in</button>
</form>
);
};

export default LoginForm;

0 comments on commit 330b0f7

Please sign in to comment.