Skip to content

Commit

Permalink
Removed redundant formType state property
Browse files Browse the repository at this point in the history
  • Loading branch information
AamirL1011 committed Mar 31, 2021
1 parent b3d1f6b commit 795b17e
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/Components/Authentication/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "./Login.css";


const initialFormState = {
email: "", password: "", authCode: "", resetCode: "", formType: "signIn"
email: "", password: "", authCode: "", resetCode: ""
}

function Login(props) {
Expand All @@ -19,9 +19,6 @@ function Login(props) {
const [newVerification, setNewVerification] = useState(false);
const [loading, setLoading] = useState(false);

useEffect(() => {
updateFormState(() => ({...formState, formType: loginState}));
}, [loginState])

useEffect(() => {
async function retrieveUser() {
Expand All @@ -48,7 +45,6 @@ function Login(props) {
updateFormState(() => ({...formState, [e.target.name]: e.target.value}))
}

const {formType} = formState;

async function signUp() {
try {
Expand Down Expand Up @@ -169,14 +165,14 @@ function Login(props) {
<Grid.Row style={{padding: "0px"}}>
<Grid.Column verticalAlign={"middle"} textAlign={"left"}>
<div className={"login-wrapper-top"}>
<span className={"login-wrapper-top-header"}>{(formType === "signIn")? <span>Sign In</span> : (formType === "signUp")? <span>Sign Up</span> : (formType === "confirmSignUp")? <span>Verify Account</span> : (formType === "forgotPassword" || formType === "resetPassword")? <span>Password Reset</span> : <span>Welcome</span>}</span>
<span className={"login-wrapper-top-header"}>{(loginState === "signIn")? <span>Sign In</span> : (loginState === "signUp")? <span>Sign Up</span> : (loginState === "confirmSignUp")? <span>Verify Account</span> : (loginState === "forgotPassword" || loginState === "resetPassword")? <span>Password Reset</span> : <span>Welcome</span>}</span>
</div>
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column verticalAlign={"middle"} textAlign={"center"}>
{
formType === "signIn" && (
loginState === "signIn" && (
<Grid>
<Grid.Row style={{paddingTop: "3px", paddingBottom: "0px"}}>
<Grid.Column verticalAlign={"middle"} textAlign={"center"}>
Expand Down Expand Up @@ -237,7 +233,7 @@ function Login(props) {
)
}
{
formType === "forgotPassword" && (
loginState === "forgotPassword" && (
<Grid>
<Grid.Row style={{paddingBottom: "0px"}}>
<Grid.Column verticalAlign={"middle"} textAlign={"center"} style={{paddingLeft: "30px", paddingRight: "30px"}}>
Expand Down Expand Up @@ -270,7 +266,7 @@ function Login(props) {
)
}
{
formType === "resetPassword" && (
loginState === "resetPassword" && (
<Grid>
<Grid.Row style={{paddingBottom: "0px"}}>
<Grid.Column verticalAlign={"middle"} textAlign={"center"} style={{paddingLeft: "30px", paddingRight: "30px"}}>
Expand Down Expand Up @@ -319,7 +315,7 @@ function Login(props) {
)
}
{
formType === "signUp" && (
loginState === "signUp" && (
<Grid>
<Grid.Row style={{paddingBottom: "0px"}}>
<Grid.Column verticalAlign={"middle"} textAlign={"center"} style={{paddingLeft: "30px", paddingRight: "30px"}}>
Expand Down Expand Up @@ -362,7 +358,7 @@ function Login(props) {
)
}
{
formType === "confirmSignUp" && (
loginState === "confirmSignUp" && (
<Grid>
<Grid.Row style={{paddingTop: "5px", paddingBottom: "0px"}}>
<Grid.Column verticalAlign={"middle"} textAlign={"center"} >
Expand Down

0 comments on commit 795b17e

Please sign in to comment.