From ac4e15001184841587858208775add46a16fa3b5 Mon Sep 17 00:00:00 2001 From: Akhilbisht798 Date: Mon, 11 Sep 2023 01:08:47 +0530 Subject: [PATCH 1/6] changed EmailVerificationVeiw Component to functional component --- .../User/pages/EmailVerificationView.jsx | 84 +++++++++---------- 1 file changed, 39 insertions(+), 45 deletions(-) diff --git a/client/modules/User/pages/EmailVerificationView.jsx b/client/modules/User/pages/EmailVerificationView.jsx index 42960062b4..4516cb57c5 100644 --- a/client/modules/User/pages/EmailVerificationView.jsx +++ b/client/modules/User/pages/EmailVerificationView.jsx @@ -1,5 +1,5 @@ import PropTypes from 'prop-types'; -import React from 'react'; +import React, { useEffect } from 'react'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import { withTranslation } from 'react-i18next'; @@ -9,57 +9,51 @@ import { verifyEmailConfirmation } from '../actions'; import RootPage from '../../../components/RootPage'; import Nav from '../../IDE/components/Header/Nav'; -class EmailVerificationView extends React.Component { - static defaultProps = { - emailVerificationTokenState: null - }; +const EmailVerificationView = (props) => { + const { emailVerificationTokenState, location, t } = props; - componentWillMount() { - const verificationToken = this.verificationToken(); - if (verificationToken != null) { - this.props.verifyEmailConfirmation(verificationToken); - } - } - - verificationToken = () => { - const { location } = this.props; + const verificationTokenFromLocation = () => { const searchParams = new URLSearchParams(location.search); return searchParams.get('t'); }; - render() { - let status = null; - const { emailVerificationTokenState } = this.props; - - if (this.verificationToken() == null) { - status =

{this.props.t('EmailVerificationView.InvalidTokenNull')}

; - } else if (emailVerificationTokenState === 'checking') { - status =

{this.props.t('EmailVerificationView.Checking')}

; - } else if (emailVerificationTokenState === 'verified') { - status =

{this.props.t('EmailVerificationView.Verified')}

; - setTimeout(() => browserHistory.push('/'), 1000); - } else if (emailVerificationTokenState === 'invalid') { - status =

{this.props.t('EmailVerificationView.InvalidState')}

; + useEffect(() => { + const verificationToken = verificationTokenFromLocation(); + if (verificationToken != null) { + props.verifyEmailConfirmation(verificationToken); } + }, [location, props]); - return ( - -