Skip to content

Commit 6b61ea4

Browse files
committed
fix blccksDetail error
1 parent 813b558 commit 6b61ea4

File tree

3 files changed

+75
-39
lines changed

3 files changed

+75
-39
lines changed

pages/blocks/[height].tsx

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const HeightDetail = (props: Props) => {
2121
Height: 0,
2222
ParentBlockSig: "",
2323
Signature: "",
24-
Size: "0B",
24+
Size: "0",
2525
TimeStamp: 0,
2626
Txs: 0,
2727
Version: 0
@@ -33,21 +33,19 @@ const HeightDetail = (props: Props) => {
3333
function getBlockDetailByall(height: any) {
3434
if (height) {
3535
if (isNaN(height)) {
36-
return new Promise(function (resovle) {
36+
return new Promise(function (resovle, reject) {
3737
getBlockDetailByID(height).then(res => {
38-
let code = res.data.code
39-
if (!code) {
40-
resovle(res)
41-
}
38+
resovle(res)
39+
}).catch(() => {
40+
reject()
4241
})
4342
})
4443
} else {
45-
return new Promise(function (resovle) {
44+
return new Promise(function (resovle, reject) {
4645
getBlockDetailByHight(height).then(res => {
47-
let code = res.data.code
48-
if (!code) {
49-
resovle(res)
50-
}
46+
resovle(res)
47+
}).catch(() => {
48+
reject()
5149
})
5250
})
5351
}
@@ -59,10 +57,36 @@ const HeightDetail = (props: Props) => {
5957
setpostID(height as any)
6058
setspinshow(false)
6159
getBlockDetailByall(height as any)?.then((res: any) => {
62-
setdetailData(res.data.data)
63-
60+
if (res.data.code) {
61+
setpostID("null" as any)
62+
setdetailData({
63+
Generator: "",
64+
Height: 0,
65+
ParentBlockSig: "",
66+
Signature: "",
67+
Size: "0",
68+
TimeStamp: 0,
69+
Txs: 0,
70+
Version: 0
71+
})
72+
} else {
73+
setdetailData(res.data.data)
74+
setpostID(res.data.data.Height)
75+
}
6476
}).finally(() => {
6577
setspinshow(true)
78+
}).catch(() => {
79+
setpostID("null" as any)
80+
setdetailData({
81+
Generator: "",
82+
Height: 0,
83+
ParentBlockSig: "",
84+
Signature: "",
85+
Size: "0",
86+
TimeStamp: 0,
87+
Txs: 0,
88+
Version: 0
89+
})
6690
})
6791
}
6892
}, [height])

src/components/commonComps/explorerDataTable/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ const CommonDataTable = (props: commonTableProps) => {
220220
if (postID) {
221221
setIsRefresh(true)
222222
let result = (await loadTableListFun(postID)).data
223+
if (!result?.data) {
224+
setTableList([])
225+
setDataAmount(0)
226+
}
223227
if (result.data.Transactions === null || result.data.list === null || result.data.Transactions) {
224228
result.data.Transactions.map((item: any) => {
225229
item.key = item.Id + Math.random()
@@ -237,6 +241,8 @@ const CommonDataTable = (props: commonTableProps) => {
237241
setTableList(newdata)
238242
setDataAmount(newdata.length)
239243
} else {
244+
setTableList([])
245+
setDataAmount(0)
240246
setIsRefresh(false)
241247
}
242248
setIsRefresh(false)

src/components/pageComps/blocks/blocksDetail/index.tsx

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useRouter } from 'next/router'
2-
import { Descriptions, Image } from 'antd';
2+
import { Descriptions, Empty, Image } from 'antd';
33
import moment from 'moment'
44
import styles from '../../transactions/transactionsDetail/tableDetail.module.scss'
55
import { BlockDetailProps } from '../../../../models/interface/block'
@@ -14,31 +14,37 @@ const TableDetail = (props: BlockDetailProps) => {
1414
return (
1515
<div className={styles.tableDetail}>
1616
<Descriptions title={props.title} column={1} style={{ display: (props.spinshow) ? 'block' : 'none' }} >
17-
<Descriptions.Item className={styles.subtitle}>{props.detailData?.Signature}</Descriptions.Item>
18-
<Descriptions.Item label='Height' style={{ border: 'none' }}>
19-
<span>{props.detailData?.Height}</span>
20-
</Descriptions.Item>
21-
<Descriptions.Item label='Version'>
22-
<span>{props.detailData?.Version}</span>
23-
</Descriptions.Item>
24-
<Descriptions.Item label='Time Stamp'>
25-
<span>{props.detailData?.TimeStamp / VSYS_TIME ? moment(props.detailData?.TimeStamp / VSYS_TIME).format('YYYY-MM-DD HH:mm:ss') : ''}</span>
26-
</Descriptions.Item>
27-
<Descriptions.Item label='Generator'>
28-
<Link replace href={'/address/' + props.detailData?.Generator}>{props.detailData?.Generator}</Link>
29-
</Descriptions.Item>
30-
<Descriptions.Item label='Txs'>
31-
<span>{props.detailData?.Txs}</span>
32-
</Descriptions.Item>
33-
<Descriptions.Item label='Block ID'>
34-
<span>{props.detailData?.Signature}</span>
35-
</Descriptions.Item>
36-
<Descriptions.Item label='Parent Block ID'>
37-
<Link replace href={'/blocks/' + props.detailData?.ParentBlockSig}>{props.detailData?.ParentBlockSig}</Link>
38-
</Descriptions.Item>
39-
<Descriptions.Item label='Size'>
40-
<span>{props.detailData?.Size} B</span>
41-
</Descriptions.Item>
17+
<Descriptions.Item className={styles.subtitle} style={{ display: props.spinshow && !props.detailData?.Height ? 'block' : 'none' }}>
18+
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
19+
</Descriptions.Item>
20+
{props.detailData?.Height && <>
21+
<Descriptions.Item className={styles.subtitle}>{props.detailData?.Signature}</Descriptions.Item>
22+
<Descriptions.Item label='Height' style={{ border: 'none' }}>
23+
<span>{props.detailData?.Height}</span>
24+
</Descriptions.Item>
25+
<Descriptions.Item label='Version'>
26+
<span>{props.detailData?.Version}</span>
27+
</Descriptions.Item>
28+
<Descriptions.Item label='Time Stamp'>
29+
<span>{props.detailData?.TimeStamp / VSYS_TIME ? moment(props.detailData?.TimeStamp / VSYS_TIME).format('YYYY-MM-DD HH:mm:ss') : ''}</span>
30+
</Descriptions.Item>
31+
<Descriptions.Item label='Generator'>
32+
<Link replace href={'/address/' + props.detailData?.Generator}>{props.detailData?.Generator}</Link>
33+
</Descriptions.Item>
34+
<Descriptions.Item label='Txs'>
35+
<span>{props.detailData?.Txs}</span>
36+
</Descriptions.Item>
37+
<Descriptions.Item label='Block ID'>
38+
<span>{props.detailData?.Signature}</span>
39+
</Descriptions.Item>
40+
<Descriptions.Item label='Parent Block ID'>
41+
<Link replace href={'/blocks/' + props.detailData?.ParentBlockSig}>{props.detailData?.ParentBlockSig}</Link>
42+
</Descriptions.Item>
43+
<Descriptions.Item label='Size'>
44+
<span>{props.detailData?.Size} B</span>
45+
</Descriptions.Item>
46+
</>
47+
}
4248
</Descriptions>
4349
<div className={styles.spinning} style={{ display: (!props.spinshow) ? 'flex' : 'none' }}>
4450
<Image

0 commit comments

Comments
 (0)