-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: auction detail #627
feat: auction detail #627
Changes from 8 commits
3001c41
521f874
1dfe9df
fd74bf5
6479f68
3b5df8c
c069055
ba4b6c2
5c48830
7cc184a
3c4d290
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,6 +104,7 @@ | |
"your_parcel": "Tu parcela" | ||
}, | ||
"auction_page": { | ||
"bid": "Oferta", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe |
||
"description": "Seleccione LAND para comprar", | ||
"maximum_parcels_message": | ||
"Si intenta comprar más de {max} parcelas en una sola transacción, fallará. ", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { Message, Header, Grid, Container } from 'semantic-ui-react' | ||
import { Message, Header, Grid, Container, Button } from 'semantic-ui-react' | ||
import { utils } from 'decentraland-commons' | ||
|
||
import { parcelType } from 'components/types' | ||
import ParcelPreview from 'components/ParcelPreview' | ||
import ParcelAttributes from 'components/ParcelAttributes' | ||
import { t } from '@dapps/modules/translation/utils' | ||
import { getParcelSorter } from 'shared/parcel' | ||
|
||
import './AuctionPage.css' | ||
|
||
// TODO: Real number here | ||
const MAX_PARCELS_PER_TX = Infinity | ||
const MAX_PARCELS_PER_TX = 20 | ||
|
||
export default class AuctionPage extends React.PureComponent { | ||
static propTypes = { | ||
|
@@ -20,6 +21,8 @@ export default class AuctionPage extends React.PureComponent { | |
|
||
constructor(props) { | ||
super(props) | ||
|
||
this.parcelPrice = 3000 // TODO: use the contract to get this value | ||
this.state = { | ||
selectedCoordsById: {} | ||
} | ||
|
@@ -29,7 +32,7 @@ export default class AuctionPage extends React.PureComponent { | |
const { selectedCoordsById } = this.state | ||
|
||
// TODO: Check ownership with contract | ||
if (asset.owner != null) return | ||
if (asset.owner != null || asset.district_id != null) return | ||
|
||
let newSelectedCoordsById = {} | ||
|
||
|
@@ -54,11 +57,28 @@ export default class AuctionPage extends React.PureComponent { | |
|
||
handleSubmit = () => {} | ||
|
||
render() { | ||
getParcels() { | ||
const { allParcels } = this.props | ||
const { selectedCoordsById } = this.state | ||
|
||
if (!allParcels) return [] | ||
|
||
const parcelIds = Object.keys(selectedCoordsById) | ||
const parcels = [] | ||
|
||
for (const parcelId of parcelIds) { | ||
const parcel = allParcels[parcelId] | ||
if (parcel) { | ||
parcels.push(parcel) | ||
} | ||
} | ||
|
||
return parcels.sort(getParcelSorter()) | ||
} | ||
|
||
render() { | ||
const { selectedCoordsById } = this.state | ||
|
||
const selected = Object.values(selectedCoordsById) | ||
|
||
return ( | ||
|
@@ -95,24 +115,57 @@ export default class AuctionPage extends React.PureComponent { | |
) : null} | ||
|
||
<Grid.Row> | ||
<Grid.Column width={16}> | ||
<Grid.Column mobile={16} computer={6}> | ||
<Header size="large">{t('auction_page.title')}</Header> | ||
</Grid.Column> | ||
<Grid.Column width={16} className="selected-parcels"> | ||
<p className="parcels-included-description"> | ||
<p className="subtitle parcels-included-description"> | ||
{t('auction_page.description')} | ||
</p> | ||
{allParcels && | ||
parcelIds.map(parcelId => { | ||
const parcel = allParcels[parcelId] | ||
return parcel ? ( | ||
<ParcelAttributes | ||
key={parcel.id} | ||
parcel={parcel} | ||
withLink={false} | ||
/> | ||
) : null | ||
})} | ||
</Grid.Column> | ||
<Grid.Column mobile={16} computer={10}> | ||
<div className="information-blocks"> | ||
<div className="information-block"> | ||
<p className="subtitle">GAS PRICE</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it worth to have this on |
||
<Header size="large">300wei</Header> | ||
</div> | ||
<div className="information-block"> | ||
<p className="subtitle">PARCEL PRICE</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe |
||
<Header size="large">{this.parcelPrice}</Header> | ||
</div> | ||
<div className="information-block"> | ||
<p className="subtitle">PARCELS</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same about translations |
||
<Header size="large"> | ||
{selected.length}/{MAX_PARCELS_PER_TX} | ||
</Header> | ||
</div> | ||
<div className="information-block"> | ||
<p className="subtitle">TOTAL PRICE</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same about translations |
||
<Header size="large"> | ||
{this.parcelPrice * selected.length} | ||
</Header> | ||
</div> | ||
<div className="information-block"> | ||
<Button | ||
type="submit" | ||
primary={true} | ||
disabled={selected.length === 0} | ||
> | ||
{t('auction_page.bid')} | ||
</Button> | ||
</div> | ||
</div> | ||
</Grid.Column> | ||
|
||
<Grid.Column width={16} className="selected-parcels"> | ||
<div className="parcels-included"> | ||
{this.getParcels().map(parcel => ( | ||
<ParcelAttributes | ||
key={parcel.id} | ||
parcel={parcel} | ||
withLink={false} | ||
withTags={false} | ||
/> | ||
))} | ||
</div> | ||
</Grid.Column> | ||
</Grid.Row> | ||
</Grid> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a thought: we could name it as
parcelSortAlgorithm
or justsortParcel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"sortParcel" would be the return value of this function, since that's the actual function that does the sorting. I think it's fine returning it as a lambda tho, as it is doing now.