diff --git a/.gitignore b/.gitignore index ca5881be..43724026 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,8 @@ yarn-error.log* yarn.lock package-lock.json + +/.vscode # IntelliJ IDEA products .idea .eslintcache diff --git a/src/features/BuyMatchPopup/store/hooks/useSubscriptions.tsx b/src/features/BuyMatchPopup/store/hooks/useSubscriptions.tsx index 438de230..4a8d2080 100644 --- a/src/features/BuyMatchPopup/store/hooks/useSubscriptions.tsx +++ b/src/features/BuyMatchPopup/store/hooks/useSubscriptions.tsx @@ -1,6 +1,7 @@ import { useState, useCallback, + useEffect, } from 'react' import find from 'lodash/find' @@ -52,6 +53,15 @@ export const useSubscriptions = () => { setSelectedSubscription(subscription === selectedSubscription ? null : subscription) } + useEffect(() => { + const isOnlySubscriptionVariant = matchSubscriptions[selectedPeriod].length === 1 + if (isOnlySubscriptionVariant) { + setSelectedSubscription(matchSubscriptions[selectedPeriod][0]) + } else { + setSelectedSubscription(null) + } + }, [matchSubscriptions, selectedPeriod]) + return { fetchSubscriptions, matchSubscriptions,