-
Notifications
You must be signed in to change notification settings - Fork 488
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
31 additions
and
5 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
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,20 +1,41 @@ | ||
import type { NextPage } from 'next'; | ||
import type { GetServerSideProps, NextPage } from 'next'; | ||
import dynamic from 'next/dynamic'; | ||
import React from 'react'; | ||
|
||
import type { Route } from 'nextjs-routes'; | ||
import type { Props } from 'nextjs/getServerSideProps'; | ||
import * as gSSP from 'nextjs/getServerSideProps'; | ||
import PageNextJs from 'nextjs/PageNextJs'; | ||
import fetchApi from 'nextjs/utils/fetchApi'; | ||
|
||
import getQueryParamString from 'lib/router/getQueryParamString'; | ||
|
||
const pathname: Route['pathname'] = '/tx/[hash]'; | ||
|
||
const Transaction = dynamic(() => import('ui/pages/Transaction'), { ssr: false }); | ||
|
||
const Page: NextPage<Props> = (props: Props) => { | ||
return ( | ||
<PageNextJs pathname="/tx/[hash]" query={ props.query }> | ||
<Transaction/> | ||
<Transaction apiData={ props.apiData }/> | ||
</PageNextJs> | ||
); | ||
}; | ||
|
||
export default Page; | ||
|
||
export { base as getServerSideProps } from 'nextjs/getServerSideProps'; | ||
export const getServerSideProps: GetServerSideProps<Props<typeof pathname>> = async(ctx) => { | ||
const baseResponse = await gSSP.base<typeof pathname>(ctx); | ||
|
||
if ('props' in baseResponse) { | ||
const txData = await fetchApi({ | ||
resource: 'tx', | ||
pathParams: { hash: getQueryParamString(ctx.query.hash) }, | ||
timeout: 1000, | ||
}); | ||
|
||
(await baseResponse.props).apiData = txData ?? null; | ||
} | ||
|
||
return baseResponse; | ||
}; |
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