mirror of
http://88.130.71.182:3000/BlitTech/contexta_fe.git
synced 2026-06-12 23:23:22 +00:00
Initial commit
This commit is contained in:
49
src/App.tsx
Normal file
49
src/App.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
import React from 'react'
|
||||
import { Routes, Route, Navigate } from 'react-router-dom'
|
||||
import { useAuthStore } from '@/store/authStore'
|
||||
import { AppLayout } from '@/components/Layout'
|
||||
import { LandingPage } from '@/pages/LandingPage'
|
||||
import { LoginPage, SignupPage } from '@/pages/AuthPages'
|
||||
import { DashboardPage } from '@/pages/DashboardPage'
|
||||
import { ChatbotBuilderPage } from '@/pages/ChatbotBuilderPage'
|
||||
import { MarketplacePage, ChatbotDetailPage } from '@/pages/MarketplacePage'
|
||||
import { PricingPage } from '@/pages/PricingPage'
|
||||
import { SettingsPage } from '@/pages/SettingsPage'
|
||||
import './App.css'
|
||||
|
||||
const PrivateRoute: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||
const { isAuthenticated } = useAuthStore()
|
||||
if (!isAuthenticated) return <Navigate to="/login" replace />
|
||||
return <AppLayout>{children}</AppLayout>
|
||||
}
|
||||
|
||||
const PublicOnlyRoute: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||
const { isAuthenticated } = useAuthStore()
|
||||
if (isAuthenticated) return <Navigate to="/dashboard" replace />
|
||||
return <>{children}</>
|
||||
}
|
||||
|
||||
export const App: React.FC = () => (
|
||||
<Routes>
|
||||
{/* Public */}
|
||||
<Route path="/" element={<LandingPage />} />
|
||||
<Route path="/pricing" element={<PricingPage />} />
|
||||
<Route path="/marketplace" element={<MarketplacePage />} />
|
||||
<Route path="/marketplace/:id" element={<ChatbotDetailPage />} />
|
||||
|
||||
{/* Auth */}
|
||||
<Route path="/login" element={<PublicOnlyRoute><LoginPage /></PublicOnlyRoute>} />
|
||||
<Route path="/signup" element={<PublicOnlyRoute><SignupPage /></PublicOnlyRoute>} />
|
||||
|
||||
{/* Protected */}
|
||||
<Route path="/dashboard" element={<PrivateRoute><DashboardPage /></PrivateRoute>} />
|
||||
<Route path="/chatbots/new" element={<PrivateRoute><ChatbotBuilderPage /></PrivateRoute>} />
|
||||
<Route path="/chatbots/:id/edit" element={<PrivateRoute><ChatbotBuilderPage /></PrivateRoute>} />
|
||||
<Route path="/chatbots/:id/preview" element={<PrivateRoute><ChatbotBuilderPage /></PrivateRoute>} />
|
||||
<Route path="/settings" element={<PrivateRoute><SettingsPage /></PrivateRoute>} />
|
||||
<Route path="/settings/billing" element={<PrivateRoute><SettingsPage /></PrivateRoute>} />
|
||||
|
||||
{/* Fallback */}
|
||||
<Route path="*" element={<Navigate to="/" replace />} />
|
||||
</Routes>
|
||||
)
|
||||
Reference in New Issue
Block a user