tahamajs's picture
download
raw
46.1 kB
// src/App.tsx
import { useState, useEffect, Suspense, lazy, ReactNode } from "react";
import { BrowserRouter, Routes, Route, Navigate, useNavigate, useParams, useLocation } from "react-router-dom";
import { motion, AnimatePresence } from "framer-motion";
import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
// In App.tsx, update your routes:
import AuthLayout from "@/components/layout/AuthLayout";
import DashboardLayout from "@/components/layout/DashboardLayout";
import PublicLayout from "@/components/layout/PublicLayout";
import AdminLayout from "@/components/layout/AdminLayout";
import EmptyLayout from "@/components/layout/EmptyLayout";
// Context Providers
import { ThemeProvider, useTheme } from "@/hooks/useTheme";
import { AuthProvider, useAuth } from "@/context/AuthContext";
import { WebSocketProvider } from "@/context/WebSocketContext";
import { ToastProvider } from "@/context/ToastContext";
import { NotificationProvider } from "@/context/NotificationContext";
import { DraftProvider } from "@/context/DraftContext";
import { CollaborationProvider } from "@/context/CollaborationContext";
import { OfflineProvider } from "@/context/OfflineContext";
import { FeatureFlagProvider, useFeatureFlags } from "@/context/FeatureFlagContext";
import { SearchProvider } from "@/context/SearchContext";
import { ModalProvider } from "@/context/ModalContext";
import { LoadingProvider } from "@/context/LoadingContext";
// Layout & Components
import MainLayout from "@/components/layout/MainLayout";
import { CommandPaletteProvider } from "@/components/command-palette";
import { FlowPreservationProvider } from "@/components/flow/FlowPreservationProvider";
import { SmartGlassProvider } from "@/components/workspace";
import { ConferenceRoom } from "@/components/conference/ConferenceRoom";
import { LoadingScreen } from "@/components/layout/LoadingScreen";
import { ErrorBoundary } from "@/components/common/ErrorBoundary";
import { AnimatedBackground } from "@/components/ui/AnimatedBackground";
import api from "@/lib/api";
// ============================================
// Lazy-loaded Pages (Alphabetical Order - NO DUPLICATES)
// ============================================
// Auth Pages
const LoginPage = lazy(() => import("@/pages/LoginPage"));
const RegisterPage = lazy(() => import("@/pages/RegisterPage"));
const ForgotPasswordPage = lazy(() => import("@/pages/ForgotPasswordPage"));
const JoinPage = lazy(() => import("@/pages/JoinPage"));
// Main Pages
const HomePage = lazy(() => import("@/pages/HomePage"));
const DashboardPage = lazy(() => import("@/pages/DashboardPage"));
const SearchPage = lazy(() => import("@/pages/SearchPage"));
const SearchUsersPage = lazy(() => import("@/pages/SearchUsersPage"));
const NotFound = lazy(() => import("@/pages/NotFound"));
// Static Pages
const AboutPage = lazy(() => import("@/pages/AboutPage"));
const ContactPage = lazy(() => import("@/pages/ContactPage"));
const FaqPage = lazy(() => import("@/pages/FaqPage"));
const TermsPage = lazy(() => import("@/pages/TermsPage"));
const PrivacyPage = lazy(() => import("@/pages/PrivacyPage"));
const TrendingPage = lazy(() => import("@/pages/TrendingPage"));
const CommunityPage = lazy(() => import("@/pages/CommunityPage"));
const SupportPage = lazy(() => import("@/pages/SupportPage"));
const OpenAccessPage = lazy(() => import("@/pages/OpenAccessPage"));
const PeerReviewPage = lazy(() => import("@/pages/PeerReviewPage"));
const ResearchDataPage = lazy(() => import("@/pages/ResearchDataPage"));
const CitationGuidePage = lazy(() => import("@/pages/CitationGuidePage"));
const AuthorGuidelinesPage = lazy(() => import("@/pages/AuthorGuidelinesPage"));
const ReviewerGuidelinesPage = lazy(() => import("@/pages/ReviewerGuidelinesPage"));
const ApplyReviewerPage = lazy(() => import("@/pages/ApplyReviewerPage"));
const EthicsPage = lazy(() => import("@/pages/EthicsPage"));
const FeaturesPage = lazy(() => import("@/pages/FeaturesPage"));
const PricingPage = lazy(() => import("@/pages/PricingPage"));
const SubscriptionPage = lazy(() => import("@/pages/SubscriptionPage"));
const RoadmapPage = lazy(() => import("@/pages/RoadmapPage"));
const ChangelogPage = lazy(() => import("@/pages/ChangelogPage"));
const DocumentationPage = lazy(() => import("@/pages/DocumentationPage"));
const TutorialsPage = lazy(() => import("@/pages/TutorialsPage"));
const TutorialDetailPage = lazy(() => import("@/pages/TutorialDetailPage"));
const CareersPage = lazy(() => import("@/pages/CareersPage"));
const CookiesPage = lazy(() => import("@/pages/CookiesPage"));
const SecurityPage = lazy(() => import("@/pages/SecurityPage"));
const PartnersPage = lazy(() => import("@/pages/PartnersPage"));
// Article Pages
const ArticlesPage = lazy(() => import("@/pages/ArticlesPage"));
const ArticleDetailPage = lazy(() => import("@/pages/ArticleDetailPage"));
const CreateArticlePage = lazy(() => import("@/pages/CreateArticlePage"));
const AddArticlePage = lazy(() => import("@/pages/AddArticlePage"));
const LikedArticlesPage = lazy(() => import("@/pages/LikedArticlesPage"));
const UserLikedArticlesPage = lazy(() => import("@/pages/UserLikedArticlesPage"));
const BookmarksPage = lazy(() => import("@/pages/BookmarksPage"));
const MyPostsPage = lazy(() => import("@/pages/MyPostsPage"));
// Tool Pages
const ToolsPage = lazy(() => import("@/pages/ToolsPage"));
const ToolDetailPage = lazy(() => import("@/pages/ToolDetailPage"));
const ToolBuilderPage = lazy(() => import("@/pages/ToolBuilderPage"));
const InstalledToolsPage = lazy(() => import("@/pages/InstalledToolsPage"));
// Collection Pages
const CollectionsPage = lazy(() => import("@/pages/CollectionsPage"));
const CollectionDetailPage = lazy(() => import("@/pages/CollectionDetailPage"));
const PaperCollectionsPage = lazy(() => import("@/pages/PaperCollectionsPage"));
const ProjectsPage = lazy(() => import("@/pages/ProjectsPage"));
const CreateProjectPage = lazy(() => import("@/pages/CreateProjectPage"));
const EditProjectPage = lazy(() => import("@/pages/EditProjectPage"));
const AdminUsersPage = lazy(() => import("@/pages/admin/AdminUsersPage"));
// Profile Pages
const ProfilePage = lazy(() => import("@/pages/ProfilePage"));
const PublicProfilePage = lazy(() => import("@/pages/PublicProfilePage"));
const ProfileHubPage = lazy(() => import("@/pages/ProfileHubPage"));
const SettingsPage = lazy(() => import("@/pages/SettingsPage"));
const FollowersPage = lazy(() => import("@/pages/FollowersPage"));
const FollowingPage = lazy(() => import("@/pages/FollowingPage"));
const FollowList = lazy(() => import("@/pages/FollowList"));
// Social & Communication
const MessagesPage = lazy(() => import("@/pages/MessagesPage"));
const UnifiedInboxPage = lazy(() => import("@/pages/UnifiedInboxPage"));
const UnifiedMessagesPage = lazy(() => import("@/pages/UnifiedMessagesPage"));
const PeerRoomPage = lazy(() => import("@/pages/PeerRoomPage"));
const GroupDetailPage = lazy(() => import("@/pages/GroupDetailPage"));
const NetworkingPage = lazy(() => import("@/pages/NetworkingPage"));
const CollaboratePage = lazy(() => import("@/pages/CollaboratePage"));
const AsyncCollaborationPage = lazy(() => import("@/pages/AsyncCollaborationPage"));
// Events & Polls
const EventPage = lazy(() => import("@/pages/EventPage"));
const ConferencePage = lazy(() => import("@/pages/ConferencePage"));
const PollsPage = lazy(() => import("@/pages/PollsPage"));
const CalendarPage = lazy(() => import("@/pages/CalendarPage"));
// Projects & Grants
const ProjectWorkspacePage = lazy(() => import("@/pages/ProjectWorkspacePage"));
const ProjectSpacePage = lazy(() => import("@/pages/ProjectSpacePage"));
const GrantsPage = lazy(() => import("@/pages/GrantsPage"));
const GrantAssistantPage = lazy(() => import("@/pages/GrantAssistantPage"));
// Research & Authoring
const ReferenceManagerPage = lazy(() => import("@/pages/ReferenceManagerPage"));
const PreprintSubmissionPage = lazy(() => import("@/pages/PreprintSubmissionPage"));
const PaperObjectPage = lazy(() => import("@/pages/PaperObjectPage"));
const ScientificEditor = lazy(() => import("@/pages/ScientificEditor"));
const AuthoringStudioPage = lazy(() => import("@/pages/AuthoringStudioPage"));
const ResearchAssistantPage = lazy(() => import("@/pages/ResearchAssistantPage"));
const AICoScientistPage = lazy(() => import("@/pages/AICoScientistPage"));
const LatexEditorIntroPage = lazy(() => import("@/pages/LatexEditorIntroPage"));
const AICoScientistIntroPage = lazy(() => import("@/pages/AICoScientistIntroPage"));
const AppStoreIntroPage = lazy(() => import("@/pages/AppStoreIntroPage"));
const APIDocsPage = lazy(() => import("@/pages/APIDocsPage"));
const DeveloperCliIntroPage = lazy(() => import("@/pages/DeveloperCliIntroPage"));
const CliDocsPage = lazy(() => import("@/pages/CliDocsPage"));
const SmartGlassIntroPage = lazy(() => import("@/pages/SmartGlassIntroPage"));
// Data & Analytics
const DataHubPage = lazy(() => import("@/pages/DataHubPage"));
const AnalyticsPage = lazy(() => import("@/pages/AnalyticsPage"));
const DiscoveryPage = lazy(() => import("@/pages/DiscoveryPage"));
const RecommendationsPage = lazy(() => import("@/pages/RecommendationsPage"));
const GapAnalysisPage = lazy(() => import("@/pages/GapAnalysisPage"));
const TagsPage = lazy(() => import("@/pages/TagsPage"));
// Lab & Inventory
const LabInventoryPage = lazy(() => import("@/pages/LabInventoryPage"));
// Admin Pages
const AdminPage = lazy(() => import("@/pages/AdminPage"));
const AdminBlogPage = lazy(() => import("@/pages/admin/AdminBlogPage"));
// Trust & Security
const TrustDashboardPage = lazy(() => import("@/pages/TrustDashboardPage"));
// UI/UX
const GenUIPage = lazy(() => import("@/pages/GenUIPage"));
const SmartGlassPage = lazy(() => import("@/pages/SmartGlassPage"));
const MultiAgentPage = lazy(() => import("@/pages/MultiAgentPage"));
const NotificationsPage = lazy(() => import("@/pages/NotificationsPage"));
// Add these lazy imports
const StatusPage = lazy(() => import("@/pages/StatusPage"));
const BlogPage = lazy(() => import("@/pages/BlogPage"));
const BlogPostPage = lazy(() => import("@/pages/BlogPostPage"));
const HelpCenterPage = lazy(() => import("@/pages/HelpCenterPage"));
const VersionPage = lazy(() => import("@/pages/VersionPage"));
const CitationGraphPage = lazy(() => import("@/pages/CitationGraphPage"));
const WebhookPage = lazy(() => import("@/pages/WebhookPage"));
const MetricsPage = lazy(() => import("@/pages/MetricsPage"));
const ProvenancePage = lazy(() => import("@/pages/ProvenancePage"));
const PreferencePage = lazy(() => import("@/pages/PreferencePage"));
const SocialFeedPage = lazy(() => import("@/pages/SocialFeedPage"));
const NewsletterPage = lazy(() => import("@/pages/NewsletterPage"));
const VoiceSettingsPage = lazy(() => import("@/pages/VoiceSettingsPage"));
const DebugPage = lazy(() => import("@/pages/DebugPage"));
const ExportPage = lazy(() => import("@/pages/ExportPage"));
const OJSIntegrationPage = lazy(() => import("@/pages/OJSIntegrationPage"));
const MediaPage = lazy(() => import("@/pages/MediaPage"));
const DownloadPage = lazy(() => import("@/pages/DownloadPage"));
const DocumentExportPage = lazy(() => import("@/pages/DocumentExportPage"));
const BroadcastPage = lazy(() => import("@/pages/BroadcastPage"));
const GraphNodePage = lazy(() => import("@/pages/GraphNodePage"));
const DataRepositoryPage = lazy(() => import("@/pages/DataRepositoryPage"));
const EncryptionPage = lazy(() => import("@/pages/EncryptionPage"));
const UploadPage = lazy(() => import("@/pages/UploadPage"));
const IntegrationPage = lazy(() => import("@/pages/IntegrationPage"));
const AuditPage = lazy(() => import("@/pages/AuditPage"));
const BackupPage = lazy(() => import("@/pages/BackupPage"));
const PeerReviewWorkflowPage = lazy(() => import("@/pages/PeerReviewWorkflowPage"));
const ReportPage = lazy(() => import("@/pages/ReportPage"));
const ApiKeyPage = lazy(() => import("@/pages/ApiKeyPage"));
const DocumentRagPage = lazy(() => import("@/pages/DocumentRagPage"));
// Add these routes inside MainLayout
// Workspace
const SmartGlassWorkspace = lazy(() =>
import("@/components/workspace/SmartGlassWorkspace").then((mod) => ({
default: mod.SmartGlassWorkspace,
}))
);
// ============================================
// Page Transition Animation
// ============================================
const pageVariants = {
initial: { opacity: 0, y: 8 },
in: { opacity: 1, y: 0 },
out: { opacity: 0, y: -8 },
};
const pageTransition = {
type: "spring" as const,
stiffness: 260,
damping: 28,
mass: 1,
};
const PageTransition = ({ children }: { children: React.ReactNode }) => (
<motion.div
initial="initial"
animate="in"
exit="out"
variants={pageVariants}
transition={pageTransition}
className="w-full flex-1 flex flex-col min-h-[calc(100vh-4rem)]"
>
{children}
</motion.div>
);
// ============================================
// Conference Room Route Component
// ============================================
const ConferenceRoomRoute = () => {
const { roomId } = useParams<{ roomId: string }>();
const { user } = useAuth();
if (!roomId) {
return <Navigate to="/conference" replace />;
}
return (
<ConferenceRoom
roomId={roomId}
currentUsername={user?.username || user?.email || "guest"}
/>
);
};
// ============================================
// Protected Route Wrapper
// ============================================
function ProtectedRoute({
children,
requireAdmin = false,
}: {
children: React.ReactNode;
requireAdmin?: boolean;
}) {
const { user, isLoading } = useAuth();
if (isLoading) return <LoadingScreen onFinish={() => {}} duration={2000} />;
if (!user) return <Navigate to="/login" replace />;
if (requireAdmin && user.role !== "admin")
return <Navigate to="/dashboard" replace />;
return <>{children}</>;
}
// ============================================
// Auth Redirect Listener
// ============================================
function AuthRedirectListener({ children }: { children: React.ReactNode }) {
const navigate = useNavigate();
useEffect(() => {
const handleUnauthorized = () => {
navigate("/login", { replace: true });
};
window.addEventListener("auth:unauthorized", handleUnauthorized);
return () => window.removeEventListener("auth:unauthorized", handleUnauthorized);
}, [navigate]);
return <>{children}</>;
}
// ============================================
// Suspense Fallback (Skeleton)
// ============================================
const PageFallback = () => (
<div className="min-h-screen bg-gray-50 dark:bg-gray-900 animate-pulse">
<div className="mx-auto max-w-7xl px-4 py-8">
<div className="h-8 w-48 bg-gray-200 dark:bg-gray-800 rounded mb-6" />
<div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
{[...Array(6)].map((_, i) => (
<div key={i} className="h-64 bg-gray-200 dark:bg-gray-800 rounded-2xl" />
))}
</div>
</div>
</div>
);
// ============================================
// App Providers Wrapper
// ============================================
function AppProviders({ children }: { children: ReactNode }) {
return (
<ErrorBoundary>
<ThemeProvider>
<AuthProvider>
<WebSocketProvider>
<ToastProvider>
<NotificationProvider>
<DraftProvider>
<CollaborationProvider>
<OfflineProvider>
<FeatureFlagProvider>
<SearchProvider>
<ModalProvider>
<LoadingProvider>
<BrowserRouter>
<AuthRedirectListener>
{children}
</AuthRedirectListener>
</BrowserRouter>
</LoadingProvider>
</ModalProvider>
</SearchProvider>
</FeatureFlagProvider>
</OfflineProvider>
</CollaborationProvider>
</DraftProvider>
</NotificationProvider>
</ToastProvider>
</WebSocketProvider>
</AuthProvider>
</ThemeProvider>
</ErrorBoundary>
);
}
// ============================================
// Main App Component
// ============================================
export default function App() {
const [showInitialLoading, setShowInitialLoading] = useState(true);
if (showInitialLoading) {
return (
<LoadingScreen
onFinish={() => setShowInitialLoading(false)}
duration={2000}
/>
);
}
return (
<AppProviders>
<AppContent />
</AppProviders>
);
}
// ============================================
// App Content with Routes
// ============================================
function AppContent() {
const navigate = useNavigate();
const location = useLocation();
const { toggleTheme, resolvedTheme } = useTheme();
const { user } = useAuth();
const { isEnabled } = useFeatureFlags();
const [appResetKey, setAppResetKey] = useState(0);
const [recentPapers, setRecentPapers] = useState<{ id: string; title: string }[]>([]);
const [recentContacts, setRecentContacts] = useState<{ username: string; fullName?: string }[]>([]);
const isDark = resolvedTheme === "dark";
// src/App.tsx - Fixed recent items fetch
useEffect(() => {
if (!user) return;
const fetchRecentItems = async () => {
try {
// ✅ Try multiple endpoints
let res;
try {
res = await api.get("/recent-items");
} catch {
res = await api.get("/recent-items");
}
setRecentPapers(res.data.papers?.slice(0, 5) ?? []);
setRecentContacts(res.data.contacts?.slice(0, 5) ?? []);
} catch (err) {
// ✅ Silent fail - use empty arrays instead of throwing
console.warn("Recent items endpoint not available, using empty data");
setRecentPapers([]);
setRecentContacts([]);
}
};
fetchRecentItems();
}, [user]);
useEffect(() => {
const handler = (e: KeyboardEvent) => {
if ((e.ctrlKey || e.metaKey) && e.key === "k") {
e.preventDefault();
window.dispatchEvent(new CustomEvent("kbar.toggle"));
}
};
document.addEventListener("keydown", handler);
return () => document.removeEventListener("keydown", handler);
}, []);
useEffect(() => {
const handleSoftReload = () => setAppResetKey((value) => value + 1);
window.addEventListener("app:soft-reload", handleSoftReload);
return () => window.removeEventListener("app:soft-reload", handleSoftReload);
}, []);
const [isOnline, setIsOnline] = useState(navigator.onLine);
useEffect(() => {
const handleOnline = () => setIsOnline(true);
const handleOffline = () => setIsOnline(false);
window.addEventListener("online", handleOnline);
window.addEventListener("offline", handleOffline);
return () => {
window.removeEventListener("online", handleOnline);
window.removeEventListener("offline", handleOffline);
};
}, []);
return (
<CommandPaletteProvider
navigate={navigate}
toggleTheme={toggleTheme}
isDark={isDark}
user={user}
recentPapers={recentPapers}
recentContacts={recentContacts}
>
<FlowPreservationProvider>
<ToastContainer
position="bottom-right"
autoClose={4000}
newestOnTop
closeOnClick
pauseOnFocusLoss
draggable
theme={isDark ? "dark" : "light"}
stacked
/>
<AnimatePresence>
{!isOnline && (
<motion.div
initial={{ y: -50, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
exit={{ y: -50, opacity: 0 }}
className="fixed top-0 left-0 right-0 z-[9999] bg-rose-500/90 backdrop-blur-md text-white px-4 py-2 flex items-center justify-center gap-2 text-sm font-medium shadow-lg"
>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><line x1="1" y1="1" x2="23" y2="23"></line><path d="M16.72 11.06A10.94 10.94 0 0 1 19 12.55"></path><path d="M5 12.55a10.94 10.94 0 0 1 5.17-2.39"></path><path d="M10.71 5.05A16 16 0 0 1 22.58 9"></path><path d="M1.42 9a15.91 15.91 0 0 1 4.7-2.88"></path><path d="M8.53 16.11a6 6 0 0 1 6.95 0"></path><line x1="12" y1="20" x2="12.01" y2="20"></line></svg>
No Internet Connection. You are currently offline.
</motion.div>
)}
</AnimatePresence>
<AnimatedBackground />
<Suspense fallback={<PageFallback />}>
<div key={appResetKey} className="w-full relative z-10">
<AnimatePresence mode="wait" onExitComplete={() => window.scrollTo({ top: 0, behavior: "instant" })}>
<Routes location={location} key={location.pathname}>
{/* ============================================ */}
{/* PUBLIC ROUTES (No Auth Required) */}
{/* ============================================ */}
<Route path="/" element={<PageTransition><HomePage /></PageTransition>} />
<Route element={<PublicLayout />}>
<Route path="/products/latex-editor" element={<LatexEditorIntroPage />} />
<Route path="/products/ai-co-scientist" element={<AICoScientistIntroPage />} />
<Route path="/products/app-store" element={<AppStoreIntroPage />} />
<Route path="/products/developer-cli" element={<DeveloperCliIntroPage />} />
<Route path="/products/smart-glass" element={<SmartGlassIntroPage />} />
<Route path="/about" element={<AboutPage />} />
<Route path="/contact" element={<ContactPage />} />
<Route path="/faq" element={<FaqPage />} />
<Route path="/terms" element={<TermsPage />} />
<Route path="/privacy" element={<PrivacyPage />} />
<Route path="/peer-room" element={<PeerRoomPage />} />
{/* Static Info Pages */}
<Route path="/community" element={<CommunityPage />} />
<Route path="/support" element={<SupportPage />} />
<Route path="/trending" element={<PageTransition><TrendingPage /></PageTransition>} />
<Route path="/open-access" element={<OpenAccessPage />} />
<Route path="/peer-review" element={<PeerReviewPage />} />
<Route path="/apply-reviewer" element={
<ProtectedRoute><PageTransition><ApplyReviewerPage /></PageTransition></ProtectedRoute>
} />
<Route path="/research-data" element={<ResearchDataPage />} />
<Route path="/citation-guide" element={<CitationGuidePage />} />
<Route path="/author-guidelines" element={<AuthorGuidelinesPage />} />
<Route path="/reviewer-guidelines" element={<ReviewerGuidelinesPage />} />
<Route path="/ethics" element={<EthicsPage />} />
<Route path="/features" element={<FeaturesPage />} />
<Route path="/pricing" element={<PricingPage />} />
<Route path="/subscription" element={
<ProtectedRoute><PageTransition><SubscriptionPage /></PageTransition></ProtectedRoute>
} />
<Route path="/roadmap" element={<RoadmapPage />} />
<Route path="/changelog" element={<ChangelogPage />} />
<Route path="/docs" element={<DocumentationPage />} />
<Route path="/docs/:section" element={<DocumentationPage />} />
<Route path="/docs/:section/:topic" element={<DocumentationPage />} />
<Route path="/api-docs" element={<APIDocsPage />} />
<Route path="/tutorials" element={<TutorialsPage />} />
<Route path="/tutorials/:id" element={<TutorialDetailPage />} />
<Route path="/careers" element={<CareersPage />} />
<Route path="/cookies" element={<CookiesPage />} />
<Route path="/security" element={<SecurityPage />} />
<Route path="/partners" element={<PartnersPage />} />
<Route path="/press" element={<Navigate to="/about" replace />} />
<Route path="/gdpr" element={<Navigate to="/privacy" replace />} />
<Route path="/tools" element={<PageTransition><ToolsPage /></PageTransition>} />
<Route path="/cli-docs" element={<PageTransition><CliDocsPage /></PageTransition>} />
<Route path="/tools/:id" element={<PageTransition><ToolDetailPage /></PageTransition>} />
<Route path="/blog" element={<PageTransition><BlogPage /></PageTransition>} />
<Route path="/blog/:slug" element={<PageTransition><BlogPostPage /></PageTransition>} />
<Route path="/blog/:id" element={<PageTransition><BlogPostPage /></PageTransition>} />
<Route path="/status" element={<PageTransition><StatusPage /></PageTransition>} />
<Route path="/help" element={<PageTransition><HelpCenterPage /></PageTransition>} />
<Route path="/help/:topic" element={<PageTransition><HelpCenterPage /></PageTransition>} />
</Route>
{/* AUTH ROUTES */}
<Route element={<AuthLayout />}>
<Route path="/login" element={<LoginPage />} />
<Route path="/register" element={<RegisterPage />} />
<Route path="/forgot-password" element={<ForgotPasswordPage />} />
<Route path="/join/:token" element={<JoinPage />} />
</Route>
{/* ============================================ */}
{/* PROTECTED ROUTES (Auth Required - No Layout) */}
{/* ============================================ */}
<Route path="/tools/builder" element={
<ProtectedRoute><PageTransition><ToolBuilderPage /></PageTransition></ProtectedRoute>
} />
<Route path="/tools/installed" element={
<ProtectedRoute><PageTransition><InstalledToolsPage /></PageTransition></ProtectedRoute>
} />
{/* ============================================ */}
{/* PROTECTED ROUTES WITH MAIN LAYOUT */}
{/* ============================================ */}
<Route element={<MainLayout />}>
{/* Dashboard & Home */}
<Route path="/dashboard" element={
<ProtectedRoute><PageTransition><DashboardPage /></PageTransition></ProtectedRoute>
} />
<Route path="/my-posts" element={
<ProtectedRoute><PageTransition><MyPostsPage /></PageTransition></ProtectedRoute>
} />
{/* Search */}
<Route path="/search" element={
<ProtectedRoute><PageTransition><SearchPage /></PageTransition></ProtectedRoute>
} />
<Route path="/search/users" element={
<ProtectedRoute><PageTransition><SearchUsersPage /></PageTransition></ProtectedRoute>
} />
{/* Articles */}
<Route path="/articles" element={
<PageTransition><ArticlesPage /></PageTransition>
} />
<Route path="/articles/new" element={
<ProtectedRoute><PageTransition><CreateArticlePage /></PageTransition></ProtectedRoute>
} />
<Route path="/articles/add" element={
<ProtectedRoute><PageTransition><AddArticlePage /></PageTransition></ProtectedRoute>
} />
<Route path="/articles/:id" element={
<PageTransition><ArticleDetailPage /></PageTransition>
} />
<Route path="/liked-articles" element={
<ProtectedRoute><PageTransition><LikedArticlesPage /></PageTransition></ProtectedRoute>
} />
<Route path="/users/:username/liked-articles" element={
<ProtectedRoute><PageTransition><UserLikedArticlesPage /></PageTransition></ProtectedRoute>
} />
<Route path="/bookmarks" element={
<ProtectedRoute><PageTransition><BookmarksPage /></PageTransition></ProtectedRoute>
} />
{/* Collections & Projects */}
<Route path="/collections" element={
<ProtectedRoute><PageTransition><CollectionsPage /></PageTransition></ProtectedRoute>
} />
<Route path="/collections/:collectionId" element={
<ProtectedRoute><PageTransition><CollectionDetailPage /></PageTransition></ProtectedRoute>
} />
<Route path="/paper-collections" element={
<ProtectedRoute><PageTransition><PaperCollectionsPage /></PageTransition></ProtectedRoute>
} />
<Route path="/projects" element={
<ProtectedRoute><PageTransition><ProjectsPage /></PageTransition></ProtectedRoute>
} />
<Route path="/projects/new" element={
<ProtectedRoute><PageTransition><CreateProjectPage /></PageTransition></ProtectedRoute>
} />
<Route path="/projects/:projectId" element={
<ProtectedRoute><PageTransition><ProjectSpacePage /></PageTransition></ProtectedRoute>
} />
<Route path="/projects/:projectId/workspace" element={
<ProtectedRoute><PageTransition><ProjectWorkspacePage /></PageTransition></ProtectedRoute>
} />
<Route path="/projects/:projectId/edit" element={
<ProtectedRoute><PageTransition><EditProjectPage /></PageTransition></ProtectedRoute>
} />
<Route path="/grants" element={
<ProtectedRoute><PageTransition><GrantsPage /></PageTransition></ProtectedRoute>
} />
<Route path="/grant-assistant" element={
<ProtectedRoute><PageTransition><GrantAssistantPage /></PageTransition></ProtectedRoute>
} />
{/* Profile */}
<Route path="/profile" element={
<ProtectedRoute><PageTransition><ProfilePage /></PageTransition></ProtectedRoute>
} />
<Route path="/profile-hub" element={
<ProtectedRoute><PageTransition><ProfileHubPage /></PageTransition></ProtectedRoute>
} />
<Route path="/settings" element={
<ProtectedRoute><PageTransition><SettingsPage /></PageTransition></ProtectedRoute>
} />
<Route path="/users/:username" element={
<ProtectedRoute><PageTransition><PublicProfilePage /></PageTransition></ProtectedRoute>
} />
<Route path="/users/:username/followers" element={
<ProtectedRoute><PageTransition><FollowersPage /></PageTransition></ProtectedRoute>
} />
<Route path="/users/:username/following" element={
<ProtectedRoute><PageTransition><FollowingPage /></PageTransition></ProtectedRoute>
} />
<Route path="/follow-list" element={
<ProtectedRoute><PageTransition><FollowList /></PageTransition></ProtectedRoute>
} />
{/* Messages & Groups */}
<Route path="/messages" element={
<ProtectedRoute><PageTransition><MessagesPage /></PageTransition></ProtectedRoute>
} />
<Route path="/inbox" element={
<ProtectedRoute><PageTransition><UnifiedInboxPage /></PageTransition></ProtectedRoute>
} />
<Route path="/unified-messages" element={
<ProtectedRoute><PageTransition><UnifiedMessagesPage /></PageTransition></ProtectedRoute>
} />
<Route path="/groups" element={
<ProtectedRoute><PageTransition><UnifiedMessagesPage /></PageTransition></ProtectedRoute>
} />
<Route path="/groups/:groupId" element={
<ProtectedRoute><PageTransition><UnifiedMessagesPage /></PageTransition></ProtectedRoute>
} />
<Route path="/groups/:groupId/messages" element={
<ProtectedRoute><PageTransition><UnifiedMessagesPage /></PageTransition></ProtectedRoute>
} />
<Route path="/networking" element={
<ProtectedRoute><PageTransition><NetworkingPage /></PageTransition></ProtectedRoute>
} />
<Route path="/collaborate" element={
<ProtectedRoute><PageTransition><CollaboratePage /></PageTransition></ProtectedRoute>
} />
<Route path="/async-collaboration" element={
<ProtectedRoute><PageTransition><AsyncCollaborationPage /></PageTransition></ProtectedRoute>
} />
{/* Events */}
<Route path="/calendar" element={
<ProtectedRoute><PageTransition><CalendarPage /></PageTransition></ProtectedRoute>
} />
<Route path="/events" element={<Navigate to="/networking" replace />} />
<Route path="/events/:eventId" element={
<ProtectedRoute><PageTransition><EventPage /></PageTransition></ProtectedRoute>
} />
<Route path="/conference" element={
<ProtectedRoute><PageTransition><ConferencePage /></PageTransition></ProtectedRoute>
} />
<Route path="/conference/:conferenceId" element={
<ProtectedRoute><PageTransition><ConferencePage /></PageTransition></ProtectedRoute>
} />
<Route path="/conference/room/:roomId" element={
<ProtectedRoute><PageTransition><ConferenceRoomRoute /></PageTransition></ProtectedRoute>
} />
<Route path="/polls" element={
<ProtectedRoute><PageTransition><PollsPage /></PageTransition></ProtectedRoute>
} />
{/* Research Tools */}
<Route path="/references" element={<Navigate to="/editor" replace />} />
<Route path="/references/:docId" element={
<ProtectedRoute><PageTransition><ReferenceManagerPage /></PageTransition></ProtectedRoute>
} />
<Route path="/submit-preprint" element={
<ProtectedRoute><PageTransition><PreprintSubmissionPage /></PageTransition></ProtectedRoute>
} />
<Route path="/paper-objects/:id" element={
<ProtectedRoute><PageTransition><PaperObjectPage /></PageTransition></ProtectedRoute>
} />
<Route path="/editor" element={
<ProtectedRoute><PageTransition><ScientificEditor /></PageTransition></ProtectedRoute>
} />
<Route path="/editor/:docId" element={
<ProtectedRoute><PageTransition><ScientificEditor /></PageTransition></ProtectedRoute>
} />
<Route path="/authoring-studio" element={
<ProtectedRoute><PageTransition><AuthoringStudioPage /></PageTransition></ProtectedRoute>
} />
<Route path="/research-assistant" element={
<ProtectedRoute><PageTransition><ResearchAssistantPage /></PageTransition></ProtectedRoute>
} />
<Route path="/ai-co-scientist" element={
<ProtectedRoute><PageTransition><AICoScientistPage /></PageTransition></ProtectedRoute>
} />
{/* Data & Analytics */}
<Route path="/data-hub" element={
<ProtectedRoute><PageTransition><DataHubPage /></PageTransition></ProtectedRoute>
} />
<Route path="/analytics" element={
<ProtectedRoute><PageTransition><AnalyticsPage /></PageTransition></ProtectedRoute>
} />
<Route path="/discovery" element={
<ProtectedRoute><PageTransition><DiscoveryPage /></PageTransition></ProtectedRoute>
} />
<Route path="/recommendations" element={
<ProtectedRoute><PageTransition><RecommendationsPage /></PageTransition></ProtectedRoute>
} />
<Route path="/gap-analysis" element={
<ProtectedRoute><PageTransition><GapAnalysisPage /></PageTransition></ProtectedRoute>
} />
<Route path="/tags" element={
<ProtectedRoute><PageTransition><TagsPage /></PageTransition></ProtectedRoute>
} />
<Route path="/tags/:name" element={
<ProtectedRoute><PageTransition><ArticlesPage /></PageTransition></ProtectedRoute>
} />
{/* Lab & Peer Review */}
<Route path="/lab-inventory" element={
<ProtectedRoute><PageTransition><LabInventoryPage /></PageTransition></ProtectedRoute>
} />
{/* Notifications */}
<Route path="/notifications" element={
<ProtectedRoute><PageTransition><NotificationsPage /></PageTransition></ProtectedRoute>
} />
{/* Innovation Labs (Feature Flagged) */}
{isEnabled("enableAdvancedSearch") && (
<>
<Route path="/gen-ui" element={
<ProtectedRoute><PageTransition><GenUIPage /></PageTransition></ProtectedRoute>
} />
<Route path="/smart-glass" element={
<ProtectedRoute><PageTransition><SmartGlassPage /></PageTransition></ProtectedRoute>
} />
<Route path="/multi-agent" element={
<ProtectedRoute><PageTransition><MultiAgentPage /></PageTransition></ProtectedRoute>
} />
</>
)}
{/* Trust & Security */}
<Route path="/trust" element={
<ProtectedRoute><PageTransition><TrustDashboardPage /></PageTransition></ProtectedRoute>
} />
{/* Workspace */}
<Route path="/workspace" element={
<ProtectedRoute>
<PageTransition>
<SmartGlassProvider>
<SmartGlassWorkspace />
</SmartGlassProvider>
</PageTransition>
</ProtectedRoute>
} />
{/* Admin (Admin Only) */}
<Route path="/admin" element={
<ProtectedRoute requireAdmin>
<PageTransition><AdminPage /></PageTransition>
</ProtectedRoute>
} />
<Route path="/admin/users" element={
<ProtectedRoute requireAdmin>
<PageTransition><AdminUsersPage /></PageTransition>
</ProtectedRoute>
} />
<Route path="/admin/blog" element={
<ProtectedRoute requireAdmin>
<PageTransition><AdminBlogPage /></PageTransition>
</ProtectedRoute>
} />
{/* Generated APIs */}
<Route path="/version" element={ <ProtectedRoute><PageTransition><VersionPage /></PageTransition></ProtectedRoute> } />
<Route path="/citationgraph" element={ <ProtectedRoute><PageTransition><CitationGraphPage /></PageTransition></ProtectedRoute> } />
<Route path="/webhook" element={ <ProtectedRoute><PageTransition><WebhookPage /></PageTransition></ProtectedRoute> } />
<Route path="/metrics" element={ <ProtectedRoute><PageTransition><MetricsPage /></PageTransition></ProtectedRoute> } />
<Route path="/provenance" element={ <ProtectedRoute><PageTransition><ProvenancePage /></PageTransition></ProtectedRoute> } />
<Route path="/preference" element={ <ProtectedRoute><PageTransition><PreferencePage /></PageTransition></ProtectedRoute> } />
<Route path="/socialfeed" element={ <ProtectedRoute><PageTransition><SocialFeedPage /></PageTransition></ProtectedRoute> } />
<Route path="/newsletter" element={ <ProtectedRoute><PageTransition><NewsletterPage /></PageTransition></ProtectedRoute> } />
<Route path="/voicesettings" element={ <ProtectedRoute><PageTransition><VoiceSettingsPage /></PageTransition></ProtectedRoute> } />
<Route path="/debug" element={ <ProtectedRoute><PageTransition><DebugPage /></PageTransition></ProtectedRoute> } />
<Route path="/export" element={ <ProtectedRoute><PageTransition><ExportPage /></PageTransition></ProtectedRoute> } />
<Route path="/ojsintegration" element={ <ProtectedRoute><PageTransition><OJSIntegrationPage /></PageTransition></ProtectedRoute> } />
<Route path="/media" element={ <ProtectedRoute><PageTransition><MediaPage /></PageTransition></ProtectedRoute> } />
<Route path="/download" element={ <ProtectedRoute><PageTransition><DownloadPage /></PageTransition></ProtectedRoute> } />
<Route path="/documentexport" element={ <ProtectedRoute><PageTransition><DocumentExportPage /></PageTransition></ProtectedRoute> } />
<Route path="/broadcast" element={ <ProtectedRoute><PageTransition><BroadcastPage /></PageTransition></ProtectedRoute> } />
<Route path="/graphnode" element={ <ProtectedRoute><PageTransition><GraphNodePage /></PageTransition></ProtectedRoute> } />
<Route path="/datarepository" element={ <ProtectedRoute><PageTransition><DataRepositoryPage /></PageTransition></ProtectedRoute> } />
<Route path="/encryption" element={ <ProtectedRoute><PageTransition><EncryptionPage /></PageTransition></ProtectedRoute> } />
<Route path="/upload" element={ <ProtectedRoute><PageTransition><UploadPage /></PageTransition></ProtectedRoute> } />
<Route path="/integration" element={ <ProtectedRoute><PageTransition><IntegrationPage /></PageTransition></ProtectedRoute> } />
<Route path="/audit" element={ <ProtectedRoute><PageTransition><AuditPage /></PageTransition></ProtectedRoute> } />
<Route path="/backup" element={ <ProtectedRoute><PageTransition><BackupPage /></PageTransition></ProtectedRoute> } />
<Route path="/peerreviewworkflow" element={ <ProtectedRoute><PageTransition><PeerReviewWorkflowPage /></PageTransition></ProtectedRoute> } />
<Route path="/report" element={ <ProtectedRoute><PageTransition><ReportPage /></PageTransition></ProtectedRoute> } />
<Route path="/apikey" element={ <ProtectedRoute><PageTransition><ApiKeyPage /></PageTransition></ProtectedRoute> } />
<Route path="/documentrag" element={ <ProtectedRoute><PageTransition><DocumentRagPage /></PageTransition></ProtectedRoute> } />
{/* Admin Redirects */}
</Route>
{/* 404 Not Found */}
<Route path="*" element={<NotFound />} />
</Routes>
</AnimatePresence>
</div>
</Suspense>
</FlowPreservationProvider>
</CommandPaletteProvider>
);
}

Xet Storage Details

Size:
46.1 kB
·
Xet hash:
38a7d71783169e7b3778a345d5b2f6a47d62b377005117d3b9f70b8fbe9b23f1

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.