import { useState, useCallback } from 'react' interface UseFullTranscriptOptions { videoId: string } export function useFullTranscript({ videoId }: UseFullTranscriptOptions) { const [fullTranscript, setFullTranscript] = useState('') const [isLoading, setIsLoading] = useState(false) const [error, setError] = useState(null) const requestFullTranscript = useCallback(async () => { setIsLoading(true) setError(null) try { const base = import.meta.env.VITE_API_BASE_URL ?? '' const resp = await fetch(`${base}/api/v1/video/${videoId}/transcribe`, { method: 'POST', }) if (!resp.ok) { throw new Error(`Server returned ${resp.status}`) } const data = await resp.json() setFullTranscript(data.text) return data.text } catch (err) { const msg = err instanceof Error ? err.message : 'Transcription failed' setError(msg) return null } finally { setIsLoading(false) } }, [videoId]) return { fullTranscript, isLoading, error, requestFullTranscript } }