diff --git a/src/config/lexics/payment.tsx b/src/config/lexics/payment.tsx index f8f4d195..d7d33afd 100644 --- a/src/config/lexics/payment.tsx +++ b/src/config/lexics/payment.tsx @@ -17,4 +17,5 @@ export const paymentLexics = { payment_method: 2010, subscription_plan: 18182, sum: 838, + watch_match: 18199, } diff --git a/src/features/BuyMatchPopup/components/BrazilPayment/hooks.tsx b/src/features/BuyMatchPopup/components/BrazilPayment/hooks.tsx index 97e7a2e4..f6c1cf9c 100644 --- a/src/features/BuyMatchPopup/components/BrazilPayment/hooks.tsx +++ b/src/features/BuyMatchPopup/components/BrazilPayment/hooks.tsx @@ -11,10 +11,12 @@ import { ProfileTypes } from 'config' import isNumber from 'lodash/isNumber' import { useLexicsStore } from 'features/LexicsStore' +import { useBuyMatchPopupStore } from 'features/BuyMatchPopup/store' import { getProfileUrl } from 'features/ProfileLink/helpers' import { getMatchInfo } from 'requests/getMatchInfo' import { getBrazilPaymentUrl } from 'requests/getBrazilPaymentUrl' + import type { Props } from './index' type ResponsePayment = { @@ -30,10 +32,13 @@ export const useBrazilPayment = ({ setIsOpenBrasilian, }: Props) => { const history = useHistory() + const { close } = useBuyMatchPopupStore() const [src, setSrc] = useState('') const { translate } = useLexicsStore() + const { id, sportType } = match + const { name, nameLexic, @@ -44,19 +49,19 @@ export const useBrazilPayment = ({ const teams = isNumber(nameLexic) ? translate(String(nameLexic)) : name const pack = translate(String(pass)) + const matchLink = getProfileUrl({ + id, + profileType: ProfileTypes.MATCHES, + sportType, + }) + const closePopup = async (e?: MouseEvent) => { e?.stopPropagation() setIsOpenBrasilian(false) - const { id, sportType } = match const accessMatch = await getMatchInfo(sportType, id) - - if (accessMatch?.access) { - const matchLink = getProfileUrl({ - id, - profileType: ProfileTypes.MATCHES, - sportType, - }) + if (!accessMatch?.access) { + close() history.push(matchLink) } } @@ -73,6 +78,7 @@ export const useBrazilPayment = ({ return { closePopup, + matchLink, src, } } diff --git a/src/features/BuyMatchPopup/components/BrazilPayment/index.tsx b/src/features/BuyMatchPopup/components/BrazilPayment/index.tsx index d1871b1a..45ab0d83 100644 --- a/src/features/BuyMatchPopup/components/BrazilPayment/index.tsx +++ b/src/features/BuyMatchPopup/components/BrazilPayment/index.tsx @@ -1,9 +1,16 @@ import { Loader } from 'features/Loader' import { MatchPackage, Match } from 'features/BuyMatchPopup/types' +import { T9n } from 'features/T9n' import { useBrazilPayment } from './hooks' -import { ScModal, LoaderWrapper } from './styled' +import { + LoaderWrapper, + ScButton, + ScModal, +} from './styled' + +import { Button } from '../../styled' export type Props = { match: Match, @@ -18,7 +25,11 @@ export const BrazilPayment = ({ selectedPackage, setIsOpenBrasilian, }: Props) => { - const { closePopup, src } = useBrazilPayment({ + const { + closePopup, + matchLink, + src, + } = useBrazilPayment({ match, open, selectedPackage, @@ -28,7 +39,16 @@ export const BrazilPayment = ({ return ( {src && open ? ( -