From 26d2b50859d5775c99d31a18f6b77c57a480246e Mon Sep 17 00:00:00 2001 From: Andy Shultz Date: Thu, 26 Aug 2021 09:31:47 -0400 Subject: [PATCH 1/4] feat: update verified name display to look at status not is_verified bool note that there is no way to trigger pending display currently without code manipulation because the verified name endpoint in use only returns approved names --- src/account-settings/AccountSettingsPage.jsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/account-settings/AccountSettingsPage.jsx b/src/account-settings/AccountSettingsPage.jsx index 966ff97..2821c2f 100644 --- a/src/account-settings/AccountSettingsPage.jsx +++ b/src/account-settings/AccountSettingsPage.jsx @@ -208,8 +208,8 @@ class AccountSettingsPage extends React.Component { ); } - renderVerifiedNameSuccessMessage() { - if (this.props.formValues.verified_name_enabled && this.props.formValues.is_verified) { + renderVerifiedNameSuccessMessage(showVerifiedApproved) { + if (showVerifiedApproved) { return (
- {this.renderVerifiedNameSuccessMessage()} + {this.renderVerifiedNameSuccessMessage(showVerifiedApproved)}

{this.props.intl.formatMessage(messages['account.settings.section.account.information'])} @@ -336,12 +337,12 @@ class AccountSettingsPage extends React.Component { (
{this.props.intl.formatMessage(messages['account.settings.field.name.verified'])} - {this.props.formValues.is_verified && } + {showVerifiedApproved && }
) } helpText={ - this.props.formValues.is_verified + showVerifiedApproved ? this.props.intl.formatMessage(messages['account.settings.field.name.verified.help.text.verified']) : this.props.intl.formatMessage(messages['account.settings.field.name.verified.help.text.pending']) } @@ -625,7 +626,7 @@ AccountSettingsPage.propTypes = { state: PropTypes.string, shouldDisplayDemographicsSection: PropTypes.bool, verified_name: PropTypes.string, - is_verified: PropTypes.bool, + status: PropTypes.string, verified_name_enabled: PropTypes.bool, }).isRequired, siteLanguage: PropTypes.shape({ From 0d9e6f8b875af9a1053b9dc2bfdb4b7528f5ba5f Mon Sep 17 00:00:00 2001 From: Andy Shultz Date: Thu, 26 Aug 2021 09:53:56 -0400 Subject: [PATCH 2/4] feat: do not smear verified name fields into general fields smooshing an unattached field name status into the general set of fields is a recipie for future bugs --- src/account-settings/AccountSettingsPage.jsx | 11 +++++------ src/account-settings/data/service.js | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/account-settings/AccountSettingsPage.jsx b/src/account-settings/AccountSettingsPage.jsx index 2821c2f..2716964 100644 --- a/src/account-settings/AccountSettingsPage.jsx +++ b/src/account-settings/AccountSettingsPage.jsx @@ -279,8 +279,9 @@ class AccountSettingsPage extends React.Component { // Show State field only if the country is US (could include Canada later) const showState = this.props.formValues.country === COUNTRY_WITH_STATES; - const showVerifiedName = this.props.formValues.verified_name_enabled && this.props.formValues.verified_name; - const showVerifiedApproved = showVerifiedName && this.props.formValues.status === 'approved'; + const showVerifiedName = this.props.formValues.verifiedName + && this.props.formValues.verifiedName.verified_name_enabled; + const showVerifiedApproved = showVerifiedName && this.props.formValues.verifiedName.status === 'approved'; const timeZoneOptions = this.getLocalizedTimeZoneOptions( this.props.timeZoneOptions, @@ -332,7 +333,7 @@ class AccountSettingsPage extends React.Component { @@ -625,9 +626,7 @@ AccountSettingsPage.propTypes = { }), state: PropTypes.string, shouldDisplayDemographicsSection: PropTypes.bool, - verified_name: PropTypes.string, - status: PropTypes.string, - verified_name_enabled: PropTypes.bool, + verifiedName: PropTypes.object, }).isRequired, siteLanguage: PropTypes.shape({ previousValue: PropTypes.string, diff --git a/src/account-settings/data/service.js b/src/account-settings/data/service.js index 1313611..21370b9 100644 --- a/src/account-settings/data/service.js +++ b/src/account-settings/data/service.js @@ -228,7 +228,7 @@ export async function getSettings(username, userRoles, userId) { shouldDisplayDemographicsSection: shouldDisplayDemographicsQuestionsResponse, ...demographics, demographicsOptions, - ...verifiedName, + verifiedName, }; } From efa682092fc6f683e5a15511eb7def0eae56166d Mon Sep 17 00:00:00 2001 From: Andy Shultz Date: Thu, 26 Aug 2021 11:09:33 -0400 Subject: [PATCH 3/4] feat: specify shape of verified name object at least the fields that we are interested in --- src/account-settings/AccountSettingsPage.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/account-settings/AccountSettingsPage.jsx b/src/account-settings/AccountSettingsPage.jsx index 2716964..61d1330 100644 --- a/src/account-settings/AccountSettingsPage.jsx +++ b/src/account-settings/AccountSettingsPage.jsx @@ -626,7 +626,11 @@ AccountSettingsPage.propTypes = { }), state: PropTypes.string, shouldDisplayDemographicsSection: PropTypes.bool, - verifiedName: PropTypes.object, + verifiedName: PropTypes.shape({ + verified_name: PropTypes.string, + status: PropTypes.string, + verified_name_enabled: PropTypes.bool, + }), }).isRequired, siteLanguage: PropTypes.shape({ previousValue: PropTypes.string, From 0dc1df07d4238e24fb21eea5de122a2afa13520b Mon Sep 17 00:00:00 2001 From: Andy Shultz Date: Thu, 26 Aug 2021 11:13:43 -0400 Subject: [PATCH 4/4] feat: gate render verified name success message outside of function this frees the function from doing logic we've already done elsewhere --- src/account-settings/AccountSettingsPage.jsx | 26 +++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/account-settings/AccountSettingsPage.jsx b/src/account-settings/AccountSettingsPage.jsx index 61d1330..398beb4 100644 --- a/src/account-settings/AccountSettingsPage.jsx +++ b/src/account-settings/AccountSettingsPage.jsx @@ -208,20 +208,16 @@ class AccountSettingsPage extends React.Component { ); } - renderVerifiedNameSuccessMessage(showVerifiedApproved) { - if (showVerifiedApproved) { - return ( - - ); - } - - return null; + renderVerifiedNameSuccessMessage() { + return ( + + ); } renderEmptyStaticFieldMessage() { @@ -294,7 +290,7 @@ class AccountSettingsPage extends React.Component { return ( <>
- {this.renderVerifiedNameSuccessMessage(showVerifiedApproved)} + {showVerifiedApproved && this.renderVerifiedNameSuccessMessage()}

{this.props.intl.formatMessage(messages['account.settings.section.account.information'])}