Skip to content

Commit

Permalink
[AI Playground] Move ChatContext to AIPlayground provider
Browse files Browse the repository at this point in the history
  • Loading branch information
yansavitski committed Feb 24, 2024
1 parent 124d90b commit 3d0165b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 25 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-ai-playground/hooks/useChatContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { useContext } from 'react';
import { ChatContext } from '../providers/chat_provider';
import { ChatContext } from '../providers/ai_playground_provider';

export const useChatContext = () => {
return useContext(ChatContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
* Side Public License, v 1.
*/

import React, { ReactNode } from 'react';
import React, { createContext, ReactNode } from 'react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { FormProvider, useForm } from 'react-hook-form';
import { ChatForm } from '../types';
import { ChatProvider } from '@kbn/ai-playground/providers/chat_provider';

interface AIPlaygroundProviderProps {
navigateToIndexPage: () => void;
children: ReactNode;
}

export const ChatContext = createContext<{ navigateToIndexPage?: () => void }>({});

const queryClient = new QueryClient({});

export const AIPlaygroundProvider: React.FC<AIPlaygroundProviderProps> = ({
Expand All @@ -26,10 +27,10 @@ export const AIPlaygroundProvider: React.FC<AIPlaygroundProviderProps> = ({
const form = useForm<ChatForm>();

return (
<ChatProvider navigateToIndexPage={navigateToIndexPage}>
<ChatContext.Provider value={{ navigateToIndexPage }}>
<QueryClientProvider client={queryClient}>
<FormProvider {...form}>{children}</FormProvider>
</QueryClientProvider>
</ChatProvider>
</ChatContext.Provider>
);
};
20 changes: 0 additions & 20 deletions packages/kbn-ai-playground/providers/chat_provider.tsx

This file was deleted.

0 comments on commit 3d0165b

Please sign in to comment.