market/src/components/@shared/Price/index.tsx

32 lines
766 B
TypeScript
Raw Normal View History

2020-09-02 11:43:15 +02:00
import React, { ReactElement } from 'react'
import PriceUnit from './PriceUnit'
2020-07-07 23:00:16 +02:00
2020-05-07 08:03:30 +02:00
export default function Price({
accessDetails,
orderPriceAndFees,
2020-05-25 14:53:38 +02:00
className,
size,
2020-08-20 14:22:32 +02:00
conversion
2020-05-07 08:03:30 +02:00
}: {
accessDetails: AccessDetails
orderPriceAndFees?: OrderPriceAndFees
2020-05-07 08:03:30 +02:00
className?: string
conversion?: boolean
size?: 'small' | 'mini' | 'large'
2020-07-07 23:00:16 +02:00
}): ReactElement {
2022-08-02 11:53:22 +02:00
const isSupported =
accessDetails?.type === 'fixed' || accessDetails?.type === 'free'
const price = `${orderPriceAndFees?.price || accessDetails?.price}`
2022-08-02 11:53:22 +02:00
return isSupported ? (
2020-10-30 14:10:21 +01:00
<PriceUnit
price={Number(price)}
symbol={accessDetails.baseToken?.symbol}
2020-10-30 14:10:21 +01:00
className={className}
size={size}
2020-10-30 14:10:21 +01:00
conversion={conversion}
type={accessDetails.type}
2020-10-30 14:10:21 +01:00
/>
2022-08-02 11:53:22 +02:00
) : null
2020-05-07 08:03:30 +02:00
}