import { useState } from 'react' const API_URL = '/api' function ExerciseResearchPanel({ exerciseId, exerciseName }) { const [loading, setLoading] = useState(false) const [research, setResearch] = useState(null) const [error, setError] = useState(null) const fetchResearch = async () => { setLoading(true) setError(null) try { const res = await fetch(`${API_URL}/exercises/${exerciseId}/research`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({}) }) if (!res.ok) { const data = await res.json() throw new Error(data.error || 'Failed to fetch research') } const data = await res.json() setResearch(data) } catch (err) { setError(err.message) } finally { setLoading(false) } } return (
{research.summary}
{result.snippet}
)}