diff options
-rw-r--r-- | frontend/src/Navigation/RootRedirect.tsx | 19 | ||||
-rw-r--r-- | frontend/src/Navigation/index.ts | 7 |
2 files changed, 26 insertions, 0 deletions
diff --git a/frontend/src/Navigation/RootRedirect.tsx b/frontend/src/Navigation/RootRedirect.tsx new file mode 100644 index 000000000..eec9a335d --- /dev/null +++ b/frontend/src/Navigation/RootRedirect.tsx @@ -0,0 +1,19 @@ +import { FunctionComponent } from "react"; +import { Redirect } from "react-router-dom"; +import { useIsRadarrEnabled, useIsSonarrEnabled } from "../@redux/hooks"; + +const RootRedirect: FunctionComponent = () => { + const sonarr = useIsSonarrEnabled(); + const radarr = useIsRadarrEnabled(); + + let path = "/settings"; + if (sonarr) { + path = "/series"; + } else if (radarr) { + path = "movies"; + } + + return <Redirect to={path}></Redirect>; +}; + +export default RootRedirect; diff --git a/frontend/src/Navigation/index.ts b/frontend/src/Navigation/index.ts index ee9e6d559..dbcb4db6a 100644 --- a/frontend/src/Navigation/index.ts +++ b/frontend/src/Navigation/index.ts @@ -37,6 +37,7 @@ import SystemTasksView from "../System/Tasks"; import WantedMoviesView from "../Wanted/Movies"; import WantedSeriesView from "../Wanted/Series"; import { Navigation } from "./nav"; +import RootRedirect from "./RootRedirect"; export function useNavigationItems() { const sonarr = useIsSonarrEnabled(); @@ -52,6 +53,12 @@ export function useNavigationItems() { routeOnly: true, }, { + name: "Redirect", + path: "/", + component: RootRedirect, + routeOnly: true, + }, + { icon: faPlay, name: "Series", path: "/series", |