refactor(ott-960): added correct currencies (#346)

keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
Andrey Razdorskiy 5 years ago committed by GitHub
parent d626f6b678
commit 28554674eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      src/config/currencies.tsx
  2. 55
      src/features/BuyMatchPopup/components/SubscriptionsList/index.tsx
  3. 3
      src/features/BuyMatchPopup/store/helpers.tsx
  4. 1
      src/features/BuyMatchPopup/types.tsx
  5. 4
      src/features/Price/index.tsx
  6. 3
      src/requests/getSubscriptions.tsx

@ -1,4 +1,16 @@
export const currencySymbols = {
dollar: '$',
ruble: '₽',
}
AUD: '$',
BRL: 'R$',
BYN: 'Br',
CAD: '$',
CHF: 'CHF',
CNY: '¥',
EUR: '€',
GBP: '£',
HUF: 'ft',
INR: '₹',
KZT: '₸',
MDL: 'L',
RUB: '₽',
USD: '$',
} as const

@ -1,13 +1,16 @@
import map from 'lodash/map'
import type { MatchSubscriptions, MatchSubscription } from 'features/BuyMatchPopup/types'
import { T9n } from 'features/T9n'
import type {
MatchSubscriptions,
MatchSubscription,
} from 'features/BuyMatchPopup/types'
import {
List,
Item,
InfoWrapper,
Header,
InfoWrapper,
Item,
List,
Price,
} from './styled'
@ -24,21 +27,37 @@ export const SubscriptionsList = ({
}: Props) => (
<List>
{
map(subscriptions, (subscription) => (
<Item
key={subscription.id}
onClick={() => onSelect?.(subscription)}
active={subscription === selectedSubscription}
>
<InfoWrapper>
<Header>
<T9n t={subscription.lexic} />
</Header>
</InfoWrapper>
map(
subscriptions,
(subscription) => {
const {
currency,
id,
lexic,
price,
type,
} = subscription
<Price amount={subscription.price} perPeriod={`per_${subscription.type}`} />
</Item>
))
return (
<Item
key={id}
onClick={() => onSelect?.(subscription)}
active={subscription === selectedSubscription}
>
<InfoWrapper>
<Header>
<T9n t={lexic} />
</Header>
</InfoWrapper>
<Price
amount={price}
currency={currency}
perPeriod={`per_${type}`}
/>
</Item>
)
},
)
}
</List>
)

@ -1,12 +1,15 @@
import map from 'lodash/map'
import isNumber from 'lodash/isNumber'
import { currencySymbols } from 'config'
import type { MatchSubscriptionsResponse } from 'requests'
import { SubscriptionType } from '../types'
export const transformSubsciptions = (subscriptions: MatchSubscriptionsResponse) => (
map(subscriptions, (subscription) => ({
currency: currencySymbols[subscription.currency_iso || 'RUB'],
id: subscription.id,
lexic: subscription.lexic,
price: subscription.price_month || subscription.price_year || 0,

@ -11,6 +11,7 @@ export enum SubscriptionType {
}
export type MatchSubscription = {
currency: string,
id: number,
lexic: number,
price: number,

@ -3,9 +3,9 @@ import { currencySymbols } from 'config'
import { T9n } from 'features/T9n'
import {
PriceWrapper,
PriceAmount,
PriceDetails,
PriceWrapper,
} from './styled'
type Props = {
@ -18,7 +18,7 @@ type Props = {
export const Price = ({
amount,
className,
currency = currencySymbols.ruble,
currency = currencySymbols.RUB,
perPeriod = 'month',
}: Props) => (
<PriceWrapper className={className}>

@ -1,4 +1,5 @@
import {
currencySymbols,
DATA_URL,
PROCEDURES,
SportTypes,
@ -8,6 +9,8 @@ import { callApi } from 'helpers'
const proc = PROCEDURES.get_match_subscriptions
type Subscription = {
currency_id: number,
currency_iso: keyof typeof currencySymbols,
id: number,
lexic: number,
price_month: number | null,

Loading…
Cancel
Save