import React from 'react'; import PropTypes from 'prop-types'; import moment from 'moment'; import { Button } from 'plugin-api/beta/client/components/ui'; import DeleteMyAccountDialog from './DeleteMyAccountDialog'; import { getErrorMessages } from 'coral-framework/utils'; import { t } from 'plugin-api/beta/client/services'; const initialState = { showDialog: false }; class DeleteMyAccount extends React.Component { state = initialState; showDialog = () => { this.setState({ showDialog: true, }); }; closeDialog = () => { this.setState({ showDialog: false, }); }; cancelAccountDeletion = async () => { const { cancelAccountDeletion, notify } = this.props; try { await cancelAccountDeletion(); notify('success', t('delete_request.account_deletion_cancelled')); } catch (err) { notify('error', getErrorMessages(err)); } }; requestAccountDeletion = async () => { const { requestAccountDeletion, notify } = this.props; try { await requestAccountDeletion(); notify('success', t('delete_request.account_deletion_requested')); } catch (err) { notify('error', getErrorMessages(err)); } }; render() { const { me: { scheduledDeletionDate }, settings: { organizationContactEmail }, } = this.props.root; return (

{t('delete_request.delete_my_account')}

{t('delete_request.delete_my_account_description')}

{scheduledDeletionDate && t( 'delete_request.already_submitted_request_description', moment(scheduledDeletionDate).format('MMM Do YYYY, h:mm:ss a') )}

{scheduledDeletionDate ? ( ) : ( )}
); } } DeleteMyAccount.propTypes = { requestAccountDeletion: PropTypes.func.isRequired, cancelAccountDeletion: PropTypes.func.isRequired, notify: PropTypes.func.isRequired, root: PropTypes.object.isRequired, }; export default DeleteMyAccount;