Update all non-major dependencies
[ProtonMail-WebClient.git] / applications / calendar / src / app / helpers / test / NotificationsTestProvider.tsx
blob8ea598f2a346517e0f37ad09d940555964b51af4
1 import React, { useRef, useState } from 'react';
3 import { NotificationsContainer, NotificationsContext, createNotificationManager } from '@proton/components';
4 import type { Notification } from '@proton/components';
5 import noop from '@proton/utils/noop';
7 interface Props {
8     children: React.ReactNode;
11 const NotificationsTestProvider = ({ children }: Props) => {
12     const [notifications, setNotifications] = useState<Notification[]>([]);
13     const managerRef = useRef<ReturnType<typeof createNotificationManager>>();
14     if (!managerRef.current) {
15         managerRef.current = createNotificationManager(setNotifications as any, noop);
16     }
17     const manager = managerRef.current;
18     const { hideNotification, removeNotification, removeDuplicate } = manager;
20     return (
21         <NotificationsContext.Provider value={manager}>
22             {children}
23             <NotificationsContainer
24                 notifications={notifications}
25                 removeNotification={removeNotification}
26                 removeDuplicate={removeDuplicate}
27                 hideNotification={hideNotification}
28             />
29         </NotificationsContext.Provider>
30     );
33 export default NotificationsTestProvider;