-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add not found page * feat: add page middleware
- Loading branch information
Showing
10 changed files
with
68 additions
and
50 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 @@ | ||
export { NotFoundPage as default } from '@/pages/not-found'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,6 @@ | ||
// Redirects "/" and "/trade" paths to "/trade/:primary/:numeraire" | ||
export const config = { | ||
matcher: ['/', '/trade'], | ||
}; | ||
|
||
export { tradeMiddleware as middleware } from '@/pages/trade/index.server'; |
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 @@ | ||
export { NotFoundPage } from './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,15 @@ | ||
'use client'; | ||
|
||
import Link from 'next/link'; | ||
import { PagePath } from '@/shared/const/pages'; | ||
import { Button } from '@penumbra-zone/ui/Button'; | ||
|
||
export const GoBackLink = () => { | ||
return ( | ||
<div className='w-full desktop:w-48 desktop:mt-0'> | ||
<Link href={PagePath.Trade}> | ||
<Button>Go back</Button> | ||
</Link> | ||
</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,21 @@ | ||
import { XCircle } from 'lucide-react'; | ||
import { Text } from '@penumbra-zone/ui/Text'; | ||
import { PenumbraWaves } from '@/pages/explore/ui/waves'; | ||
import { GoBackLink } from './link'; | ||
|
||
export const NotFoundPage = () => { | ||
return ( | ||
<div> | ||
<PenumbraWaves /> | ||
|
||
<section className='h-[calc(100dvh_-_80px)] max-w-[1062px] flex flex-col items-center justify-center desktop:justify-start gap-6 pt-8 px-4 mx-auto text-neutral-light'> | ||
<div className='flex flex-col gap-4 grow justify-center items-center desktop:justify-start desktop:grow-0'> | ||
<XCircle className='size-12' /> | ||
<Text large>Page not found</Text> | ||
</div> | ||
|
||
<GoBackLink /> | ||
</section> | ||
</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,23 @@ | ||
import { NextResponse, NextRequest } from 'next/server'; | ||
import { ChainRegistryClient } from '@penumbra-labs/registry'; | ||
import { getClientSideEnv } from '@/shared/api/env/getClientSideEnv'; | ||
import { assetPatterns } from '@penumbra-zone/types/assets'; | ||
|
||
export const tradeMiddleware = async (request: NextRequest) => { | ||
const { PENUMBRA_CHAIN_ID } = getClientSideEnv(); | ||
|
||
const chainRegistryClient = new ChainRegistryClient(); | ||
const registry = await chainRegistryClient.remote.get(PENUMBRA_CHAIN_ID); | ||
const allAssets = registry | ||
.getAllAssets() | ||
.filter(m => !assetPatterns.delegationToken.matches(m.display)) | ||
.toSorted((a, b) => Number(b.priorityScore - a.priorityScore)); | ||
|
||
const baseAsset = allAssets[0]?.symbol; | ||
const quoteAsset = allAssets[1]?.symbol; | ||
if (!baseAsset || !quoteAsset) { | ||
return NextResponse.redirect(new URL('not-found', request.url)); | ||
} | ||
|
||
return NextResponse.redirect(new URL(`/trade/${baseAsset}/${quoteAsset}`, request.url)); | ||
}; |
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 @@ | ||
export { tradeMiddleware } from './api/middleware'; |
This file was deleted.
Oops, something went wrong.