data model

This commit is contained in:
Kamen Stoykov 2019-05-02 18:30:50 +03:00
parent 0e4ff75d62
commit 3f7d45d309
12 changed files with 245 additions and 61 deletions

View File

@ -9,7 +9,7 @@ const DappList = props => {
dapps && dapps &&
dapps.map((dapp, i) => ( dapps.map((dapp, i) => (
<DappListItem <DappListItem
{...dapp} dapp={dapp}
key={dapp.name} key={dapp.name}
isRanked={isRanked} isRanked={isRanked}
position={i + 1} position={i + 1}

View File

@ -3,16 +3,20 @@ import DappListItem from './DappListItem'
import { import {
showDownVoteAction, showDownVoteAction,
showUpVoteAction, showUpVoteAction,
switchToUpvoteAction,
switchToUpDownvoteAction,
} from '../../../modules/Vote/Vote.reducer' } from '../../../modules/Vote/Vote.reducer'
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
onClickUpVote: () => { onClickUpVote: dapp => {
window.location.hash = 'vote' window.location.hash = 'vote'
dispatch(showUpVoteAction()) dispatch(switchToUpvoteAction())
dispatch(showUpVoteAction(dapp))
}, },
onClickDownVote: () => { onClickDownVote: dapp => {
window.location.hash = 'vote' window.location.hash = 'vote'
dispatch(showDownVoteAction()) dispatch(switchToUpDownvoteAction())
dispatch(showDownVoteAction(dapp))
}, },
}) })

View File

@ -10,17 +10,24 @@ import downvoteArrowIcon from '../../assets/images/downvote-arrow.svg'
const DappListItem = props => { const DappListItem = props => {
const { const {
name, dapp,
description, onClickUpVote,
url, onClickDownVote,
image,
isRanked, isRanked,
position, position,
showActionButtons, showActionButtons,
onClickUpVote,
onClickDownVote,
} = props } = props
const { name, description, url, image } = dapp
const handleUpVote = () => {
onClickUpVote(dapp)
}
const handleDownVote = () => {
onClickDownVote(dapp)
}
return ( return (
<div className={isRanked ? styles.rankedListItem : styles.listItem}> <div className={isRanked ? styles.rankedListItem : styles.listItem}>
{isRanked && <div className={styles.position}>{position}</div>} {isRanked && <div className={styles.position}>{position}</div>}
@ -43,13 +50,13 @@ const DappListItem = props => {
<p className={styles.actionArea}> <p className={styles.actionArea}>
<span className={styles.sntAmount}> <span className={styles.sntAmount}>
<img src={sntIcon} alt="SNT" width="16" height="16" /> <img src={sntIcon} alt="SNT" width="16" height="16" />
12,345 {dapp.sntValue}
</span> </span>
<span className={styles.vote} onClick={onClickUpVote}> <span className={styles.vote} onClick={handleUpVote}>
<img src={upvoteArrowIcon} alt="" /> <img src={upvoteArrowIcon} alt="" />
Upvote Upvote
</span> </span>
<span className={styles.vote} onClick={onClickDownVote}> <span className={styles.vote} onClick={handleDownVote}>
<img src={downvoteArrowIcon} alt="" /> <img src={downvoteArrowIcon} alt="" />
Downvote Downvote
</span> </span>
@ -65,9 +72,13 @@ DappListItem.defaultProps = {
showActionButtons: false, showActionButtons: false,
} }
DappListItem.propTypes = Object.assign({}, DappModel, { DappListItem.propTypes = {
dapp: PropTypes.shape(DappModel).isRequired,
isRanked: PropTypes.bool,
showActionButtons: PropTypes.bool,
position: PropTypes.number.isRequired,
onClickUpVote: PropTypes.func.isRequired, onClickUpVote: PropTypes.func.isRequired,
onClickDownVote: PropTypes.func.isRequired, onClickDownVote: PropTypes.func.isRequired,
}) }
export default DappListItem export default DappListItem

View File

@ -32,6 +32,7 @@ Modal.defaultProps = {
modalClassName: '', modalClassName: '',
windowClassName: '', windowClassName: '',
contentClassName: '', contentClassName: '',
children: null,
} }
Modal.propTypes = { Modal.propTypes = {
@ -42,7 +43,7 @@ Modal.propTypes = {
children: PropTypes.oneOfType([ children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node), PropTypes.arrayOf(PropTypes.node),
PropTypes.node, PropTypes.node,
]).isRequired, ]),
onClickClose: PropTypes.func.isRequired, onClickClose: PropTypes.func.isRequired,
} }

View File

@ -8,6 +8,8 @@ const Dapps = [
description: 'Meet the future of trading', description: 'Meet the future of trading',
category: Categories.EXCHANGES, category: Categories.EXCHANGES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Bancor', name: 'Bancor',
@ -16,6 +18,8 @@ const Dapps = [
description: 'Bancor is a decentralized liquidity network', description: 'Bancor is a decentralized liquidity network',
category: Categories.EXCHANGES, category: Categories.EXCHANGES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Kyber', name: 'Kyber',
@ -25,6 +29,8 @@ const Dapps = [
image: '/images/dapps/kyber.png', image: '/images/dapps/kyber.png',
category: Categories.EXCHANGES, category: Categories.EXCHANGES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Uniswap', name: 'Uniswap',
@ -34,6 +40,8 @@ const Dapps = [
image: '/images/dapps/uniswap.png', image: '/images/dapps/uniswap.png',
category: Categories.EXCHANGES, category: Categories.EXCHANGES,
dateAdded: '2019-04-23', dateAdded: '2019-04-23',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'DAI by MakerDao', name: 'DAI by MakerDao',
@ -42,6 +50,8 @@ const Dapps = [
image: '/images/dapps/dai.png', image: '/images/dapps/dai.png',
category: Categories.EXCHANGES, category: Categories.EXCHANGES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Augur', name: 'Augur',
@ -51,6 +61,8 @@ const Dapps = [
image: '/images/dapps/augur.svg', image: '/images/dapps/augur.svg',
category: Categories.EXCHANGES, category: Categories.EXCHANGES,
dateAdded: '2019-04-11', dateAdded: '2019-04-11',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'LocalEthereum', name: 'LocalEthereum',
@ -59,6 +71,8 @@ const Dapps = [
image: '/images/dapps/local-ethereum.png', image: '/images/dapps/local-ethereum.png',
category: Categories.EXCHANGES, category: Categories.EXCHANGES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Eth2phone', name: 'Eth2phone',
@ -67,6 +81,8 @@ const Dapps = [
image: '/images/dapps/eth2phone.png', image: '/images/dapps/eth2phone.png',
category: Categories.EXCHANGES, category: Categories.EXCHANGES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'DDEX', name: 'DDEX',
@ -76,6 +92,8 @@ const Dapps = [
image: '/images/dapps/ddex.png', image: '/images/dapps/ddex.png',
category: Categories.EXCHANGES, category: Categories.EXCHANGES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Nuo', name: 'Nuo',
@ -85,6 +103,8 @@ const Dapps = [
image: '/images/dapps/nuo.png', image: '/images/dapps/nuo.png',
category: Categories.EXCHANGES, category: Categories.EXCHANGES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'EasyTrade', name: 'EasyTrade',
@ -93,6 +113,8 @@ const Dapps = [
image: '/images/dapps/easytrade.png', image: '/images/dapps/easytrade.png',
category: Categories.EXCHANGES, category: Categories.EXCHANGES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'slow.trade', name: 'slow.trade',
@ -102,6 +124,8 @@ const Dapps = [
image: '/images/dapps/slowtrade.png', image: '/images/dapps/slowtrade.png',
category: Categories.EXCHANGES, category: Categories.EXCHANGES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Expo Trading', name: 'Expo Trading',
@ -110,6 +134,8 @@ const Dapps = [
image: '/images/dapps/expotrading.png', image: '/images/dapps/expotrading.png',
category: Categories.EXCHANGES, category: Categories.EXCHANGES,
dateAdded: '2019-04-11', dateAdded: '2019-04-11',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'blockimmo', name: 'blockimmo',
@ -119,6 +145,8 @@ const Dapps = [
image: '/images/dapps/blockimmo.png', image: '/images/dapps/blockimmo.png',
category: Categories.MARKETPLACES, category: Categories.MARKETPLACES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'CryptoCribs', name: 'CryptoCribs',
@ -127,6 +155,8 @@ const Dapps = [
image: '/images/dapps/cryptocribs.png', image: '/images/dapps/cryptocribs.png',
category: Categories.MARKETPLACES, category: Categories.MARKETPLACES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Ethlance', name: 'Ethlance',
@ -136,6 +166,8 @@ const Dapps = [
image: '/images/dapps/ethlance.png', image: '/images/dapps/ethlance.png',
category: Categories.MARKETPLACES, category: Categories.MARKETPLACES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'OpenSea', name: 'OpenSea',
@ -144,6 +176,8 @@ const Dapps = [
image: '/images/dapps/opensea.png', image: '/images/dapps/opensea.png',
category: Categories.MARKETPLACES, category: Categories.MARKETPLACES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'KnownOrigin', name: 'KnownOrigin',
@ -152,6 +186,8 @@ const Dapps = [
image: '/images/dapps/knownorigin.png', image: '/images/dapps/knownorigin.png',
category: Categories.MARKETPLACES, category: Categories.MARKETPLACES,
dateAdded: '2019-04-11', dateAdded: '2019-04-11',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'dBay', name: 'dBay',
@ -160,6 +196,8 @@ const Dapps = [
image: '/images/dapps/dBay.png', image: '/images/dapps/dBay.png',
category: Categories.MARKETPLACES, category: Categories.MARKETPLACES,
dateAdded: '2019-04-23', dateAdded: '2019-04-23',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Name Bazaar', name: 'Name Bazaar',
@ -168,6 +206,8 @@ const Dapps = [
image: '/images/dapps/name-bazaar.png', image: '/images/dapps/name-bazaar.png',
category: Categories.MARKETPLACES, category: Categories.MARKETPLACES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'The Bounties Network', name: 'The Bounties Network',
@ -176,6 +216,8 @@ const Dapps = [
image: '/images/dapps/bounties-network.png', image: '/images/dapps/bounties-network.png',
category: Categories.MARKETPLACES, category: Categories.MARKETPLACES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Emoon', name: 'Emoon',
@ -185,6 +227,8 @@ const Dapps = [
image: '/images/dapps/emoon.png', image: '/images/dapps/emoon.png',
category: Categories.MARKETPLACES, category: Categories.MARKETPLACES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Astro Ledger', name: 'Astro Ledger',
@ -193,6 +237,8 @@ const Dapps = [
image: '/images/dapps/astroledger.svg', image: '/images/dapps/astroledger.svg',
category: Categories.MARKETPLACES, category: Categories.MARKETPLACES,
dateAdded: '2019-04-11', dateAdded: '2019-04-11',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'SuperRare', name: 'SuperRare',
@ -202,6 +248,8 @@ const Dapps = [
image: '/images/dapps/superrare.png', image: '/images/dapps/superrare.png',
category: Categories.MARKETPLACES, category: Categories.MARKETPLACES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'CryptoCare', name: 'CryptoCare',
@ -211,6 +259,8 @@ const Dapps = [
image: '/images/dapps/cryptocare.jpg', image: '/images/dapps/cryptocare.jpg',
category: Categories.COLLECTIBLES, category: Categories.COLLECTIBLES,
dateAdded: '2019-04-11', dateAdded: '2019-04-11',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'CryptoKitties', name: 'CryptoKitties',
@ -219,6 +269,8 @@ const Dapps = [
image: '/images/dapps/cryptokitties.png', image: '/images/dapps/cryptokitties.png',
category: Categories.COLLECTIBLES, category: Categories.COLLECTIBLES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Cryptographics', name: 'Cryptographics',
@ -228,6 +280,8 @@ const Dapps = [
image: '/images/dapps/cryptographics.png', image: '/images/dapps/cryptographics.png',
category: Categories.COLLECTIBLES, category: Categories.COLLECTIBLES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'CryptoPunks', name: 'CryptoPunks',
@ -236,6 +290,8 @@ const Dapps = [
image: '/images/dapps/cryptopunks.png', image: '/images/dapps/cryptopunks.png',
category: Categories.COLLECTIBLES, category: Categories.COLLECTIBLES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Crypto Takeovers', name: 'Crypto Takeovers',
@ -244,6 +300,8 @@ const Dapps = [
image: '/images/dapps/cryptotakeovers.png', image: '/images/dapps/cryptotakeovers.png',
category: Categories.GAMES, category: Categories.GAMES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'CryptoFighters', name: 'CryptoFighters',
@ -252,6 +310,8 @@ const Dapps = [
image: '/images/dapps/cryptofighters.png', image: '/images/dapps/cryptofighters.png',
category: Categories.GAMES, category: Categories.GAMES,
dateAdded: '2019-04-11', dateAdded: '2019-04-11',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Decentraland', name: 'Decentraland',
@ -261,6 +321,8 @@ const Dapps = [
image: '/images/dapps/decentraland.png', image: '/images/dapps/decentraland.png',
category: Categories.GAMES, category: Categories.GAMES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Dragonereum', name: 'Dragonereum',
@ -269,6 +331,8 @@ const Dapps = [
image: '/images/dapps/dragonereum.png', image: '/images/dapps/dragonereum.png',
category: Categories.GAMES, category: Categories.GAMES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Etherbots', name: 'Etherbots',
@ -277,6 +341,8 @@ const Dapps = [
image: '/images/dapps/etherbots.png', image: '/images/dapps/etherbots.png',
category: Categories.GAMES, category: Categories.GAMES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Etheremon', name: 'Etheremon',
@ -285,6 +351,8 @@ const Dapps = [
image: '/images/dapps/etheremon.png', image: '/images/dapps/etheremon.png',
category: Categories.GAMES, category: Categories.GAMES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'CryptoStrikers', name: 'CryptoStrikers',
@ -293,6 +361,8 @@ const Dapps = [
image: '/images/dapps/cryptostrikers.png', image: '/images/dapps/cryptostrikers.png',
category: Categories.GAMES, category: Categories.GAMES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
// { // {
// name: 'FairHouse', // name: 'FairHouse',
@ -301,6 +371,8 @@ const Dapps = [
// image: '/images/dapps/fairhouse.png', // image: '/images/dapps/fairhouse.png',
// category: Categories.GAMES, // category: Categories.GAMES,
// dateAdded: '2019-04-11', // dateAdded: '2019-04-11',
// sntValue: 12345,
// categoryPosition: 2,
// }, // },
{ {
name: 'Cent', name: 'Cent',
@ -309,6 +381,8 @@ const Dapps = [
image: '/images/dapps/cent.png', image: '/images/dapps/cent.png',
category: Categories.SOCIAL_NETWORKS, category: Categories.SOCIAL_NETWORKS,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Kickback', name: 'Kickback',
@ -318,6 +392,8 @@ const Dapps = [
image: '/images/dapps/kickback.png', image: '/images/dapps/kickback.png',
category: Categories.SOCIAL_NETWORKS, category: Categories.SOCIAL_NETWORKS,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Peepeth', name: 'Peepeth',
@ -326,6 +402,8 @@ const Dapps = [
image: '/images/dapps/peepeth.png', image: '/images/dapps/peepeth.png',
category: Categories.SOCIAL_NETWORKS, category: Categories.SOCIAL_NETWORKS,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'livepeer.tv', name: 'livepeer.tv',
@ -334,6 +412,8 @@ const Dapps = [
image: '/images/dapps/livepeer.png', image: '/images/dapps/livepeer.png',
category: Categories.OTHER, category: Categories.OTHER,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Aragon', name: 'Aragon',
@ -342,6 +422,8 @@ const Dapps = [
image: '/images/dapps/aragon.png', image: '/images/dapps/aragon.png',
category: Categories.UTILITIES, category: Categories.UTILITIES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Compound Finance', name: 'Compound Finance',
@ -351,6 +433,8 @@ const Dapps = [
image: '/images/dapps/compoundfinance.png', image: '/images/dapps/compoundfinance.png',
category: Categories.UTILITIES, category: Categories.UTILITIES,
dateAdded: '2019-04-11', dateAdded: '2019-04-11',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'InstaDApp', name: 'InstaDApp',
@ -359,6 +443,8 @@ const Dapps = [
image: '/images/dapps/instadapp.jpg', image: '/images/dapps/instadapp.jpg',
category: Categories.UTILITIES, category: Categories.UTILITIES,
dateAdded: '2019-04-11', dateAdded: '2019-04-11',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Livepeer', name: 'Livepeer',
@ -367,6 +453,8 @@ const Dapps = [
image: '/images/dapps/livepeer.png', image: '/images/dapps/livepeer.png',
category: Categories.UTILITIES, category: Categories.UTILITIES,
dateAdded: '2019-04-11', dateAdded: '2019-04-11',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'ETHLend', name: 'ETHLend',
@ -375,6 +463,8 @@ const Dapps = [
image: '/images/dapps/ethlend.png', image: '/images/dapps/ethlend.png',
category: Categories.UTILITIES, category: Categories.UTILITIES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Civitas', name: 'Civitas',
@ -383,6 +473,8 @@ const Dapps = [
image: '/images/dapps/civitas.png', image: '/images/dapps/civitas.png',
category: Categories.UTILITIES, category: Categories.UTILITIES,
dateAdded: '2019-04-11', dateAdded: '2019-04-11',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: '3Box', name: '3Box',
@ -391,6 +483,8 @@ const Dapps = [
image: '/images/dapps/3Box.png', image: '/images/dapps/3Box.png',
category: Categories.UTILITIES, category: Categories.UTILITIES,
dateAdded: '2019-04-11', dateAdded: '2019-04-11',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Hexel', name: 'Hexel',
@ -399,6 +493,8 @@ const Dapps = [
image: '/images/dapps/hexel.png', image: '/images/dapps/hexel.png',
category: Categories.UTILITIES, category: Categories.UTILITIES,
dateAdded: '2019-04-11', dateAdded: '2019-04-11',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'Smartz', name: 'Smartz',
@ -407,6 +503,8 @@ const Dapps = [
image: '/images/dapps/smartz.png', image: '/images/dapps/smartz.png',
category: Categories.UTILITIES, category: Categories.UTILITIES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
{ {
name: 'SNT Voting DApp', name: 'SNT Voting DApp',
@ -416,6 +514,8 @@ const Dapps = [
image: '/images/dapps/snt-voting.png', image: '/images/dapps/snt-voting.png',
category: Categories.UTILITIES, category: Categories.UTILITIES,
dateAdded: '2019-04-05', dateAdded: '2019-04-05',
sntValue: 12345,
categoryPosition: 2,
}, },
] ]

View File

@ -1,5 +1,8 @@
const vote = { const vote = {
visible: false, visible: false,
dapp: null,
isUpvote: false,
sntValue: '0',
} }
export default vote export default vote

View File

@ -7,9 +7,8 @@ export const DappModel = {
description: PropTypes.string, description: PropTypes.string,
category: PropTypes.string, category: PropTypes.string,
dateAdded: PropTypes.string, dateAdded: PropTypes.string,
isRanked: PropTypes.bool, sntValue: PropTypes.number,
position: PropTypes.number, categoryPosition: PropTypes.number,
showActionButtons: PropTypes.bool,
} }
export const DappListModel = PropTypes.arrayOf(PropTypes.shape(DappModel)) export const DappListModel = PropTypes.arrayOf(PropTypes.shape(DappModel))

View File

@ -11,7 +11,7 @@ const recentDapps = createSelector(
return ( return (
moment(dapp.dateAdded).toISOString() > moment(dapp.dateAdded).toISOString() >
moment() moment()
.subtract(21, 'days') .subtract(31, 'days')
.utc() .utc()
.toISOString() .toISOString()
) )

View File

@ -1,7 +1,12 @@
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom' import { withRouter } from 'react-router-dom'
import Vote from './Vote' import Vote from './Vote'
import { closeVoteAction } from './Vote.reducer' import {
closeVoteAction,
switchToUpvoteAction,
switchToUpDownvoteAction,
onInputSntValueAction,
} from './Vote.reducer'
const mapStateToProps = state => state.vote const mapStateToProps = state => state.vote
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
@ -9,6 +14,9 @@ const mapDispatchToProps = dispatch => ({
window.history.back() window.history.back()
dispatch(closeVoteAction()) dispatch(closeVoteAction())
}, },
onClickUpvote: () => dispatch(switchToUpvoteAction()),
onClickDownvote: () => dispatch(switchToUpDownvoteAction()),
onInputSntValue: sntValue => dispatch(onInputSntValueAction(sntValue)),
}) })
export default withRouter( export default withRouter(

View File

@ -7,6 +7,7 @@ import CategoriesUtils from '../Categories/Categories.utils'
import Categories from '../../common/utils/categories' import Categories from '../../common/utils/categories'
import icon from '../../common/assets/images/icon.svg' import icon from '../../common/assets/images/icon.svg'
import Modal from '../../common/components/Modal' import Modal from '../../common/components/Modal'
import { DappModel } from '../../common/utils/models'
const getCategoryName = category => const getCategoryName = category =>
Categories.find(x => x.key === category).value Categories.find(x => x.key === category).value
@ -14,46 +15,36 @@ const getCategoryName = category =>
class Vote extends Component { class Vote extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = {
isUpvote: true,
sntValue: 0,
}
this.onClickTab = this.onClickTab.bind(this)
this.handleChange = this.handleChange.bind(this) this.handleChange = this.handleChange.bind(this)
} }
onClickTab(showUpvote) {
return () => {
this.setState({ isUpvote: showUpvote })
}
}
handleChange(e) { handleChange(e) {
const { value } = e.target const { value } = e.target
if (value !== '' && /^[1-9][0-9]*$/.test(value) === false) return if (value !== '' && /^[1-9][0-9]*$/.test(value) === false) return
if (parseInt(value, 10) > 1571296) return if (parseInt(value, 10) > 1571296) return
this.setState({ sntValue: value }) const { onInputSntValue } = this.props
onInputSntValue(value)
} }
render() { render() {
const { isUpvote, sntValue } = this.state const {
const { visible, onClickClose } = this.props visible,
onClickClose,
isUpvote,
dapp,
onClickUpvote,
onClickDownvote,
sntValue,
} = this.props
// TODO: extract these to props if (dapp === null) {
return <Modal visible={false} onClickClose={onClickClose} />
const dapp = {
name: 'Kyber',
url: 'https://web3.kyber.network',
description:
'On-chain, instant and liquid platform for exchange and payment service',
image: '/images/dapps/kyber.png',
category: 'EXCHANGES',
dateAdded: null,
} }
const currentSNTamount = 23456 const currentSNTamount = dapp.sntValue
const categoryPosition = 2 const catPosition = dapp.categoryPosition
const upvoteSNTcost = currentSNTamount + parseInt(sntValue, 10) const upvoteSNTcost = currentSNTamount + parseInt(sntValue, 10)
const downvoteSNTcost = 3244 const downvoteSNTcost = 3244
@ -68,14 +59,14 @@ class Vote extends Component {
<button <button
className={isUpvote ? styles.active : ''} className={isUpvote ? styles.active : ''}
type="button" type="button"
onClick={this.onClickTab(true)} onClick={onClickUpvote}
> >
UPVOTE UPVOTE
</button> </button>
<button <button
className={!isUpvote ? styles.active : ''} className={!isUpvote ? styles.active : ''}
type="button" type="button"
onClick={this.onClickTab(false)} onClick={onClickDownvote}
> >
DOWNVOTE DOWNVOTE
</button> </button>
@ -116,11 +107,11 @@ class Vote extends Component {
width="24" width="24"
height="24" height="24"
/> />
{`${getCategoryName(dapp.category)}${categoryPosition}`} {`${getCategoryName(dapp.category)}${catPosition}`}
</span> </span>
{isUpvote && upvoteSNTcost > currentSNTamount && ( {isUpvote && upvoteSNTcost > currentSNTamount && (
<span className={styles.greenBadge}> <span className={styles.greenBadge}>
{`${categoryPosition - 1}`} {`${catPosition - 1}`}
</span> </span>
)} )}
</div> </div>
@ -136,7 +127,7 @@ class Vote extends Component {
type="text" type="text"
value={sntValue} value={sntValue}
onChange={this.handleChange} onChange={this.handleChange}
style={{ width: `${19 * sntValue.length}px` }} style={{ width: `${19 * Math.max(1, sntValue.length)}px` }}
/> />
</div> </div>
)} )}
@ -161,7 +152,10 @@ class Vote extends Component {
</a> </a>
</p> </p>
)} )}
<button type="submit" disabled={!sntValue}> <button
type="submit"
disabled={(!sntValue || sntValue === '0') && isUpvote}
>
{isUpvote ? 'Upvote' : 'Downvote'} {isUpvote ? 'Upvote' : 'Downvote'}
</button> </button>
</div> </div>
@ -170,9 +164,19 @@ class Vote extends Component {
} }
} }
Vote.defaultProps = {
dapp: null,
}
Vote.propTypes = { Vote.propTypes = {
dapp: PropTypes.shape(DappModel),
isUpvote: PropTypes.bool.isRequired,
visible: PropTypes.bool.isRequired, visible: PropTypes.bool.isRequired,
sntValue: PropTypes.string.isRequired,
onClickClose: PropTypes.func.isRequired, onClickClose: PropTypes.func.isRequired,
onClickUpvote: PropTypes.func.isRequired,
onClickDownvote: PropTypes.func.isRequired,
onInputSntValue: PropTypes.func.isRequired,
} }
export default Vote export default Vote

View File

@ -43,13 +43,17 @@
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
cursor: pointer; cursor: pointer;
outline: none;
transition-property: color;
transition-duration: 0.4s;
} }
.tabs button:first-child { .tabs button:first-child {
margin-right: 32px; margin-right: 32px;
} }
.tabs button.active:after { .tabs button:after {
display: block; display: block;
clear: both; clear: both;
content: ''; content: '';
@ -58,14 +62,21 @@
right: 0; right: 0;
bottom: 0; bottom: 0;
width: 24px; width: 24px;
border-bottom: 2px solid $link-color; border-bottom: 2px solid transparent;
margin: 0 auto 0 auto; margin: 0 auto 0 auto;
transition-property: border-color;
transition-duration: 0.4s;
} }
.tabs button.active { .tabs button.active {
color: $link-color; color: $link-color;
} }
.tabs button.active:after {
border-bottom-color: $link-color;
}
.dapp { .dapp {
height: 48px; height: 48px;
display: flex; display: flex;

View File

@ -4,14 +4,27 @@ import reducerUtil from '../../common/utils/reducer'
const SHOW_UP_VOTE = 'SHOW_UP_VOTE' const SHOW_UP_VOTE = 'SHOW_UP_VOTE'
const SHOW_DOWN_VOTE = 'SHOW_DOWN_VOTE' const SHOW_DOWN_VOTE = 'SHOW_DOWN_VOTE'
const CLOSE_VOTE = 'CLOSE_VOTE' const CLOSE_VOTE = 'CLOSE_VOTE'
const SWITCH_TO_UPVOTE = 'SWITCH_TO_UPVOTE'
const SWITCH_TO_DOWNVOTE = 'SWITCH_TO_DOWNVOTE'
const ON_INPUT_SNT_VALUE = 'ON_INPUT_SNT_VALUE'
export const showUpVoteAction = () => ({ export const showUpVoteAction = dapp => ({
type: SHOW_UP_VOTE, type: SHOW_UP_VOTE,
payload: dapp,
})
export const showDownVoteAction = dapp => ({
type: SHOW_DOWN_VOTE,
payload: dapp,
})
export const switchToUpvoteAction = () => ({
type: SWITCH_TO_UPVOTE,
payload: null, payload: null,
}) })
export const showDownVoteAction = () => ({ export const switchToUpDownvoteAction = () => ({
type: SHOW_DOWN_VOTE, type: SWITCH_TO_DOWNVOTE,
payload: null, payload: null,
}) })
@ -20,15 +33,24 @@ export const closeVoteAction = () => ({
payload: null, payload: null,
}) })
const showUpVote = state => { export const onInputSntValueAction = sntValue => ({
type: ON_INPUT_SNT_VALUE,
payload: sntValue,
})
const showUpVote = (state, dapp) => {
return Object.assign({}, state, { return Object.assign({}, state, {
visible: true, visible: true,
dapp,
sntValue: '0',
}) })
} }
const showDownVote = state => { const showDownVote = (state, dapp) => {
return Object.assign({}, state, { return Object.assign({}, state, {
visible: true, visible: true,
dapp,
sntValue: '0',
}) })
} }
@ -38,10 +60,31 @@ const closeVote = state => {
}) })
} }
const switchToUpvote = state => {
return Object.assign({}, state, {
isUpvote: true,
})
}
const switchToDownvote = state => {
return Object.assign({}, state, {
isUpvote: false,
})
}
const onInputSntValue = (state, sntValue) => {
return Object.assign({}, state, {
sntValue,
})
}
const map = { const map = {
[SHOW_UP_VOTE]: showUpVote, [SHOW_UP_VOTE]: showUpVote,
[SHOW_DOWN_VOTE]: showDownVote, [SHOW_DOWN_VOTE]: showDownVote,
[CLOSE_VOTE]: closeVote, [CLOSE_VOTE]: closeVote,
[SWITCH_TO_UPVOTE]: switchToUpvote,
[SWITCH_TO_DOWNVOTE]: switchToDownvote,
[ON_INPUT_SNT_VALUE]: onInputSntValue,
} }
export default reducerUtil(map, voteState) export default reducerUtil(map, voteState)