generated from goitacademy/react-homework-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4429c4
commit 4f45ff0
Showing
11 changed files
with
97 additions
and
5 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
6 changes: 3 additions & 3 deletions
6
src/components/ContactForm/ContactForm.jsx → ...mponents/Form/ContactForm/ContactForm.jsx
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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
|
||
export const LoginForm = () => { | ||
const dispatch = useDispatch(); | ||
const errorLogin = useSelector(state => state.error); // Dont FORGET !!! import selector | ||
|
||
const handleSubmit = e => { | ||
e.preventDefault(); | ||
const form = e.currentTarget; | ||
|
||
dispatch( | ||
logIn({ | ||
email: form.elements.email.value, | ||
password: form.elements.password.value, | ||
}) | ||
); | ||
form.reset(); | ||
}; | ||
|
||
return ( | ||
<> | ||
{errorLogin && <div>Error login</div>} | ||
<form autoComplete="off" onSubmit={handleSubmit}> | ||
<label> | ||
<input type="email" name="email" required /> | ||
</label> | ||
<label> | ||
Password | ||
<input type="password" name="password" required /> | ||
</label> | ||
<button type="submit">Log In</button> | ||
</form> | ||
</> | ||
); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { useDispatch } from 'react-redux'; | ||
|
||
export const RegisterForm = () => { | ||
const dispatch = useDispatch(); | ||
|
||
const handleSubmit = e => { | ||
e.preventDefault(); | ||
const form = e.currentTarget; | ||
|
||
dispatch( | ||
register({ | ||
name: form.elements.name.value, | ||
email: form.elements.email.value, | ||
password: form.elements.password.value, | ||
}) | ||
); | ||
form.reset(); | ||
}; | ||
|
||
return ( | ||
<form autoComplete="off" onSubmit={handleSubmit}> | ||
<label> | ||
Username | ||
<input | ||
type="text" | ||
name="name" | ||
required | ||
placeholder="Nick Name" | ||
minLength={3} | ||
/> | ||
</label> | ||
<label> | ||
<input | ||
type="email" | ||
name="email" | ||
required | ||
placeholder="your-mail@gmail.com" | ||
/> | ||
</label> | ||
<label> | ||
Password | ||
<input | ||
type="password" | ||
name="password" | ||
minLength={7} | ||
required | ||
placeholder="*******" | ||
/> | ||
</label> | ||
<button type="submit">Register</button> | ||
</form> | ||
); | ||
}; |
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