11import React , { useMemo } from "react" ;
22import styled , { useTheme } from "styled-components" ;
33
4- import { responsiveSize } from "styles/responsiveSize" ;
5-
4+ import Skeleton from "react-loading-skeleton" ;
65import { useParams } from "react-router-dom" ;
76
87import { _TimelineItem1 , CustomTimeline } from "@kleros/ui-components-library" ;
@@ -14,14 +13,20 @@ import { Periods } from "consts/periods";
1413import { usePopulatedDisputeData } from "hooks/queries/usePopulatedDisputeData" ;
1514import { getLocalRounds } from "utils/getLocalRounds" ;
1615import { getVoteChoice } from "utils/getVoteChoice" ;
16+ import { shortenTxnHash } from "utils/shortenAddress" ;
1717
1818import { DisputeDetailsQuery , useDisputeDetailsQuery } from "queries/useDisputeDetailsQuery" ;
1919import { useVotingHistory } from "queries/useVotingHistory" ;
2020
2121import { ClassicRound } from "src/graphql/graphql" ;
22+ import { getTxnExplorerLink } from "src/utils" ;
23+
24+ import { responsiveSize } from "styles/responsiveSize" ;
2225
2326import { StyledClosedCircle } from "components/StyledIcons/ClosedCircleIcon" ;
2427
28+ import { ExternalLink } from "../ExternalLink" ;
29+
2530const Container = styled . div `
2631 display: flex;
2732 position: relative;
@@ -50,6 +55,16 @@ const StyledCalendarIcon = styled(CalendarIcon)`
5055 height: 14px;
5156` ;
5257
58+ const LinkContainer = styled . div `
59+ display: flex;
60+ gap: 4px;
61+ align-items: center;
62+ span {
63+ font-size: 14px;
64+ color: ${ ( { theme } ) => theme . primaryText } ;
65+ }
66+ ` ;
67+
5368const formatDate = ( date : string ) => {
5469 const options : Intl . DateTimeFormatOptions = { year : "numeric" , month : "long" , day : "numeric" } ;
5570 const startingDate = new Date ( parseInt ( date ) * 1000 ) ;
@@ -67,6 +82,9 @@ const useItems = (disputeDetails?: DisputeDetailsQuery, arbitrable?: `0x${string
6782 const localRounds : ClassicRound [ ] = getLocalRounds ( votingHistory ?. dispute ?. disputeKitDispute ) as ClassicRound [ ] ;
6883 const rounds = votingHistory ?. dispute ?. rounds ;
6984 const theme = useTheme ( ) ;
85+ const txnExplorerLink = useMemo ( ( ) => {
86+ return getTxnExplorerLink ( votingHistory ?. dispute ?. transactionHash ?? "" ) ;
87+ } , [ votingHistory ] ) ;
7088
7189 return useMemo < TimelineItems | undefined > ( ( ) => {
7290 const dispute = disputeDetails ?. dispute ;
@@ -119,7 +137,18 @@ const useItems = (disputeDetails?: DisputeDetailsQuery, arbitrable?: `0x${string
119137 [
120138 {
121139 title : "Dispute created" ,
122- party : "" ,
140+ party : (
141+ < LinkContainer >
142+ < span > at</ span >
143+ < ExternalLink to = { txnExplorerLink } rel = "noopener noreferrer" target = "_blank" >
144+ { votingHistory ?. dispute ?. transactionHash ? (
145+ shortenTxnHash ( votingHistory ?. dispute ?. transactionHash )
146+ ) : (
147+ < Skeleton height = { 16 } width = { 56 } />
148+ ) }
149+ </ ExternalLink >
150+ </ LinkContainer >
151+ ) ,
123152 subtitle : formatDate ( votingHistory ?. dispute ?. createdAt ) ,
124153 rightSided : true ,
125154 variant : theme . secondaryPurple ,
@@ -128,7 +157,7 @@ const useItems = (disputeDetails?: DisputeDetailsQuery, arbitrable?: `0x${string
128157 ) ;
129158 }
130159 return ;
131- } , [ disputeDetails , disputeData , localRounds , theme ] ) ;
160+ } , [ disputeDetails , disputeData , localRounds , theme , rounds , votingHistory , txnExplorerLink ] ) ;
132161} ;
133162
134163interface IDisputeTimeline {
@@ -138,15 +167,30 @@ interface IDisputeTimeline {
138167const DisputeTimeline : React . FC < IDisputeTimeline > = ( { arbitrable } ) => {
139168 const { id } = useParams ( ) ;
140169 const { data : disputeDetails } = useDisputeDetailsQuery ( id ) ;
170+ const { data : votingHistory } = useVotingHistory ( id ) ;
141171 const items = useItems ( disputeDetails , arbitrable ) ;
142172
173+ const transactionExplorerLink = useMemo ( ( ) => {
174+ return getTxnExplorerLink ( disputeDetails ?. dispute ?. rulingTransactionHash ?? "" ) ;
175+ } , [ disputeDetails ] ) ;
176+
143177 return (
144178 < Container >
145179 { items && < StyledTimeline { ...{ items } } /> }
146- { disputeDetails ?. dispute ?. ruled && items && (
180+ { disputeDetails ?. dispute ?. ruled && (
147181 < EnforcementContainer >
148182 < StyledCalendarIcon />
149- < small > Enforcement: { items . at ( - 1 ) ?. subtitle } </ small >
183+ < small >
184+ Enforcement:{ " " }
185+ { disputeDetails . dispute . rulingTimestamp ? (
186+ < ExternalLink to = { transactionExplorerLink } rel = "noopener noreferrer" target = "_blank" >
187+ { formatDate ( disputeDetails . dispute . rulingTimestamp ) }
188+ </ ExternalLink >
189+ ) : (
190+ < Skeleton height = { 16 } width = { 56 } />
191+ ) } { " " }
192+ / { votingHistory ?. dispute ?. rounds . at ( - 1 ) ?. court . name }
193+ </ small >
150194 </ EnforcementContainer >
151195 ) }
152196 </ Container >
0 commit comments