mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-21 17:56:13 +01:00
57 lines
1.4 KiB
React
57 lines
1.4 KiB
React
|
|
import { createBrowserRouter, Navigate, Outlet } from 'react-router-dom';
|
||
|
|
import Root from './Root';
|
||
|
|
import Chat from './Chat';
|
||
|
|
import Search from './Search';
|
||
|
|
import { Login, Registration, RequestPasswordReset, ResetPassword } from '../components/Auth';
|
||
|
|
import { AuthContextProvider } from '../hooks/AuthContext';
|
||
|
|
import ApiErrorWatcher from '../components/Auth/ApiErrorWatcher';
|
||
|
|
import { ALLOW_REGISTRATION } from '../utils/envConstants';
|
||
|
|
|
||
|
|
const AuthLayout = () => (
|
||
|
|
<AuthContextProvider>
|
||
|
|
<Outlet />
|
||
|
|
<ApiErrorWatcher />
|
||
|
|
</AuthContextProvider>
|
||
|
|
);
|
||
|
|
|
||
|
|
export const router = createBrowserRouter([
|
||
|
|
{
|
||
|
|
path: 'register',
|
||
|
|
element: ALLOW_REGISTRATION ? <Registration /> : <Navigate to="/login" replace={true} />
|
||
|
|
},
|
||
|
|
{
|
||
|
|
path: 'forgot-password',
|
||
|
|
element: <RequestPasswordReset />
|
||
|
|
},
|
||
|
|
{
|
||
|
|
path: 'reset-password',
|
||
|
|
element: <ResetPassword />
|
||
|
|
},
|
||
|
|
{
|
||
|
|
element: <AuthLayout />,
|
||
|
|
children: [
|
||
|
|
{
|
||
|
|
path: 'login',
|
||
|
|
element: <Login />
|
||
|
|
},
|
||
|
|
{
|
||
|
|
path: '/',
|
||
|
|
element: <Root />,
|
||
|
|
children: [
|
||
|
|
{
|
||
|
|
index: true,
|
||
|
|
element: <Navigate to="/chat/new" replace={true} />
|
||
|
|
},
|
||
|
|
{
|
||
|
|
path: 'chat/:conversationId?',
|
||
|
|
element: <Chat />
|
||
|
|
},
|
||
|
|
{
|
||
|
|
path: 'search/:query?',
|
||
|
|
element: <Search />
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
]);
|