fix(#2524): wrong currency icon for the subscription price

keep-around/453f30f8d1d828f045db1c1ebcb54ea5b9c628d0
Rakov Roman 4 years ago
parent cc0b08ae4d
commit 453f30f8d1
  1. 16
      src/features/BuyMatchPopup/components/SelectSubscription/index.tsx

@ -1,4 +1,5 @@
import first from 'lodash/first'
import { useCallback } from 'react'
import map from 'lodash/map'
import { MDASH } from 'config'
@ -7,7 +8,6 @@ import { Name as Names } from 'features/Name'
import { T9n } from 'features/T9n'
import { useBuyMatchPopupStore } from 'features/BuyMatchPopup/store'
import { CloseButton, HeaderActions } from 'features/PopupComponents'
import {
Body,
Button,
@ -16,6 +16,9 @@ import {
HeaderTitle,
Wrapper,
} from 'features/BuyMatchPopup/styled'
import { MatchPackage, SubscriptionType } from '../../types'
import {
Description,
InfoWrapper,
@ -40,6 +43,13 @@ export const SelectSubscriptionStep = () => {
selectedSubscription,
} = useBuyMatchPopupStore()
const getPackagesCurrency = useCallback(
(packages: Record<SubscriptionType, Array<MatchPackage>>) => {
const packageWithValue = Object.entries(packages).find(([key, value]) => value.length)?.[1][0]
return packageWithValue ? packageWithValue.currency : 'RUB'
}, [],
)
if (!match || !matchSubscriptions) return null
return (
@ -79,7 +89,7 @@ export const SelectSubscriptionStep = () => {
<Price
amount={subscription.min_price || 0}
currency={first(subscription.packages.month)?.currency}
currency={getPackagesCurrency(subscription.packages)}
isFrom={Boolean(subscription.min_price)}
/>
</ChooseSubItem>

Loading…
Cancel
Save