1+ import { WalletAddress } from "@/components/blocks/wallet-address" ;
12import { Spinner } from "@/components/ui/Spinner/Spinner" ;
3+ import { Button } from "@/components/ui/button" ;
24import { Card , CardContent , CardHeader , CardTitle } from "@/components/ui/card" ;
35import {
46 Table ,
@@ -9,18 +11,12 @@ import {
911 TableRow ,
1012} from "@/components/ui/table" ;
1113import { TabButtons } from "@/components/ui/tabs" ;
14+ import { formatDistanceToNow } from "date-fns" ;
15+ import { ArrowLeft , ArrowRight , WalletIcon } from "lucide-react" ;
1216import { useState } from "react" ;
13-
14- interface Transaction {
15- id : string ;
16- type : "out" | "in" ;
17- amount : string ;
18- to ?: string ;
19- from ?: string ;
20- contract ?: string ;
21- method ?: string ;
22- date : string ;
23- }
17+ import type { ChainMetadata } from "thirdweb/chains" ;
18+ import { shortenHex } from "thirdweb/utils" ;
19+ import type { TransactionDetails } from "../hooks/useGetRecentTransactions" ;
2420
2521interface Contract {
2622 address : string ;
@@ -29,12 +25,14 @@ interface Contract {
2925}
3026
3127interface ActivityOverviewProps {
32- transactions : Transaction [ ] ;
28+ chain : ChainMetadata ;
29+ transactions : TransactionDetails [ ] ;
3330 contracts : Contract [ ] ;
3431 isLoading : boolean ;
3532}
3633
3734export function ActivityOverview ( {
35+ chain,
3836 transactions,
3937 contracts,
4038 isLoading,
@@ -54,6 +52,8 @@ export function ActivityOverview({
5452 // Calculate total pages
5553 const totalPages = Math . ceil ( transactions . length / itemsPerPage ) ;
5654
55+ const explorer = chain . explorers ?. [ 0 ] ;
56+
5757 return (
5858 < Card >
5959 < CardHeader >
@@ -85,24 +85,58 @@ export function ActivityOverview({
8585 < Table >
8686 < TableHeader >
8787 < TableRow >
88- < TableHead > Type</ TableHead >
89- < TableHead > Amount</ TableHead >
90- < TableHead > Details</ TableHead >
9188 < TableHead > Date</ TableHead >
89+ < TableHead > Hash</ TableHead >
90+ < TableHead > Activity</ TableHead >
91+ < TableHead > Value ({ chain . nativeCurrency . symbol } )</ TableHead >
9292 </ TableRow >
9393 </ TableHeader >
9494 < TableBody >
95- { currentTransactions . map ( ( tx ) => (
96- < TableRow key = { tx . id } >
97- < TableCell > { tx . type } </ TableCell >
98- < TableCell > { tx . amount } </ TableCell >
95+ { currentTransactions . map ( ( transaction ) => (
96+ < TableRow key = { transaction . hash } >
97+ < TableCell >
98+ < span title = { transaction . date . toLocaleString ( ) } >
99+ { formatDistanceToNow ( transaction . date , {
100+ addSuffix : true ,
101+ } ) }
102+ </ span >
103+ </ TableCell >
104+ < TableCell >
105+ < Button
106+ variant = "link"
107+ onClick = { ( ) =>
108+ window . open ( `${ explorer ?. url } /tx/${ transaction . hash } ` )
109+ }
110+ className = "font-mono"
111+ >
112+ { shortenHex ( transaction . hash ) }
113+ </ Button >
114+ </ TableCell >
115+ < TableCell >
116+ { transaction . type === "in" ? (
117+ < div className = "flex items-center gap-2" >
118+ < WalletIcon />
119+ < ArrowLeft className = "text-blue-500" />
120+ < WalletAddress
121+ address = { transaction . from }
122+ shortenAddress = { false }
123+ />
124+ </ div >
125+ ) : (
126+ < div className = "flex items-center gap-2" >
127+ < WalletIcon />
128+ < ArrowRight className = "text-green-500" />
129+ < WalletAddress
130+ address = { transaction . to }
131+ shortenAddress = { false }
132+ />
133+ </ div >
134+ ) }
135+ </ TableCell >
99136 < TableCell >
100- { tx . to && `To: ${ tx . to } ` }
101- { tx . from && `From: ${ tx . from } ` }
102- { tx . contract && `Contract: ${ tx . contract } ` }
103- { tx . method && ` Method: ${ tx . method } ` }
137+ { transaction . valueTokens > 0 &&
138+ transaction . valueTokens . toPrecision ( 4 ) }
104139 </ TableCell >
105- < TableCell > { tx . date } </ TableCell >
106140 </ TableRow >
107141 ) ) }
108142 </ TableBody >
@@ -139,22 +173,21 @@ export function ActivityOverview({
139173 </ >
140174 ) : activeTab === "contracts" ? (
141175 < Table >
142- < TableHeader >
176+ { /* <TableHeader>
143177 <TableRow>
144178 <TableHead>Name</TableHead>
145179 <TableHead>Address</TableHead>
146180 <TableHead>Last Interaction</TableHead>
147181 </TableRow>
148182 </TableHeader>
149- < TableBody >
150- { contracts . map ( ( contract , index ) => (
183+ <TableBody>contracts.map((contract, index) => (
151184 <TableRow key={`${contract.address}-${index}`}>
152185 <TableCell>{contract.name}</TableCell>
153186 <TableCell>{contract.address}</TableCell>
154187 <TableCell>{contract.lastInteraction}</TableCell>
155188 </TableRow>
156- ) ) }
157- </ TableBody >
189+ ))
190+ </TableBody> */ }
158191 </ Table >
159192 ) : null }
160193 </ CardContent >
0 commit comments