import React from 'react'; import { BrowserRouter, Routes, Route, useLocation, Navigate } from 'react-router-dom'; import { Helmet } from 'react-helmet'; import { useTranslation } from 'react-i18next'; import { useEffect } from 'react'; import { Toaster } from 'sonner'; import { AuthProvider } from '@/context/AuthContext'; import { I18nextProvider } from 'react-i18next'; import i18n from './i18n/config'; import { useAuth } from '@/context/AuthContext'; import Index from '@/pages/Index'; import Home from '@/pages/Home'; import About from '@/pages/About'; import Faq from '@/pages/Faq'; import Contact from '@/pages/Contact'; import Privacy from '@/pages/Privacy'; import Terms from '@/pages/Terms'; import Profile from '@/pages/Profile'; import ExtensionView from '@/pages/ExtensionView'; import MyExtensionsPage from '@/pages/MyExtensionsPage'; import Tutorials from '@/pages/Tutorials'; import TutorialDetail from '@/pages/TutorialDetail'; import Billing from '@/pages/Billing'; import PaymentSuccess from '@/pages/PaymentSuccess'; import PaymentFailed from '@/pages/PaymentFailed'; import UseCases from '@/pages/UseCases'; import Timeline from '@/pages/Timeline'; import NotFound from '@/pages/NotFound'; import Pricing from '@/pages/Pricing'; import AdminRoute from '@/components/AdminRoute'; import AdminDashboard from '@/pages/admin/AdminDashboard'; import AdminUsers from '@/pages/admin/AdminUsers'; import AdminExtensions from '@/pages/admin/AdminExtensions'; import AdminSettings from '@/pages/admin/AdminSettings'; import CookieConsent from '@/components/CookieConsent'; import Analytics from '@/components/Analytics'; const ScrollToTop = () => { const { pathname } = useLocation(); useEffect(() => { window.scrollTo(0, 0); }, [pathname]); return null; }; const SEO = () => { const { pathname } = useLocation(); const { t } = useTranslation(); const baseUrl = 'https://chromify.app'; const canonicalUrl = `${baseUrl}${pathname}`; const getMetaTags = () => { const defaultTags = { title: t('heroTitle'), description: t('heroSubtitle'), keywords: 'chrome extension, ai extension, no-code extension' }; const routeSpecificTags = { '/': defaultTags, '/about': { title: t('about') + ' - ' + t('heroTitle'), description: t('heroSubtitle'), keywords: 'chrome extension, ai development, extension generator' }, }; return routeSpecificTags[pathname] || defaultTags; }; const metaTags = getMetaTags(); return ( {metaTags.title} ); }; const ProtectedRoute = ({ element }: { element: React.ReactNode }) => { const { user } = useAuth(); if (!user) { return ; } return <>{element}; }; const IndexRedirect = () => { const { user } = useAuth(); if (user) { return ; } return ; }; const AppRoutes = () => { const { i18n } = useTranslation(); useEffect(() => { document.documentElement.lang = i18n.language; const isRTL = i18n.language === 'ar'; document.documentElement.dir = isRTL ? 'rtl' : 'ltr'; const event = new Event('languageChanged'); document.dispatchEvent(event); }, [i18n.language]); return ( <> } /> } /> } /> } /> } /> } /> } /> } />} /> } />} /> } />} /> } /> } /> } /> } />} /> } /> } />} /> } />} /> } /> } /> } /> } /> } /> } /> } /> ); }; const App = () => { return ( ); }; export default App;