Skip to content

Commit

Permalink
Merge pull request #317 from AElfProject/feature/refactor-2.0.0-Block…
Browse files Browse the repository at this point in the history
…chain

feat: block detail jump
  • Loading branch information
Peterbjx committed Apr 27, 2024
2 parents 76f41ae + de6fc09 commit 57a1c89
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 54 deletions.
4 changes: 2 additions & 2 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NEXT_PUBLIC_NETWORK_TYPE = 'TESTNET'
NEXT_PUBLIC_CHAIN_ID = 'AELF'
NEXT_PUBLIC_SYMBOL = 'ELF'
NEXT_PUBLIC_API_URL = http://localhost:4000
NEXT_PUBLIC_API_URL = https://aelfscan.io
NEXT_PUBLIC_REMOTE_URL = http://localhost:3001
NEXT_PUBLIC_CMS_URL = http://192.168.66.62:3200
NEXT_PUBLIC_CMS_URL = https://explorer-cms.prod.aelf.dev
2 changes: 1 addition & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ NEXT_PUBLIC_CHAIN_ID = 'AELF'
NEXT_PUBLIC_SYMBOL = 'ELF'
NEXT_PUBLIC_API_URL = https://aelfscan.io
NEXT_PUBLIC_REMOTE_URL = http://localhost:3001
NEXT_PUBLIC_CMS_URL = http://192.168.66.62:3200
NEXT_PUBLIC_CMS_URL = https://explorer-cms.prod.aelf.dev
1 change: 0 additions & 1 deletion src/_api/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { RequestWithParams } from './server';

const BASE_API = '/api'; // server local
const SERVER_BASE_API = `${process.env.NEXT_PUBLIC_API_URL}/api`; // server

const Block_API_List = {
getBlockList: `${BASE_API}/app/blockchain/blocks`,
getLatestBlocksList: `${BASE_API}/app/blockchain/latestBlocks`,
Expand Down
4 changes: 4 additions & 0 deletions src/_api/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ async function service(url: string, options: RequestWithParams) {
}
}

console.log(url, 'url-----------');

try {
const response = await fetch(url, options);

if (response.ok) {
return await response.json();
} else {
console.log(response.status);
}
} catch (error) {
console.log(error, 'r');
// TODO: need to recover
// return Promise.reject(error);
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/[chain]/block/[hash]/_components/baseinfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export default function BaseInfo({ data }) {
(type: JumpTypes) => {
switch (type) {
case JumpTypes.Prev:
router.push(`/block/${data.preBlockHeight}`);
router.push(`/${data.chainId}/block/${data.preBlockHeight}`);
break;
case JumpTypes.Next:
router.push(`/block/${data.nextBlockHeight}`);
router.push(`/${data.chainId}/block/${data.nextBlockHeight}`);
}
},
[data, router],
Expand Down
1 change: 0 additions & 1 deletion src/app/[chain]/block/[hash]/_components/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { useAppSelector } from '@_store';
import { useParams } from 'next/navigation';

export default function Detail({ SSRData }) {
console.log(SSRData, 'SSRData');
const { isMobile } = useMobileAll();
const [detailData] = useState<IBlocksDetailData>(SSRData);
const [showMore, setShowMore] = useState<boolean>(false);
Expand Down
46 changes: 0 additions & 46 deletions src/app/[chain]/block/[hash]/_components/mock.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/app/[chain]/block/[hash]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ import Detail from './_components/detail';
import { TChainID } from '@_api/type';
export default async function Block({ params }: { params: { hash: string; chain: TChainID } }) {
const data = await fetchServerBlocksDetail({ blockHeight: Number(params.hash), chainId: params.chain });
console.log(data, 'data');
return <Detail SSRData={data} />;
}
4 changes: 3 additions & 1 deletion src/app/[chain]/blocks/columnConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export default function getColumns({ timeFormat, handleTimeChange, chianId }): C
<Link
className="block text-xs leading-5 text-link"
title={`${addressFormat(address, chianId)}`}
href={`${chianId}/address/${addressFormat(address, chianId)}`}>
href=""
// href={`${chianId}/address/${addressFormat(address, chianId)}`}
>
{record.producerName ? record.producerName : `${addressFormat(hiddenAddress(address, 4, 4), chianId)}`}
</Link>
<Copy value={addressFormat(address, chianId)} />
Expand Down

0 comments on commit 57a1c89

Please sign in to comment.