feat: add copilot setting to config

refactor: move getConfig to actions, extracted Settings
This commit is contained in:
Justin Luoma 2024-05-25 08:04:40 -04:00
parent d788ca8eba
commit 79d4d87f24
10 changed files with 140 additions and 113 deletions

View file

@ -7,7 +7,7 @@ import Chat from './Chat';
import EmptyChat from './EmptyChat';
import { toast } from 'sonner';
import { useSearchParams } from 'next/navigation';
import { getSuggestions } from '@/lib/actions';
import { getConfig, getSuggestions } from '@/lib/actions';
export type Message = {
id: string;
@ -156,6 +156,15 @@ const ChatWindow = () => {
messagesRef.current = messages;
}, [messages]);
useEffect(() => {
const fetchConfig = async () => {
const config = await getConfig();
localStorage.setItem('copilotEnabled', config.copilotEnabled.toString());
};
fetchConfig();
});
const sendMessage = async (message: string) => {
if (loading) return;
setLoading(true);