diff --git a/src/account-settings/BetaLanguageBanner.jsx b/src/account-settings/BetaLanguageBanner.jsx index e309857..b73a820 100644 --- a/src/account-settings/BetaLanguageBanner.jsx +++ b/src/account-settings/BetaLanguageBanner.jsx @@ -1,7 +1,7 @@ -import React from 'react'; +import { useContext } from 'react'; import PropTypes from 'prop-types'; import { AppContext } from '@edx/frontend-platform/react'; -import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; +import { useIntl } from '@edx/frontend-platform/i18n'; import { connect } from 'react-redux'; import { Button, Hyperlink } from '@openedx/paragon'; @@ -11,18 +11,11 @@ import { saveSettings } from './data/actions'; import { TRANSIFEX_LANGUAGE_BASE_URL } from './data/constants'; import Alert from './Alert'; -class BetaLanguageBanner extends React.Component { - getSiteLanguageEntry(languageCode) { - return this.props.siteLanguageList.filter(l => l.code === languageCode)[0]; - } +const BetaLanguageBanner = ({ siteLanguage = null, siteLanguageList }) => { + const intl = useIntl(); + const { locale } = useContext(AppContext); - /** - * Returns a link to the Transifex URL where contributors can provide translations. - * This code is tightly coupled to how Transifex chooses to design its URLs. - */ - getTransifexLink(languageCode) { - return TRANSIFEX_LANGUAGE_BASE_URL + this.getTransifexURLPath(languageCode); - } + const getSiteLanguageEntry = (languageCode) => siteLanguageList.filter(l => l.code === languageCode)[0]; /** * Returns the URL path that Transifex chooses to use for its language sub-pages. @@ -34,67 +27,70 @@ class BetaLanguageBanner extends React.Component { * For short language codes, it returns the code as is. * example: fr -> fr */ - getTransifexURLPath(languageCode) { + const getTransifexURLPath = (languageCode) => { const tokenizedCode = languageCode.split('-'); if (tokenizedCode.length > 1) { return `${tokenizedCode[0]}_${tokenizedCode[1].toUpperCase()}`; } return tokenizedCode[0]; - } - - handleRevertLanguage = () => { - const previousSiteLanguage = this.props.siteLanguage.previousValue; - this.props.saveSettings('siteLanguage', previousSiteLanguage); }; - render() { - const savedLanguage = this.getSiteLanguageEntry(this.context.locale); - if (!savedLanguage) { - return null; - } - const isSavedLanguageReleased = savedLanguage.released === true; - const noPreviousLanguageSet = this.props.siteLanguage.previousValue === null; - if (isSavedLanguageReleased || noPreviousLanguageSet) { - return null; - } + /** + * Returns a link to the Transifex URL where contributors can provide translations. + * This code is tightly coupled to how Transifex chooses to design its URLs. + */ + const getTransifexLink = (languageCode) => TRANSIFEX_LANGUAGE_BASE_URL + getTransifexURLPath(languageCode); - const previousLanguage = this.getSiteLanguageEntry(this.props.siteLanguage.previousValue); - return ( -
- {this.props.intl.formatMessage(messages['account.settings.banner.beta.language'], { - beta_language: savedLanguage.name, - })} -
-+ {intl.formatMessage(messages['account.settings.banner.beta.language'], { + beta_language: savedLanguage.name, + })} +
+- {intl.formatMessage( - messages[deleteAccountModalText2MessageKey], - { siteName: getConfig().SITE_NAME }, - )} -
-
-
+ {intl.formatMessage( + messages[deleteAccountModalText2MessageKey], + { siteName: getConfig().SITE_NAME }, + )} +
+
+
{intl.formatMessage(messages['account.settings.delete.account.subheader'])}
@@ -109,7 +106,7 @@ export class DeleteAccount extends React.Component {