1
1
import { OutsideHandlesProvider , Staking } from '@lace/staking' ;
2
- import React , { useCallback } from 'react' ;
2
+ import React , { useCallback , useEffect } from 'react' ;
3
3
import {
4
4
useAnalyticsContext ,
5
5
useBackgroundServiceAPIContext ,
@@ -17,6 +17,9 @@ import {
17
17
MULTIDELEGATION_FIRST_VISIT_LS_KEY ,
18
18
MULTIDELEGATION_FIRST_VISIT_SINCE_PORTFOLIO_PERSISTENCE_LS_KEY
19
19
} from '@utils/constants' ;
20
+ import { ActivityDetail } from '../../activity' ;
21
+ import { Drawer , DrawerNavigation } from '@lace/common' ;
22
+ import { useTranslation } from 'react-i18next' ;
20
23
21
24
export const MultiDelegationStaking = ( ) : JSX . Element => {
22
25
const { theme } = useTheme ( ) ;
@@ -38,7 +41,9 @@ export const MultiDelegationStaking = (): JSX.Element => {
38
41
fetchNetworkInfo,
39
42
networkInfo,
40
43
blockchainProvider,
41
- currentChain
44
+ currentChain,
45
+ activityDetail,
46
+ resetActivityState
42
47
} = useWalletStore ( ( state ) => ( {
43
48
getKeyAgentType : state . getKeyAgentType ,
44
49
inMemoryWallet : state . inMemoryWallet ,
@@ -50,8 +55,11 @@ export const MultiDelegationStaking = (): JSX.Element => {
50
55
fetchNetworkInfo : state . fetchNetworkInfo ,
51
56
blockchainProvider : state . blockchainProvider ,
52
57
walletInfo : state . walletInfo ,
53
- currentChain : state . currentChain
58
+ currentChain : state . currentChain ,
59
+ activityDetail : state . activityDetail ,
60
+ resetActivityState : state . resetActivityState
54
61
} ) ) ;
62
+ const { t } = useTranslation ( ) ;
55
63
const sendAnalytics = useCallback ( ( ) => {
56
64
// TODO implement analytics for the new flow
57
65
const analytics = {
@@ -80,6 +88,11 @@ export const MultiDelegationStaking = (): JSX.Element => {
80
88
const walletAddress = walletInfo . addresses ?. [ 0 ] . address ?. toString ( ) ;
81
89
const analytics = useAnalyticsContext ( ) ;
82
90
91
+ // Reset current transaction details and close drawer if network (blockchainProvider) has changed
92
+ useEffect ( ( ) => {
93
+ resetActivityState ( ) ;
94
+ } , [ resetActivityState , blockchainProvider ] ) ;
95
+
83
96
return (
84
97
< OutsideHandlesProvider
85
98
{ ...{
@@ -119,6 +132,27 @@ export const MultiDelegationStaking = (): JSX.Element => {
119
132
} }
120
133
>
121
134
< Staking currentChain = { currentChain } theme = { theme . name } />
135
+ { /*
136
+ Note: Mounting the browser-extension activity details drawer here is just a workaround.
137
+ Ideally, the Drawer/Activity detail should be fully managed within the "Staking" component,
138
+ which contains the respective "Activity" section, but that would require moving/refactoring
139
+ large chunks of code, ATM tightly coupled with browser-extension state/logic,
140
+ to a separate package (core perhaps?).
141
+ */ }
142
+ < Drawer
143
+ visible = { ! ! activityDetail }
144
+ onClose = { resetActivityState }
145
+ navigation = {
146
+ < DrawerNavigation
147
+ title = { t ( 'transactions.detail.title' ) }
148
+ onCloseIconClick = { ( ) => {
149
+ resetActivityState ( ) ;
150
+ } }
151
+ />
152
+ }
153
+ >
154
+ { activityDetail && priceResult && < ActivityDetail price = { priceResult } /> }
155
+ </ Drawer >
122
156
</ OutsideHandlesProvider >
123
157
) ;
124
158
} ;
0 commit comments