Files
spotlightcam/frontend/src/App.jsx

287 lines
8.0 KiB
React
Raw Normal View History

import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
import { Toaster } from 'react-hot-toast';
import { useEffect } from 'react';
import { AuthProvider, useAuth } from './contexts/AuthContext';
import { initGA } from './utils/analytics';
import usePageTracking from './hooks/usePageTracking';
import HomePage from './pages/HomePage';
import LoginPage from './pages/LoginPage';
import RegisterPage from './pages/RegisterPage';
import VerifyEmailPage from './pages/VerifyEmailPage';
import ForgotPasswordPage from './pages/ForgotPasswordPage';
import ResetPasswordPage from './pages/ResetPasswordPage';
import DashboardPage from './pages/DashboardPage';
import EventsPage from './pages/EventsPage';
import EventChatPage from './pages/EventChatPage';
import EventDetailsPage from './pages/admin/EventDetailsPage';
import EventCheckinPage from './pages/EventCheckinPage';
import MatchChatPage from './pages/MatchChatPage';
import MatchesPage from './pages/MatchesPage';
import RatePartnerPage from './pages/RatePartnerPage';
import HistoryPage from './pages/HistoryPage';
import ProfilePage from './pages/ProfilePage';
import PublicProfilePage from './pages/PublicProfilePage';
feat(admin): implement activity logs frontend page (Phase 6-7) Complete implementation of admin activity logs dashboard with real-time streaming capabilities. Admin users can now monitor all system activity through a comprehensive web interface. Features: - Stats dashboard with 4 key metrics (total logs, unique users, failures, 24h activity) - Category breakdown visualization with color-coded badges - Advanced filtering (date range, category, action type, username, success/failure) - Paginated log table (50 entries per page) with sort by timestamp - Real-time streaming toggle using Socket.IO - Color-coded action badges (blue=auth, green=event, purple=match, red=admin, yellow=chat) - Admin-only access with automatic redirect for non-admin users - Responsive design for mobile and desktop Frontend Changes: - Created ActivityLogsPage.jsx (600+ lines) with complete UI implementation - Added 3 admin API methods to api.js (getActivityLogs, getActivityLogActions, getActivityLogStats) - Added /admin/activity-logs route to App.jsx - Added admin navigation link to Navbar (desktop & mobile) with Shield icon - Only visible to users with isAdmin flag Implementation Details: - Uses getSocket() from socket service for real-time updates - Joins 'admin_activity_logs' Socket.IO room on streaming enable - Receives 'activity_log_entry' events and prepends to table (first page only) - Comprehensive error handling and loading states - Empty states for no data - Clean disconnect handling when streaming disabled Testing: - Build successful (no errors) - Ready for manual testing and verification Phase 8 (Testing) remains for manual verification of all features.
2025-12-02 23:17:19 +01:00
import ActivityLogsPage from './pages/admin/ActivityLogsPage';
feat(contact): add contact form with admin panel and navbar dropdown Database changes: - Added ContactMessage model to Prisma schema - Fields: userId, username, firstName, lastName, email, subject, message, status, ipAddress - Status enum: new, read, resolved - Relation to User model Backend changes: - Added POST /api/public/contact endpoint for form submissions - Works for both authenticated and non-authenticated users - Validation for email, subject (3-255 chars), message (10-5000 chars) - Activity logging for submissions - Added admin endpoints: - GET /api/admin/contact-messages - list with filtering by status - GET /api/admin/contact-messages/:id - view single message (auto-marks as read) - PATCH /api/admin/contact-messages/:id/status - update status - DELETE /api/admin/contact-messages/:id - delete message Frontend changes: - Created ContactPage at /contact route - For non-logged-in users: firstName, lastName, email, subject, message fields - For logged-in users: auto-fills username, shows only email, subject, message - Character counter for message (max 5000) - Success screen with auto-redirect to homepage - Created ContactMessagesPage at /admin/contact-messages - Two-column layout: message list + detail view - Filter by status (all, new, read, resolved) - View message details with sender info and IP address - Update status and delete messages - Added admin dropdown menu to Navbar - Desktop: dropdown with Activity Logs and Contact Messages - Mobile: expandable submenu - Click outside to close on desktop - ChevronDown icon rotates when open Note: CAPTCHA integration planned for future enhancement
2025-12-05 17:15:25 +01:00
import ContactMessagesPage from './pages/admin/ContactMessagesPage';
import ContactPage from './pages/ContactPage';
import AboutUsPage from './pages/AboutUsPage';
import HowItWorksPage from './pages/HowItWorksPage';
feat(beta): add beta testing features and privacy policy page Implemented comprehensive beta testing system with tier badges and reorganized environment configuration for better maintainability. Beta Testing Features: - Beta banner component with dismissible state (localStorage) - Auto-assign SUPPORTER tier to new registrations (env controlled) - TierBadge component with SUPPORTER/COMFORT tier display - Badge shown in Navbar, ProfilePage, and PublicProfilePage - Environment variables: VITE_BETA_MODE, BETA_AUTO_SUPPORTER Environment Configuration Reorganization: - Moved .env files from root to frontend/ and backend/ directories - Created .env.{development,production}{,.example} structure - Updated docker-compose.yml to use env_file for frontend - All env vars properly namespaced and documented Privacy Policy Implementation: - New /privacy route with dedicated PrivacyPage component - Comprehensive GDPR/RODO compliant privacy policy (privacy.html) - Updated CookieConsent banner to link to /privacy - Added Privacy Policy links to all footers (HomePage, PublicFooter) - Removed privacy section from About Us page HTML Content System: - Replaced react-markdown dependency with simple HTML loader - New HtmlContentPage component for rendering .html files - Converted about-us.md and how-it-works.md to .html format - Inline CSS support for full styling control - Easier content editing without React knowledge Backend Changes: - Registration auto-assigns SUPPORTER tier when BETA_AUTO_SUPPORTER=true - Added accountTier to auth middleware and user routes - Updated public profile endpoint to include accountTier Files: - Added: frontend/.env.{development,production}{,.example} - Added: backend/.env variables for BETA_AUTO_SUPPORTER - Added: components/BetaBanner.jsx, TierBadge.jsx, HtmlContentPage.jsx - Added: pages/PrivacyPage.jsx - Added: public/content/{about-us,how-it-works,privacy}.html - Modified: docker-compose.yml (env_file configuration) - Modified: App.jsx (privacy route, beta banner) - Modified: auth.js (auto SUPPORTER tier logic)
2025-12-06 11:50:28 +01:00
import PrivacyPage from './pages/PrivacyPage';
import NotFoundPage from './pages/NotFoundPage';
import VerificationBanner from './components/common/VerificationBanner';
import InstallPWA from './components/pwa/InstallPWA';
import CookieConsent from './components/common/CookieConsent';
feat(beta): add beta testing features and privacy policy page Implemented comprehensive beta testing system with tier badges and reorganized environment configuration for better maintainability. Beta Testing Features: - Beta banner component with dismissible state (localStorage) - Auto-assign SUPPORTER tier to new registrations (env controlled) - TierBadge component with SUPPORTER/COMFORT tier display - Badge shown in Navbar, ProfilePage, and PublicProfilePage - Environment variables: VITE_BETA_MODE, BETA_AUTO_SUPPORTER Environment Configuration Reorganization: - Moved .env files from root to frontend/ and backend/ directories - Created .env.{development,production}{,.example} structure - Updated docker-compose.yml to use env_file for frontend - All env vars properly namespaced and documented Privacy Policy Implementation: - New /privacy route with dedicated PrivacyPage component - Comprehensive GDPR/RODO compliant privacy policy (privacy.html) - Updated CookieConsent banner to link to /privacy - Added Privacy Policy links to all footers (HomePage, PublicFooter) - Removed privacy section from About Us page HTML Content System: - Replaced react-markdown dependency with simple HTML loader - New HtmlContentPage component for rendering .html files - Converted about-us.md and how-it-works.md to .html format - Inline CSS support for full styling control - Easier content editing without React knowledge Backend Changes: - Registration auto-assigns SUPPORTER tier when BETA_AUTO_SUPPORTER=true - Added accountTier to auth middleware and user routes - Updated public profile endpoint to include accountTier Files: - Added: frontend/.env.{development,production}{,.example} - Added: backend/.env variables for BETA_AUTO_SUPPORTER - Added: components/BetaBanner.jsx, TierBadge.jsx, HtmlContentPage.jsx - Added: pages/PrivacyPage.jsx - Added: public/content/{about-us,how-it-works,privacy}.html - Modified: docker-compose.yml (env_file configuration) - Modified: App.jsx (privacy route, beta banner) - Modified: auth.js (auto SUPPORTER tier logic)
2025-12-06 11:50:28 +01:00
import BetaBanner from './components/BetaBanner';
// Protected Route Component with Verification Banner
const ProtectedRoute = ({ children }) => {
const { isAuthenticated, loading } = useAuth();
if (loading) {
return (
<div className="min-h-screen flex items-center justify-center">
<div className="text-lg text-gray-600">Loading...</div>
</div>
);
}
if (!isAuthenticated) {
return <Navigate to="/login" replace />;
}
return (
<>
<VerificationBanner />
{children}
</>
);
};
// Public Route Component (redirect to dashboard if already logged in)
const PublicRoute = ({ children }) => {
const { isAuthenticated, loading } = useAuth();
if (loading) {
return (
<div className="min-h-screen flex items-center justify-center">
<div className="text-lg text-gray-600">Loading...</div>
</div>
);
}
if (isAuthenticated) {
return <Navigate to="/dashboard" replace />;
}
return children;
};
// Analytics wrapper component
const AnalyticsWrapper = ({ children }) => {
usePageTracking(); // Track page views on route changes
useEffect(() => {
// Initialize Google Analytics when user consents to cookies
const measurementId = import.meta.env.VITE_GA_MEASUREMENT_ID;
if (measurementId) {
// Wait a bit for cookie consent banner to be processed
const timer = setTimeout(() => {
initGA(measurementId);
}, 1500);
return () => clearTimeout(timer);
}
}, []);
return children;
};
function App() {
return (
<BrowserRouter>
<AuthProvider>
<AnalyticsWrapper>
feat(beta): add beta testing features and privacy policy page Implemented comprehensive beta testing system with tier badges and reorganized environment configuration for better maintainability. Beta Testing Features: - Beta banner component with dismissible state (localStorage) - Auto-assign SUPPORTER tier to new registrations (env controlled) - TierBadge component with SUPPORTER/COMFORT tier display - Badge shown in Navbar, ProfilePage, and PublicProfilePage - Environment variables: VITE_BETA_MODE, BETA_AUTO_SUPPORTER Environment Configuration Reorganization: - Moved .env files from root to frontend/ and backend/ directories - Created .env.{development,production}{,.example} structure - Updated docker-compose.yml to use env_file for frontend - All env vars properly namespaced and documented Privacy Policy Implementation: - New /privacy route with dedicated PrivacyPage component - Comprehensive GDPR/RODO compliant privacy policy (privacy.html) - Updated CookieConsent banner to link to /privacy - Added Privacy Policy links to all footers (HomePage, PublicFooter) - Removed privacy section from About Us page HTML Content System: - Replaced react-markdown dependency with simple HTML loader - New HtmlContentPage component for rendering .html files - Converted about-us.md and how-it-works.md to .html format - Inline CSS support for full styling control - Easier content editing without React knowledge Backend Changes: - Registration auto-assigns SUPPORTER tier when BETA_AUTO_SUPPORTER=true - Added accountTier to auth middleware and user routes - Updated public profile endpoint to include accountTier Files: - Added: frontend/.env.{development,production}{,.example} - Added: backend/.env variables for BETA_AUTO_SUPPORTER - Added: components/BetaBanner.jsx, TierBadge.jsx, HtmlContentPage.jsx - Added: pages/PrivacyPage.jsx - Added: public/content/{about-us,how-it-works,privacy}.html - Modified: docker-compose.yml (env_file configuration) - Modified: App.jsx (privacy route, beta banner) - Modified: auth.js (auto SUPPORTER tier logic)
2025-12-06 11:50:28 +01:00
{/* Beta Testing Banner */}
<BetaBanner />
{/* PWA Install Prompt */}
<InstallPWA />
{/* Cookie Consent Banner */}
<CookieConsent />
{/* Toast Notifications */}
<Toaster
position="top-right"
toastOptions={{
duration: 4000,
style: {
background: '#333',
color: '#fff',
},
success: {
iconTheme: {
primary: '#22c55e',
secondary: '#fff',
},
},
error: {
iconTheme: {
primary: '#ef4444',
secondary: '#fff',
},
},
}}
/>
<Routes>
{/* Public Routes */}
<Route
path="/login"
element={
<PublicRoute>
<LoginPage />
</PublicRoute>
}
/>
<Route
path="/register"
element={
<PublicRoute>
<RegisterPage />
</PublicRoute>
}
/>
<Route path="/verify-email" element={<VerifyEmailPage />} />
<Route path="/forgot-password" element={<ForgotPasswordPage />} />
<Route path="/reset-password" element={<ResetPasswordPage />} />
{/* Protected Routes */}
<Route
path="/dashboard"
element={
<ProtectedRoute>
<DashboardPage />
</ProtectedRoute>
}
/>
<Route
path="/events"
element={
<ProtectedRoute>
<EventsPage />
</ProtectedRoute>
}
/>
<Route
path="/events/:slug/chat"
element={
<ProtectedRoute>
<EventChatPage />
</ProtectedRoute>
}
/>
<Route
path="/admin/events/:slug/details"
element={
<ProtectedRoute>
<EventDetailsPage />
</ProtectedRoute>
}
/>
<Route
path="/events/checkin/:token"
element={
<ProtectedRoute>
<EventCheckinPage />
</ProtectedRoute>
}
/>
<Route
path="/matches"
element={
<ProtectedRoute>
<MatchesPage />
</ProtectedRoute>
}
/>
<Route
path="/matches/:slug/chat"
element={
<ProtectedRoute>
<MatchChatPage />
</ProtectedRoute>
}
/>
<Route
path="/matches/:slug/rate"
element={
<ProtectedRoute>
<RatePartnerPage />
</ProtectedRoute>
}
/>
<Route
path="/history"
element={
<ProtectedRoute>
<HistoryPage />
</ProtectedRoute>
}
/>
<Route
path="/profile"
element={
<ProtectedRoute>
<ProfilePage />
</ProtectedRoute>
}
/>
feat(admin): implement activity logs frontend page (Phase 6-7) Complete implementation of admin activity logs dashboard with real-time streaming capabilities. Admin users can now monitor all system activity through a comprehensive web interface. Features: - Stats dashboard with 4 key metrics (total logs, unique users, failures, 24h activity) - Category breakdown visualization with color-coded badges - Advanced filtering (date range, category, action type, username, success/failure) - Paginated log table (50 entries per page) with sort by timestamp - Real-time streaming toggle using Socket.IO - Color-coded action badges (blue=auth, green=event, purple=match, red=admin, yellow=chat) - Admin-only access with automatic redirect for non-admin users - Responsive design for mobile and desktop Frontend Changes: - Created ActivityLogsPage.jsx (600+ lines) with complete UI implementation - Added 3 admin API methods to api.js (getActivityLogs, getActivityLogActions, getActivityLogStats) - Added /admin/activity-logs route to App.jsx - Added admin navigation link to Navbar (desktop & mobile) with Shield icon - Only visible to users with isAdmin flag Implementation Details: - Uses getSocket() from socket service for real-time updates - Joins 'admin_activity_logs' Socket.IO room on streaming enable - Receives 'activity_log_entry' events and prepends to table (first page only) - Comprehensive error handling and loading states - Empty states for no data - Clean disconnect handling when streaming disabled Testing: - Build successful (no errors) - Ready for manual testing and verification Phase 8 (Testing) remains for manual verification of all features.
2025-12-02 23:17:19 +01:00
{/* Admin Routes */}
<Route
path="/admin/activity-logs"
element={
<ProtectedRoute>
<ActivityLogsPage />
</ProtectedRoute>
}
/>
feat(contact): add contact form with admin panel and navbar dropdown Database changes: - Added ContactMessage model to Prisma schema - Fields: userId, username, firstName, lastName, email, subject, message, status, ipAddress - Status enum: new, read, resolved - Relation to User model Backend changes: - Added POST /api/public/contact endpoint for form submissions - Works for both authenticated and non-authenticated users - Validation for email, subject (3-255 chars), message (10-5000 chars) - Activity logging for submissions - Added admin endpoints: - GET /api/admin/contact-messages - list with filtering by status - GET /api/admin/contact-messages/:id - view single message (auto-marks as read) - PATCH /api/admin/contact-messages/:id/status - update status - DELETE /api/admin/contact-messages/:id - delete message Frontend changes: - Created ContactPage at /contact route - For non-logged-in users: firstName, lastName, email, subject, message fields - For logged-in users: auto-fills username, shows only email, subject, message - Character counter for message (max 5000) - Success screen with auto-redirect to homepage - Created ContactMessagesPage at /admin/contact-messages - Two-column layout: message list + detail view - Filter by status (all, new, read, resolved) - View message details with sender info and IP address - Update status and delete messages - Added admin dropdown menu to Navbar - Desktop: dropdown with Activity Logs and Contact Messages - Mobile: expandable submenu - Click outside to close on desktop - ChevronDown icon rotates when open Note: CAPTCHA integration planned for future enhancement
2025-12-05 17:15:25 +01:00
<Route
path="/admin/contact-messages"
element={
<ProtectedRoute>
<ContactMessagesPage />
</ProtectedRoute>
}
/>
feat(admin): implement activity logs frontend page (Phase 6-7) Complete implementation of admin activity logs dashboard with real-time streaming capabilities. Admin users can now monitor all system activity through a comprehensive web interface. Features: - Stats dashboard with 4 key metrics (total logs, unique users, failures, 24h activity) - Category breakdown visualization with color-coded badges - Advanced filtering (date range, category, action type, username, success/failure) - Paginated log table (50 entries per page) with sort by timestamp - Real-time streaming toggle using Socket.IO - Color-coded action badges (blue=auth, green=event, purple=match, red=admin, yellow=chat) - Admin-only access with automatic redirect for non-admin users - Responsive design for mobile and desktop Frontend Changes: - Created ActivityLogsPage.jsx (600+ lines) with complete UI implementation - Added 3 admin API methods to api.js (getActivityLogs, getActivityLogActions, getActivityLogStats) - Added /admin/activity-logs route to App.jsx - Added admin navigation link to Navbar (desktop & mobile) with Shield icon - Only visible to users with isAdmin flag Implementation Details: - Uses getSocket() from socket service for real-time updates - Joins 'admin_activity_logs' Socket.IO room on streaming enable - Receives 'activity_log_entry' events and prepends to table (first page only) - Comprehensive error handling and loading states - Empty states for no data - Clean disconnect handling when streaming disabled Testing: - Build successful (no errors) - Ready for manual testing and verification Phase 8 (Testing) remains for manual verification of all features.
2025-12-02 23:17:19 +01:00
{/* Home Page */}
<Route path="/" element={<HomePage />} />
feat(contact): add contact form with admin panel and navbar dropdown Database changes: - Added ContactMessage model to Prisma schema - Fields: userId, username, firstName, lastName, email, subject, message, status, ipAddress - Status enum: new, read, resolved - Relation to User model Backend changes: - Added POST /api/public/contact endpoint for form submissions - Works for both authenticated and non-authenticated users - Validation for email, subject (3-255 chars), message (10-5000 chars) - Activity logging for submissions - Added admin endpoints: - GET /api/admin/contact-messages - list with filtering by status - GET /api/admin/contact-messages/:id - view single message (auto-marks as read) - PATCH /api/admin/contact-messages/:id/status - update status - DELETE /api/admin/contact-messages/:id - delete message Frontend changes: - Created ContactPage at /contact route - For non-logged-in users: firstName, lastName, email, subject, message fields - For logged-in users: auto-fills username, shows only email, subject, message - Character counter for message (max 5000) - Success screen with auto-redirect to homepage - Created ContactMessagesPage at /admin/contact-messages - Two-column layout: message list + detail view - Filter by status (all, new, read, resolved) - View message details with sender info and IP address - Update status and delete messages - Added admin dropdown menu to Navbar - Desktop: dropdown with Activity Logs and Contact Messages - Mobile: expandable submenu - Click outside to close on desktop - ChevronDown icon rotates when open Note: CAPTCHA integration planned for future enhancement
2025-12-05 17:15:25 +01:00
{/* Contact Page - Public route */}
<Route path="/contact" element={<ContactPage />} />
{/* About Us Page - Public route */}
<Route path="/about-us" element={<AboutUsPage />} />
{/* How It Works Page - Public route */}
<Route path="/how-it-works" element={<HowItWorksPage />} />
feat(beta): add beta testing features and privacy policy page Implemented comprehensive beta testing system with tier badges and reorganized environment configuration for better maintainability. Beta Testing Features: - Beta banner component with dismissible state (localStorage) - Auto-assign SUPPORTER tier to new registrations (env controlled) - TierBadge component with SUPPORTER/COMFORT tier display - Badge shown in Navbar, ProfilePage, and PublicProfilePage - Environment variables: VITE_BETA_MODE, BETA_AUTO_SUPPORTER Environment Configuration Reorganization: - Moved .env files from root to frontend/ and backend/ directories - Created .env.{development,production}{,.example} structure - Updated docker-compose.yml to use env_file for frontend - All env vars properly namespaced and documented Privacy Policy Implementation: - New /privacy route with dedicated PrivacyPage component - Comprehensive GDPR/RODO compliant privacy policy (privacy.html) - Updated CookieConsent banner to link to /privacy - Added Privacy Policy links to all footers (HomePage, PublicFooter) - Removed privacy section from About Us page HTML Content System: - Replaced react-markdown dependency with simple HTML loader - New HtmlContentPage component for rendering .html files - Converted about-us.md and how-it-works.md to .html format - Inline CSS support for full styling control - Easier content editing without React knowledge Backend Changes: - Registration auto-assigns SUPPORTER tier when BETA_AUTO_SUPPORTER=true - Added accountTier to auth middleware and user routes - Updated public profile endpoint to include accountTier Files: - Added: frontend/.env.{development,production}{,.example} - Added: backend/.env variables for BETA_AUTO_SUPPORTER - Added: components/BetaBanner.jsx, TierBadge.jsx, HtmlContentPage.jsx - Added: pages/PrivacyPage.jsx - Added: public/content/{about-us,how-it-works,privacy}.html - Modified: docker-compose.yml (env_file configuration) - Modified: App.jsx (privacy route, beta banner) - Modified: auth.js (auto SUPPORTER tier logic)
2025-12-06 11:50:28 +01:00
{/* Privacy Policy Page - Public route */}
<Route path="/privacy" element={<PrivacyPage />} />
{/* Public Profile - /u/username format (no auth required) */}
<Route path="/u/:username" element={<PublicProfilePage />} />
{/* 404 Not Found - Catch all unmatched routes */}
<Route path="*" element={<NotFoundPage />} />
</Routes>
</AnalyticsWrapper>
</AuthProvider>
</BrowserRouter>
);
}
export default App;