mirror of
https://github.com/snowball-tools/snowballtools-base.git
synced 2024-12-23 00:57:44 +00:00
934aa1a26b
This PR centralizes all the environment variable references into a single constants file. The change includes replacing various `import.meta.env` references with imports from the new `utils/constants` module. This improves maintainability by providing a single place to manage environment variables.
84 lines
1.8 KiB
TypeScript
84 lines
1.8 KiB
TypeScript
import { useEffect } from 'react';
|
|
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
|
|
|
|
import Projects from './pages/org-slug';
|
|
import Settings from './pages/org-slug/Settings';
|
|
import {
|
|
projectsRoutesWithSearch,
|
|
projectsRoutesWithoutSearch,
|
|
} from './pages/org-slug/projects/routes';
|
|
import ProjectSearchLayout from './layouts/ProjectSearch';
|
|
import Index from './pages';
|
|
import AuthPage from './pages/AuthPage';
|
|
import { DashboardLayout } from './pages/org-slug/layout';
|
|
import Web3Provider from 'context/Web3Provider';
|
|
import { baseUrl } from 'utils/constants';
|
|
|
|
const router = createBrowserRouter([
|
|
{
|
|
path: ':orgSlug',
|
|
element: <DashboardLayout />,
|
|
children: [
|
|
{
|
|
element: <ProjectSearchLayout />,
|
|
children: [
|
|
{
|
|
path: '',
|
|
element: <Projects />,
|
|
},
|
|
{
|
|
path: 'projects',
|
|
children: projectsRoutesWithSearch,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: 'settings',
|
|
element: <Settings />,
|
|
},
|
|
{
|
|
path: 'projects',
|
|
children: projectsRoutesWithoutSearch,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: '/',
|
|
element: <Index />,
|
|
},
|
|
{
|
|
path: '/login',
|
|
element: <AuthPage />,
|
|
},
|
|
{
|
|
path: '/signup',
|
|
element: <AuthPage />,
|
|
},
|
|
]);
|
|
|
|
function App() {
|
|
// Hacky way of checking session
|
|
// TODO: Handle redirect backs
|
|
useEffect(() => {
|
|
fetch(`${baseUrl}/auth/session`, {
|
|
credentials: 'include',
|
|
}).then((res) => {
|
|
if (res.status !== 200) {
|
|
localStorage.clear();
|
|
const path = window.location.pathname;
|
|
if (path !== '/login' && path !== '/signup') {
|
|
window.location.pathname = '/login';
|
|
}
|
|
}
|
|
});
|
|
}, []);
|
|
|
|
return (
|
|
<Web3Provider>
|
|
<RouterProvider router={router} />
|
|
</Web3Provider>
|
|
);
|
|
}
|
|
|
|
export default App;
|