kopia lustrzana https://github.com/Tldraw/Tldraw
57 wiersze
1.9 KiB
TypeScript
57 wiersze
1.9 KiB
TypeScript
import { captureException } from '@sentry/react'
|
|
import {
|
|
READ_ONLY_LEGACY_PREFIX,
|
|
READ_ONLY_PREFIX,
|
|
ROOM_PREFIX,
|
|
SNAPSHOT_PREFIX,
|
|
} from '@tldraw/dotcom-shared'
|
|
import { useEffect } from 'react'
|
|
import { Outlet, Route, createRoutesFromElements, useRouteError } from 'react-router-dom'
|
|
import { DefaultErrorFallback } from './components/DefaultErrorFallback/DefaultErrorFallback'
|
|
import { ErrorPage } from './components/ErrorPage/ErrorPage'
|
|
|
|
export const router = createRoutesFromElements(
|
|
<Route
|
|
element={
|
|
// Add all top level providers that require the router here
|
|
|
|
<Outlet />
|
|
}
|
|
ErrorBoundary={() => {
|
|
const error = useRouteError()
|
|
useEffect(() => {
|
|
captureException(error)
|
|
}, [error])
|
|
return (
|
|
<ErrorPage
|
|
messages={{
|
|
header: 'Something went wrong',
|
|
para1:
|
|
'Please try refreshing the page. Still having trouble? Let us know at hello@tldraw.com.',
|
|
}}
|
|
/>
|
|
)
|
|
}}
|
|
>
|
|
<Route errorElement={<DefaultErrorFallback />}>
|
|
<Route path="/" lazy={() => import('./pages/root')} />
|
|
<Route path={`/${ROOM_PREFIX}`} lazy={() => import('./pages/new')} />
|
|
<Route path="/new" lazy={() => import('./pages/new')} />
|
|
<Route path={`/ts-side`} lazy={() => import('./pages/public-touchscreen-side-panel')} />
|
|
<Route path={`/${ROOM_PREFIX}/:roomId`} lazy={() => import('./pages/public-multiplayer')} />
|
|
<Route path={`/${ROOM_PREFIX}/:boardId/history`} lazy={() => import('./pages/history')} />
|
|
<Route
|
|
path={`/${ROOM_PREFIX}/:boardId/history/:timestamp`}
|
|
lazy={() => import('./pages/history-snapshot')}
|
|
/>
|
|
<Route path={`/${SNAPSHOT_PREFIX}/:roomId`} lazy={() => import('./pages/public-snapshot')} />
|
|
<Route
|
|
path={`/${READ_ONLY_LEGACY_PREFIX}/:roomId`}
|
|
lazy={() => import('./pages/public-readonly-legacy')}
|
|
/>
|
|
<Route path={`/${READ_ONLY_PREFIX}/:roomId`} lazy={() => import('./pages/public-readonly')} />
|
|
</Route>
|
|
<Route path="*" lazy={() => import('./pages/not-found')} />
|
|
</Route>
|
|
)
|