You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
spa_instat_tv/src/features/PaymentPeriodTabs/helpers.tsx

31 lines
803 B

import omitBy from 'lodash/omitBy'
import isEmpty from 'lodash/isEmpty'
import map from 'lodash/map'
import type { MatchSubscription, SubscriptionType } from 'features/BuyMatchPopup/types'
type PaymentTab = {
tabLexic: string,
type: SubscriptionType,
}
const getTabLexic = (type: string) => {
switch (type) {
case 'month':
return 'for_month'
case 'year':
return 'for_year'
case 'pay_per_view':
return 'for_view'
default:
return ''
}
}
export const getCorrectPaymentTabs = (matchSubscriptions: MatchSubscription) => {
const matchSubscriptionsWithValues = omitBy(matchSubscriptions.packages, isEmpty)
return map(matchSubscriptionsWithValues, (matchSubscription, key) => ({
tabLexic: getTabLexic(key),
type: key,
})) as Array<PaymentTab>
}