Revert "fix: exception at progressive profiling page (#727)" (#728)

This reverts commit d06290642b.
This commit is contained in:
Syed Sajjad Hussain Shah
2023-01-06 15:23:50 +05:00
committed by GitHub
parent 7dee21eb72
commit 72510047d8
5 changed files with 14 additions and 70 deletions

View File

@@ -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({}),
};

View File

@@ -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,

View File

@@ -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',
},
);
});
});