Skip to content

Commit

Permalink
All NFT page
Browse files Browse the repository at this point in the history
  • Loading branch information
1aerostorm committed Nov 10, 2023
1 parent 110d60b commit 68051f2
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/ResolveRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,8 @@ export default function resolveRoute(path)
if (match) {
return {page: 'NFTMarketPage', params: match.slice(1)}
}
if (path === '/all-nft') {
return {page: 'AllNFTPage'}
}
return {page: 'NotFound'};
}
2 changes: 2 additions & 0 deletions app/RootRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export default {
cb(null, [require('@pages/nft/NFTTokenPage')]);
} else if (route.page === 'NFTMarketPage') {
cb(null, [require('@pages/nft/NFTMarketPage')]);
} else if (route.page === 'AllNFTPage') {
cb(null, [require('@pages/nft/AllNFTPage')])
} else if (route.page === 'Market') {
cb(null, [require('@pages/MarketLoader')]);
} else if (route.page === 'Rating') {
Expand Down
1 change: 1 addition & 0 deletions app/components/all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
@import "./pages/Rating";
@import "./pages/UserProfile";
@import "./pages/Witnesses";
@import "./pages/nft/AllNFTPage";
@import "./pages/nft/NFTCollectionPage";
@import "./pages/nft/NFTMarketPage";
@import "./pages/nft/NFTTokenPage";
2 changes: 2 additions & 0 deletions app/components/modules/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ class Header extends React.Component {
page_title = tt('header_jsx.nft_token')
} else if (route.page === `NFTMarketPage`){
page_title = tt('header_jsx.nft_market')
} else if (route.page === `AllNFTPage`){
page_title = tt('all_nft_page_jsx.title')
} else {
page_name = ''; //page_title = route.page.replace( /([a-z])([A-Z])/g, '$1 $2' ).toLowerCase();
}
Expand Down
177 changes: 177 additions & 0 deletions app/components/pages/nft/AllNFTPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
import React from 'react'
import { connect, } from 'react-redux'
import tt from 'counterpart'
import Reveal from 'react-foundation-components/lib/global/reveal'

import DropdownMenu from 'app/components/elements/DropdownMenu'
import Icon from 'app/components/elements/Icon'
import LoadingIndicator from 'app/components/elements/LoadingIndicator'
import NFTTokenItem from 'app/components/elements/nft/NFTTokenItem'
import NFTTokenTransfer from 'app/components/modules/nft/NFTTokenTransfer'
import NFTTokenSell from 'app/components/modules/nft/NFTTokenSell'
import g from 'app/redux/GlobalReducer'

class AllNFTPage extends React.Component {
state = {}

componentDidMount() {
this.refetch()
}

refetch = () => {
this.props.fetchNFTTokens(0, this.sort, this.sortReversed)
}

showTransfer = (e, tokenIdx) => {
e.preventDefault()
this.setState({
showTransfer: true,
tokenIdx,
})
}

hideTransfer = () => {
this.setState({
showTransfer: false,
})
}

showSell = (e, tokenIdx) => {
e.preventDefault()
this.setState({
showSell: true,
tokenIdx,
})
}

hideSell = () => {
this.setState({
showSell: false,
})
}

sortOrder = (e, sort, sortReversed) => {
e.preventDefault()
this.sort = sort
this.sortReversed = sortReversed
this.refetch()
}

render() {
const { currentUser, nft_tokens, nft_assets, } = this.props

const tokens = nft_tokens ? nft_tokens.toJS().data : null
const assets = nft_assets ? nft_assets.toJS() : {}

const next_from = nft_tokens && nft_tokens.get('next_from')

let items = []
if (!tokens) {
items = <LoadingIndicator type='circle' />
} else if (!tokens.length) {
items = <span>{tt('nft_tokens_jsx.not_yet')}</span>
} else {
for (let i = 0; i < tokens.length; ++i) {
const token = tokens[i]
items.push(<NFTTokenItem key={i} token={token} tokenIdx={i}
assets={assets}
showTransfer={this.showTransfer}
showSell={this.showSell}
refetch={this.refetch} />)
}
}

const { showTransfer, showSell, tokenIdx } = this.state

const sortItems = [
{ link: '#', onClick: e => {
this.sortOrder(e, 'by_last_update', false)
}, value: tt('nft_tokens_jsx.sort_new') },
{ link: '#', onClick: e => {
this.sortOrder(e, 'by_last_update', true)
}, value: tt('nft_tokens_jsx.sort_old') },
{ link: '#', onClick: e => {
this.sortOrder(e, 'by_last_price', false)
}, value: tt('nft_tokens_jsx.sort_price') },
{ link: '#', onClick: e => {
this.sortOrder(e, 'by_name', false)
}, value: tt('nft_tokens_jsx.sort_name') },
]

let currentSort
if (this.sort === 'by_last_price') {
currentSort = tt('nft_tokens_jsx.sort_price')
} else if (this.sort === 'by_name') {
currentSort = tt('nft_tokens_jsx.sort_name')
} else {
if (this.sortReversed) {
currentSort = tt('nft_tokens_jsx.sort_old')
} else {
currentSort = tt('nft_tokens_jsx.sort_new')
}
}

return (<div className='AllNFTPage'>
<div className="row">
<div className="column small-12">
<h4 className="Assets__header">{tt('all_nft_page_jsx.title')}</h4>
<span className='float-right'>&nbsp;&nbsp;</span>
<DropdownMenu className='float-right' el='div' items={sortItems} selected={currentSort}>
<span title={tt('nft_tokens_jsx.sort')} style={{ display: 'block', marginTop: '5px' }}>
{currentSort}
<Icon name='dropdown-arrow' size='0_95x' />
</span>
</DropdownMenu>
</div>
</div>
<div className="row">
<div className="column small-12">
{items}
{next_from ? <div className='load-more' key='load_more'>
<center><button className='button hollow small' onClick={
e => this.props.fetchNFTTokens(next_from, this.sort, this.sortReversed)
}>{tt('g.load_more')}</button></center>
</div> : null}
</div>
</div>

<Reveal show={showTransfer} onHide={this.hideTransfer} revealStyle={{ width: '450px' }}>
<NFTTokenTransfer
currentUser={currentUser}
onClose={this.hideTransfer}
tokenIdx={tokenIdx}
refetch={this.refetch}
/>
</Reveal>

<Reveal show={showSell} onHide={this.hideSell} revealStyle={{ width: '450px' }}>
<NFTTokenSell
currentUser={currentUser}
onClose={this.hideSell}
tokenIdx={tokenIdx}
refetch={this.refetch}
/>
</Reveal>
</div>)
}
}

module.exports = {
path: '/all-nft',
component: connect(
(state, ownProps) => {
const currentUser = state.user.getIn(['current'])

return {
currentUser,
nft_tokens: state.global.get('nft_tokens'),
nft_assets: state.global.get('nft_assets')
}
},
dispatch => ({
fetchNFTTokens: (start_token_id, sort, sortReversed) => {
dispatch(g.actions.fetchNftTokens({ account: '', start_token_id, sort, reverse_sort: sortReversed }))
},
})
)(AllNFTPage),
}
7 changes: 7 additions & 0 deletions app/components/pages/nft/AllNFTPage.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.AllNFTPage {
padding-top: 1rem;
padding-bottom: 1rem;
padding-left: 0.2rem;
padding-right: 0.2rem;
flex: 1;
}
8 changes: 7 additions & 1 deletion app/components/pages/nft/NFTMarketPage.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import { connect, } from 'react-redux'
import { Link } from 'react-router'
import tt from 'counterpart'

import LoadingIndicator from 'app/components/elements/LoadingIndicator'
Expand Down Expand Up @@ -74,7 +75,12 @@ class NFTMarketPage extends React.Component {

return <div className='row'>
<div className='NFTMarketPage'>
<h4>{tt('header_jsx.nft_market')}</h4>
<div style={{ marginTop: '0.25rem' }}>
<h4 style={{ display: 'inline-block' }}>{tt('header_jsx.nft_market')}</h4>
<Link to={`/all-nft`} className="button hollow float-right">
{tt('all_nft_page_jsx.title')}
</Link>
</div>
{content}
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions app/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,11 @@
"your_token": "Your token",
"owner": "Owner"
},
"all_nft_page_jsx": {
"title": "All NFT on the Golos",
"no_at_all": "No NFT-tokens on Golos. You can ",
"no_at_all2": "issue your own!"
},
"nft_collection_page_jsx": {
"owner_is": "Owner of collection is ",
"not_yet": "No tokens yet in this collection."
Expand Down
5 changes: 5 additions & 0 deletions app/locales/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,11 @@
"your_token": "Ваш токен",
"owner": "Владелец"
},
"all_nft_page_jsx": {
"title": "Все NFT на Golos",
"no_at_all": "На Golos нет ни одного NFT-токена. Вы можете ",
"no_at_all2": "выпустить первый токен!"
},
"nft_collection_page_jsx": {
"owner_is": "Владелец коллекции - ",
"not_yet": "В этой коллекции еще нет токенов."
Expand Down

0 comments on commit 68051f2

Please sign in to comment.