From 923a6b62e5580f00aff7d3e24a3a69cd1155122c Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Fri, 22 Apr 2022 20:12:55 +0700 Subject: [PATCH] feat(#2386): add brazilian payment --- .../components/BrazilPayment/index.tsx | 43 ++++++++++ .../components/BrazilPayment/styled.tsx | 38 +++++++++ .../components/PackageSelectionStep/index.tsx | 78 ++++++++++++------- src/helpers/clientCountry/index.tsx | 6 ++ src/requests/getBrazilPaymentUrl.tsx | 21 +++++ 5 files changed, 157 insertions(+), 29 deletions(-) create mode 100644 src/features/BuyMatchPopup/components/BrazilPayment/index.tsx create mode 100644 src/features/BuyMatchPopup/components/BrazilPayment/styled.tsx create mode 100644 src/helpers/clientCountry/index.tsx create mode 100644 src/requests/getBrazilPaymentUrl.tsx diff --git a/src/features/BuyMatchPopup/components/BrazilPayment/index.tsx b/src/features/BuyMatchPopup/components/BrazilPayment/index.tsx new file mode 100644 index 00000000..fb4a509d --- /dev/null +++ b/src/features/BuyMatchPopup/components/BrazilPayment/index.tsx @@ -0,0 +1,43 @@ +import { useEffect, useState } from 'react' + +import { Loader } from 'features/Loader' + +import { getBrazilPaymentUrl } from 'requests/getBrazilPaymentUrl' +import type { SubscriptionResponse } from 'requests/getSubscriptions' + +import { ScModal, LoaderWrapper } from './styled' + +type Props = { + item: SubscriptionResponse, + open: boolean, + product_name: string, +} + +export const BrazilPayment = ({ + item, + open, + product_name, +}: Props) => { + const [src, setSrc] = useState('') + + useEffect(() => { + if (open) { + (async () => { + const json: any = await getBrazilPaymentUrl({ item, product_name }) + setSrc(json[0]?.url) + })() + } + }, [item, open, product_name]) + + return ( + + {src && open ? ( +