diff --git a/apps/frontend/app/escrow/[id]/page.tsx b/apps/frontend/app/escrow/[id]/page.tsx new file mode 100644 index 0000000..ad72f70 --- /dev/null +++ b/apps/frontend/app/escrow/[id]/page.tsx @@ -0,0 +1,110 @@ +'use client'; + +import { useState, useEffect } from 'react'; +import { useParams } from 'next/navigation'; +import Link from 'next/link'; +import { useEscrow } from '@/hooks/useEscrow'; +import { useWallet } from '@/hooks/useWallet'; +import EscrowHeader from '@/components/escrow/detail/EscrowHeader'; +import PartiesSection from '@/components/escrow/detail/PartiesSection'; +import TermsSection from '@/components/escrow/detail/TermsSection'; +import TimelineSection from '@/components/escrow/detail/TimelineSection'; +import TransactionHistory from '@/components/escrow/detail/TransactionHistory'; +import { IEscrowExtended } from '@/types/escrow'; + +const EscrowDetailPage = () => { + const { id } = useParams(); + const { escrow, loading, error } = useEscrow(id as string); + const { connected, publicKey, connect } = useWallet(); // Assuming wallet hook exists + const [userRole, setUserRole] = useState<'creator' | 'counterparty' | null>(null); + + useEffect(() => { + if (escrow && publicKey) { + if (escrow.creatorId === publicKey) { + setUserRole('creator'); + } else if (escrow.parties?.some((party: any) => party.userId === publicKey)) { + setUserRole('counterparty'); + } + } + }, [escrow, publicKey]); + + if (loading) { + return ( +
Loading escrow details...
+{error}
+ +The requested escrow agreement could not be found.
+ + Back to Escrows + +{escrow.description}
+ ++ User ID: {party.userId} +
+{condition.description}
+No events recorded yet.
+ ) : ( ++ + {event.eventType.replace(/_/g, ' ').toLowerCase()} + + + {event.eventType === 'CREATED' && 'Escrow agreement created'} + {event.eventType === 'FUNDED' && 'Escrow funded'} + {event.eventType === 'CONDITION_MET' && 'Condition met'} + {event.eventType === 'COMPLETED' && 'Escrow completed'} + {event.eventType === 'CANCELLED' && 'Escrow cancelled'} + {event.eventType === 'PARTY_ACCEPTED' && 'Party accepted the agreement'} + {event.eventType === 'PARTY_REJECTED' && 'Party rejected the agreement'} + {event.eventType === 'PARTY_ADDED' && 'Party added to the agreement'} + {event.eventType === 'DISPUTED' && 'Dispute raised'} + {event.eventType === 'STATUS_CHANGED' && 'Status changed'} + {event.eventType === 'UPDATED' && 'Agreement updated'} + +
+ {event.data && Object.keys(event.data).length > 0 && ( +{JSON.stringify(event.data, null, 2)}
+ No transaction history available.
+ ) : ( +| + Type + | ++ Amount + | ++ Status + | ++ Date + | ++ Transaction + | +
|---|---|---|---|---|
|
+
+ {event.eventType.replace(/_/g, ' ').toLowerCase()}
+
+ |
+
+
+ {event.eventType === 'FUNDED' && `${Number(escrow.amount).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 7 })} ${escrow.asset}`}
+ {event.eventType === 'COMPLETED' && `${Number(escrow.amount).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 7 })} ${escrow.asset}`}
+ {event.eventType === 'CANCELLED' && '0 XLM'}
+ {event.eventType === 'CONDITION_MET' && 'Variable'}
+
+ |
+ + + {event.eventType === 'COMPLETED' ? 'Completed' : + event.eventType === 'CANCELLED' ? 'Cancelled' : 'Processed'} + + | ++ {new Date(event.createdAt).toLocaleDateString()} + | ++ {event.data?.transactionHash ? ( + + View Transaction + + ) : ( + N/A + )} + | +