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

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

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

Loading…
Cancel
Save