movie-web/src/setup/App.tsx

95 lines
3.2 KiB
TypeScript
Raw Normal View History

2023-03-26 09:41:39 +02:00
import { lazy } from "react";
import { Redirect, Route, Switch } from "react-router-dom";
2023-01-07 21:36:18 +01:00
2023-01-12 22:04:28 +01:00
import { MWMediaType } from "@/backend/metadata/types";
import { BannerContextProvider } from "@/hooks/useBanner";
import { Layout } from "@/setup/Layout";
import { BookmarkContextProvider } from "@/state/bookmark";
import { SettingsProvider } from "@/state/settings";
import { WatchedContextProvider } from "@/state/watched";
import { MediaView } from "@/views/media/MediaView";
import { NotFoundPage } from "@/views/notfound/NotFoundView";
import { V2MigrationView } from "@/views/other/v2Migration";
import { SearchView } from "@/views/search/SearchView";
2023-02-24 19:23:00 +01:00
2022-05-03 20:58:34 +02:00
function App() {
2022-02-06 20:56:48 +01:00
return (
2023-03-09 18:08:13 +01:00
<SettingsProvider>
<WatchedContextProvider>
<BookmarkContextProvider>
<BannerContextProvider>
<Layout>
<Switch>
{/* functional routes */}
<Route exact path="/v2-migration" component={V2MigrationView} />
<Route exact path="/">
<Redirect to={`/search/${MWMediaType.MOVIE}`} />
</Route>
2023-02-22 19:02:23 +01:00
2023-03-09 18:08:13 +01:00
{/* pages */}
<Route exact path="/media/:media" component={MediaView} />
<Route
exact
path="/media/:media/:season/:episode"
component={MediaView}
/>
<Route
exact
path="/search/:type/:query?"
component={SearchView}
/>
2023-02-22 19:02:23 +01:00
2023-03-09 18:08:13 +01:00
{/* other */}
2023-04-25 17:35:09 +02:00
<Route
exact
path="/dev"
component={lazy(
() => import("@/views/developer/DeveloperView")
)}
/>
<Route
exact
path="/dev/video"
component={lazy(
() => import("@/views/developer/VideoTesterView")
)}
/>
{/* developer routes that can abuse workers are disabled in production */}
{process.env.NODE_ENV === "development" ? (
2023-03-26 09:41:39 +02:00
<>
<Route
exact
path="/dev/test"
component={lazy(
() => import("@/views/developer/TestView")
)}
/>
2023-04-25 17:35:09 +02:00
2023-03-26 09:41:39 +02:00
<Route
exact
path="/dev/providers"
component={lazy(
() => import("@/views/developer/ProviderTesterView")
)}
/>
<Route
exact
path="/dev/embeds"
component={lazy(
() => import("@/views/developer/EmbedTesterView")
)}
/>
</>
) : null}
2023-03-09 18:08:13 +01:00
<Route path="*" component={NotFoundPage} />
</Switch>
</Layout>
</BannerContextProvider>
</BookmarkContextProvider>
</WatchedContextProvider>
</SettingsProvider>
2022-02-06 20:56:48 +01:00
);
}
export default App;