/* globals gettext */ import React from 'react'; import PropTypes from 'prop-types'; import { Button, Icon, StatusAlert } from '@edx/paragon/static'; import StringUtils from 'edx-ui-toolkit/js/utils/string-utils'; import StudentAccountDeletionModal from './StudentAccountDeletionModal'; // eslint-disable-next-line import/prefer-default-export export class StudentAccountDeletion extends React.Component { constructor(props) { super(props); this.closeDeletionModal = this.closeDeletionModal.bind(this); this.loadDeletionModal = this.loadDeletionModal.bind(this); this.state = { deletionModalOpen: false, isActive: props.isActive, socialAuthConnected: this.getConnectedSocialAuth(), }; } getConnectedSocialAuth() { const { socialAccountLinks } = this.props; if (socialAccountLinks && socialAccountLinks.providers) { return socialAccountLinks.providers.reduce((acc, value) => acc || value.connected, false); } return false; } closeDeletionModal() { this.setState({ deletionModalOpen: false }); this.modalTrigger.focus(); } loadDeletionModal() { this.setState({ deletionModalOpen: true }); } render() { const { deletionModalOpen, socialAuthConnected, isActive } = this.state; const loseAccessText = gettext('You may also lose access to verified certificates and other program credentials. You can make a copy of these for your records before proceeding with deletion.') const showError = socialAuthConnected || !isActive; const socialAuthError = StringUtils.interpolate( gettext('Before proceeding, please {htmlStart}unlink all social media accounts{htmlEnd}.'), { htmlStart: '', htmlEnd: '', }, ); const activationError = StringUtils.interpolate( gettext('Before proceeding, please {htmlStart}{emailMsg}{htmlEnd}.'), { htmlStart: '', htmlEnd: '', emailMsg: this.props.mktgEmailOptIn ? 'confirm your email' : 'activate your account', }, ); const changeAcctInfoText = StringUtils.interpolate( gettext('{htmlStart}Want to change your email, name, or password instead?{htmlEnd}'), { htmlStart: '', htmlEnd: '', }, ); const acctDeletionWarningText = StringUtils.interpolate( gettext('{strongStart}Warning: Account deletion is permanent.{strongEnd} Please read the above carefully before proceeding. This is an irreversible action, and {strongStart}you will no longer be able to use the same email on {platformName}.{strongEnd}'), { strongStart: '', strongEnd: '', platformName: this.props.platformName, }, ); const noteDeletion = StringUtils.interpolate( gettext('Please note: Deletion of your account and personal data is permanent and cannot be undone. {platformName} will not be able to recover your account or the data that is deleted.'), { platformName: this.props.platformName, }, ); const bodyDeletion = StringUtils.interpolate( gettext('Once your account is deleted, you cannot use it to take courses on the {platformName} app, {siteName}, or any other site hosted by {platformName}.'), { platformName: this.props.platformName, siteName: this.props.siteName, }, ); const bodyDeletion2 = StringUtils.interpolate( gettext('This includes access to {siteName} from your employer’s or university’s system{additionalSiteSpecificDeletionText}.'), { siteName: this.props.siteName, additionalSiteSpecificDeletionText: this.props.additionalSiteSpecificDeletionText, }, ); return (
{ gettext('We’re sorry to see you go!') }
{noteDeletion}
{bodyDeletion} {bodyDeletion2}
{loseAccessText}