Skip to content

Commit 4fd5200

Browse files
authored
Fix purchase completion error (#13783)
1 parent 6cb4b6f commit 4fd5200

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

packages/web/src/components/premium-content-purchase-modal/PremiumContentPurchaseModal.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ import {
4646
import cn from 'classnames'
4747
import { Formik, useField, useFormikContext } from 'formik'
4848
import { useDispatch, useSelector } from 'react-redux'
49+
import { useNavigate, useLocation } from 'react-router'
4950
import { useLocalStorage } from 'react-use'
5051
import { z } from 'zod'
5152
import { toFormikValidationSchema } from 'zod-formik-adapter'
5253

53-
import { useHistoryContext } from 'app/HistoryProvider'
5454
import * as signOnActions from 'common/store/pages/signon/actions'
5555
import ModalDrawer from 'components/modal-drawer/ModalDrawer'
5656
import { ModalForm } from 'components/modal-form/ModalForm'
5757
import { USDCManualTransfer } from 'components/usdc-manual-transfer/USDCManualTransfer'
5858
import { useIsMobile } from 'hooks/useIsMobile'
5959
import { useIsUSDCEnabled } from 'hooks/useIsUSDCEnabled'
6060
import { useManagedAccountNotAllowedCallback } from 'hooks/useManagedAccountNotAllowedRedirect'
61-
import { pushUniqueRoute } from 'utils/route'
61+
import { getPathname } from 'utils/route'
6262
import zIndex from 'utils/zIndex'
6363

6464
import styles from './PremiumContentPurchaseModal.module.css'
@@ -113,7 +113,8 @@ const PremiumContentPurchaseForm = (props: PremiumContentPurchaseFormProps) => {
113113
const currentPageIndex = pageToPageIndex(page)
114114

115115
const { submitForm, resetForm } = useFormikContext()
116-
const { history } = useHistoryContext()
116+
const navigate = useNavigate()
117+
const location = useLocation()
117118
const { data: isAccountComplete = false } = useCurrentAccountUser({
118119
select: selectIsAccountComplete
119120
})
@@ -126,9 +127,12 @@ const PremiumContentPurchaseForm = (props: PremiumContentPurchaseFormProps) => {
126127
// Navigate to track on successful purchase behind the modal
127128
useEffect(() => {
128129
if (stage === PurchaseContentStage.FINISH && permalink) {
129-
dispatch(pushUniqueRoute(history.location, permalink))
130+
const pathname = getPathname(location)
131+
if (permalink !== pathname) {
132+
navigate(permalink)
133+
}
130134
}
131-
}, [stage, permalink, dispatch, history])
135+
}, [stage, permalink, navigate, location])
132136

133137
const handleUSDCManualTransferClose = useCallback(() => {
134138
dispatch(setPurchasePage({ page: PurchaseContentPageType.PURCHASE }))

0 commit comments

Comments
 (0)