fix(#2485): redirect to matchpage after payment

keep-around/72d57d0225e2a72a734ba38f8c6f87fbb6c04704
Andrei Dekterev 4 years ago
parent e74c2f5303
commit 72d57d0225
  1. 13
      src/features/BuyMatchPopup/store/hooks/index.tsx

@ -12,9 +12,7 @@ import last from 'lodash/last'
import isEmpty from 'lodash/isEmpty'
import size from 'lodash/size'
import { PAGES, ProfileTypes } from 'config'
import { isMatchPage } from 'helpers/isMatchPage'
import { ProfileTypes } from 'config'
import {
buyMatchSubscription,
@ -30,7 +28,6 @@ import {
Steps,
SubscriptionType,
} from 'features/BuyMatchPopup/types'
import { useAuthStore } from 'features/AuthStore'
import { getProfileUrl } from 'features/ProfileLink/helpers'
import { useSubscriptions } from './useSubscriptions'
@ -52,7 +49,6 @@ export const useBuyMatchPopup = () => {
const [error, setError] = useState('')
const [loader, setLoader] = useState(false)
const [disabledBuyBtn, setDisabledBuyBtn] = useState(false)
const { user } = useAuthStore()
const goTo = useCallback(
(step: Steps, e?: MouseEvent<HTMLButtonElement>) => setSteps((state) => {
@ -108,7 +104,6 @@ export const useBuyMatchPopup = () => {
setError('')
resetSubscriptions()
setSelectedPackage(null)
if (isMatchPage() && user?.profile.country_code !== 'BR') history.push(PAGES.home)
}
const redirectToMatchProfile = ({ id, sportType }: Match) => {
@ -122,13 +117,9 @@ export const useBuyMatchPopup = () => {
const onSuccessfulSubscription = () => goTo(Steps.Success)
const postPaymentHandler = () => {
closePopup()
if (!match) return
if (match.hasVideo || match.calc) {
redirectToMatchProfile(match)
} else {
window.location.reload()
}
closePopup()
}
const goToError = () => goTo(Steps.Error)

Loading…
Cancel
Save