import React, { useState, useEffect, lazy, Suspense } from 'react' import { motion, AnimatePresence, MotionConfig, LazyMotion, domAnimation } from 'framer-motion' import { Backpack, Heart, MapPin, Phone, Shirt, Users, Building2, BookOpenText, Quote, FileText, X, DollarSign, Award, Settings, UserCheck, School, ClipboardList, Calendar, FileCheck, AlertCircle, Package, Truck, Plus, Lock, Database, Check, Clock, Bell, BellRing, BarChart3, TrendingUp, Languages, Brain, Cpu, Download, WifiOff, ChevronDown, Eye, Zap, Target, Activity, } from 'lucide-react' // Phase 3: AI Components (lazy — portal routes only) const AIAssistancePortal = lazy(() => import('./components/AIAssistancePortal')) // Phase 3B: Enterprise Components (lazy — portal routes only) const AdvancedAnalyticsDashboard = lazy(() => import('./components/AdvancedAnalyticsDashboard')) const MobileVolunteerApp = lazy(() => import('./components/MobileVolunteerApp')) const StaffTrainingDashboard = lazy(() => import('./components/StaffTrainingDashboard')) const MimChatAgent = lazy(() => import('./components/MimChatAgent')) import { AppPageShell as PageShell } from './components/layout/AppPageShell' import { AuthProvider, useAuth } from './contexts/AuthContext' import { LanguageProvider, useLanguage } from './contexts/LanguageContext' import { NotificationProvider, useNotifications } from './contexts/NotificationContext' // Lazy route chunks — home, donate, assistance (motion-heavy / form pages) const HomePage = lazy(() => import('./routes/HomePageRoute')) const DonatePage = lazy(() => import('./routes/DonatePageRoute')) const AssistanceRequestPage = lazy(() => import('./routes/AssistanceRequestPageRoute')) // Phase 4: Extracted Components import { Navigation } from './components/Navigation' import { SiteHeader } from './components/SiteHeader' import { Footer } from './components/Footer' import { BrandAssetsPage } from './pages/BrandPage' import { AboutPage, ContactPage, EventsPage, MissionPage, StoriesIntroBlock, WhatWeDoPage, } from './pages/foundation' import { EMAILS, SITE, mailto } from './content/siteContent' import { FormSuccess } from './components/ui/FormSuccess' import { submitContactFromForm } from './lib/submitContactFromForm' import { MimApiError } from './lib/mimApi' function RouteFallback({ label = 'Loading…' }: { label?: string }) { return (
{label}
) } function PortalRouteFallback() { return (
Loading portal…
) } function LazyPortal({ children }: { children: React.ReactNode }) { return }>{children} } function LazyRoute({ children, label }: { children: React.ReactNode; label?: string }) { return }>{children} } /** * Miracles in Motion — Complete Non-Profit Website * A comprehensive 501(c)3 organization website with modern design, * donation processing, volunteer management, and impact tracking. */ /* ===================== Phase 2: Enhanced Context Systems ===================== */ /* ===================== Analytics Tracking ===================== */ function trackEvent(eventName: string, properties: Record = {}) { // In production, integrate with Google Analytics, Mixpanel, or similar if (typeof window !== 'undefined' && (window as any).gtag) { (window as any).gtag('event', eventName, properties) } console.log(`Analytics: ${eventName}`, properties) } function useAnalytics() { const [analyticsData, setAnalyticsData] = useState(() => ({ pageViews: [ { page: 'Home', views: 2847, trend: 12.5 }, { page: 'Donate', views: 1203, trend: 8.3 }, { page: 'Volunteer', views: 856, trend: -2.1 }, { page: 'Stories', views: 645, trend: 15.8 }, { page: 'About', views: 432, trend: 5.2 } ], donationMetrics: { amount: 45280, count: 186, recurring: 67 }, userEngagement: { sessions: 3241, avgDuration: 185, bounceRate: 0.34 }, conversionRates: { donation: 0.078, volunteer: 0.032, contact: 0.156 } })) const refreshAnalytics = () => { // Simulate real-time data updates setAnalyticsData(prev => ({ ...prev, pageViews: prev.pageViews.map(pv => ({ ...pv, views: pv.views + Math.floor(Math.random() * 10), trend: (Math.random() - 0.5) * 20 })), donationMetrics: { ...prev.donationMetrics, amount: prev.donationMetrics.amount + Math.floor(Math.random() * 500), count: prev.donationMetrics.count + Math.floor(Math.random() * 3) } })) } useEffect(() => { const interval = setInterval(refreshAnalytics, 30000) // Update every 30 seconds return () => clearInterval(interval) }, []) return { analyticsData, refreshAnalytics } } /* ===================== PWA Features ===================== */ function usePWA() { const [isOnline, setIsOnline] = useState(navigator.onLine) const [installPrompt, setInstallPrompt] = useState(null) const [isInstallable, setIsInstallable] = useState(false) useEffect(() => { const handleOnline = () => setIsOnline(true) const handleOffline = () => setIsOnline(false) window.addEventListener('online', handleOnline) window.addEventListener('offline', handleOffline) // PWA Install Prompt const handleBeforeInstallPrompt = (e: any) => { e.preventDefault() setInstallPrompt(e) setIsInstallable(true) } window.addEventListener('beforeinstallprompt', handleBeforeInstallPrompt) return () => { window.removeEventListener('online', handleOnline) window.removeEventListener('offline', handleOffline) window.removeEventListener('beforeinstallprompt', handleBeforeInstallPrompt) } }, []) const installApp = async () => { if (!installPrompt) return false installPrompt.prompt() const { outcome } = await installPrompt.userChoice if (outcome === 'accepted') { trackEvent('pwa_installed') setInstallPrompt(null) setIsInstallable(false) return true } return false } return { isOnline, isInstallable, installApp } } /* ===================== SEO Meta Tags Component ===================== */ function SEOHead({ title, description, image }: { title?: string, description?: string, image?: string }) { useEffect(() => { // Update document title if (title) { document.title = `${title} | Miracles in Motion` } // Update meta description const metaDescription = document.querySelector('meta[name="description"]') if (description && metaDescription) { metaDescription.setAttribute('content', description) } // Update Open Graph tags const updateOGTag = (property: string, content: string) => { let tag = document.querySelector(`meta[property="${property}"]`) if (!tag) { tag = document.createElement('meta') tag.setAttribute('property', property) document.head.appendChild(tag) } tag.setAttribute('content', content) } updateOGTag('og:title', title || `${SITE.name} — ${SITE.brandMessage}`) updateOGTag('og:description', description || 'Faith-centered nonprofit bringing hope, outreach, emergency assistance, and wellness support to families in Los Angeles County.') updateOGTag('og:image', image || `${SITE.url}/og-image.png`) updateOGTag('og:type', 'website') }, [title, description, image]) return null } /* ===================== Types ===================== */ interface IconProps { className?: string } interface AnalyticsData { pageViews: { page: string; views: number; trend: number }[] donationMetrics: { amount: number; count: number; recurring: number } userEngagement: { sessions: number; avgDuration: number; bounceRate: number } conversionRates: { donation: number; volunteer: number; contact: number } } interface CardProps { title: string icon: React.ComponentType children: React.ReactNode } interface PolicySectionProps { id: string title: string children: React.ReactNode } /* ===================== Shared UI ===================== */ export function useHashRoute() { const parse = () => (window.location.hash?.slice(1) || "/") const [route, setRoute] = useState(parse()) useEffect(() => { const onHash = () => setRoute(parse()) window.addEventListener("hashchange", onHash) return () => window.removeEventListener("hashchange", onHash) }, []) return route } /* ===================== Legacy Router Component (Repurposed) ===================== */ /* ===================== Shared UI ===================== */ function SkipToContent() { return ( Skip to content ) } // Nav component has been extracted to ./components/Navigation.tsx // LogoMark component has been extracted to ./components/ui/LogoMark.tsx /* ===================== Home Page ===================== */ /* ===================== Pages ===================== */ function VolunteerPage() { const [submitted, setSubmitted] = useState(null) const [submitting, setSubmitting] = useState(false) const [formError, setFormError] = useState(null) const onVolunteerSubmit = async (e: React.FormEvent) => { e.preventDefault() setSubmitting(true) setFormError(null) try { const res = await submitContactFromForm(e.currentTarget, 'volunteer') setSubmitted(res.message) e.currentTarget.reset() } catch (err) { setFormError(err instanceof MimApiError ? err.message : 'Could not submit. Please email info@mim4u.org.') } finally { setSubmitting(false) } } return (
Sign-up form
{submitted ? ( setSubmitted(null)} /> ) : (
{formError &&

{formError}

}
)}
) } function SponsorsPage() { const [submitted, setSubmitted] = useState(null) const [submitting, setSubmitting] = useState(false) const [formError, setFormError] = useState(null) const onSponsorSubmit = async (e: React.FormEvent) => { e.preventDefault() setSubmitting(true) setFormError(null) try { const res = await submitContactFromForm(e.currentTarget, 'sponsor') setSubmitted(res.message) e.currentTarget.reset() } catch (err) { setFormError(err instanceof MimApiError ? err.message : 'Could not submit. Please email info@mim4u.org.') } finally { setSubmitting(false) } } const tiers = [ { name: "Bronze", amt: "$2,500", perks: ["Logo on website", "Social thank-you", "Quarterly impact note"] }, { name: "Silver", amt: "$5,000", perks: ["All Bronze", "Logo on event signage", "Volunteer day for your team"] }, { name: "Gold", amt: "$10,000", perks: ["All Silver", "Co-branded kit drive", "Annual report feature"] }, { name: "Platinum", amt: "$25,000+", perks: ["All Gold", "Program naming opportunity", "Custom partnership plan"] }, ] return ( Brand assets}>
{tiers.map((t) => (
{t.name}
{t.amt}
    {t.perks.map((p, i) => (
  • {p}
  • ))}
))}
Start a conversation
{submitted ? ( setSubmitted(null)} /> ) : (
{formError &&

{formError}

}
)}
) } function StoriesPage() { const [submitted, setSubmitted] = useState(null) const [submitting, setSubmitting] = useState(false) const [formError, setFormError] = useState(null) const onStorySubmit = async (e: React.FormEvent) => { e.preventDefault() setSubmitting(true) setFormError(null) try { const res = await submitContactFromForm(e.currentTarget, 'story') setSubmitted(res.message) e.currentTarget.reset() } catch (err) { setFormError(err instanceof MimApiError ? err.message : 'Could not submit. Please email info@mim4u.org.') } finally { setSubmitting(false) } } const stories = [ { title: "A family found hope again", tag: "Outreach", body: "After a fire displaced their home, a mother and children received emergency support and compassionate guidance through recovery.", by: "Community partner" }, { title: "Strength after hardship", tag: "Advocacy", body: "A survivor connected with resources and encouragement — reminded that she matters and brighter days are ahead.", by: "Volunteer" }, { title: "Community showed up", tag: "Events", body: "Neighbors and volunteers came together at an outreach event to serve families with supplies, prayer, and heartfelt support.", by: "Event volunteer" }, ] return ( Read testimonies}>
{stories.map((s, i) => (
{s.tag}

{s.title}

{s.body}

— {s.by}
))}
Submit your story
{submitted ? ( setSubmitted(null)} /> ) : (