import { TextField, Button, Box, CircularProgress } from '@mui/material'; import { useState } from 'react'; interface QuizGeneratorProps { onProblemsGenerated: (problems: string[], query: string) => void; } function QuizGenerator({ onProblemsGenerated }: QuizGeneratorProps) { const [query, setQuery] = useState(''); const [isLoading, setIsLoading] = useState(false); const handleGenerate = async () => { try { setIsLoading(true); const response = await fetch('/api/problems/', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ user_query: query }), }); if (!response.ok) { throw new Error('Failed to generate problems'); } const data = await response.json(); onProblemsGenerated(data.Problems, query); setQuery(''); } catch (error) { console.error('Error:', error); } finally { setIsLoading(false); } }; return ( setQuery(e.target.value)} disabled={isLoading} /> ); } export default QuizGenerator;