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

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

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

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

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

Loading…
Cancel
Save