Separate CP admin panel into independent Vite project at /cp/
- New /cp/ Vite project with own package.json, Dockerfile, tailwind config - Migrated CpLoginPage, CpLayout, AdminDashboard → cp/src/ (self-contained) - cp/src/lib/utils.ts has only what CP needs (cn, PLAN_LABELS, PLAN_COLORS) - cp/src/data/mockData.ts has Hotel/User types and mock data - cp/ builds to nginx static container (hotelsync-cp) - docker-compose.yml: added cp service - nginx: added cp.hotelsync.ru → hotelsync-cp:80 (SSL block ready for certbot) - deploy.yml: builds hotelsync-cp:latest and restarts container on push - Cleaned src/App.tsx: removed IS_CP branch, CpLoginPage/CpLayout/AdminDashboard imports Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
38
src/App.tsx
38
src/App.tsx
@@ -5,9 +5,7 @@ import { ModulesProvider } from './contexts/ModulesContext'
|
||||
import { AmenitiesProvider } from './contexts/AmenitiesContext'
|
||||
import { NotificationsProvider } from './contexts/NotificationsContext'
|
||||
import { AppLayout } from './layouts/AppLayout'
|
||||
import { CpLayout } from './layouts/CpLayout'
|
||||
import { LoginPage } from './pages/LoginPage'
|
||||
import { CpLoginPage } from './pages/CpLoginPage'
|
||||
import { CalendarPage } from './pages/CalendarPage'
|
||||
import { BookingsPage } from './pages/BookingsPage'
|
||||
import { RoomsPage } from './pages/RoomsPage'
|
||||
@@ -21,7 +19,6 @@ import { WebsitePage } from './pages/WebsitePage'
|
||||
import { BookingWidgetPage } from './pages/BookingWidgetPage'
|
||||
import { AvailabilityPage } from './pages/AvailabilityPage'
|
||||
import { FloorMapPage } from './pages/FloorMapPage'
|
||||
import { AdminDashboard } from './pages/AdminDashboard'
|
||||
import { MigrationPage } from './pages/MigrationPage'
|
||||
import { PosPage } from './pages/PosPage'
|
||||
import { ReviewsPage } from './pages/ReviewsPage'
|
||||
@@ -39,42 +36,7 @@ import { DiscountsPage } from './pages/DiscountsPage'
|
||||
import { GuestReviewPage } from './pages/GuestReviewPage'
|
||||
import { GuestRoomServicePage } from './pages/GuestRoomServicePage'
|
||||
|
||||
// Определяем на каком домене работаем
|
||||
const IS_CP = window.location.hostname === 'cp.hotelsync.ru'
|
||||
|
||||
// ── Guard для CP: если не авторизован → /login ────────────────────────────
|
||||
function CpGuard({ children }: { children: React.ReactNode }) {
|
||||
const auth = localStorage.getItem('cpAuth')
|
||||
if (!auth) return <Navigate to="/login" replace />
|
||||
return <>{children}</>
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
// ── Control Panel (cp.hotelsync.ru) ──────────────────────────────────────
|
||||
if (IS_CP) {
|
||||
return (
|
||||
<ThemeProvider>
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="/login" element={<CpLoginPage />} />
|
||||
|
||||
<Route element={<CpGuard><CpLayout /></CpGuard>}>
|
||||
<Route path="/" element={<AdminDashboard />} />
|
||||
<Route path="/hotels" element={<AdminDashboard />} />
|
||||
<Route path="/cp-users" element={<AdminDashboard />} />
|
||||
<Route path="/billing" element={<AdminDashboard />} />
|
||||
<Route path="/monitoring" element={<AdminDashboard />} />
|
||||
<Route path="/cp-settings" element={<AdminDashboard />} />
|
||||
</Route>
|
||||
|
||||
<Route path="*" element={<Navigate to="/" replace />} />
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
</ThemeProvider>
|
||||
)
|
||||
}
|
||||
|
||||
// ── PMS App (app.hotelsync.ru) ────────────────────────────────────────────
|
||||
return (
|
||||
<ThemeProvider>
|
||||
<AuthProvider>
|
||||
|
||||
Reference in New Issue
Block a user