1 import type { ReactNode } from 'react';
2 import { createContext, useContext } from 'react';
4 import type { UploadProviderState } from './UploadProviderState';
5 import { usePublicUpload, useUpload } from './useUpload';
7 const UploadContext = createContext<UploadProviderState | null>(null);
9 export const UploadProvider = ({ children }: { children: ReactNode }) => {
10 const [providerState, { conflictModal, fileThresholdModal }] = useUpload();
13 <UploadContext.Provider value={{ ...providerState }}>
17 </UploadContext.Provider>
21 export const PublicUploadProvider = ({ children }: { children: ReactNode }) => {
22 const [providerState, { conflictModal, fileThresholdModal }] = usePublicUpload();
25 <UploadContext.Provider value={{ ...providerState }}>
29 </UploadContext.Provider>
33 export const useUploadProvider = (): UploadProviderState => {
34 const state = useContext(UploadContext);
36 throw new Error('Trying to use uninitialized UploadProvider');