11import { useEffect , useMemo , useRef , useState } from 'react' ;
22import { Button } from '@/components/ui/button' ;
3+ import { StableButtonContent } from '@/components/ui/stable-button-content' ;
34import {
45 Dialog ,
56 DialogContent ,
@@ -55,7 +56,10 @@ const TradeDialog: React.FC<TradeDialogProps> = ({
5556 const confirmLabel = side === 'buy' ? 'Confirm buy' : 'Confirm sell' ;
5657
5758 return (
58- < Dialog open = { open } onOpenChange = { next => ! isSubmitting && onOpenChange ( next ) } >
59+ < Dialog
60+ open = { open }
61+ onOpenChange = { next => ! isSubmitting && onOpenChange ( next ) }
62+ >
5963 < DialogContent
6064 className = "max-w-md"
6165 showCloseButton = { ! isSubmitting }
@@ -91,14 +95,18 @@ const TradeDialog: React.FC<TradeDialogProps> = ({
9195 className = { cn (
9296 'w-full rounded-xl border bg-white/[0.04] px-3 py-2 text-white outline-none transition-colors' ,
9397 'border-white/10 focus:border-amber-500/50 focus:ring-2 focus:ring-amber-500/15' ,
94- ! amountValid && amountText . trim ( ) ? 'border-red-500/40' : ''
98+ ! amountValid && amountText . trim ( )
99+ ? 'border-red-500/40'
100+ : ''
95101 ) }
96102 aria-label = "Trade amount"
97103 data-focus-order = "1"
98104 data-testid = "trade-dialog-amount"
99105 />
100106 < div className = "flex flex-wrap items-center gap-2 text-xs text-white/45" >
101- < span aria-label = { `Current wallet holdings: ${ formatNumber ( availableHoldings ) } keys` } >
107+ < span
108+ aria-label = { `Current wallet holdings: ${ formatNumber ( availableHoldings ) } keys` }
109+ >
102110 Holdings: { formatNumber ( availableHoldings ) } keys
103111 </ span >
104112 { side === 'sell' &&
@@ -109,7 +117,9 @@ const TradeDialog: React.FC<TradeDialogProps> = ({
109117 label = "of holdings"
110118 value = { ( parsedAmount / availableHoldings ) * 100 }
111119 tone = {
112- parsedAmount > availableHoldings ? 'negative' : 'neutral'
120+ parsedAmount > availableHoldings
121+ ? 'negative'
122+ : 'neutral'
113123 }
114124 />
115125 ) }
@@ -145,10 +155,16 @@ const TradeDialog: React.FC<TradeDialogProps> = ({
145155 type = "button"
146156 onClick = { ( ) => onConfirm ( parsedAmount ) }
147157 disabled = { ! amountValid || isSubmitting }
158+ aria-busy = { isSubmitting || undefined }
148159 data-focus-order = "3"
149160 data-testid = "trade-dialog-confirm"
150161 >
151- { isSubmitting ? 'Submitting…' : confirmLabel }
162+ < StableButtonContent
163+ isLoading = { isSubmitting }
164+ loadingLabel = "Submitting…"
165+ >
166+ { confirmLabel }
167+ </ StableButtonContent >
152168 </ Button >
153169 </ DialogFooter >
154170 </ DialogContent >
0 commit comments