added advertising

This commit is contained in:
SlimusMinus
2026-09-23 23:38:54 +03:00
parent 3661985a6a
commit 4e20315998
33 changed files with 3351 additions and 18 deletions

View File

@@ -1,6 +1,6 @@
// src/App.jsx
import { useEffect, useRef } from 'react';
import { BrowserRouter, Routes, Route, useLocation } from 'react-router-dom';
import { BrowserRouter, Routes, Route, useLocation, Navigate } from 'react-router-dom';
import { AuthProvider } from './context/AuthContext';
import { ThemeProvider } from './context/ThemeContext';
import { useAuthContext } from './context/AuthContext';
@@ -11,6 +11,7 @@ import MainFeed from './pages/MainFeed';
import ChatPage from './pages/ChatPage';
import ChatListPage from './pages/ChatListPage';
import ReviewsPage from './pages/ReviewsPage';
import AdminAdsPage from './pages/AdminAdsPage';
import './styles/chat.css';
function ScrollToTop() {
@@ -38,6 +39,15 @@ function UnreadListener() {
return null;
}
// Защита десктоп-only админ-роутов: доступен только при isAdmin.
// Дополнительная проверка на уровне роута — defense in depth к тому,
// что пункт меню в Sidebar скрыт для не-админов.
function AdminRoute({ children }) {
const { isAdmin } = useAuthContext();
if (!isAdmin) return <Navigate to="/feed" replace />;
return children;
}
function App() {
return (
<ThemeProvider>
@@ -51,6 +61,7 @@ function App() {
<Route path="/reviews" element={<ReviewsPage />} />
<Route path="/chats" element={<ChatListPage />} />
<Route path="/chats/:chatId" element={<ChatPage />} />
<Route path="/admin/ads" element={<AdminRoute><AdminAdsPage /></AdminRoute>} />
<Route path="*" element={<LandingPage />} />
</Routes>
</BrowserRouter>