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

View File

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

View File

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

View File

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

View File

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