Skip to content

Commit

Permalink
feat/Signup: Implement validations for all fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Diegogagan2587 committed Jul 22, 2024
1 parent a5a2334 commit 91d84d9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/pages/Signup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ const Signup = () => {
const userStatus = useSelector((state) => state.user.status);
const successMessage = useSelector((state) => state.user.details.status.message);
const errorMessage = useSelector((state) => state.user.details.status.error);
const [ validationError, setValidationError ] = useState('');
const [userData, setUserData] = useState({
name: '',
email: '',
password: '',
});
const handleSignup = () => {
dispatch(registerUser(userData));
if(userData.name && userData.email && userData.password){
dispatch(registerUser(userData));
} else {
setValidationError('Please fill in all fields');
}
};

useEffect(() => {
Expand Down Expand Up @@ -58,6 +63,7 @@ const Signup = () => {
{userStatus === 'loading' && <Loading />}
{errorMessage && <div className="error">{errorMessage}</div>}
{successMessage && <div className="error">{successMessage}</div>}
{validationError && <div className="error">{validationError}</div>}
</div>
</AuthContainer>
);
Expand Down

0 comments on commit 91d84d9

Please sign in to comment.