1 import { c } from 'ttag';
3 import { useAddresses } from '@proton/account/addresses/hooks';
4 import { useSubscription } from '@proton/account/subscription/hooks';
5 import { Button, Href } from '@proton/atoms';
6 import Loader from '@proton/components/components/loader/Loader';
7 import useModalState from '@proton/components/components/modalTwo/useModalState';
8 import useConfig from '@proton/components/hooks/useConfig';
9 import { ADDRESS_TYPE, APPS, MAIL_APP_NAME, VPN_APP_NAME } from '@proton/shared/lib/constants';
10 import { hasMigrationDiscount, hasVisionary } from '@proton/shared/lib/helpers/subscription';
12 import { DiscountWarningModal, VisionaryWarningModal } from '../payments/subscription/PlanLossWarningModal';
13 import DeleteAccountModal from './DeleteAccountModal';
14 import MozillaInfoPanel from './MozillaInfoPanel';
15 import SettingsParagraph from './SettingsParagraph';
17 const DeleteSection = () => {
18 const [addresses, loadingAddresses] = useAddresses();
19 const [subscription, loadingSubscription] = useSubscription();
20 const { APP_NAME } = useConfig();
21 const [deleteAccountModalProps, setDeleteAccountModalOpen, renderDeleteAccountModal] = useModalState();
22 const [migrationDiscountModalProps, setMigrationDiscountModal, renderDiscountModal] = useModalState();
23 const [visionaryLossModalProps, setVisionaryLossModal, renderVisionaryLossModal] = useModalState();
25 if (loadingAddresses || loadingSubscription) {
30 APP_NAME === APPS.PROTONVPN_SETTINGS &&
31 addresses?.some((address) => address.Type !== ADDRESS_TYPE.TYPE_EXTERNAL)
34 <Href key="0" href="https://account.proton.me/login?product=mail">
42 .jt`Your ${VPN_APP_NAME} and ${MAIL_APP_NAME} accounts are linked. To delete them both, please sign in at ${loginLink} and delete your account there.`}
47 if (subscription?.isManagedByMozilla) {
48 return <MozillaInfoPanel />;
53 {renderDiscountModal && (
56 {...migrationDiscountModalProps}
58 if (hasVisionary(subscription)) {
59 setVisionaryLossModal(true);
62 setDeleteAccountModalOpen(true);
66 {renderVisionaryLossModal && (
67 <VisionaryWarningModal
69 {...visionaryLossModalProps}
71 setDeleteAccountModalOpen(true);
75 {renderDeleteAccountModal && <DeleteAccountModal {...deleteAccountModalProps} />}
78 .t`This will permanently delete your account and all of its data. You will not be able to reactivate this account.`}
85 if (hasMigrationDiscount(subscription)) {
86 setMigrationDiscountModal(true);
89 if (hasVisionary(subscription)) {
90 setVisionaryLossModal(true);
93 setDeleteAccountModalOpen(true);
96 {c('Action').t`Delete your account`}
102 export default DeleteSection;