Merge branch 'feat/inda-383-daily-stat' into 'main'
[ProtonMail-WebClient.git] / packages / pass / components / Item / Actions / ConfirmItemActions.tsx
blob00def995eaf0f6b4d4fa33c58681fbc6fc9c1f1a
1 import { type FC } from 'react';
2 import { useSelector } from 'react-redux';
4 import { c } from 'ttag';
6 import {
7     ConfirmationPrompt,
8     type ConfirmationPromptHandles,
9 } from '@proton/pass/components/Confirmation/ConfirmationPrompt';
10 import { ConfirmDeleteAlias } from '@proton/pass/components/Item/Actions/ConfirmAliasActions';
11 import { WithVault } from '@proton/pass/components/Vault/WithVault';
12 import { isAliasItem } from '@proton/pass/lib/items/item.predicates';
13 import { selectItemSecureLinks } from '@proton/pass/store/selectors';
14 import type { ItemRevision } from '@proton/pass/types';
16 export const ConfirmDeleteItem: FC<ConfirmationPromptHandles & { item: ItemRevision }> = (props) =>
17     isAliasItem(props.item.data) ? (
18         <ConfirmDeleteAlias {...props} />
19     ) : (
20         <ConfirmationPrompt
21             {...props}
22             danger
23             title={c('Title').t`Delete this item?`}
24             message={c('Warning').t`Are you sure you want to permanently delete this item?`}
25         />
26     );
28 export const ConfirmMoveItem: FC<
29     ConfirmationPromptHandles & {
30         item: ItemRevision;
31         shareId: string;
32     }
33 > = ({ item, shareId, onCancel, onConfirm }) => {
34     const hasLinks = Boolean(useSelector(selectItemSecureLinks(item.shareId, item.itemId)).length);
36     return (
37         <WithVault shareId={shareId} onFallback={onCancel}>
38             {({ content: { name: vaultName } }) => (
39                 <ConfirmationPrompt
40                     onConfirm={onConfirm}
41                     onCancel={onCancel}
42                     title={c('Title').t`Move item to "${vaultName}"`}
43                     message={
44                         hasLinks
45                             ? c('Info').t`Moving an item to another vault will erase its history and all secure links.`
46                             : c('Info').t`Moving an item to another vault will erase its history.`
47                     }
48                 />
49             )}
50         </WithVault>
51     );