import React, { useState, useCallback } from 'react'; import { CaseIntakeForm } from './components/CaseIntakeForm'; import { ActionPlanComponent } from './components/ActionPlan'; import { generateActionPlan } from './services/geminiService'; import type { ActionPlan, CaseData, ActionItemStatus } from './types'; import { Spinner } from './components/icons/Spinner'; const App: React.FC = () => { const [view, setView] = useState<'form' | 'plan'>('form'); const [actionPlan, setActionPlan] = useState(null); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); const handleFormSubmit = useCallback(async (data: CaseData) => { setIsLoading(true); setError(null); try { const plan = await generateActionPlan(data); setActionPlan(plan); setView('plan'); } catch (err) { console.error(err); setError('Failed to generate an action plan. Please check your API key and try again.'); } finally { setIsLoading(false); } }, []); const handleToggleItem = useCallback((categoryIndex: number, itemIndex: number) => { setActionPlan(prevPlan => { if (!prevPlan) return null; const newPlan = JSON.parse(JSON.stringify(prevPlan)); const currentStatus = newPlan.categories[categoryIndex].items[itemIndex].status; const newStatus: ActionItemStatus = currentStatus === 'Completed' ? 'Not Started' : 'Completed'; newPlan.categories[categoryIndex].items[itemIndex].status = newStatus; return newPlan; }); }, []); const handleReset = useCallback(() => { setView('form'); setActionPlan(null); setError(null); }, []); return (

SSDI Case Prep Assistant

Your AI-powered guide to organizing and strengthening your Social Security Disability claim.

{isLoading && (

Generating your personalized action plan...

This may take a moment. The AI is analyzing your case details.

)} {error && (
Error: {error}
)}
{view === 'form' && !actionPlan ? ( ) : ( actionPlan && )}
); }; export default App;