From bb6f79288b8b80ea77017f9cc58aae1be7689b44 Mon Sep 17 00:00:00 2001 From: muhammadadeeltajamul Date: Fri, 20 Dec 2024 10:59:52 +0500 Subject: [PATCH] refactor: moved unable to delete into component --- src/account-settings/AccountSettingsPage.jsx | 15 +- .../AccountSettingsPage.messages.jsx | 5 - .../delete-account/DeleteAccount.jsx | 131 ++++++++++-------- .../delete-account/messages.js | 5 + 4 files changed, 80 insertions(+), 76 deletions(-) diff --git a/src/account-settings/AccountSettingsPage.jsx b/src/account-settings/AccountSettingsPage.jsx index 94c589821..1d1b813da 100644 --- a/src/account-settings/AccountSettingsPage.jsx +++ b/src/account-settings/AccountSettingsPage.jsx @@ -813,16 +813,11 @@ class AccountSettingsPage extends React.Component { {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 a1726b3a7..765378216 100644 --- a/src/account-settings/AccountSettingsPage.messages.jsx +++ b/src/account-settings/AccountSettingsPage.messages.jsx @@ -1,11 +1,6 @@ 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/account-settings/delete-account/DeleteAccount.jsx b/src/account-settings/delete-account/DeleteAccount.jsx index 6c04cb989..51d3fc78a 100644 --- a/src/account-settings/delete-account/DeleteAccount.jsx +++ b/src/account-settings/delete-account/DeleteAccount.jsx @@ -76,67 +76,74 @@ export class DeleteAccount extends React.Component {

{intl.formatMessage(messages['account.settings.delete.account.header'])}

-

{intl.formatMessage(messages['account.settings.delete.account.subheader'])}

-

- {intl.formatMessage( - messages['account.settings.delete.account.text.1'], - { siteName: getConfig().SITE_NAME }, - )} -

-

- {intl.formatMessage( - messages[deleteAccountText2MessageKey], - { siteName: getConfig().SITE_NAME }, - )} -

-

- -

-

- {intl.formatMessage( - messages['account.settings.delete.account.text.warning'], - { siteName: getConfig().SITE_NAME }, - )} -

-

- - {intl.formatMessage(messages['account.settings.delete.account.text.change.instead'])} - -

-

- -

- - {isVerifiedAccount ? null : ( - - )} - - {hasLinkedTPA ? ( - - ) : null} - - - - + { + this.props.canDeleteAccount ? ( + <> +

{intl.formatMessage(messages['account.settings.delete.account.subheader'])}

+

+ {intl.formatMessage( + messages['account.settings.delete.account.text.1'], + { siteName: getConfig().SITE_NAME }, + )} +

+

+ {intl.formatMessage( + messages[deleteAccountText2MessageKey], + { siteName: getConfig().SITE_NAME }, + )} +

+

+ +

+

+ {intl.formatMessage( + messages['account.settings.delete.account.text.warning'], + { siteName: getConfig().SITE_NAME }, + )} +

+

+ + {intl.formatMessage(messages['account.settings.delete.account.text.change.instead'])} + +

+

+ +

+ {isVerifiedAccount ? null : ( + + )} + {hasLinkedTPA ? ( + + ) : null} + + + + + + ) : ( +

{intl.formatMessage(messages['account.settings.cannot.delete.account.text'])}

+ ) + } + ); } @@ -152,6 +159,7 @@ DeleteAccount.propTypes = { errorType: PropTypes.oneOf(['empty-password', 'server']), hasLinkedTPA: PropTypes.bool, isVerifiedAccount: PropTypes.bool, + canDeleteAccount: PropTypes.bool, intl: intlShape.isRequired, }; @@ -160,6 +168,7 @@ DeleteAccount.defaultProps = { isVerifiedAccount: true, status: null, errorType: null, + canDeleteAccount: true, }; // Assume we're part of the accountSettings state. diff --git a/src/account-settings/delete-account/messages.js b/src/account-settings/delete-account/messages.js index 3654e2300..8f10f2845 100644 --- a/src/account-settings/delete-account/messages.js +++ b/src/account-settings/delete-account/messages.js @@ -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 note that, for legal and regulatory compliance purposes, account deletion is currently unavailable.', + description: 'This text is visible when user is not allowed to delete account', + }, 'account.settings.delete.account.header': { id: 'account.settings.delete.account.header', defaultMessage: 'Delete My Account',