fix(#2592): fix logic for disable button in popup payment

keep-around/32d01affbea7fe6359a08e9406ef2656eec49f08
Andrei Dekterev 3 years ago
parent 1e28a34fbd
commit 32d01affbe
  1. 12
      src/features/BuyMatchPopup/components/PackageSelectionStep/index.tsx
  2. 3
      src/features/BuyMatchPopup/store/hooks/index.tsx

@ -33,7 +33,10 @@ import {
} from '../../styled'
export const PackageSelectionStep = () => {
const { cards, fetchCards } = useCardsStore()
const {
cards,
fetchCards,
} = useCardsStore()
const [isOpenBrasilian, setIsOpenBrasilian] = useState(false)
const { user } = useAuthStore()
@ -42,12 +45,14 @@ export const PackageSelectionStep = () => {
disabledBuyBtn,
goBack,
hasPreviousStep,
lastSelectedPackage,
loader,
match,
onBuyClick,
selectedPackage,
selectedSubscription,
setDisabledBuyBtn,
setLastSelectedPackage,
} = useBuyMatchPopupStore()
useEffect(() => {
@ -61,12 +66,15 @@ export const PackageSelectionStep = () => {
const isBrasil = user?.profile.country_code === 'BR'
const onHandleClick = (e?: MouseEvent<HTMLButtonElement>) => {
setDisabledBuyBtn(true)
cards?.length
&& lastSelectedPackage === selectedPackage?.id
&& setDisabledBuyBtn(true)
if (isBrasil) {
setIsOpenBrasilian(true)
} else {
onBuyClick(e)
}
setLastSelectedPackage(selectedPackage?.id || '')
}
return (

@ -53,6 +53,7 @@ export const useBuyMatchPopup = () => {
const [error, setError] = useState('')
const [loader, setLoader] = useState(false)
const [disabledBuyBtn, setDisabledBuyBtn] = useState(false)
const [lastSelectedPackage, setLastSelectedPackage] = useState('')
const setDataHighlights = useSetRecoilState(dataForPayHighlights)
const goTo = useCallback(
@ -205,6 +206,7 @@ export const useBuyMatchPopup = () => {
goBack,
goTo,
hasPreviousStep: size(steps) > 1,
lastSelectedPackage,
loader,
match,
matchSubscriptions,
@ -223,6 +225,7 @@ export const useBuyMatchPopup = () => {
selectedPeriod,
selectedSubscription,
setDisabledBuyBtn,
setLastSelectedPackage,
subscriptions,
}
}

Loading…
Cancel
Save