2017-04-29 19:02:25 +02:00
|
|
|
import React from 'react'
|
|
|
|
import {
|
|
|
|
CreditAmount,
|
|
|
|
} from 'component/common'
|
|
|
|
|
2017-05-12 19:14:06 +02:00
|
|
|
class FilePrice extends React.Component{
|
2017-05-18 19:58:28 +02:00
|
|
|
componentWillMount() {
|
2017-05-12 19:14:06 +02:00
|
|
|
this.fetchCost(this.props)
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
|
this.fetchCost(nextProps)
|
|
|
|
}
|
2017-04-29 19:02:25 +02:00
|
|
|
|
2017-05-12 19:14:06 +02:00
|
|
|
fetchCost(props) {
|
|
|
|
const {
|
|
|
|
costInfo,
|
|
|
|
fetchCostInfo,
|
|
|
|
uri
|
|
|
|
} = props
|
2017-04-29 19:02:25 +02:00
|
|
|
|
2017-05-12 19:14:06 +02:00
|
|
|
if (costInfo === undefined) {
|
|
|
|
fetchCostInfo(uri)
|
|
|
|
}
|
2017-04-29 19:02:25 +02:00
|
|
|
}
|
|
|
|
|
2017-05-12 19:14:06 +02:00
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
costInfo,
|
|
|
|
look = 'indicator',
|
|
|
|
} = this.props
|
|
|
|
|
|
|
|
const isEstimate = costInfo ? !costInfo.includesData : null
|
|
|
|
|
|
|
|
if (!costInfo) {
|
|
|
|
return <span className={`credit-amount credit-amount--${look}`}>???</span>;
|
|
|
|
}
|
|
|
|
|
|
|
|
return <CreditAmount label={false} amount={costInfo.cost} isEstimate={isEstimate} showFree={true} />
|
|
|
|
}
|
2017-04-29 19:02:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export default FilePrice
|