Show correct price on Show page

This commit is contained in:
Alex Liebowitz 2016-08-23 01:22:29 -04:00
parent f80b057a6b
commit d16c4aa181

View file

@ -12,6 +12,7 @@ var FormatItem = React.createClass({
claimInfo: React.PropTypes.object, claimInfo: React.PropTypes.object,
amount: React.PropTypes.number, amount: React.PropTypes.number,
name: React.PropTypes.string, name: React.PropTypes.string,
available: React.PropTypes.string,
}, },
render: function() { render: function() {
@ -24,6 +25,7 @@ var FormatItem = React.createClass({
var license = claimInfo.license; var license = claimInfo.license;
var fileContentType = claimInfo['content-type']; var fileContentType = claimInfo['content-type'];
var available = this.props.available;
var amount = this.props.amount || 0.0; var amount = this.props.amount || 0.0;
return ( return (
@ -39,7 +41,7 @@ var FormatItem = React.createClass({
<td>Content-Type</td><td>{fileContentType}</td> <td>Content-Type</td><td>{fileContentType}</td>
</tr> </tr>
<tr> <tr>
<td>Cost</td><td><CreditAmount amount={amount} isEstimate={true}/></td> <td>Cost</td><td><CreditAmount amount={amount} isEstimate={!available}/></td>
</tr> </tr>
<tr> <tr>
<td>Author</td><td>{author}</td> <td>Author</td><td>{author}</td>
@ -65,6 +67,7 @@ var FormatsSection = React.createClass({
claimInfo: React.PropTypes.object, claimInfo: React.PropTypes.object,
amount: React.PropTypes.number, amount: React.PropTypes.number,
name: React.PropTypes.string, name: React.PropTypes.string,
available: React.PropTypes.string,
}, },
render: function() { render: function() {
var name = this.props.name; var name = this.props.name;
@ -86,7 +89,7 @@ var FormatsSection = React.createClass({
{/* In future, anticipate multiple formats, just a guess at what it could look like {/* In future, anticipate multiple formats, just a guess at what it could look like
// var formats = this.props.claimInfo.formats // var formats = this.props.claimInfo.formats
// return (<tbody>{formats.map(function(format,i){ */} // return (<tbody>{formats.map(function(format,i){ */}
<FormatItem claimInfo={format} amount={this.props.amount} name={this.props.name} /> <FormatItem claimInfo={format} amount={this.props.amount} name={this.props.name} available={this.props.available} />
{/* })}</tbody>); */} {/* })}</tbody>); */}
</div>); </div>);
} }
@ -109,7 +112,8 @@ var DetailPage = React.createClass({
lbry.search(this.props.name, (results) => { lbry.search(this.props.name, (results) => {
var result = results[0]; var result = results[0];
this.setState({ this.setState({
amount: result.amount, amount: result.cost,
available: result.available,
claimInfo: result.value, claimInfo: result.value,
searching: false, searching: false,
}); });
@ -122,13 +126,14 @@ var DetailPage = React.createClass({
} }
var name = this.props.name; var name = this.props.name;
var available = this.state.available;
var claimInfo = this.state.claimInfo; var claimInfo = this.state.claimInfo;
var amount = this.state.amount; var amount = this.state.amount;
return ( return (
<main> <main>
<section className="card"> <section className="card">
<FormatsSection name={name} claimInfo={claimInfo} amount={amount} /> <FormatsSection name={name} claimInfo={claimInfo} amount={amount} available={available} />
</section> </section>
</main>); </main>);
} }