|
1 | 1 | import { ModalContainer } from '@/components/core/modals/ModalContainer/ModalContainer'; |
2 | 2 | import type { ModalContainerProps } from '@/components/core/modals/ModalContainer/ModalContainer'; |
3 | 3 | import type { EarnOpportunityExtended } from '@/stores/depositFlow/DepositFlowStore'; |
4 | | -import { useMemo, useState, useCallback, type FC } from 'react'; |
| 4 | +import { useMemo, useState, useCallback, useRef, type FC } from 'react'; |
5 | 5 | import { useRedeemableClaims } from '@/hooks/earn/useRedeemableClaims'; |
6 | 6 | import type { FormattedClaim } from './hooks/useFormatRedeemClaimData'; |
7 | 7 | import { useFormatRedeemClaimData } from './hooks/useFormatRedeemClaimData'; |
8 | 8 | import { useTransactionForm } from '@/hooks/transactions/useTransactionForm'; |
9 | 9 | import { JumperWidget } from '@/components/composite/JumperWidget/JumperWidget'; |
| 10 | +import type { NavigationContextValue } from '../JumperWidget/context'; |
10 | 11 | import { createTokenBalance } from '@/types/tokens'; |
11 | 12 | import { useTranslation } from 'react-i18next'; |
12 | 13 | import { RequestViewSubmitButton } from './components/RequestViewSubmitButton'; |
@@ -53,6 +54,15 @@ export const RequestRedeemModal: FC<RequestRedeemModalProps> = ({ |
53 | 54 | const { lpToken, lpTokenAmount, assetToken, refetchLpTokenAmount } = |
54 | 55 | useEarnOpportunityTokens(earnOpportunity); |
55 | 56 |
|
| 57 | + const widgetNavigationRef = useRef<NavigationContextValue | null>(null); |
| 58 | + |
| 59 | + const handleWidgetNavigationReady = useCallback( |
| 60 | + (value: NavigationContextValue) => { |
| 61 | + widgetNavigationRef.current = value; |
| 62 | + }, |
| 63 | + [], |
| 64 | + ); |
| 65 | + |
56 | 66 | const isClaimFlow = selectedClaim !== null; |
57 | 67 |
|
58 | 68 | const fetchCallData = useCallback(async () => { |
@@ -141,6 +151,14 @@ export const RequestRedeemModal: FC<RequestRedeemModalProps> = ({ |
141 | 151 | setSelectedClaim(null); |
142 | 152 | handleResetAmount(); |
143 | 153 | refetchLpTokenAmount(); |
| 154 | + if ( |
| 155 | + widgetNavigationRef.current?.currentViewId !== |
| 156 | + RequestRedeemModalView.REQUEST_WITHDRAW |
| 157 | + ) { |
| 158 | + widgetNavigationRef.current?.goToView( |
| 159 | + RequestRedeemModalView.REQUEST_WITHDRAW, |
| 160 | + ); |
| 161 | + } |
144 | 162 | }, |
145 | 163 | }); |
146 | 164 |
|
@@ -227,6 +245,7 @@ export const RequestRedeemModal: FC<RequestRedeemModalProps> = ({ |
227 | 245 | <JumperWidget |
228 | 246 | views={views} |
229 | 247 | statusSheet={statusSheet} |
| 248 | + onNavigationReady={handleWidgetNavigationReady} |
230 | 249 | style={widgetStyle} |
231 | 250 | /> |
232 | 251 | ) : null} |
|
0 commit comments