Skip to content

Commit

Permalink
feat: add work experience field
Browse files Browse the repository at this point in the history
  • Loading branch information
attiyaIshaque committed Jan 10, 2024
1 parent b7181d5 commit 819d671
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/account-settings/AccountSettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
GENDER_OPTIONS,
COUNTRY_WITH_STATES,
COPPA_COMPLIANCE_YEAR,
WORK_EXPERIENCE_OPTIONS,
getStatesList,
} from './data/constants';
import { fetchSiteLanguages } from './site-language';
Expand Down Expand Up @@ -142,6 +143,10 @@ class AccountSettingsPage extends React.Component {
value: key,
label: this.props.intl.formatMessage(messages[`account.settings.field.gender.options.${key || 'empty'}`]),
})),
workExperienceOptions : WORK_EXPERIENCE_OPTIONS.map(key => ({

Check failure on line 146 in src/account-settings/AccountSettingsPage.jsx

View workflow job for this annotation

GitHub Actions / tests (lint)

Extra space after key 'workExperienceOptions'
value: key,
label: this.props.intl.formatMessage(messages[`account.settings.field.work.experience.options.${key || 'empty'}`]),
})),
}));

handleEditableFieldChange = (name, value) => {
Expand Down Expand Up @@ -469,11 +474,12 @@ class AccountSettingsPage extends React.Component {
yearOfBirthOptions,
educationLevelOptions,
genderOptions,
workExperienceOptions

Check failure on line 477 in src/account-settings/AccountSettingsPage.jsx

View workflow job for this annotation

GitHub Actions / tests (lint)

Missing trailing comma
} = this.getLocalizedOptions(this.context.locale, this.props.formValues.country);

// Show State field only if the country is US (could include Canada later)
const showState = this.props.formValues.country === COUNTRY_WITH_STATES;

console.log("values", this.props.formValues)

Check warning on line 482 in src/account-settings/AccountSettingsPage.jsx

View workflow job for this annotation

GitHub Actions / tests (lint)

Unexpected console statement

Check failure on line 482 in src/account-settings/AccountSettingsPage.jsx

View workflow job for this annotation

GitHub Actions / tests (lint)

Strings must use singlequote

Check failure on line 482 in src/account-settings/AccountSettingsPage.jsx

View workflow job for this annotation

GitHub Actions / tests (lint)

Missing semicolon
const { verifiedName } = this.props;

const timeZoneOptions = this.getLocalizedTimeZoneOptions(
Expand Down Expand Up @@ -679,6 +685,15 @@ class AccountSettingsPage extends React.Component {
emptyLabel={this.props.intl.formatMessage(messages['account.settings.field.gender.empty'])}
{...editableFieldProps}
/>
<EditableSelectField
name="work_experience"
type="select"
value={this.props.formValues.extended_profile.find(profile => profile.field_name === 'work_experience')?.field_value}

Check failure on line 691 in src/account-settings/AccountSettingsPage.jsx

View workflow job for this annotation

GitHub Actions / tests (lint)

'formValues.extended_profile' is missing in props validation

Check failure on line 691 in src/account-settings/AccountSettingsPage.jsx

View workflow job for this annotation

GitHub Actions / tests (lint)

'formValues.extended_profile.find' is missing in props validation
options={workExperienceOptions}
label={this.props.intl.formatMessage(messages['account.settings.field.work.experience'])}
emptyLabel={this.props.intl.formatMessage(messages['account.settings.field.work.experience.empty'])}
{...editableFieldProps}
/>
<EditableSelectField
name="language_proficiencies"
type="select"
Expand Down Expand Up @@ -850,6 +865,7 @@ AccountSettingsPage.propTypes = {
country: PropTypes.string,
level_of_education: PropTypes.string,
gender: PropTypes.string,
work_experience: PropTypes.string,
language_proficiencies: PropTypes.string,
pending_name_change: PropTypes.string,
phone_number: PropTypes.string,
Expand Down
70 changes: 70 additions & 0 deletions src/account-settings/AccountSettingsPage.messages.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,76 @@ const messages = defineMessages({
defaultMessage: 'Notifications',
description: 'Label for Notifications',
},
'account.settings.field.work.experience': {
id: 'account.settings.work.experience',
defaultMessage: 'Work Experience',
description: 'Label for account settings Work experience field.',
},
'account.settings.field.work.experience.empty': {

Check failure on line 578 in src/account-settings/AccountSettingsPage.messages.jsx

View workflow job for this annotation

GitHub Actions / tests (lint)

Expected indentation of 2 spaces but found 3
id: 'account.settings.field.work.experience.empty',
defaultMessage: 'Add work experience',
description: 'Placeholder for empty account settings work experience field.',
},
'account.settings.field.work.experience.options.empty': {
id: 'account.settings.field.work.experience.options.empty',
defaultMessage: 'Select work experience',
description: 'Placeholder for the work experience levels dropdown.',
},
'account.settings.field.work.experience.options.0': {
id: 'account.settings.field.work.experience.options.0',
defaultMessage: "0",

Check failure on line 590 in src/account-settings/AccountSettingsPage.messages.jsx

View workflow job for this annotation

GitHub Actions / tests (lint)

Strings must use singlequote
description: 'The label for account settings work experience option.',
},
'account.settings.field.work.experience.options.1': {
id: 'account.settings.field.work.experience.options.1',
defaultMessage: "1",

Check failure on line 595 in src/account-settings/AccountSettingsPage.messages.jsx

View workflow job for this annotation

GitHub Actions / tests (lint)

Strings must use singlequote
description: 'The label for account settings work experience option.',
},
'account.settings.field.work.experience.options.2': {
id: 'account.settings.field.work.experience.options.2',
defaultMessage: "2",

Check failure on line 600 in src/account-settings/AccountSettingsPage.messages.jsx

View workflow job for this annotation

GitHub Actions / tests (lint)

Strings must use singlequote
description: 'The label for account settings work experience option.',
},
'account.settings.field.work.experience.options.3': {
id: 'account.settings.field.work.experience.options.3',
defaultMessage: "3",
description: 'The label for account settings work experience option.',
},
'account.settings.field.work.experience.options.4': {
id: 'account.settings.field.work.experience.options.4',
defaultMessage: "4",
description: 'The label for account settings work experience option.',
},
'account.settings.field.work.experience.options.5': {
id: 'account.settings.field.work.experience.options.5',
defaultMessage: "5",
description: 'The label for account settings work experience option.',
},
'account.settings.field.work.experience.options.6': {
id: 'account.settings.field.work.experience.options.6',
defaultMessage: "6",
description: 'The label for account settings work experience option.',
},
'account.settings.field.work.experience.options.7': {
id: 'account.settings.field.work.experience.options.7',
defaultMessage: "7",
description: 'The label for account settings work experience option.',
},
'account.settings.field.work.experience.options.8': {
id: 'account.settings.field.work.experience.options.8',
defaultMessage: "8",
description: 'The label for account settings work experience option.',
},
'account.settings.field.work.experience.options.9': {
id: 'account.settings.field.work.experience.options.9',
defaultMessage: "9",
description: 'The label for account settings work experience option.',
},
'account.settings.field.work.experience.options.10+': {
id: 'account.settings.field.work.experience.options.10+',
defaultMessage: "10+",
description: 'The label for account settings work experience option.',
},
});

export default messages;
16 changes: 16 additions & 0 deletions src/account-settings/data/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ export const GENDER_OPTIONS = [
'm',
'o',
];
export const WORK_EXPERIENCE_OPTIONS = [
'',
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'10+',


]

export const COUNTRY_WITH_STATES = 'US';

Expand Down
16 changes: 15 additions & 1 deletion src/account-settings/data/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,21 @@ const formValuesSelector = createSelector(
Object.entries(values).forEach(([name, value]) => {
if (typeof value === 'boolean') {
formValues[name] = chooseFormValue(drafts[name], value);
} else {
}
else if (typeof value === 'object' && name === 'extended_profile' && value !== null && Object.keys(drafts).length !== 0 ) {

const draftFieldName = Object.keys(drafts)[0];
const extendedProfile = value;

const index = extendedProfile.findIndex((profile) => profile.field_name === draftFieldName);

if (index !== -1) {
extendedProfile[index].field_value = drafts[draftFieldName];
formValues[name] = extendedProfile;
}

}
else {
formValues[name] = chooseFormValue(drafts[name], value) || '';
}
});
Expand Down

0 comments on commit 819d671

Please sign in to comment.