Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 56: "Please make sure any specific error or warning should show" #57

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/Pages/Signup/Signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Cookies from 'js-cookie';
import { useNavigate } from 'react-router-dom';
import { login } from '../../Reducers/userReducer';


const RegisterValidationSchema = Yup.object().shape({
firstName: Yup.string()
.min(2, 'Too Short!')
Expand Down Expand Up @@ -49,6 +50,7 @@ function Signup() {
const [genderError, setGenderError] = useState('');
const [branchError, setBranchError] = useState('');

const [isSubmitted, setIsSubmitted] = useState(false);
const [registerError, setRegisterError] = useState('');
const [registerSuccess, setRegisterSuccess] = useState('');
const [registerLoading, setRegisterLoading] = useState(false);
Expand Down Expand Up @@ -199,6 +201,14 @@ function Signup() {
});
};

useEffect(()=>{
if( isSubmitted == true )
setTimeout(() => {
navigate("/");
}, 1000);

},[isSubmitted])

console.log(register);
return (
<Registeration>
Expand Down Expand Up @@ -229,8 +239,11 @@ function Signup() {
validateGender(values.gender);
validateBirthDay(values.bYear, values.bMonth, values.bDay);
registerUser(values);
setIsSubmitted(true)
// alert(JSON.stringify(values, null, 2));
}}
>

{(formik) => (
<Form className="register_form" onSubmit={formik.handleSubmit}>
<div className="reg_line">
Expand Down Expand Up @@ -407,10 +420,12 @@ function Signup() {
)}
</Formik>
{registerLoading && <Loading loading={registerLoading} />}
{registerError && <ErrorRegister>{registerError}</ErrorRegister>}
{registerError && <ErrorRegister>{registerError}</ErrorRegister>}
{registerSuccess && (
<SuccessRegister>{registerSuccess}</SuccessRegister>
)}

{ isSubmitted && <SignupConfirm>{ "Your account has been successfully created"}</SignupConfirm >}
</div>
</Registeration>
);
Expand Down Expand Up @@ -446,6 +461,17 @@ const MessageError = styled.div`
box-shadow: 0 1px 2px var(--shadow-1);
`;

const SignupConfirm = styled.div`
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #b1ede6;
padding: 30px 20px 30px 20px;
border: 1px solid #cccccc;
border-radius: 5px;
`;

const Registeration = styled.div`
display: flex;
flex-direction: column;
Expand Down