Skip to content

Commit d11c9e8

Browse files
committed
Chatbot for only logged in users
1 parent 2055b29 commit d11c9e8

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/components/AIChatbot.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ import { Input } from '@/components/ui/input';
66
import { ScrollArea } from '@/components/ui/scroll-area';
77
import { supabase } from '@/integrations/supabase/client';
88
import { toast } from 'sonner';
9+
import { useAuth } from '@/hooks/useAuth';
910

1011
interface Message {
1112
role: 'user' | 'assistant';
1213
content: string;
1314
}
1415

1516
export 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

0 commit comments

Comments
 (0)