2023-08-16 06:31:11 +08:00
|
|
|
import React, {
|
2023-09-05 20:49:55 +08:00
|
|
|
createContext,
|
|
|
|
useState,
|
2023-08-16 06:31:11 +08:00
|
|
|
} from 'react';
|
|
|
|
|
|
|
|
import { PluginProvidedState } from '/imports/ui/components/plugins-engine/types'
|
|
|
|
|
2023-09-05 20:49:55 +08:00
|
|
|
import { PluginsContextType, UserListGraphqlVariables } from './types';
|
2023-08-16 06:31:11 +08:00
|
|
|
|
|
|
|
export const PluginsContext = createContext<PluginsContextType>({} as PluginsContextType);
|
|
|
|
|
|
|
|
export const PluginsContextProvider = (props: any) => {
|
|
|
|
const [pluginsProvidedAggregatedState,
|
|
|
|
setPluginsProvidedAggregatedState] = useState<PluginProvidedState>(
|
|
|
|
{} as PluginProvidedState,
|
|
|
|
);
|
2023-09-05 20:49:55 +08:00
|
|
|
const [userListGraphqlVariables,
|
|
|
|
setUserListGraphqlVariables] = useState<UserListGraphqlVariables>(
|
|
|
|
{} as UserListGraphqlVariables,
|
|
|
|
);
|
2023-08-16 06:31:11 +08:00
|
|
|
return (
|
|
|
|
<PluginsContext.Provider value={
|
2023-09-05 20:49:55 +08:00
|
|
|
{
|
|
|
|
...props,
|
|
|
|
setPluginsProvidedAggregatedState,
|
|
|
|
pluginsProvidedAggregatedState,
|
|
|
|
userListGraphqlVariables,
|
|
|
|
setUserListGraphqlVariables,
|
|
|
|
}
|
|
|
|
}
|
2023-08-16 06:31:11 +08:00
|
|
|
>
|
|
|
|
{props.children}
|
|
|
|
</PluginsContext.Provider>
|
|
|
|
);
|
|
|
|
};
|