From efaa83a1bcaeeba300b1228af520aab6f3f844a5 Mon Sep 17 00:00:00 2001 From: Mubbshar Anwar <78487564+mubbsharanwar@users.noreply.github.com> Date: Tue, 11 Jun 2024 12:01:30 +0500 Subject: [PATCH] feat: hard code fields on frontend (#1256) * feat: hard code fields hard code configurable fields on frontend which includes country field on register page & level of education & gender field on progressive profiling VAN-1971 * fix: fix secondary provider null name issue --- .../InstitutionLogistration.jsx | 2 +- src/common-components/data/constants.js | 79 +++++++++++++++++++ src/common-components/data/sagas.js | 13 ++- src/config/index.js | 1 + 4 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 src/common-components/data/constants.js diff --git a/src/common-components/InstitutionLogistration.jsx b/src/common-components/InstitutionLogistration.jsx index b773bc6e..ba26cf3c 100644 --- a/src/common-components/InstitutionLogistration.jsx +++ b/src/common-components/InstitutionLogistration.jsx @@ -60,7 +60,7 @@ const InstitutionLogistration = props => { className="btn nav-item p-0 mb-1 institutions--provider-link" destination={lmsBaseUrl + provider.loginUrl} > - {provider.name} + {provider?.name} diff --git a/src/common-components/data/constants.js b/src/common-components/data/constants.js new file mode 100644 index 00000000..4f9ec72c --- /dev/null +++ b/src/common-components/data/constants.js @@ -0,0 +1,79 @@ +export const registerFields = { + fields: { + country: { + name: 'country', + error_message: 'Select your country or region of residence', + }, + honor_code: { + name: 'honor_code', + type: 'tos_and_honor_code', + error_message: '', + }, + }, +}; + +export const progressiveProfilingFields = { + extended_profile: [], + fields: { + level_of_education: { + name: 'level_of_education', + type: 'select', + label: 'Highest level of education completed', + error_message: '', + options: [ + [ + 'p', + 'Doctorate', + ], + [ + 'm', + "Master's or professional degree", + ], + [ + 'b', + "Bachelor's degree", + ], + [ + 'a', + 'Associate degree', + ], + [ + 'hs', + 'Secondary/high school', + ], + [ + 'jhs', + 'Junior secondary/junior high/middle school', + ], + [ + 'none', + 'No formal education', + ], + [ + 'other', + 'Other education', + ], + ], + }, + gender: { + name: 'gender', + type: 'select', + label: 'Gender', + error_message: '', + options: [ + [ + 'm', + 'Male', + ], + [ + 'f', + 'Female', + ], + [ + 'o', + 'Other/Prefer Not to Say', + ], + ], + }, + }, +}; diff --git a/src/common-components/data/sagas.js b/src/common-components/data/sagas.js index ffe0be37..65105866 100644 --- a/src/common-components/data/sagas.js +++ b/src/common-components/data/sagas.js @@ -1,3 +1,4 @@ +import { getConfig } from '@edx/frontend-platform'; import { logError } from '@edx/frontend-platform/logging'; import { call, put, takeEvery } from 'redux-saga/effects'; @@ -7,6 +8,7 @@ import { getThirdPartyAuthContextSuccess, THIRD_PARTY_AUTH_CONTEXT, } from './actions'; +import { progressiveProfilingFields, registerFields } from './constants'; import { getThirdPartyAuthContext, } from './service'; @@ -20,7 +22,16 @@ export function* fetchThirdPartyAuthContext(action) { } = yield call(getThirdPartyAuthContext, action.payload.urlParams); yield put(setCountryFromThirdPartyAuthContext(thirdPartyAuthContext.countryCode)); - yield put(getThirdPartyAuthContextSuccess(fieldDescriptions, optionalFields, thirdPartyAuthContext)); + // hard code country field, level of education and gender fields + if (getConfig().ENABLE_HARD_CODE_OPTIONAL_FIELDS) { + yield put(getThirdPartyAuthContextSuccess( + registerFields, + progressiveProfilingFields, + thirdPartyAuthContext, + )); + } else { + yield put(getThirdPartyAuthContextSuccess(fieldDescriptions, optionalFields, thirdPartyAuthContext)); + } } catch (e) { yield put(getThirdPartyAuthContextFailure()); logError(e); diff --git a/src/config/index.js b/src/config/index.js index 78cea882..6399b549 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -11,6 +11,7 @@ const configuration = { MARKETING_EMAILS_OPT_IN: process.env.MARKETING_EMAILS_OPT_IN || '', SHOW_CONFIGURABLE_EDX_FIELDS: process.env.SHOW_CONFIGURABLE_EDX_FIELDS || false, SHOW_REGISTRATION_LINKS: process.env.SHOW_REGISTRATION_LINKS !== 'false', + ENABLE_HARD_CODE_OPTIONAL_FIELDS: process.env.ENABLE_HARD_CODE_OPTIONAL_FIELDS || false, ENABLE_IMAGE_LAYOUT: process.env.ENABLE_IMAGE_LAYOUT || false, // Links ACTIVATION_EMAIL_SUPPORT_LINK: process.env.ACTIVATION_EMAIL_SUPPORT_LINK || null,