2023-06-03 19:28:07 -07:00
|
|
|
import React, { lazy, Suspense } from "react";
|
|
|
|
import { Routes, Route } from "react-router-dom";
|
|
|
|
import { ContextWrapper } from "./AuthContext";
|
2023-07-25 10:37:04 -07:00
|
|
|
import PrivateRoute, { AdminRoute } from "./components/PrivateRoute";
|
2023-08-22 21:14:24 -07:00
|
|
|
import { ToastContainer } from "react-toastify";
|
|
|
|
import "react-toastify/dist/ReactToastify.css";
|
2023-06-03 19:28:07 -07:00
|
|
|
|
|
|
|
const Main = lazy(() => import("./pages/Main"));
|
2023-07-25 10:37:04 -07:00
|
|
|
const InvitePage = lazy(() => import("./pages/Invite"));
|
2023-06-03 19:28:07 -07:00
|
|
|
const WorkspaceChat = lazy(() => import("./pages/WorkspaceChat"));
|
2023-07-25 10:37:04 -07:00
|
|
|
const AdminUsers = lazy(() => import("./pages/Admin/Users"));
|
|
|
|
const AdminInvites = lazy(() => import("./pages/Admin/Invitations"));
|
|
|
|
const AdminWorkspaces = lazy(() => import("./pages/Admin/Workspaces"));
|
|
|
|
const AdminChats = lazy(() => import("./pages/Admin/Chats"));
|
|
|
|
const AdminSystem = lazy(() => import("./pages/Admin/System"));
|
2023-08-14 15:22:55 -07:00
|
|
|
const AdminAppearance = lazy(() => import("./pages/Admin/Appearance"));
|
2023-08-23 19:15:07 -07:00
|
|
|
const AdminApiKeys = lazy(() => import("./pages/Admin/ApiKeys"));
|
2023-06-03 19:28:07 -07:00
|
|
|
|
|
|
|
export default function App() {
|
|
|
|
return (
|
|
|
|
<Suspense fallback={<div />}>
|
|
|
|
<ContextWrapper>
|
|
|
|
<Routes>
|
|
|
|
<Route path="/" element={<Main />} />
|
2023-07-25 10:37:04 -07:00
|
|
|
<Route
|
|
|
|
path="/workspace/:slug"
|
|
|
|
element={<PrivateRoute Component={WorkspaceChat} />}
|
|
|
|
/>
|
|
|
|
<Route path="/accept-invite/:code" element={<InvitePage />} />
|
|
|
|
|
|
|
|
{/* Admin Routes */}
|
|
|
|
<Route
|
|
|
|
path="/admin/system-preferences"
|
|
|
|
element={<AdminRoute Component={AdminSystem} />}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
path="/admin/invites"
|
|
|
|
element={<AdminRoute Component={AdminInvites} />}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
path="/admin/users"
|
|
|
|
element={<AdminRoute Component={AdminUsers} />}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
path="/admin/workspaces"
|
|
|
|
element={<AdminRoute Component={AdminWorkspaces} />}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
path="/admin/workspace-chats"
|
|
|
|
element={<AdminRoute Component={AdminChats} />}
|
|
|
|
/>
|
2023-08-14 15:22:55 -07:00
|
|
|
<Route
|
|
|
|
path="/admin/appearance"
|
|
|
|
element={<AdminRoute Component={AdminAppearance} />}
|
|
|
|
/>
|
2023-08-23 19:15:07 -07:00
|
|
|
<Route
|
|
|
|
path="/admin/api-keys"
|
|
|
|
element={<AdminRoute Component={AdminApiKeys} />}
|
|
|
|
/>
|
2023-06-03 19:28:07 -07:00
|
|
|
</Routes>
|
2023-08-22 21:14:24 -07:00
|
|
|
<ToastContainer />
|
2023-06-03 19:28:07 -07:00
|
|
|
</ContextWrapper>
|
|
|
|
</Suspense>
|
|
|
|
);
|
|
|
|
}
|