mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-03-02 06:10:18 +01:00
* don't require conversation for bookmark button * wrap marketplace component so it can correctly use context hooks * chore: re-order import statement for MarketplaceProvider --------- Co-authored-by: Danny Avila <danacordially@gmail.com>
136 lines
3.3 KiB
TypeScript
136 lines
3.3 KiB
TypeScript
import { createBrowserRouter, Navigate, Outlet } from 'react-router-dom';
|
|
import {
|
|
Login,
|
|
VerifyEmail,
|
|
Registration,
|
|
ResetPassword,
|
|
ApiErrorWatcher,
|
|
TwoFactorScreen,
|
|
RequestPasswordReset,
|
|
} from '~/components/Auth';
|
|
import { MarketplaceProvider } from '~/components/Agents/MarketplaceContext';
|
|
import AgentMarketplace from '~/components/Agents/Marketplace';
|
|
import { OAuthSuccess, OAuthError } from '~/components/OAuth';
|
|
import { AuthContextProvider } from '~/hooks/AuthContext';
|
|
import RouteErrorBoundary from './RouteErrorBoundary';
|
|
import StartupLayout from './Layouts/Startup';
|
|
import LoginLayout from './Layouts/Login';
|
|
import dashboardRoutes from './Dashboard';
|
|
import ShareRoute from './ShareRoute';
|
|
import ChatRoute from './ChatRoute';
|
|
import Search from './Search';
|
|
import Root from './Root';
|
|
|
|
const AuthLayout = () => (
|
|
<AuthContextProvider>
|
|
<Outlet />
|
|
<ApiErrorWatcher />
|
|
</AuthContextProvider>
|
|
);
|
|
|
|
const baseEl = document.querySelector('base');
|
|
const baseHref = baseEl?.getAttribute('href') || '/';
|
|
|
|
export const router = createBrowserRouter(
|
|
[
|
|
{
|
|
path: 'share/:shareId',
|
|
element: <ShareRoute />,
|
|
errorElement: <RouteErrorBoundary />,
|
|
},
|
|
{
|
|
path: 'oauth',
|
|
errorElement: <RouteErrorBoundary />,
|
|
children: [
|
|
{
|
|
path: 'success',
|
|
element: <OAuthSuccess />,
|
|
},
|
|
{
|
|
path: 'error',
|
|
element: <OAuthError />,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: '/',
|
|
element: <StartupLayout />,
|
|
errorElement: <RouteErrorBoundary />,
|
|
children: [
|
|
{
|
|
path: 'register',
|
|
element: <Registration />,
|
|
},
|
|
{
|
|
path: 'forgot-password',
|
|
element: <RequestPasswordReset />,
|
|
},
|
|
{
|
|
path: 'reset-password',
|
|
element: <ResetPassword />,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: 'verify',
|
|
element: <VerifyEmail />,
|
|
errorElement: <RouteErrorBoundary />,
|
|
},
|
|
{
|
|
element: <AuthLayout />,
|
|
errorElement: <RouteErrorBoundary />,
|
|
children: [
|
|
{
|
|
path: '/',
|
|
element: <LoginLayout />,
|
|
children: [
|
|
{
|
|
path: 'login',
|
|
element: <Login />,
|
|
},
|
|
{
|
|
path: 'login/2fa',
|
|
element: <TwoFactorScreen />,
|
|
},
|
|
],
|
|
},
|
|
dashboardRoutes,
|
|
{
|
|
path: '/',
|
|
element: <Root />,
|
|
children: [
|
|
{
|
|
index: true,
|
|
element: <Navigate to="/c/new" replace={true} />,
|
|
},
|
|
{
|
|
path: 'c/:conversationId?',
|
|
element: <ChatRoute />,
|
|
},
|
|
{
|
|
path: 'search',
|
|
element: <Search />,
|
|
},
|
|
{
|
|
path: 'agents',
|
|
element: (
|
|
<MarketplaceProvider>
|
|
<AgentMarketplace />
|
|
</MarketplaceProvider>
|
|
),
|
|
},
|
|
{
|
|
path: 'agents/:category',
|
|
element: (
|
|
<MarketplaceProvider>
|
|
<AgentMarketplace />
|
|
</MarketplaceProvider>
|
|
),
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
{ basename: baseHref },
|
|
);
|