1 import { useState } from 'react';
3 import type { ModalWithProps } from '@proton/shared/lib/interfaces/Modal';
5 export const useModalsMap = <T extends Record<string, ModalWithProps<any>>>(map: T) => {
6 const [modalsMap, setModalsMap] = useState<T>(map);
8 const updateModal = <K extends keyof T>(key: K, newValue: T[K]) =>
9 setModalsMap((prevState) => ({
14 const closeModal = (key: keyof T) =>
15 setModalsMap((prevState) => ({
22 return { modalsMap, closeModal, setModalsMap, updateModal };