@@ -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 } > ( ) ;
@@ -223,12 +238,24 @@ const CardTransactionDetail = memo(function CardTransactionDetail({
223238 < Value
224239 className = { cashbackInfo . amount === 'Pending' ? 'text-yellow-500' : 'text-[#34C759]' }
225240 >
226- { cashbackInfo . isPending && cashbackInfo . amount !== 'Pending'
227- ? `${ cashbackInfo . amount } (Pending)`
228- : cashbackInfo . amount }
241+ { cashbackInfo . amount === 'Pending'
242+ ? cashbackInfo . isEscrowed
243+ ? 'Escrowed'
244+ : 'Pending'
245+ : cashbackInfo . isEscrowed
246+ ? `${ cashbackInfo . amount } (Escrowed)`
247+ : cashbackInfo . isPending
248+ ? `${ cashbackInfo . amount } (Pending)`
249+ : cashbackInfo . amount }
229250 </ Value >
230251 ) ,
231252 } ,
253+ cashbackInfo ?. isEscrowed &&
254+ cashbackInfo . payoutAt && {
255+ key : 'cashback-escrow-time-left' ,
256+ label : < Label > Releases in</ Label > ,
257+ value : < EscrowTimeLeft payoutAt = { cashbackInfo . payoutAt } /> ,
258+ } ,
232259 txHash && {
233260 key : 'explorer' ,
234261 label : < Label > Explorer</ Label > ,
0 commit comments