@@ -4,60 +4,60 @@ import { dateFormatter } from '@/utils/format'
44import { DisplayAlgo } from '@/features/common/components/display-algo'
55import { useMemo } from 'react'
66import { PaymentTransactionModel } from '../models'
7+ import { DescriptionList } from '@/features/common/components/description-list'
8+ import { isDefined } from '@/utils/is-defined'
9+ import { transactionPageConstants } from '@/features/theme/constant'
710
811export type Props = {
912 transaction : PaymentTransactionModel
1013}
1114
1215export function TransactionInfo ( { transaction } : Props ) {
13- const transactionCardItems = useMemo (
14- ( ) => [
15- {
16- dt : 'Transaction ID' ,
17- dd : transaction . id ,
18- } ,
19- {
20- dt : 'Type' ,
21- dd : transaction . type ,
22- } ,
23- {
24- dt : 'Timestamp' ,
25- // TODO: check timezone
26- dd : dateFormatter . asLongDateTime ( transaction . roundTime ) ,
27- } ,
28- {
29- dt : 'Block' ,
30- dd : (
31- < a href = "#" className = { cn ( 'text-primary underline' ) } >
32- { transaction . confirmedRound }
33- </ a >
34- ) ,
35- } ,
36- {
37- dt : 'Group' ,
38- dd : (
39- < a href = "#" className = { cn ( 'text-primary underline' ) } >
40- { transaction . group }
41- </ a >
42- ) ,
43- } ,
44- {
45- dt : 'Fee' ,
46- dd : < DisplayAlgo amount = { transaction . fee } /> ,
47- } ,
48- ] ,
16+ const transactionInfoItems = useMemo (
17+ ( ) =>
18+ [
19+ {
20+ dt : transactionPageConstants . labels . transactionId ,
21+ dd : transaction . id ,
22+ } ,
23+ {
24+ dt : transactionPageConstants . labels . type ,
25+ dd : transaction . type ,
26+ } ,
27+ {
28+ dt : transactionPageConstants . labels . timestamp ,
29+ dd : dateFormatter . asLongDateTime ( new Date ( transaction . roundTime ) ) ,
30+ } ,
31+ {
32+ dt : transactionPageConstants . labels . block ,
33+ dd : (
34+ < a href = "#" className = { cn ( 'text-primary underline' ) } >
35+ { transaction . confirmedRound }
36+ </ a >
37+ ) ,
38+ } ,
39+ transaction . group
40+ ? {
41+ dt : transactionPageConstants . labels . group ,
42+ dd : (
43+ < a href = "#" className = { cn ( 'text-primary underline' ) } >
44+ { transaction . group }
45+ </ a >
46+ ) ,
47+ }
48+ : undefined ,
49+ {
50+ dt : transactionPageConstants . labels . fee ,
51+ dd : transaction . fee ? < DisplayAlgo amount = { transaction . fee } /> : 'N/A' ,
52+ } ,
53+ ] . filter ( isDefined ) ,
4954 [ transaction . confirmedRound , transaction . fee , transaction . group , transaction . id , transaction . roundTime , transaction . type ]
5055 )
5156
5257 return (
5358 < Card className = { cn ( 'p-4' ) } >
5459 < CardContent className = { cn ( 'text-sm space-y-2' ) } >
55- { transactionCardItems . map ( ( item , index ) => (
56- < dl className = { cn ( 'grid grid-cols-8' ) } key = { index } >
57- < dt > { item . dt } </ dt >
58- < dd className = { cn ( 'col-span-7' ) } > { item . dd } </ dd >
59- </ dl >
60- ) ) }
60+ < DescriptionList items = { transactionInfoItems } />
6161 </ CardContent >
6262 </ Card >
6363 )
0 commit comments