fix(ott-1457): add default subscription setter (#441)

keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
Aleksey Miroshnichenko 4 years ago committed by GitHub
parent 1f21b70ab7
commit ee4ea069a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .gitignore
  2. 10
      src/features/BuyMatchPopup/store/hooks/useSubscriptions.tsx

2
.gitignore vendored

@ -24,6 +24,8 @@ yarn-error.log*
yarn.lock yarn.lock
package-lock.json package-lock.json
/.vscode
# IntelliJ IDEA products # IntelliJ IDEA products
.idea .idea
.eslintcache .eslintcache

@ -1,6 +1,7 @@
import { import {
useState, useState,
useCallback, useCallback,
useEffect,
} from 'react' } from 'react'
import find from 'lodash/find' import find from 'lodash/find'
@ -52,6 +53,15 @@ export const useSubscriptions = () => {
setSelectedSubscription(subscription === selectedSubscription ? null : subscription) setSelectedSubscription(subscription === selectedSubscription ? null : subscription)
} }
useEffect(() => {
const isOnlySubscriptionVariant = matchSubscriptions[selectedPeriod].length === 1
if (isOnlySubscriptionVariant) {
setSelectedSubscription(matchSubscriptions[selectedPeriod][0])
} else {
setSelectedSubscription(null)
}
}, [matchSubscriptions, selectedPeriod])
return { return {
fetchSubscriptions, fetchSubscriptions,
matchSubscriptions, matchSubscriptions,

Loading…
Cancel
Save