774a628d19
* [plugin-sdk-issue-27] - new data-consumption-hook * [plugin-sdk-issue-27] - update SDK
39 lines
1.5 KiB
TypeScript
39 lines
1.5 KiB
TypeScript
import React, { createContext, useState } from 'react';
|
|
import { ExtensibleArea } from '/imports/ui/components/plugins-engine/extensible-areas/types';
|
|
import { ChatMessagesGraphqlVariablesAndQuery, PluginsContextType, UserListGraphqlVariables } from './types';
|
|
import { CHAT_MESSAGE_PUBLIC_SUBSCRIPTION } from '../../chat/chat-graphql/chat-message-list/page/queries';
|
|
|
|
export const PluginsContext = createContext<PluginsContextType>({} as PluginsContextType);
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
export const PluginsContextProvider = ({ children, ...props }: any) => {
|
|
const [pluginsExtensibleAreasAggregatedState, setPluginsExtensibleAreasAggregatedState] = useState<ExtensibleArea>(
|
|
{} as ExtensibleArea,
|
|
);
|
|
const [userListGraphqlVariables, setUserListGraphqlVariables] = useState<UserListGraphqlVariables>(
|
|
{} as UserListGraphqlVariables,
|
|
);
|
|
const [
|
|
chatMessagesGraphqlVariablesAndQuery,
|
|
setChatMessagesGraphqlVariablesAndQuery,
|
|
] = useState<ChatMessagesGraphqlVariablesAndQuery>(
|
|
{ query: CHAT_MESSAGE_PUBLIC_SUBSCRIPTION } as ChatMessagesGraphqlVariablesAndQuery,
|
|
);
|
|
|
|
return (
|
|
<PluginsContext.Provider
|
|
value={{
|
|
...props,
|
|
setPluginsExtensibleAreasAggregatedState,
|
|
pluginsExtensibleAreasAggregatedState,
|
|
userListGraphqlVariables,
|
|
setUserListGraphqlVariables,
|
|
chatMessagesGraphqlVariablesAndQuery,
|
|
setChatMessagesGraphqlVariablesAndQuery,
|
|
}}
|
|
>
|
|
{children}
|
|
</PluginsContext.Provider>
|
|
);
|
|
};
|