fix(#ott): fix send request in landing page and catch error in pagbrasil

keep-around/60fc538b5ed00f569ce567b4e7667489412012bb
Andrei Dekterev 4 years ago
parent 596ac9c7ac
commit 60fc538b5e
  1. 7
      src/features/BuyMatchPopup/components/BrazilPayment/hooks.tsx
  2. 7
      src/features/BuyMatchPopup/components/BrazilPayment/index.tsx
  3. 2
      src/features/JoinMatchPage/hooks.tsx

@ -35,6 +35,7 @@ export const useBrazilPayment = ({
const { close } = useBuyMatchPopupStore()
const [src, setSrc] = useState('')
const [error, setError] = useState('')
const { translate } = useLexicsStore()
const { id, sportType } = match
@ -58,6 +59,7 @@ export const useBrazilPayment = ({
const closePopup = async (e?: MouseEvent) => {
e?.stopPropagation()
setIsOpenBrasilian(false)
setError('')
const accessMatch = await getMatchInfo(sportType, id)
if (accessMatch?.access) {
@ -69,8 +71,12 @@ export const useBrazilPayment = ({
useEffect(() => {
if (open) {
(async () => {
try {
const json: ResponsePaymentArray = await getBrazilPaymentUrl({ item: originalObject, product_name: `${pack} ${teams}` })
setSrc(json?.url || '')
} catch (err) {
setError('error_payment_unsuccessful')
}
})()
}
// eslint-disable-next-line react-hooks/exhaustive-deps
@ -78,6 +84,7 @@ export const useBrazilPayment = ({
return {
closePopup,
error,
matchLink,
src,
}

@ -27,6 +27,7 @@ export const BrazilPayment = ({
}: Props) => {
const {
closePopup,
error,
matchLink,
src,
} = useBrazilPayment({
@ -49,11 +50,17 @@ export const BrazilPayment = ({
</Button>
</ScButton>
</>
) : (
<>
{error ? (
<T9n t={error} />
) : (
<LoaderWrapper>
<Loader color='#515151' />
</LoaderWrapper>
)}
</>
)}
</ScModal>
)
}

@ -28,7 +28,7 @@ export const useUnauthenticatedMatch = () => {
: ''
useEffect(() => {
getUnauthenticatedMatch(sportType, matchId).then(setMatchInfo)
if (sportType && matchId) getUnauthenticatedMatch(sportType, matchId).then(setMatchInfo)
return () => setMatchInfo(null)
}, [sportType, matchId])

Loading…
Cancel
Save