-
Notifications
You must be signed in to change notification settings - Fork 126
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
Conversation
819d671
to
9ca4c25
Compare
Codecov ReportAttention:
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. |
9ca4c25
to
9395fd2
Compare
be331a9
to
5850743
Compare
const { verifiedName } = this.props; | ||
|
||
const hasWorkExperience = !!this.props.formValues?.extended_profile?.find(profile => profile.field_name === 'work_experience'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename:
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
'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.', | ||
}, |
There was a problem hiding this comment.
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.
{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} | ||
/> | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: fix formatting
{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 }, |
There was a problem hiding this comment.
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
payload: { formId, commitValues: false, extendedProfile: null }, | |
payload: { formId, commitValues: false, extendedProfile: {} }, |
src/account-settings/data/actions.js
Outdated
@@ -77,9 +77,9 @@ export const beginNameChange = (formId) => ({ | |||
}); | |||
// SAVE SETTINGS ACTIONS | |||
|
|||
export const saveSettings = (formId, commitValues) => ({ | |||
export const saveSettings = (formId, commitValues, extendedProfile = null) => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const saveSettings = (formId, commitValues, extendedProfile = null) => ({ | |
export const saveSettings = (formId, commitValues, extendedProfile = {}) => ({ |
5850743
to
8ecdedc
Compare
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
and the field will be shown of auth account settings. You can add or edit the field.