Merge branch 'pass-lifetime-fixes' into 'main'
[ProtonMail-WebClient.git] / packages / components / containers / contacts / hooks / useContactMergeModals.tsx
blob3a3e45e725ef88983dc16241780321f4e07523f9
1 import { useModalTwoStatic } from '@proton/components/components/modalTwo/useModalTwo';
3 import ContactMergeDetailsModal from '../merge/ContactMergeDetailsModal';
4 import type { ContactMergeProps } from '../merge/ContactMergeModal';
5 import ContactMergeModal from '../merge/ContactMergeModal';
6 import type { ContactMergePreviewModalProps } from '../merge/ContactMergePreviewModal';
7 import ContactMergePreviewModal from '../merge/ContactMergePreviewModal';
9 export const useContactMergeModals = () => {
10     const [contactMergeModal, handleShowContactMergeModal] = useModalTwoStatic(ContactMergeModal);
12     const [contactMergePreviewModal, handleShowContactMergePreviewModal] = useModalTwoStatic(ContactMergePreviewModal);
14     const [contactMergeDetailsModal, handleShowContactMergeDetailsModal] = useModalTwoStatic(ContactMergeDetailsModal);
16     const handleMergeDetails = (contactID: string) => {
17         handleShowContactMergeDetailsModal({ contactID });
18     };
20     const handleMergePreview = (props: ContactMergePreviewModalProps) => {
21         handleShowContactMergePreviewModal(props);
22     };
24     const handleMerge = (props: ContactMergeProps) => {
25         handleShowContactMergeModal({
26             ...props,
27             onMergeDetails: handleMergeDetails,
28             onMergePreview: handleMergePreview,
29         });
30     };
32     const modals = (
33         <>
34             {contactMergeModal}
35             {contactMergePreviewModal}
36             {contactMergeDetailsModal}
37         </>
38     );
40     return {
41         modals,
42         onMerge: handleMerge,
43     };