Fix optional fields issue. (#152)

This commit is contained in:
Waheed Ahmed
2021-02-20 10:24:08 +05:00
committed by GitHub
parent 484c895ff3
commit d03ec8397a
3 changed files with 5 additions and 5 deletions

View File

@@ -23,4 +23,4 @@ AUTHN_MINIMAL_HEADER=true
LOGIN_ISSUE_SUPPORT_LINK=''
TOS_AND_HONOR_CODE='http://localhost:18000/honor'
PRIVACY_POLICY='http://localhost:18000/privacy'
REGISTRATION_OPTIONAL_FIELDS='gender goals level_of_education year_of_birth'
REGISTRATION_OPTIONAL_FIELDS='gender,goals,level_of_education,year_of_birth'

View File

@@ -122,7 +122,7 @@ class RegistrationPage extends React.Component {
getOptionalFields() {
const values = {};
const optionalFields = getConfig().REGISTRATION_OPTIONAL_FIELDS.split(' ');
const optionalFields = getConfig().REGISTRATION_OPTIONAL_FIELDS.split(',');
optionalFields.forEach((key) => {
values[camelCase(key)] = this.state[camelCase(key)];
});
@@ -171,7 +171,7 @@ class RegistrationPage extends React.Component {
}
// Since optional fields are not validated we can add it to payload after required fields
// have been validated. This will save us unwanted calls to validateInput()
const optionalFields = getConfig().REGISTRATION_OPTIONAL_FIELDS.split(' ');
const optionalFields = getConfig().REGISTRATION_OPTIONAL_FIELDS.split(',');
optionalFields.forEach((key) => {
const stateKey = camelCase(key);
if (this.state[stateKey]) {

View File

@@ -27,7 +27,7 @@ const mockStore = configureStore();
describe('RegistrationPageTests', () => {
mergeConfig({
PRIVACY_POLICY: 'http://privacy-policy.com',
REGISTRATION_OPTIONAL_FIELDS: 'gender goals level_of_education year_of_birth',
REGISTRATION_OPTIONAL_FIELDS: 'gender,goals,level_of_education,year_of_birth',
TOS_AND_HONOR_CODE: 'http://tos-and-honot-code.com',
});
@@ -153,7 +153,7 @@ describe('RegistrationPageTests', () => {
expect(registrationPage.find('input#optional').length).toEqual(0);
mergeConfig({
REGISTRATION_OPTIONAL_FIELDS: 'gender goals level_of_education year_of_birth',
REGISTRATION_OPTIONAL_FIELDS: 'gender,goals,level_of_education,year_of_birth',
});
registrationPage = mount(reduxWrapper(<IntlRegistrationPage {...props} />));