diff --git a/src/common-components/RedirectLogistration.jsx b/src/common-components/RedirectLogistration.jsx index 6c332603..1adf7a91 100644 --- a/src/common-components/RedirectLogistration.jsx +++ b/src/common-components/RedirectLogistration.jsx @@ -9,7 +9,7 @@ import { setCookie } from '../data/utils'; function RedirectLogistration(props) { const { - finishAuthUrl, redirectUrl, redirectToProgressiveProfilingPage, success, optionalFields, + finishAuthUrl, redirectUrl, redirectToWelcomePage, success, optionalFields, } = props; let finalRedirectUrl = ''; @@ -25,7 +25,7 @@ function RedirectLogistration(props) { } // Redirect to Progressive Profiling after successful registration - if (redirectToProgressiveProfilingPage) { + if (redirectToWelcomePage) { // TODO: Do we still need this cookie? setCookie('van-504-returning-user', true); const registrationResult = { redirectUrl: finalRedirectUrl, success }; @@ -50,7 +50,7 @@ RedirectLogistration.defaultProps = { finishAuthUrl: null, success: false, redirectUrl: '', - redirectToProgressiveProfilingPage: false, + redirectToWelcomePage: false, optionalFields: {}, }; @@ -58,7 +58,7 @@ RedirectLogistration.propTypes = { finishAuthUrl: PropTypes.string, success: PropTypes.bool, redirectUrl: PropTypes.string, - redirectToProgressiveProfilingPage: PropTypes.bool, + redirectToWelcomePage: PropTypes.bool, optionalFields: PropTypes.shape({}), }; diff --git a/src/common-components/data/reducers.js b/src/common-components/data/reducers.js index 7574e9ed..139a0b3e 100644 --- a/src/common-components/data/reducers.js +++ b/src/common-components/data/reducers.js @@ -23,21 +23,15 @@ const reducer = (state = defaultState, action) => { ...state, thirdPartyAuthApiStatus: PENDING_STATE, }; - case THIRD_PARTY_AUTH_CONTEXT.SUCCESS: { - const extendedProfile = action.payload.optionalFields.extended_profile; - const extendedProfileArray = extendedProfile && JSON.parse(extendedProfile.replaceAll('\'', '"')); + case THIRD_PARTY_AUTH_CONTEXT.SUCCESS: return { ...state, - extendedProfile: extendedProfileArray, + extendedProfile: action.payload.fieldDescriptions.extended_profile, fieldDescriptions: action.payload.fieldDescriptions.fields, - optionalFields: { - ...action.payload.optionalFields, - extended_profile: extendedProfileArray, - }, + optionalFields: action.payload.optionalFields, thirdPartyAuthContext: action.payload.thirdPartyAuthContext, thirdPartyAuthApiStatus: COMPLETE_STATE, }; - } case THIRD_PARTY_AUTH_CONTEXT.FAILURE: return { ...state, diff --git a/src/common-components/data/tests/reducers.test.js b/src/common-components/data/tests/reducers.test.js deleted file mode 100644 index ea525d3f..00000000 --- a/src/common-components/data/tests/reducers.test.js +++ /dev/null @@ -1,49 +0,0 @@ -import { THIRD_PARTY_AUTH_CONTEXT } from '../actions'; -import reducer from '../reducers'; - -describe('common components reducer', () => { - it('should convert extended profile from string to array', () => { - const state = { - extendedProfile: [], - fieldDescriptions: {}, - optionalFields: {}, - thirdPartyAuthApiStatus: null, - thirdPartyAuthContext: { - currentProvider: null, - finishAuthUrl: null, - countryCode: null, - providers: [], - secondaryProviders: [], - pipelineUserDetails: null, - }, - }; - const fieldDescriptions = { - fields: [], - extended_profile: "['state', 'profession']", - }; - const optionalFields = { - fields: [], - extended_profile: "['state', 'profession']", - }; - const thirdPartyAuthContext = { ...state.thirdPartyAuthContext }; - const action = { - type: THIRD_PARTY_AUTH_CONTEXT.SUCCESS, - payload: { fieldDescriptions, optionalFields, thirdPartyAuthContext }, - }; - - expect( - reducer(state, action), - ).toEqual( - { - ...state, - extendedProfile: ['state', 'profession'], - fieldDescriptions: [], - optionalFields: { - fields: [], - extended_profile: ['state', 'profession'], - }, - thirdPartyAuthApiStatus: 'complete', - }, - ); - }); -}); diff --git a/src/progressive-profiling/ProgressiveProfiling.jsx b/src/progressive-profiling/ProgressiveProfiling.jsx index 944e8156..cd92f9f2 100644 --- a/src/progressive-profiling/ProgressiveProfiling.jsx +++ b/src/progressive-profiling/ProgressiveProfiling.jsx @@ -46,13 +46,11 @@ const ProgressiveProfiling = (props) => { useEffect(() => { configureAuth(AxiosJwtAuthService, { loggingService: getLoggingService(), config: getConfig() }); - ensureAuthenticatedUser(DASHBOARD_URL) - .then(() => { - hydrateAuthenticatedUser().then(() => { - setReady(true); - }); - }) - .catch(() => {}); + ensureAuthenticatedUser(DASHBOARD_URL).then(() => { + hydrateAuthenticatedUser().then(() => { + setReady(true); + }); + }); if (props.location.state && props.location.state.registrationResult) { setRegistrationResult(props.location.state.registrationResult); @@ -196,6 +194,7 @@ const ProgressiveProfiling = (props) => { }; ProgressiveProfiling.propTypes = { + // eslint-disable-next-line react/no-unused-prop-types formRenderState: PropTypes.string.isRequired, intl: intlShape.isRequired, location: PropTypes.shape({ diff --git a/src/register/RegistrationPage.jsx b/src/register/RegistrationPage.jsx index 19a060b2..1377ba5c 100644 --- a/src/register/RegistrationPage.jsx +++ b/src/register/RegistrationPage.jsx @@ -461,7 +461,7 @@ const RegistrationPage = (props) => { redirectUrl={registrationResult.redirectUrl} finishAuthUrl={finishAuthUrl} optionalFields={optionalFields} - redirectToProgressiveProfilingPage={ + redirectToWelcomePage={ getConfig().ENABLE_PROGRESSIVE_PROFILING_ON_AUTHN && Object.keys(optionalFields).length !== 0 } />