Various fixes

This commit is contained in:
Richard Ramos 2018-07-01 22:48:50 -04:00
parent 10c0269a4d
commit 3adf8b9469
5 changed files with 29 additions and 11 deletions

View File

@ -72,10 +72,15 @@ h1.title {
visibility: hidden;
}
.ship:hover button {
.ship:hover button,
.ship:hover .input-group {
visibility: visible;
}
.ship .input-group {
visibility: hidden;
}
.ship span.price {
position: absolute;
background: rgb(38, 121, 21);
@ -129,6 +134,13 @@ h1.title {
clear: both;
}
#enableSales {
float: left;
clear: both;
display: block;
width: 100%;
}
#enableSales span {
position: relative;
top: -5px;

View File

@ -68,6 +68,8 @@ class AddToken extends Component {
this.props.loadShipsForSale();
// TODO: show success
return true;
})
.catch((err) => {
console.error(err);

View File

@ -63,7 +63,7 @@ class Ship extends Component {
})
.then(receipt => {
console.log(receipt);
this.props.onAction();
// TODO: show success
@ -79,7 +79,7 @@ class Ship extends Component {
}
render(){
const { energy, lasers, shield, price, wallet } = this.props;
const { energy, lasers, shield, price, wallet, salesEnabled } = this.props;
const { image, isSubmitting, showSellForm } = this.state;
const formattedPrice = !wallet ? web3.utils.fromWei(price, "ether") : '';
@ -95,7 +95,7 @@ class Ship extends Component {
</ul>
{ !wallet
? <Button disabled={isSubmitting} bsStyle="success" onClick={this.buyShip}>Comprar</Button>
: (!showSellForm
: (!showSellForm && salesEnabled
? <Button bsStyle="success" onClick={e => { this.showSellForm(true) }}>Vender</Button>
: '')
}

View File

@ -11,7 +11,8 @@ class ShipList extends Component {
constructor(props){
super(props);
this.state = {
isSubmitting: false
isSubmitting: false,
salesEnabled: false
}
}
@ -30,7 +31,7 @@ enableMarketplace = () => {
const { setApprovalForAll } = SpaceshipToken.methods;
this.setState({isSubmitting: true});
console.log(SpaceshipMarketplace);
const toSend = setApprovalForAll(SpaceshipMarketplace.options.address, !this.state.salesEnabled);
toSend.estimateGas()
@ -54,9 +55,12 @@ enableMarketplace = () => {
render = () => {
const { list, title, id, wallet, onAction } = this.props;
const { salesEnabled } = this.state;
return <div id={id}>
<h3>{title}</h3> { wallet ? <EnableSales isSubmitting={this.state.isSubmitting} handleChange={this.enableMarketplace} salesEnabled={this.state.salesEnabled} /> : ''}
{ list.map((ship, i) => <Ship onAction={onAction} wallet={wallet} key={i} {...ship} />) }
<h3>{title}</h3>
{ wallet ? <EnableSales isSubmitting={this.state.isSubmitting} handleChange={this.enableMarketplace} salesEnabled={this.state.salesEnabled} /> : ''}
{ list.map((ship, i) => <Ship onAction={onAction} wallet={wallet} salesEnabled={salesEnabled} key={i} {...ship} />) }
</div>;
}

View File

@ -1,10 +1,10 @@
pragma solidity 0.4.24;
import "./SpaceshipToken.sol";
import "zeppelin-solidity/contracts/token/ERC721/ERC721Receiver.sol";
import "zeppelin-solidity/contracts/token/ERC721/ERC721Holder.sol";
contract SpaceshipMarketplace is ERC721Receiver {
contract SpaceshipMarketplace is ERC721Holder {
// Esta estructura guarda informacion sobre las ventas
struct Sale {
@ -23,7 +23,7 @@ contract SpaceshipMarketplace is ERC721Receiver {
event ShipSold(uint indexed spaceshipId, uint price, address indexed oldOwner, address indexed newOwner);
constructor(SpaceshipToken _token) public{
constructor(SpaceshipToken _token) public {
token = _token;
}