Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add work experience field #971

Merged
merged 1 commit into from
Jan 19, 2024
Merged

feat: add work experience field #971

merged 1 commit into from
Jan 19, 2024

Conversation

attiyaIshaque
Copy link
Contributor

@attiyaIshaque attiyaIshaque commented Jan 10, 2024

Description

I have added a work experience field that will be shown on the front-end account setting page.

Ticket

https://2u-internal.atlassian.net/browse/VAN-1790

How Has This Been Tested?
you can add settings in django admin site configuration like this

"extended_profile_fields": [
        "work_experience"
    ],
    "EXTRA_FIELD_OPTIONS": {
        "work_experience": [
            "0",
            "1",
            "2",
            "3",
            "4",
            "5",
            "6",
            "7",
            "8",
            "9",
            "10+"
        ]
    }

and the field will be shown of auth account settings. You can add or edit the field.

Copy link

codecov bot commented Jan 11, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (11e144d) 46.70% compared to head (8ecdedc) 56.50%.

Files Patch % Lines
src/account-settings/data/sagas.js 0.00% 1 Missing and 1 partial ⚠️
src/account-settings/AccountSettingsPage.jsx 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #971      +/-   ##
==========================================
+ Coverage   46.70%   56.50%   +9.80%     
==========================================
  Files         117      118       +1     
  Lines        2411     2435      +24     
  Branches      640      652      +12     
==========================================
+ Hits         1126     1376     +250     
+ Misses       1211      988     -223     
+ Partials       74       71       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@attiyaIshaque attiyaIshaque marked this pull request as ready for review January 12, 2024 14:46
@attiyaIshaque attiyaIshaque force-pushed the attiya/VAN-1790 branch 4 times, most recently from be331a9 to 5850743 Compare January 17, 2024 15:03
const { verifiedName } = this.props;

const hasWorkExperience = !!this.props.formValues?.extended_profile?.find(profile => profile.field_name === 'work_experience');
Copy link

@zainab-amir zainab-amir Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename:

Suggested change
const hasWorkExperience = !!this.props.formValues?.extended_profile?.find(profile => profile.field_name === 'work_experience');
const showWorkExperience = !!this.props.formValues?.extended_profile?.find(field => field.field_name === 'work_experience');

Change it in handleSubmit too

Comment on lines 588 to 642
'account.settings.field.work.experience.options.0': {
id: 'account.settings.field.work.experience.options.0',
defaultMessage: '0',
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',
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',
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.',
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need these as translation strings because in every language "1" will be translated as "1". Please remove these from here and update code.

Comment on lines 699 to 710
{hasWorkExperience && (
<EditableSelectField
name="work_experience"
type="select"
value={this.props.formValues?.extended_profile?.find(profile => profile.field_name === 'work_experience')?.field_value}
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}
/>
)}
Copy link

@zainab-amir zainab-amir Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: fix formatting

Suggested change
{hasWorkExperience && (
<EditableSelectField
name="work_experience"
type="select"
value={this.props.formValues?.extended_profile?.find(profile => profile.field_name === 'work_experience')?.field_value}
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}
/>
)}
{hasWorkExperience
&& (
<EditableSelectField
name="work_experience"
type="select"
value={this.props.formValues?.extended_profile?.find(profile => profile.field_name === 'work_experience')?.field_value}
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}
/>
)}

@@ -151,7 +151,7 @@ describe('NameChange', () => {
const submitButton = screen.getByText('Choose name');
fireEvent.click(submitButton);
expect(mockDispatch).toHaveBeenCalledWith({
payload: { formId, commitValues: false },
payload: { formId, commitValues: false, extendedProfile: null },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use same default value as you have used in handleSubmit because you check following in Sagas file and it will break with null

Object.keys(extendedProfile).length > 0 

Change default to empty dict

Suggested change
payload: { formId, commitValues: false, extendedProfile: null },
payload: { formId, commitValues: false, extendedProfile: {} },

@@ -77,9 +77,9 @@ export const beginNameChange = (formId) => ({
});
// SAVE SETTINGS ACTIONS

export const saveSettings = (formId, commitValues) => ({
export const saveSettings = (formId, commitValues, extendedProfile = null) => ({

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const saveSettings = (formId, commitValues, extendedProfile = null) => ({
export const saveSettings = (formId, commitValues, extendedProfile = {}) => ({

@attiyaIshaque attiyaIshaque merged commit 594ffe4 into master Jan 19, 2024
9 checks passed
@attiyaIshaque attiyaIshaque deleted the attiya/VAN-1790 branch January 19, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants