From c5d4941535e15edb01ae20dc757cfbae59c3ecfa Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Tue, 28 Mar 2017 05:07:52 -0400 Subject: [PATCH] Basic views for reward and reward list pages --- ui/js/app.js | 18 ++++++++---- ui/js/page/reward.js | 46 +++++++++++++++++++++++++++++ ui/js/page/rewards.js | 68 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 5 deletions(-) create mode 100644 ui/js/page/reward.js create mode 100644 ui/js/page/rewards.js diff --git a/ui/js/app.js b/ui/js/app.js index 7e8559be7..2677c0b91 100644 --- a/ui/js/app.js +++ b/ui/js/app.js @@ -9,6 +9,8 @@ import ReportPage from './page/report.js'; import StartPage from './page/start.js'; import ClaimCodePage from './page/claim_code.js'; import ReferralPage from './page/referral.js'; +import RewardsPage from './page/rewards.js'; +import RewardPage from './page/reward.js'; import WalletPage from './page/wallet.js'; import ShowPage from './page/show.js'; import PublishPage from './page/publish.js'; @@ -233,12 +235,14 @@ var App = React.createClass({ case 'receive': case 'claim': case 'referral': + case 'rewards': return { - '?wallet' : 'Overview', - '?send' : 'Send', - '?receive' : 'Receive', - '?claim' : 'Claim Beta Code', - '?referral' : 'Check Referral Credit', + '?wallet': 'Overview', + '?send': 'Send', + '?receive': 'Receive', + '?claim': 'Claim Beta Code', + '?referral': 'Check Referral Credit', + '?rewards': 'Rewards', }; case 'downloaded': case 'published': @@ -272,6 +276,10 @@ var App = React.createClass({ return ; case 'referral': return ; + case 'rewards': + return ; + case 'reward': + return ; case 'wallet': case 'send': case 'receive': diff --git a/ui/js/page/reward.js b/ui/js/page/reward.js new file mode 100644 index 000000000..9c613ef3c --- /dev/null +++ b/ui/js/page/reward.js @@ -0,0 +1,46 @@ +import React from 'react'; + +// Placeholder for something like api.lbry.io/reward_type/get/[name] */ +function apiRewardTypeGet(name) { + return { + name: 'reward1', + title: 'Reward 1', + description: 'Reward 1 description', + value: 50, + claimed: true, + }; +} + +const RewardPage = React.createClass({ + propTypes: { + name: React.PropTypes.string, + }, + getInitialState: function() { + return { + rewardType: null, + }; + }, + componentWillMount: function() { + this.setState({ + rewardType: apiRewardTypeGet(this.props.name), + }); + }, + render: function() { + if (!this.state.rewardType) { + return null; + } + + let {title, description, value} = this.state.rewardType; + return ( +
+
+

{title}

+

{description}

+ {/* Most likely have a component included here for each reward (e.g. WatchVideoReward) */} +
+
+ ); + } +}); + +export default RewardPage; diff --git a/ui/js/page/rewards.js b/ui/js/page/rewards.js new file mode 100644 index 000000000..093821f31 --- /dev/null +++ b/ui/js/page/rewards.js @@ -0,0 +1,68 @@ +import React from 'react'; +import lbry from '../lbry.js'; +import Modal from '../component/modal.js'; +import {Link} from '../component/link.js'; + +// Placeholder for something like api.lbry.io/reward_type/list */ +function apiRewardTypeList() { + return [ + { + name: 'link_github', + title: 'Link your GitHub account', + description: 'Link LBRY to your GitHub account', + value: 50, + claimed: false, + }, + ]; +} + +var RewardTile = React.createClass({ + propTypes: { + name: React.PropTypes.string, + title: React.PropTypes.string, + }, + render: function() { + return ( +
+
+

+
{this.props.description}
+ {this.props.claimed + ? This reward has been claimed. + : } +
+
+ ); + } +}); + +var RewardsPage = React.createClass({ + componentWillMount: function() { + this.setState({ + rewardTypes: apiRewardTypeList(), + }); + }, + getInitialState: function() { + return { + rewardTypes: null, + }; + }, + render: function() { + return ( +
+
+
+

Rewards

+ {!this.state.rewardTypes + ? null + : this.state.rewardTypes.map(({name, title, description, claimed, value}) => { + return ; + })} +
+
+
+ ); + } +}); + +export default RewardsPage;