1
+ /* eslint-disable react/no-multi-comp */
1
2
/* eslint-disable promise/catch-or-return */
2
3
/* eslint-disable no-magic-numbers */
3
4
/* eslint-disable unicorn/no-null */
@@ -10,14 +11,16 @@ import { PasswordInput } from './PasswordInput';
10
11
import { TransactionSuccess } from './TransactionSuccess' ;
11
12
import { TransactionFailed } from './TransactionFailed' ;
12
13
import { useFetchCoinPrice , useRedirection , useWalletManager } from '@hooks' ;
13
- import { PostHogAction , useObservable } from '@lace/common' ;
14
+ import { DrawerNavigation , PostHogAction , useObservable } from '@lace/common' ;
14
15
import { Bitcoin } from '@lace/bitcoin' ;
15
16
import { Wallet as Cardano } from '@lace/cardano' ;
16
17
import { walletRoutePaths } from '@routes' ;
17
18
import { useDrawer } from '@src/views/browser-view/stores' ;
18
19
import { useWalletStore } from '@src/stores' ;
19
20
import { APP_MODE_POPUP } from '@src/utils/constants' ;
20
21
import { useAnalyticsContext } from '@providers' ;
22
+ import { DrawerContent } from '@src/views/browser-view/components/Drawer' ;
23
+ import { useTranslation } from 'react-i18next' ;
21
24
22
25
const SATS_IN_BTC = 100_000_000 ;
23
26
@@ -102,6 +105,7 @@ const btcStringToSatoshisBigint = (btcString: string): bigint => {
102
105
} ;
103
106
104
107
export const SendFlow : React . FC = ( ) => {
108
+ const { t } = useTranslation ( ) ;
105
109
const [ step , setStep ] = useState < Step > ( 'AMOUNT' ) ;
106
110
107
111
const [ amount , setAmount ] = useState < string > ( '' ) ;
@@ -126,7 +130,7 @@ export const SendFlow: React.FC = () => {
126
130
const btcToUsdRate = useMemo ( ( ) => priceResult . bitcoin ?. price ?? 0 , [ priceResult . bitcoin ] ) ;
127
131
const balance = useObservable ( bitcoinWallet . balance$ , BigInt ( 0 ) ) ;
128
132
129
- const [ config , clearContent ] = useDrawer ( ) ;
133
+ const [ config , setDrawerConfig ] = useDrawer ( ) ;
130
134
131
135
const redirectToTransactions = useRedirection ( walletRoutePaths . activity ) ;
132
136
const redirectToOverview = useRedirection ( walletRoutePaths . assets ) ;
@@ -205,6 +209,24 @@ export const SendFlow: React.FC = () => {
205
209
} ) ;
206
210
} , [ bitcoinWallet ] ) ;
207
211
212
+ const onClose = useCallback ( ( ) => {
213
+ if ( isPopupView ) redirectToOverview ( ) ;
214
+ else {
215
+ config ?. onClose ? config ?. onClose ( ) : setDrawerConfig ( ) ;
216
+ }
217
+ } , [ setDrawerConfig , config , isPopupView , redirectToOverview ] ) ;
218
+
219
+ const backToAmount = ( ) => {
220
+ setStep ( 'AMOUNT' ) ;
221
+ setDrawerConfig ( {
222
+ ...config ,
223
+ content : DrawerContent . SEND_BITCOIN_TRANSACTION ,
224
+ renderHeader : ( ) => (
225
+ < DrawerNavigation title = { < div > { t ( 'browserView.transaction.send.title' ) } </ div > } onCloseIconClick = { onClose } />
226
+ )
227
+ } ) ;
228
+ } ;
229
+
208
230
// Step 1 -> 2
209
231
const goToReview = ( newFeeRate : number ) => {
210
232
setFeeRate ( newFeeRate ) ;
@@ -220,6 +242,17 @@ export const SendFlow: React.FC = () => {
220
242
} )
221
243
) ;
222
244
setStep ( 'REVIEW' ) ;
245
+ setDrawerConfig ( {
246
+ ...config ,
247
+ content : DrawerContent . SEND_BITCOIN_TRANSACTION ,
248
+ renderHeader : ( ) => (
249
+ < DrawerNavigation
250
+ title = { < div > { t ( 'browserView.transaction.send.title' ) } </ div > }
251
+ onCloseIconClick = { onClose }
252
+ onArrowIconClick = { backToAmount }
253
+ />
254
+ )
255
+ } ) ;
223
256
} ;
224
257
// Step 2 -> 3
225
258
const goToPassword = ( ) => setStep ( 'PASSWORD' ) ;
@@ -243,13 +276,6 @@ export const SendFlow: React.FC = () => {
243
276
}
244
277
} ;
245
278
246
- const onClose = useCallback ( ( ) => {
247
- if ( isPopupView ) redirectToOverview ( ) ;
248
- else {
249
- config ?. onClose ? config ?. onClose ( ) : clearContent ( ) ;
250
- }
251
- } , [ clearContent , config , isPopupView , redirectToOverview ] ) ;
252
-
253
279
const backToReview = ( ) => setStep ( 'REVIEW' ) ;
254
280
255
281
if ( step === 'AMOUNT' ) {
@@ -302,7 +328,7 @@ export const SendFlow: React.FC = () => {
302
328
onClose = { onClose }
303
329
isPopupView = { isPopupView }
304
330
onViewTransaction = { ( ) => {
305
- clearContent ( ) ;
331
+ setDrawerConfig ( ) ;
306
332
redirectToTransactions ( ) ;
307
333
} }
308
334
hash = { confirmationHash }
0 commit comments