|
|
|
|
@ -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() |
|
|
|
|
} |
|
|
|
|
redirectToMatchProfile(match) |
|
|
|
|
closePopup() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const goToError = () => goTo(Steps.Error) |
|
|
|
|
|