diff --git a/src/features/BuyMatchPopup/components/BrazilPayment/index.tsx b/src/features/BuyMatchPopup/components/BrazilPayment/index.tsx index fb4a509d..d45cd9e8 100644 --- a/src/features/BuyMatchPopup/components/BrazilPayment/index.tsx +++ b/src/features/BuyMatchPopup/components/BrazilPayment/index.tsx @@ -1,33 +1,51 @@ import { useEffect, useState } from 'react' import { Loader } from 'features/Loader' +import { useLexicsStore } from 'features/LexicsStore' + +import { MatchPackage } from 'features/BuyMatchPopup/types' import { getBrazilPaymentUrl } from 'requests/getBrazilPaymentUrl' -import type { SubscriptionResponse } from 'requests/getSubscriptions' + +import isNumber from 'lodash/isNumber' import { ScModal, LoaderWrapper } from './styled' type Props = { - item: SubscriptionResponse, open: boolean, - product_name: string, + selectedPackage: MatchPackage, } +type ResponsePayment = { + url: string, +} + +type ResponsePaymentArray =Array + export const BrazilPayment = ({ - item, open, - product_name, + selectedPackage, }: Props) => { + const { + name, + nameLexic, + originalObject, + pass, + } = selectedPackage const [src, setSrc] = useState('') + const { translate } = useLexicsStore() + const teams = isNumber(nameLexic) ? translate(String(nameLexic)) : name + const pack = translate(String(pass)) useEffect(() => { if (open) { (async () => { - const json: any = await getBrazilPaymentUrl({ item, product_name }) - setSrc(json[0]?.url) + const json: ResponsePaymentArray = await getBrazilPaymentUrl({ item: originalObject, product_name: `${pack} ${teams}` }) + setSrc(json[0]?.url || '') })() } - }, [item, open, product_name]) + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [selectedPackage, open]) return ( diff --git a/src/features/BuyMatchPopup/components/PackageSelectionStep/index.tsx b/src/features/BuyMatchPopup/components/PackageSelectionStep/index.tsx index c89fb6d0..b328ffb7 100644 --- a/src/features/BuyMatchPopup/components/PackageSelectionStep/index.tsx +++ b/src/features/BuyMatchPopup/components/PackageSelectionStep/index.tsx @@ -17,6 +17,7 @@ import { Name } from 'features/Name' import { useCardsStore } from 'features/CardsStore' import { ArrowLoader } from 'features/ArrowLoader' import { Arrow } from 'features/HeaderFilters/components/DateFilter/styled' + import { BrazilPayment } from '../BrazilPayment' import { useBuyMatchPopupStore } from '../../store' @@ -55,7 +56,7 @@ export const PackageSelectionStep = () => { if (!match) return null - const isBrasil = clientCountry() === 'TH' + const isBrasil = clientCountry() === 'BR' const onHandleClick = (e?: MouseEvent) => { if (isBrasil) { @@ -107,11 +108,7 @@ export const PackageSelectionStep = () => { )} {selectedPackage && isOpenBrasilian && ( - + )} )