From 0f532fe8b2a8bb491ad24e81070d3f3d09a86e2b Mon Sep 17 00:00:00 2001 From: Anuoluwapo25 Date: Wed, 25 Mar 2026 20:45:35 +0100 Subject: [PATCH] feat: add TransactionPendingModal component for Stellar transaction states MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements a reusable modal shell for transaction feedback (pending/success/error). Supports title, status text, description, and an optional action area — ready for buy and sell flows. Co-Authored-By: Claude Sonnet 4.6 --- .../common/TransactionPendingModal.tsx | 173 ++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 src/components/common/TransactionPendingModal.tsx diff --git a/src/components/common/TransactionPendingModal.tsx b/src/components/common/TransactionPendingModal.tsx new file mode 100644 index 0000000..7625088 --- /dev/null +++ b/src/components/common/TransactionPendingModal.tsx @@ -0,0 +1,173 @@ +import React from 'react'; +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, + DialogDescription, + DialogFooter, +} from '@/components/ui/dialog'; +import { Button } from '@/components/ui/button'; +import CircularSpinner from '@/components/common/CircularSpinnerProps'; +import { cn } from '@/lib/utils'; + +export type TransactionStatus = 'pending' | 'success' | 'error'; + +export interface TransactionPendingModalProps { + isOpen: boolean; + onClose: () => void; + title?: string; + statusText?: string; + description?: string; + status?: TransactionStatus; + actionLabel?: string; + onAction?: () => void; + className?: string; +} + +const STATUS_CONFIG: Record< + TransactionStatus, + { color: string; spinnerColor: string; dotColor: string } +> = { + pending: { + color: 'text-amber-400', + spinnerColor: '#f59e0b', + dotColor: 'bg-amber-400', + }, + success: { + color: 'text-emerald-400', + spinnerColor: '#34d399', + dotColor: 'bg-emerald-400', + }, + error: { + color: 'text-red-400', + spinnerColor: '#f87171', + dotColor: 'bg-red-400', + }, +}; + +const TransactionPendingModal: React.FC = ({ + isOpen, + onClose, + title = 'Transaction Pending', + statusText = 'Waiting for confirmation...', + description = 'Please do not close this window while your transaction is being processed on the network.', + status = 'pending', + actionLabel, + onAction, + className, +}) => { + const config = STATUS_CONFIG[status]; + + return ( + !open && onClose()}> + + +
+
+ {status === 'pending' && ( + + )} + {status !== 'pending' && ( +
+ {status === 'success' ? ( + + + + ) : ( + + + + )} +
+ )} +
+ +
+ + + {statusText} + +
+
+ + + {title} + + + + {description} + +
+ + + {onAction && actionLabel && ( + + )} + {status !== 'pending' && ( + + )} + +
+
+ ); +}; + +export default TransactionPendingModal;