Merge branch 'MAILWEB-6067-improve-circular-dependencies-prevention' into 'main'
[ProtonMail-WebClient.git] / packages / drive-store / store / DriveProvider.tsx
blobc551edb0dcb25a28794d9a85d369dbaac168e71a
1 import type { ReactNode } from 'react';
3 import { useApi } from '@proton/components';
4 import { UnleashFlagProvider } from '@proton/unleash';
6 import { PublicSessionProvider } from './_api';
7 import { DevicesProvider } from './_devices';
8 import { DownloadsProvider, PublicDownloadsProvider } from './_downloads';
9 import { DriveEventManagerProvider } from './_events';
10 import { InvitationsStateProvider } from './_invitations/useInvitationsState';
11 import { LinksProvider, PublicLinksProvider } from './_links';
12 import { PhotosProvider } from './_photos';
13 import { SearchProvider } from './_search';
14 import { SharesProvider } from './_shares';
15 import { UploadProvider } from './_uploads';
16 import { VolumesProvider } from './_volumes';
18 interface DriveProviderProps {
19     children: ReactNode;
22 export function DriveProvider({ children }: DriveProviderProps) {
23     return (
24         <DriveEventManagerProvider>
25             <VolumesProvider>
26                 <SharesProvider>
27                     <LinksProvider>
28                         <DevicesProvider>
29                             <DownloadsProvider>
30                                 <UploadProvider>
31                                     <SearchProvider>
32                                         <PhotosProvider>
33                                             <InvitationsStateProvider>{children}</InvitationsStateProvider>
34                                         </PhotosProvider>
35                                     </SearchProvider>
36                                 </UploadProvider>
37                             </DownloadsProvider>
38                         </DevicesProvider>
39                     </LinksProvider>
40                 </SharesProvider>
41             </VolumesProvider>
42         </DriveEventManagerProvider>
43     );
46 interface PublicDriveProviderProps {
47     children: ReactNode;
50 export function PublicDriveProvider({ children }: PublicDriveProviderProps) {
51     const api = useApi();
52     return (
53         <UnleashFlagProvider api={api}>
54             <PublicSessionProvider>
55                 <VolumesProvider>
56                     <SharesProvider>
57                         <PublicLinksProvider>
58                             <PublicDownloadsProvider>{children}</PublicDownloadsProvider>
59                         </PublicLinksProvider>
60                     </SharesProvider>
61                 </VolumesProvider>
62             </PublicSessionProvider>
63         </UnleashFlagProvider>
64     );