Skip to content

Commit

Permalink
fix: fix blocks jump url
Browse files Browse the repository at this point in the history
  • Loading branch information
Peterbjx committed Apr 28, 2024
1 parent 2d5bd0d commit b40dbfb
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/_api/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,5 @@ export interface TTokenListRequestParams extends RequestInit {
skipCount: number;
maxResultCount: number;
sort: SortEnum;
sortBy: string;
orderBy: string;
}
4 changes: 2 additions & 2 deletions src/_utils/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ export const addSymbol = (str: string | number) => {
return `${str} ${process.env.NEXT_PUBLIC_SYMBOL}`;
};

export const divDecimals = (num: number | string, decimals = 1e10) => {
export const divDecimals = (num: number | string, decimals = 1e8) => {
const bigNumber = new BigNumber(num);
return bigNumber.dividedBy(decimals || 1e10).toNumber();
return bigNumber.dividedBy(decimals || 1e8).toNumber();
};

export const getPageNumber = (page: number, pageSize: number): number => {
Expand Down
1 change: 1 addition & 0 deletions src/app/[chain]/block/[hash]/_components/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default function Detail({ SSRData }) {
setTimeFormat(timeFormat === 'Age' ? 'Date Time (UTC)' : 'Age');
},
chainId: chain as string,
type: 'block',
});
}, [chain, timeFormat]);

Expand Down
39 changes: 21 additions & 18 deletions src/app/[chain]/blocks/blockList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { pageSizeOption } from '@_utils/contant';
import { fetchBlocks } from '@_api/fetchBlocks';
import { useAppSelector } from '@_store';
import { useParams } from 'next/navigation';
import { Spin } from 'antd';

export enum pageType {
first,
Expand Down Expand Up @@ -110,24 +111,26 @@ export default function BlockList({ SSRData }) {
return (
<div>
<HeadTitle content="Blocks"></HeadTitle>
<Table
headerTitle={{
multi: {
title: multiTitle,
desc: `(Showing blocks between #${pageMinBlock} to #${pageMaxBlock})`,
},
}}
loading={loading}
dataSource={data}
columns={columns}
isMobile={isMobile}
rowKey="blockHeight"
total={total}
options={pageSizeOption}
pageSize={pageSize}
pageNum={currentPage}
pageChange={pageChange}
pageSizeChange={pageSizeChange}></Table>
<Spin spinning={loading}>
<Table
headerTitle={{
multi: {
title: multiTitle,
desc: `(Showing blocks between #${pageMinBlock} to #${pageMaxBlock})`,
},
}}
loading={false}
dataSource={data}
columns={columns}
isMobile={isMobile}
rowKey="blockHeight"
total={total}
options={pageSizeOption}
pageSize={pageSize}
pageNum={currentPage}
pageChange={pageChange}
pageSizeChange={pageSizeChange}></Table>
</Spin>
</div>
);
}
4 changes: 2 additions & 2 deletions src/app/[chain]/blocks/columnConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export default function getColumns({ timeFormat, handleTimeChange, chianId }): C
width: '208px',
key: 'transactionCount',
dataIndex: 'transactionCount',
render: (text) => (
<Link className="block text-xs leading-5 text-link" href={`Transactions/${text}`}>
render: (text, record) => (
<Link className="block text-xs leading-5 text-link" href={`/${chianId}/block/${record.blockHeight}#txns`}>
{text}
</Link>
),
Expand Down
2 changes: 2 additions & 0 deletions src/app/[chain]/blocks/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ export default async function BlocksPage({ params }) {
});
return <BlockList SSRData={data} />;
}
export const revalidate = 1;
export const dynamic = 'force-dynamic';
2 changes: 1 addition & 1 deletion src/app/[chain]/tokens/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default async function TokensPage({ params }: { params: ChainId }) {
skipCount: 0,
maxResultCount: 50,
chainId: params.chain as TChainID,
sortBy: 'HolderCount',
orderBy: 'HolderCount',
sort: SortEnum.desc,
cache: 'no-store',
});
Expand Down
2 changes: 1 addition & 1 deletion src/app/[chain]/tokens/tokensList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function TokensList({ SSRData }: TokensListProps) {
maxResultCount: 50,
chainId: chain as TChainID,
sort,
sortBy: 'HolderCount',
orderBy: 'HolderCount',
};
setLoading(true);
const data = await fetchTokenList(params);
Expand Down
4 changes: 3 additions & 1 deletion src/app/transactions/columnConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function getColumns({
timeFormat,
handleTimeChange,
chainId = 'AELF',
type,
}): ColumnsType<ITransactionsResponseItem> {
return [
{
Expand Down Expand Up @@ -70,9 +71,10 @@ export default function getColumns({
title: 'Block',
width: 112,
dataIndex: 'blockHeight',
hidden: type === 'block',
key: 'blockHeight',
render: (text) => (
<Link className="block text-xs leading-5 text-link" href={`block/${text}`}>
<Link className="block text-xs leading-5 text-link" href={`/${chainId}/block/${text}`}>
{text}
</Link>
),
Expand Down
1 change: 1 addition & 0 deletions src/app/transactions/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default function List({ SSRData, showHeader = true }) {
handleTimeChange: () => {
setTimeFormat(timeFormat === 'Age' ? 'Date Time (UTC)' : 'Age');
},
type: 'tx',
});
}, [timeFormat]);

Expand Down

0 comments on commit b40dbfb

Please sign in to comment.