import { useState, useRef, useEffect } from 'react'; import { Toaster } from 'react-hot-toast'; import { ThemeProvider } from './context/ThemeContext'; import { AuthProvider, useAuth } from './context/AuthContext'; import { FormProvider, useForm } from './context/FormContext'; import { fetchTemplateData, hydrateTemplateData } from './data/templateData'; import LoginPage from './components/auth/LoginPage'; import Navbar from './components/layout/Navbar'; import Sidebar from './components/layout/Sidebar'; import PatientHeader from './components/sections/PatientHeader'; import SectionRenderer from './components/sections/SectionRenderer'; import AbbreviationPanel from './components/reference/AbbreviationPanel'; import SmartPhrasesPanel from './components/reference/SmartPhrasesPanel'; import AIGeneratorPanel from './components/ai/AIGeneratorPanel'; import PreviewPanel from './components/preview/PreviewPanel'; import AddSectionModal from './components/modals/AddSectionModal'; import './index.css'; function AppContent({ templateSections }) { const [activeSection, setActiveSection] = useState('_header'); const [showPreview, setShowPreview] = useState(false); const [showGenerator, setShowGenerator] = useState(false); const [showAddSection, setShowAddSection] = useState(false); const [sidebarOpen, setSidebarOpen] = useState(() => window.innerWidth > 1024); const mainRef = useRef(null); const { addCustomSection, formState } = useForm(); const isMobile = () => window.innerWidth <= 1024; const handleSectionClick = (sectionId) => { setActiveSection(sectionId); const el = document.getElementById(`section-${sectionId}`); if (el) { el.scrollIntoView({ behavior: 'smooth', block: 'start' }); } // Auto-close sidebar on mobile after clicking a section if (isMobile()) { setSidebarOpen(false); } }; const handleAddSection = (title) => { addCustomSection(title); }; return ( <> setShowPreview(true)} onGenerate={() => setShowGenerator(true)} onToggleSidebar={() => setSidebarOpen(!sidebarOpen)} />
{/* Backdrop overlay for mobile sidebar */} {sidebarOpen && isMobile() && (
setSidebarOpen(false)} /> )} setShowAddSection(true)} isOpen={sidebarOpen} />
{templateSections.map(section => ( ))} {formState.customSections.map(cs => (
C

{cs.title}

Custom Content

This custom section will be included in AI generation. Add relevant notes below.