|
|
|
|
@ -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, |
|
|
|
|
|