Cleanup - unused files / unused exports / duplicate exports
[ProtonMail-WebClient.git] / packages / components / containers / organization / ReactivatePasswordlessOrganizationKey.tsx
blob5b077f2aa835a02d68ecd7f7e106950a1ee3c619
1 import { c } from 'ttag';
3 import { Button, ButtonLike } from '@proton/atoms';
4 import SettingsLink from '@proton/components/components/link/SettingsLink';
5 import type { ModalProps } from '@proton/components/components/modalTwo/Modal';
6 import ModalTwo from '@proton/components/components/modalTwo/Modal';
7 import ModalTwoContent from '@proton/components/components/modalTwo/ModalContent';
8 import ModalTwoFooter from '@proton/components/components/modalTwo/ModalFooter';
9 import ModalTwoHeader from '@proton/components/components/modalTwo/ModalHeader';
10 import type { Member, UserModel } from '@proton/shared/lib/interfaces';
11 import { getMemberEmailOrName } from '@proton/shared/lib/keys/memberHelper';
13 import AdministratorList from './AdministratorList';
15 interface Props extends Omit<ModalProps, 'buttons' | 'title' | 'children'> {
16     onResetKeys: () => void;
17     disableResetOrganizationKeys: boolean;
18     otherAdminsWithKeyAccess: Member[];
19     user: UserModel;
22 const ReactivatePasswordlessOrganizationKey = ({
23     onResetKeys,
24     otherAdminsWithKeyAccess,
25     disableResetOrganizationKeys,
26     user,
27     ...rest
28 }: Props) => {
29     return (
30         <ModalTwo open {...rest}>
31             <ModalTwoHeader title={c('Title').t`Restore administrator privileges`} {...rest} />
32             <ModalTwoContent>
33                 {(() => {
34                     if (otherAdminsWithKeyAccess.length) {
35                         return (
36                             <div>
37                                 <div className="mb-4">
38                                     {c('passwordless')
39                                         .t`Use a data recovery method, contact another administrator, or reset the organization key to restore administrator privileges.`}
40                                 </div>
42                                 <AdministratorList
43                                     members={otherAdminsWithKeyAccess.map((member) => ({
44                                         member,
45                                         email: getMemberEmailOrName(member),
46                                     }))}
47                                     expandByDefault={true}
48                                 />
49                             </div>
50                         );
51                     }
53                     return (
54                         <div>{c('passwordless')
55                             .t`Use a data recovery method or reset the organization key to restore administrator privileges.`}</div>
56                     );
57                 })()}
58             </ModalTwoContent>
59             <ModalTwoFooter>
60                 <Button onClick={rest.onClose}>{c('Action').t`Close`}</Button>
61                 <div>
62                     <Button
63                         color="danger"
64                         className="mr-4"
65                         onClick={() => {
66                             rest.onClose?.();
67                             onResetKeys();
68                         }}
69                     >{c('Action').t`Reset keys`}</Button>
70                     {user.isPrivate && (
71                         <ButtonLike color="norm" as={SettingsLink} path="/recovery" onClick={rest.onClose}>
72                             {c('Action').t`Recover data`}
73                         </ButtonLike>
74                     )}
75                 </div>
76             </ModalTwoFooter>
77         </ModalTwo>
78     );
81 export default ReactivatePasswordlessOrganizationKey;