import React, { useEffect } from 'react' import { Box, Text } from 'ink' import { Header } from '../components/index.js' import { theme } from '../theme.js' export interface TransactionSyncSuccessScreenProps { /** * Safe address in EIP-3770 format */ safeEip3770: string /** * Number of transactions pulled (imported) from API */ pullImported: number /** * Number of transactions updated with new signatures from API */ pullUpdated: number /** * Number of transactions proposed (pushed) to API */ pushProposed: number /** * Number of transactions updated with new signatures on API */ pushUpdated: number /** * Optional callback when the screen is ready to exit */ onExit?: () => void } /** * TransactionSyncSuccessScreen displays results after two-way sync with Safe API. * This replaces the console.log implementation in commands/tx/sync.ts * * Features: * - Shows pull statistics (imported, updated) * - Shows push statistics (proposed, updated) * - Displays summary with directional indicators * - Color-coded success indicators */ export function TransactionSyncSuccessScreen({ safeEip3770, pullImported, pullUpdated, pushProposed, pushUpdated, onExit, }: TransactionSyncSuccessScreenProps): React.ReactElement { // Auto-exit after rendering useEffect(() => { if (onExit) { onExit() } }, [onExit]) const totalPull = pullImported + pullUpdated const totalPush = pushProposed + pushUpdated const hasChanges = totalPull > 0 || totalPush > 0 return (
Safe: {safeEip3770} {hasChanges ? ( {/* Pull results */} {totalPull > 0 && ( ↓ Pull from API: {pullImported > 0 && ( Imported: {pullImported} transaction{pullImported !== 1 ? 's' : ''} )} {pullUpdated > 0 && ( Updated: {pullUpdated} transaction{pullUpdated !== 1 ? 's' : ''} )} )} {/* Push results */} {totalPush > 0 && ( ↑ Push to API: {pushProposed > 0 && ( Proposed: {pushProposed} transaction{pushProposed !== 1 ? 's' : ''} )} {pushUpdated > 0 && ( Updated: {pushUpdated} transaction{pushUpdated !== 1 ? 's' : ''} )} )} {/* Summary */} Summary: ↓ Pulled: {pullImported} new, {pullUpdated} updated ↑ Pushed: {pushProposed} new, {pushUpdated} updated ) : ( No changes - local and remote are in sync )} ) }