From 4174ee1508850bac8bfa497454264a2d95699309 Mon Sep 17 00:00:00 2001 From: muhammadadeeltajamul Date: Wed, 18 Dec 2024 17:03:35 +0500 Subject: [PATCH] feat: added feature to hide delete button for countries --- .env | 1 + .env.development | 1 + .env.test | 1 + src/account-settings/AccountSettingsPage.jsx | 25 +++++++++++++------ .../AccountSettingsPage.messages.jsx | 5 ++++ src/index.jsx | 1 + 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/.env b/.env index ff9614e38..402b8965a 100644 --- a/.env +++ b/.env @@ -33,3 +33,4 @@ MFE_CONFIG_API_URL= PASSWORD_RESET_SUPPORT_LINK='' LEARNER_FEEDBACK_URL='' SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT='https://help.edx.org/edxlearner/s/article/How-do-I-link-or-unlink-my-edX-account-to-a-social-media-account' +COUNTRIES_WITH_DELETE_ACCOUNT_DISABLED='[]' diff --git a/.env.development b/.env.development index 8e866555f..7abc30d6c 100644 --- a/.env.development +++ b/.env.development @@ -34,3 +34,4 @@ MFE_CONFIG_API_URL= PASSWORD_RESET_SUPPORT_LINK='mailto:support@example.com' LEARNER_FEEDBACK_URL='' SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT='https://help.edx.org/edxlearner/s/article/How-do-I-link-or-unlink-my-edX-account-to-a-social-media-account' +COUNTRIES_WITH_DELETE_ACCOUNT_DISABLED='[]' diff --git a/.env.test b/.env.test index ab43a461e..df5caf4a9 100644 --- a/.env.test +++ b/.env.test @@ -31,3 +31,4 @@ APP_ID= MFE_CONFIG_API_URL= LEARNER_FEEDBACK_URL='' SUPPORT_URL_TO_UNLINK_SOCIAL_MEDIA_ACCOUNT='https://help.edx.org/edxlearner/s/article/How-do-I-link-or-unlink-my-edX-account-to-a-social-media-account' +COUNTRIES_WITH_DELETE_ACCOUNT_DISABLED='[]' diff --git a/src/account-settings/AccountSettingsPage.jsx b/src/account-settings/AccountSettingsPage.jsx index 352f53e76..94c589821 100644 --- a/src/account-settings/AccountSettingsPage.jsx +++ b/src/account-settings/AccountSettingsPage.jsx @@ -155,6 +155,11 @@ class AccountSettingsPage extends React.Component { })), })); + canDeleteAccount = () => { + const { committedValues } = this.props; + return !getConfig().COUNTRIES_WITH_DELETE_ACCOUNT_DISABLED.includes(committedValues.country); + }; + removeDisabledCountries = (countryList) => { const { disabledCountries, committedValues } = this.props; @@ -806,16 +811,20 @@ class AccountSettingsPage extends React.Component { - {getConfig().ENABLE_ACCOUNT_DELETION - && ( + {getConfig().ENABLE_ACCOUNT_DELETION && (
- + { + this.canDeleteAccount() + ? ( + + ) + : this.props.intl.formatMessage(messages['account.settings.cannot.delete.account.text']) + }
- )} - + )} ); } diff --git a/src/account-settings/AccountSettingsPage.messages.jsx b/src/account-settings/AccountSettingsPage.messages.jsx index 765378216..a1726b3a7 100644 --- a/src/account-settings/AccountSettingsPage.messages.jsx +++ b/src/account-settings/AccountSettingsPage.messages.jsx @@ -1,6 +1,11 @@ import { defineMessages } from '@edx/frontend-platform/i18n'; const messages = defineMessages({ + 'account.settings.cannot.delete.account.text': { + id: 'account.settings.cannot.delete.account.text', + defaultMessage: 'Please contact support to delete your account.', + description: 'This text is visible when useris not allowed to delete account', + }, 'account.settings.page.heading': { id: 'account.settings.page.heading', defaultMessage: 'Account Settings', diff --git a/src/index.jsx b/src/index.jsx index 520486ea4..4c23e2a82 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -69,6 +69,7 @@ initialize({ SHOW_EMAIL_CHANNEL: process.env.SHOW_EMAIL_CHANNEL || 'false', ENABLE_COPPA_COMPLIANCE: (process.env.ENABLE_COPPA_COMPLIANCE || false), ENABLE_ACCOUNT_DELETION: (process.env.ENABLE_ACCOUNT_DELETION !== 'false'), + COUNTRIES_WITH_DELETE_ACCOUNT_DISABLED: JSON.parse(process.env.COUNTRIES_WITH_DELETE_ACCOUNT_DISABLED || '[]'), ENABLE_DOB_UPDATE: (process.env.ENABLE_DOB_UPDATE || false), MARKETING_EMAILS_OPT_IN: (process.env.MARKETING_EMAILS_OPT_IN || false), PASSWORD_RESET_SUPPORT_LINK: process.env.PASSWORD_RESET_SUPPORT_LINK,