@@ -3,7 +3,7 @@ import { Linking, Pressable, View } from 'react-native';
33import { useLocalSearchParams , useRouter } from 'expo-router' ;
44import * as Sentry from '@sentry/react-native' ;
55import { useQuery } from '@tanstack/react-query' ;
6- import { format , minutesToSeconds } from 'date-fns' ;
6+ import { format , formatDistanceStrict , minutesToSeconds } from 'date-fns' ;
77import { ArrowUpRight , ChevronLeft , X } from 'lucide-react-native' ;
88import { mainnet } from 'viem/chains' ;
99
@@ -92,6 +92,21 @@ const Value = memo(function Value({ children, className }: ValueProps) {
9292 return < Text className = { cn ( 'text-lg font-bold' , className ) } > { children } </ Text > ;
9393} ) ;
9494
95+ const EscrowTimeLeft = memo ( function EscrowTimeLeft ( { payoutAt } : { payoutAt : string } ) {
96+ const [ now , setNow ] = useState ( ( ) => Date . now ( ) ) ;
97+
98+ useEffect ( ( ) => {
99+ const interval = setInterval ( ( ) => setNow ( Date . now ( ) ) , 60_000 ) ;
100+ return ( ) => clearInterval ( interval ) ;
101+ } , [ ] ) ;
102+
103+ const target = useMemo ( ( ) => new Date ( payoutAt ) . getTime ( ) , [ payoutAt ] ) ;
104+
105+ if ( target - now <= 0 ) return < Value > Releasing soon</ Value > ;
106+
107+ return < Value > { formatDistanceStrict ( target , now ) } </ Value > ;
108+ } ) ;
109+
95110const Back = memo ( function Back ( { title, className } : BackProps ) {
96111 const router = useRouter ( ) ;
97112 const params = useLocalSearchParams < { tab ?: string ; from ?: string } > ( ) ;
@@ -217,12 +232,24 @@ const CardTransactionDetail = memo(function CardTransactionDetail({
217232 < Value
218233 className = { cashbackInfo . amount === 'Pending' ? 'text-yellow-500' : 'text-[#34C759]' }
219234 >
220- { cashbackInfo . isPending && cashbackInfo . amount !== 'Pending'
221- ? `${ cashbackInfo . amount } (Pending)`
222- : cashbackInfo . amount }
235+ { cashbackInfo . amount === 'Pending'
236+ ? cashbackInfo . isEscrowed
237+ ? 'Escrowed'
238+ : 'Pending'
239+ : cashbackInfo . isEscrowed
240+ ? `${ cashbackInfo . amount } (Escrowed)`
241+ : cashbackInfo . isPending
242+ ? `${ cashbackInfo . amount } (Pending)`
243+ : cashbackInfo . amount }
223244 </ Value >
224245 ) ,
225246 } ,
247+ cashbackInfo ?. isEscrowed &&
248+ cashbackInfo . payoutAt && {
249+ key : 'cashback-escrow-time-left' ,
250+ label : < Label > Releases in</ Label > ,
251+ value : < EscrowTimeLeft payoutAt = { cashbackInfo . payoutAt } /> ,
252+ } ,
226253 txHash && {
227254 key : 'explorer' ,
228255 label : < Label > Explorer</ Label > ,
0 commit comments