diff --git a/apps/client/src/AppRouter.tsx b/apps/client/src/AppRouter.tsx index fdbf7fc28..7dcb736db 100644 --- a/apps/client/src/AppRouter.tsx +++ b/apps/client/src/AppRouter.tsx @@ -1,38 +1,30 @@ -import React from 'react'; +import { ComponentType, lazy, Suspense, useMemo } from 'react'; import { Navigate, Route, useLocation } from 'react-router'; +import { OntimeView, OntimeViewPresettable } from 'ontime-types'; import { useClientPath } from './common/hooks/useClientPath'; +import useUrlPresets from './common/hooks-query/useUrlPresets'; import Log from './features/log/Log'; -import withPreset from './features/PresetWrapper'; -import withData from './features/viewers/ViewWrapper'; +import Loader from './views/common/loader/Loader'; +import NotFound from './views/common/not-found/NotFound'; import ViewLoader from './views/ViewLoader'; import { initializeSentry } from './sentry.config'; -const Editor = React.lazy(() => import('./views/editor/ProtectedEditor')); -const Cuesheet = React.lazy(() => import('./views/cuesheet/ProtectedCuesheet')); -const Operator = React.lazy(() => import('./features/operator/OperatorExport')); +const Timer = lazy(() => import('./views/timer/Timer')); +const Countdown = lazy(() => import('./views/countdown/Countdown')); +const Backstage = lazy(() => import('./views/backstage/Backstage')); +const StudioClock = lazy(() => import('./views/studio/Studio')); +const Timeline = lazy(() => import('./views/timeline/TimelinePage')); +const ProjectInfo = lazy(() => import('./views/project-info/ProjectInfo')); -const TimerView = React.lazy(() => import('./views/timer/Timer')); -const Countdown = React.lazy(() => import('./views/countdown/Countdown')); +const Editor = lazy(() => import('./views/editor/ProtectedEditor')); +const Cuesheet = lazy(() => import('./views/cuesheet/ProtectedCuesheet')); +const Operator = lazy(() => import('./features/operator/OperatorExport')); -const Backstage = React.lazy(() => import('./views/backstage/Backstage')); -const Timeline = React.lazy(() => import('./views/timeline/TimelinePage')); -const StudioClock = React.lazy(() => import('./views/studio/Studio')); -const ProjectInfo = React.lazy(() => import('./views/project-info/ProjectInfo')); - -const STimer = withPreset(withData(TimerView)); -const SCountdown = withPreset(withData(Countdown)); -const SBackstage = withPreset(withData(Backstage)); -const SProjectInfo = withPreset(ProjectInfo); // NOTE: ProjectInfo does not use the viewWrapper since it has no options -const SStudio = withPreset(withData(StudioClock)); -const STimeline = withPreset(withData(Timeline)); -const PCuesheet = withPreset(Cuesheet); -const POperator = withPreset(Operator); - -const EditorFeatureWrapper = React.lazy(() => import('./features/EditorFeatureWrapper')); -const RundownPanel = React.lazy(() => import('./features/rundown/RundownExport')); -const TimerControl = React.lazy(() => import('./features/control/playback/TimerControlExport')); -const MessageControl = React.lazy(() => import('./features/control/message/MessageControlExport')); +const EditorFeatureWrapper = lazy(() => import('./features/EditorFeatureWrapper')); +const RundownPanel = lazy(() => import('./features/rundown/RundownExport')); +const TimerControl = lazy(() => import('./features/control/playback/TimerControlExport')); +const MessageControl = lazy(() => import('./features/control/message/MessageControlExport')); // Initialize Sentry with our configuration const SentryRouter = initializeSentry(); @@ -42,73 +34,73 @@ export default function AppRouter() { useClientPath(); return ( - + }> } /> - + } /> - + } /> - + } /> - + } /> - + } /> - + } /> {/*/!* Protected Routes *!/*/} - } /> - } /> + } /> + } /> - + } /> {/*/!* Protected Routes - Elements *!/*/} @@ -116,7 +108,7 @@ export default function AppRouter() { } /> @@ -124,7 +116,7 @@ export default function AppRouter() { } /> @@ -132,16 +124,14 @@ export default function AppRouter() { } /> } /> - {/*/!* Send to default if nothing found *!/*/} - } /> - + ); } diff --git a/apps/client/src/views/utils/viewLoader.utils.ts b/apps/client/src/views/utils/viewLoader.utils.ts new file mode 100644 index 000000000..410f04b0f --- /dev/null +++ b/apps/client/src/views/utils/viewLoader.utils.ts @@ -0,0 +1,6 @@ +import { QueryStatus } from '@tanstack/react-query'; + +export type ViewData = { + data: T; + status: QueryStatus; +};