import React from 'react'; import { Hero } from './components/Hero'; import { Gallery } from './components/Gallery'; import { Button } from './components/ui/Button'; import { popularSheets } from './data/mockData'; import { HowItWorks } from './components/HowItWorks'; function App() { const [generatedSheet, setGeneratedSheet] = React.useState(null); const [isGenerating, setIsGenerating] = React.useState(false); const [history, setHistory] = React.useState([]); const handleGenerate = async (data) => { setIsGenerating(true); try { const response = await fetch('/api/generate', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(data), }); if (!response.ok) throw new Error('Generation failed'); const result = await response.json(); setGeneratedSheet(result); // Add to history const newHistoryItem = { id: Date.now(), title: result.title, subtitle: result.subtitle, age: data.age, downloads: 0, bgColor: 'bg-primary-50', // Default color // We'll need to figure out how to preview it in the gallery. // For now, Gallery expects 'bgColor'. }; setHistory(prev => [newHistoryItem, ...prev]); } catch (error) { console.error("Error generating sheet:", error); // Optional: Show error state } finally { setIsGenerating(false); } }; const galleryItems = history.length > 0 ? history.slice(0, 3) : popularSheets.slice(0, 3); const galleryTitle = history.length > 0 ? "Your Recent Creations" : "Most Popular Printables"; return (
{/* Navbar */} {/* Main Content */}
{/* Footer */}
); } export default App;