import { cn } from '@/lib/utils'; import { Switch } from '@headlessui/react'; import { useEffect } from 'react'; const CopilotToggle = ({ copilotEnabled, setCopilotEnabled, }: { copilotEnabled: boolean; setCopilotEnabled: (enabled: boolean) => void; }) => { const fetchAndSetCopilotEnabled = async () => { const res = await fetch( `${process.env.NEXT_PUBLIC_API_URL}/config/preferences`, { method: 'GET', headers: { 'Content-Type': 'application/json', }, }, ); const preferences = await res.json(); setCopilotEnabled(preferences.isCopilotEnabled); }; useEffect(() => { fetchAndSetCopilotEnabled(); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return (
Copilot

setCopilotEnabled(!copilotEnabled)} className={cn( 'text-xs font-medium transition-colors duration-150 ease-in-out', copilotEnabled ? 'text-[#24A0ED]' : 'text-black/50 dark:text-white/50 group-hover:text-black dark:group-hover:text-white', )} > Copilot

); }; export default CopilotToggle;