File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,13 +6,15 @@ import { Input } from '@/components/ui/input';
66import { ScrollArea } from '@/components/ui/scroll-area' ;
77import { supabase } from '@/integrations/supabase/client' ;
88import { toast } from 'sonner' ;
9+ import { useAuth } from '@/hooks/useAuth' ;
910
1011interface Message {
1112 role : 'user' | 'assistant' ;
1213 content : string ;
1314}
1415
1516export const AIChatbot = ( ) => {
17+ const { user } = useAuth ( ) ;
1618 const [ isOpen , setIsOpen ] = useState ( false ) ;
1719 const [ messages , setMessages ] = useState < Message [ ] > ( [
1820 {
@@ -23,6 +25,10 @@ export const AIChatbot = () => {
2325 const [ input , setInput ] = useState ( '' ) ;
2426 const [ loading , setLoading ] = useState ( false ) ;
2527
28+ if ( ! user ) {
29+ return null ;
30+ }
31+
2632 const sendMessage = async ( ) => {
2733 if ( ! input . trim ( ) || loading ) return ;
2834
You can’t perform that action at this time.
0 commit comments