feat: update welcome page logic (#947)

This commit is contained in:
Zainab Amir
2023-06-15 17:09:52 +05:00
committed by GitHub
parent 5edcee9eb9
commit cd6c1c0e42
2 changed files with 12 additions and 3 deletions

View File

@@ -30,7 +30,11 @@ import { RedirectLogistration } from '../common-components';
import { getThirdPartyAuthContext } from '../common-components/data/actions';
import { optionalFieldsSelector } from '../common-components/data/selectors';
import {
DEFAULT_REDIRECT_URL, DEFAULT_STATE, FAILURE_STATE, PENDING_STATE,
COMPLETE_STATE,
DEFAULT_REDIRECT_URL,
DEFAULT_STATE,
FAILURE_STATE,
PENDING_STATE,
} from '../data/constants';
import { getAllPossibleQueryParams, isRegistrationEmbedded } from '../data/utils';
import { FormFieldRenderer } from '../field-renderer';
@@ -91,14 +95,14 @@ const ProgressiveProfiling = (props) => {
}, [registrationEmbedded, getFieldDataFromBackend]);
useEffect(() => {
if (Object.keys(welcomePageContext).length !== 0) {
if (registrationEmbedded && Object.keys(welcomePageContext).includes('fields')) {
setFormFieldData({
fields: welcomePageContext.fields,
extendedProfile: welcomePageContext.extended_profile,
});
setRegistrationResult({ redirectUrl: getConfig().SEARCH_CATALOG_URL });
}
}, [welcomePageContext]);
}, [registrationEmbedded, welcomePageContext]);
useEffect(() => {
if (canViewWelcomePage && authenticatedUser?.userId) {
@@ -128,6 +132,7 @@ const ProgressiveProfiling = (props) => {
if (
!(location.state?.registrationResult || registrationEmbedded)
|| welcomePageContextApiStatus === FAILURE_STATE
|| (welcomePageContextApiStatus === COMPLETE_STATE && !Object.keys(welcomePageContext).includes('fields'))
) {
global.location.assign(DASHBOARD_URL);
return null;

View File

@@ -232,6 +232,10 @@ describe('ProgressiveProfilingTests', () => {
});
describe('Embedded Form Workflow Test', () => {
mergeConfig({
SEARCH_CATALOG_URL: 'http://localhost/search',
});
delete window.location;
window.location = {
assign: jest.fn().mockImplementation((value) => { window.location.href = value; }),