Skip to content

Commit

Permalink
Merge branch 'master' into zamir/VAN-1837/fix_tpa_skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
zainab-amir authored Mar 6, 2024
2 parents 6b08fc3 + 6695fb6 commit 380c7c4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
11 changes: 7 additions & 4 deletions src/register/RegistrationPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,15 @@ const RegistrationPage = (props) => {

if (simplifyRegistrationExpVariation === SIMPLIFIED_REGISTRATION_VARIATION
&& simplifiedRegisterPageStep === FIRST_STEP) {
const payload = { ...formFields };
// We dont want to validate username since it is in second step of registration
delete payload.username;
// We don't want to validate username and country since these are in the second step of registration
const { username, ...formFieldsPayload } = formFields;
const { country, ...configurableFormFieldsPayload } = configurableFormFields;
const { country: countryDescription, ...fieldDescriptionsPayload } = fieldDescriptions;

const { isValid, fieldErrors } = isFormValid(
payload, errors, configurableFormFields, fieldDescriptions, formatMessage,
formFieldsPayload, errors, configurableFormFieldsPayload, fieldDescriptionsPayload, formatMessage,
);

setErrors(prevErrors => ({
...prevErrors,
...fieldErrors,
Expand Down
6 changes: 4 additions & 2 deletions src/register/data/optimizelyExperiment/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export const SIMPLIFIED_REGISTRATION_VARIATION = 'simplified-register-page';
export const FIRST_STEP = 'first-step';
export const SECOND_STEP = 'second-step';

export const SIMPLIFIED_REGISTER_PAGE_SECOND_STEP_FIELDS = ['username', 'tos_and_honor_code', 'honor_code'];
export const SIMPLIFIED_REGISTER_PAGE_SECOND_STEP_FIELDS = ['username', 'country'];
export const SIMPLIFIED_REGISTER_PAGE_COMMON_FIELDS = ['tos_and_honor_code', 'honor_code'];

const SIMPLIFY_REGISTRATION_EXP_PAGE = 'authn_register_page';

Expand Down Expand Up @@ -45,7 +46,8 @@ export const shouldDisplayFieldInExperiment = (fieldName, expVariation, register
!expVariation || expVariation === NOT_INITIALIZED || expVariation === DEFAULT_VARIATION
|| (expVariation === SIMPLIFIED_REGISTRATION_VARIATION
&& (
(registerPageStep === FIRST_STEP && fieldName !== 'username')
SIMPLIFIED_REGISTER_PAGE_COMMON_FIELDS.includes(fieldName)
|| (registerPageStep === FIRST_STEP && !SIMPLIFIED_REGISTER_PAGE_SECOND_STEP_FIELDS.includes(fieldName))
|| (registerPageStep === SECOND_STEP && SIMPLIFIED_REGISTER_PAGE_SECOND_STEP_FIELDS.includes(fieldName))
))
);
Expand Down
2 changes: 1 addition & 1 deletion src/register/data/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const reducer = (state = defaultState, action = {}) => {
};
case BACKUP_REGISTRATION_DATA.BEGIN:
return {
...defaultState,
...state,
usernameSuggestions: state.usernameSuggestions,
registrationFormData: { ...action.payload },
userPipelineDataLoaded: state.userPipelineDataLoaded,
Expand Down
2 changes: 1 addition & 1 deletion src/register/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const isFormValid = (
}

Object.keys(fieldDescriptions).forEach(key => {
if (key === 'country' && !configurableFormFields.country.displayValue) {
if (key === 'country' && !configurableFormFields?.country?.displayValue) {
fieldErrors[key] = formatMessage(messages['empty.country.field.error']);
} else if (!configurableFormFields[key]) {
fieldErrors[key] = fieldDescriptions[key].error_message;
Expand Down
5 changes: 3 additions & 2 deletions src/register/messages.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ const messages = defineMessages({
},
'simplify.registration.username.guideline.content': {
id: 'simplify.registration.username.guideline.content',
defaultMessage: 'To finalize your registration, please create a public username that will '
+ 'identify you in your course communication forums. The username cannot be changed.',
defaultMessage: 'To finalize your registration, please confirm your country of residence '
+ 'and create a public username that will identify you in your course communication forums. '
+ 'The username cannot be changed.',
description: 'Guideline content for username field in simplify registration experiment step 2',
},
'simplify.registration.form.submission.error': {
Expand Down

0 comments on commit 380c7c4

Please sign in to comment.