import { useState, useCallback } from 'react'; import { useToast } from '@/components/feedback/ToastProvider'; import { FEATURED_STREAM, CHAT_MESSAGES } from './mockData'; import type { LiveStream } from '@/types'; import type { LiveViewChatMessage } from './types'; export interface UseLiveViewOptions { stream?: LiveStream | null; chatMessages?: LiveViewChatMessage[]; onSendMessage?: (text: string) => void; } export function useLiveView(options: UseLiveViewOptions = {}) { const { addToast } = useToast(); const stream = options.stream ?? FEATURED_STREAM; const chatMessages = options.chatMessages ?? CHAT_MESSAGES; const [msgInput, setMsgInput] = useState(''); const handleSend = useCallback(() => { if (!msgInput.trim()) return; if (options.onSendMessage) { options.onSendMessage(msgInput); } else { addToast('Message sent to chat', 'success'); } setMsgInput(''); }, [msgInput, options.onSendMessage, addToast]); return { stream, chatMessages, msgInput, setMsgInput, handleSend, addToast, }; }