From d9bec106cd77ac6b2ff489d06573b75b43f8f86c Mon Sep 17 00:00:00 2001 From: Vu Nguyen Date: Thu, 9 Jul 2020 09:49:54 +0700 Subject: [PATCH] feat: #1917 Remove unused code from register page in dev portal (#2005) --- .../__snapshots__/register.test.tsx.snap | 37 +++++++++++-------- .../register/__tests__/register.test.tsx | 9 +---- .../components/pages/register/register.tsx | 22 +++-------- 3 files changed, 27 insertions(+), 41 deletions(-) diff --git a/packages/developer-portal/src/components/pages/register/__tests__/__snapshots__/register.test.tsx.snap b/packages/developer-portal/src/components/pages/register/__tests__/__snapshots__/register.test.tsx.snap index 3f3ce36783..1fcfcd529d 100644 --- a/packages/developer-portal/src/components/pages/register/__tests__/__snapshots__/register.test.tsx.snap +++ b/packages/developer-portal/src/components/pages/register/__tests__/__snapshots__/register.test.tsx.snap @@ -506,24 +506,29 @@ exports[`Register should match a snapshot 1`] = ` - - +
- - Back to home - - - + + + Login + + + +
+ diff --git a/packages/developer-portal/src/components/pages/register/__tests__/register.test.tsx b/packages/developer-portal/src/components/pages/register/__tests__/register.test.tsx index 6718ee5059..f55ea348b5 100644 --- a/packages/developer-portal/src/components/pages/register/__tests__/register.test.tsx +++ b/packages/developer-portal/src/components/pages/register/__tests__/register.test.tsx @@ -4,7 +4,6 @@ import * as ReactRedux from 'react-redux' import configureStore from 'redux-mock-store' import { Register, onSubmit, onRegisterButtonClick, onDeclineTermsAndConditions, onLoginButtonClick } from '../register' import { developerCreate } from '@/actions/developer' -import { authLogout } from '@/actions/auth' import { DATE_TIME_FORMAT } from '@reapit/elements' import MockDate from 'mockdate' import appState from '@/reducers/__stubs__/app-state' @@ -87,15 +86,9 @@ describe('Register', () => { }) describe('onLoginButtonClick', () => { it('should redirect to developer login page', () => { - const fn = onLoginButtonClick(history, spyDispatch, '') + const fn = onLoginButtonClick(history) fn() expect(history.replace).toBeCalledWith(`${Routes.LOGIN}`) }) - it('should run dispatch logout first and then redirect to developer login page', () => { - const fn = onLoginButtonClick(history, spyDispatch, 'testClientId') - fn() - expect(spyDispatch).toBeCalledWith(authLogout()) - expect(history.replace).toBeCalledWith(`${Routes.LOGIN}`) - }) }) }) diff --git a/packages/developer-portal/src/components/pages/register/register.tsx b/packages/developer-portal/src/components/pages/register/register.tsx index d695b03a0e..1072beab84 100644 --- a/packages/developer-portal/src/components/pages/register/register.tsx +++ b/packages/developer-portal/src/components/pages/register/register.tsx @@ -27,8 +27,6 @@ import TermsAndConditionsModal from '@/components/ui/terms-and-conditions-modal' import Routes from '@/constants/routes' import loginStyles from '@/styles/pages/login.scss?mod' import logoImage from '@/assets/images/reapit-graphic.jpg' -import { selectClientId } from '@/selector/auth' -import { authLogout } from '@/actions/auth' import { formFields } from './form-fields' import { validationSchema } from './validation-schema' @@ -83,11 +81,8 @@ export const onDeclineTermsAndConditions = (setTermsAndConditionsModalVisible: ( } } -export const onLoginButtonClick = (history: History, dispatch: Dispatch, clientId: string) => { +export const onLoginButtonClick = (history: History) => { return () => { - if (clientId) { - dispatch(authLogout()) - } history.replace(Routes.LOGIN) } } @@ -97,7 +92,6 @@ export const Register: React.FunctionComponent = () => { const dispatch = useDispatch() const [visible, setVisible] = React.useState(false) const formState = useSelector(selectDeveloperFormState) - const clientId = useSelector(selectClientId) || '' const isSubmitting = formState === 'SUBMITTING' return ( @@ -110,7 +104,7 @@ export const Register: React.FunctionComponent = () => { title="Success!" buttonText="Login" dataTest="register-success-message" - onButtonClick={onLoginButtonClick(history, dispatch, clientId)} + onButtonClick={onLoginButtonClick(history)} isCenter >
Check your email to confirm your account
@@ -183,15 +177,9 @@ export const Register: React.FunctionComponent = () => { Register - {clientId ? ( - - Back to home - - ) : ( - - Already have an account?Login - - )} + + Already have an account?Login + {formState === 'ERROR' && ( )}