import { useState } from "react"; import { Navigation } from "@/components/Navigation"; import { UploadZone } from "@/components/UploadZone"; import { ResultsDisplay } from "@/components/ResultsDisplay"; import { AboutPage } from "@/components/AboutPage"; import { Heart, Sparkles } from "lucide-react"; import { useToast } from "@/hooks/use-toast"; const Index = () => { const [activeTab, setActiveTab] = useState<"upload" | "about">("upload"); const [isLoading, setIsLoading] = useState(false); const [results, setResults] = useState(null); const { toast } = useToast(); const handleUpload = async (file: File) => { setIsLoading(true); setResults(null); // Call backend API (served from the same Hugging Face Space) try { const formData = new FormData(); formData.append("video", file); const response = await fetch("/api/analyze", { method: "POST", body: formData, }); if (!response.ok) { const msg = await response.text(); throw new Error(msg || "Analysis failed"); } const data = await response.json(); setResults({ ejectionFraction: data.ejectionFraction, heartFunction: data.heartFunction, }); toast({ title: "Analysis Complete", description: "Your echocardiography video has been analyzed successfully.", }); } catch (error) { toast({ title: "Analysis Failed", description: "There was an error analyzing your video. Please try again.", variant: "destructive", }); } finally { setIsLoading(false); } }; return (
{activeTab === "upload" ? (
{/* Hero Section */}
AI-Powered Cardiac Analysis

Analyze Your{" "} Echocardiography

Upload your echocardiography video and let our AI model automatically extract key cardiac measurements and assess heart function.

{/* Upload Zone */} {/* Results */} {results && } {/* Features */} {!results && !isLoading && (

Ejection Fraction

Accurate EF calculation for cardiac assessment

Function Status

AI-based heart function classification

)}
) : ( )}
); }; export default Index;