import { createBrowserRouter, Navigate, RouterProvider } from 'react-router-dom' import { useAuthStore } from '@/app/store/auth' import { AppLayout } from '@/components/layout/AppLayout' import type { ReactNode } from 'react' import { LoginPage } from '@/pages/auth/LoginPage' import { RegisterPage } from '@/pages/auth/RegisterPage' function RequireAuth({ children }: { children: ReactNode }) { const token = useAuthStore((s) => s.token) if (!token) return return <>{children} } function GuestOnly({ children }: { children: ReactNode }) { const token = useAuthStore((s) => s.token) if (token) return return <>{children} } const router = createBrowserRouter([ { path: '/login', element: }, { path: '/register', element: }, { path: '/', element: ( ), children: [ { index: true, element: }, { path: 'dashboard', lazy: async () => ({ Component: (await import('@/pages/dashboard/DashboardPage')).DashboardPage }) }, { path: 'inbox', lazy: async () => ({ Component: (await import('@/pages/inbox/InboxPage')).InboxPage }) }, { path: 'customers', lazy: async () => ({ Component: (await import('@/pages/customers/CustomersPage')).CustomersPage }) }, { path: 'customers/:id', lazy: async () => ({ Component: (await import('@/pages/customers/CustomerDetailPage')).CustomerDetailPage }) }, { path: 'opportunities', lazy: async () => ({ Component: (await import('@/pages/opportunities/OpportunitiesPage')).OpportunitiesPage }) }, { path: 'translate', lazy: async () => ({ Component: (await import('@/pages/translate/TranslatePage')).TranslatePage }) }, { path: 'risks', lazy: async () => ({ Component: (await import('@/pages/risks/RisksPage')).RisksPage }) }, { path: 'knowledge', lazy: async () => ({ Component: (await import('@/pages/knowledge/KnowledgePage')).KnowledgePage }) }, { path: 'analytics', lazy: async () => ({ Component: (await import('@/pages/analytics/AnalyticsPage')).AnalyticsPage }) }, { path: 'channels', lazy: async () => ({ Component: (await import('@/pages/channels/ChannelsPage')).ChannelsPage }) }, { path: 'team', lazy: async () => ({ Component: (await import('@/pages/team/TeamPage')).TeamPage }) }, { path: 'billing', lazy: async () => ({ Component: (await import('@/pages/billing/BillingPage')).BillingPage }) }, { path: 'settings', lazy: async () => ({ Component: (await import('@/pages/settings/SettingsPage')).SettingsPage }) }, { path: 'help', lazy: async () => ({ Component: (await import('@/pages/help/HelpPage')).HelpPage }) }, { path: '*', lazy: async () => ({ Component: (await import('@/pages/NotFoundPage')).NotFoundPage }) }, ], }, ]) export function AppRouter() { return }