From 1bc99252ac4f82b063d8d6138c4639b024cef656 Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Fri, 12 Aug 2022 16:13:29 +0400 Subject: [PATCH] fix(#2652): add check brasilian user from backend --- .../components/PackageSelectionStep/index.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/features/BuyMatchPopup/components/PackageSelectionStep/index.tsx b/src/features/BuyMatchPopup/components/PackageSelectionStep/index.tsx index 3664b63d..e1994140 100644 --- a/src/features/BuyMatchPopup/components/PackageSelectionStep/index.tsx +++ b/src/features/BuyMatchPopup/components/PackageSelectionStep/index.tsx @@ -9,7 +9,8 @@ import isNull from 'lodash/isNull' import { MDASH } from 'config' -import { useAuthStore } from 'features/AuthStore' +import { CountryCodeType, getCountryCode } from 'requests/getCountryCode' + import { CloseButton, HeaderActions } from 'features/PopupComponents' import { T9n } from 'features/T9n' import { Name } from 'features/Name' @@ -38,7 +39,7 @@ export const PackageSelectionStep = () => { fetchCards, } = useCardsStore() const [isOpenBrasilian, setIsOpenBrasilian] = useState(false) - const { user } = useAuthStore() + const [countryCode, setCountryCode] = useState(null) const { close, @@ -56,6 +57,7 @@ export const PackageSelectionStep = () => { } = useBuyMatchPopupStore() useEffect(() => { + getUserCountry() if (isNull(cards)) { fetchCards() } @@ -63,7 +65,11 @@ export const PackageSelectionStep = () => { if (!match) return null - const isBrasil = user?.profile.country_code === 'BR' + const isBrasil = countryCode?.country_code === 'BR' + + const getUserCountry = () => { + getCountryCode().then(setCountryCode) + } const onHandleClick = (e?: MouseEvent) => { cards?.length