-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(apps): add 404 page and redirect
- Loading branch information
1 parent
675bd8f
commit d4af4c3
Showing
11 changed files
with
105 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'hostd': minor | ||
'renterd': minor | ||
'walletd': minor | ||
--- | ||
|
||
Invalid and not found routes now redirect to the home page. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { | ||
HostdAuthedLayout, | ||
HostdAuthedPageLayoutProps, | ||
} from '../HostdAuthedLayout' | ||
import { HostdSidenav } from '../HostdSidenav' | ||
import { routes } from '../../config/routes' | ||
import { useDialog } from '../../contexts/dialog' | ||
|
||
export const Layout = HostdAuthedLayout | ||
export function useLayoutProps(): HostdAuthedPageLayoutProps { | ||
const { openDialog } = useDialog() | ||
return { | ||
title: 'Home', | ||
routes, | ||
sidenav: <HostdSidenav />, | ||
openSettings: () => openDialog('settings'), | ||
} | ||
} |
7 changes: 3 additions & 4 deletions
7
apps/renterd/components/Home/index.tsx → apps/hostd/components/Redirect/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
import { routes } from '../../config/routes' | ||
import { useEffect } from 'react' | ||
import { useRouter } from 'next/router' | ||
|
||
export function Home() { | ||
export function Redirect({ route }: { route: string }) { | ||
const router = useRouter() | ||
|
||
useEffect(() => { | ||
router.replace(routes.buckets.index) | ||
}, [router]) | ||
router.replace(route) | ||
}, [router, route]) | ||
|
||
return <div /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Redirect } from '../components/Redirect' | ||
import { Layout, useLayoutProps } from '../components/Redirect/Layout' | ||
import { routes } from '../config/routes' | ||
|
||
export default function Page() { | ||
return <Redirect route={routes.home} /> | ||
} | ||
|
||
Page.Layout = Layout | ||
Page.useLayoutProps = useLayoutProps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { useEffect } from 'react' | ||
import { useRouter } from 'next/router' | ||
|
||
export function Redirect({ route }: { route: string }) { | ||
const router = useRouter() | ||
|
||
useEffect(() => { | ||
router.replace(route) | ||
}, [router, route]) | ||
|
||
return <div /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Redirect } from '../components/Redirect' | ||
import { Layout, useLayoutProps } from '../components/Redirect/Layout' | ||
import { routes } from '../config/routes' | ||
|
||
export default function Page() { | ||
return <Redirect route={routes.buckets.index} /> | ||
} | ||
|
||
Page.Layout = Layout | ||
Page.useLayoutProps = useLayoutProps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { | ||
WalletdAuthedLayout, | ||
WalletdAuthedPageLayoutProps, | ||
} from '../WalletdAuthedLayout' | ||
import { WalletdSidenav } from '../WalletdSidenav' | ||
import { routes } from '../../config/routes' | ||
import { useDialog } from '../../contexts/dialog' | ||
|
||
export const Layout = WalletdAuthedLayout | ||
export function useLayoutProps(): WalletdAuthedPageLayoutProps { | ||
const { openDialog } = useDialog() | ||
return { | ||
title: 'Home', | ||
routes, | ||
sidenav: <WalletdSidenav />, | ||
openSettings: () => openDialog('settings'), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { useEffect } from 'react' | ||
import { useRouter } from 'next/router' | ||
|
||
export function Redirect({ route }: { route: string }) { | ||
const router = useRouter() | ||
|
||
useEffect(() => { | ||
router.replace(route) | ||
}, [router, route]) | ||
|
||
return <div /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Redirect } from '../components/Redirect' | ||
import { Layout, useLayoutProps } from '../components/Redirect/Layout' | ||
import { routes } from '../config/routes' | ||
|
||
export default function Page() { | ||
return <Redirect route={routes.home} /> | ||
} | ||
|
||
Page.Layout = Layout | ||
Page.useLayoutProps = useLayoutProps |