Skip to content
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

Wiring up new homepage to new dashboard #281

Merged
merged 7 commits into from
Sep 27, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions unlock-app/src/components/Unlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import React from 'react'
import { Route, Switch } from 'react-router'

import LockMaker from './creator/LockMaker'
import Dashboard from './creator/Dashboard'
import Lock from './consumer/Lock'
import Home from './pages/Home'
import Jobs from './pages/Jobs'
Expand Down Expand Up @@ -63,6 +64,7 @@ export function Unlock({ network, config, path }) {
return (
<Switch>
<Route path="/provider" component={Provider} />
<Route path="/dashboard" component={Dashboard} />
<Route path="/creator" component={LockMaker} />
<Route path="/lock/:lockAddress" component={Lock} />
<Route path="/jobs" component={Jobs} />
Expand Down
23 changes: 22 additions & 1 deletion unlock-app/src/components/creator/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ import React, { Component } from 'react'
import Layout from '../interface/Layout'
import CreatorAccount from './CreatorAccount'
import CreatorLocks from './CreatorLocks'
import {setTransaction} from '../../actions/transaction'
import { connect } from 'react-redux'

export default class Dashboard extends Component {
export class Dashboard extends Component {
render() {
if (!this.props.account) {
return null //loading
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably eventually handle that at a higher level.. But that'll do for now!


return (
<Layout title="Creator Dashboard">
<CreatorAccount network={this.props.network} account={this.props.account} />
Expand All @@ -22,3 +28,18 @@ Dashboard.propTypes = {
transactions: UnlockPropTypes.transactions,
locks: UnlockPropTypes.locks,
}

const mapStateToProps = state => {
return {
account: state.network.account, // TODO change account to base level
network: state.network,
transactions: state.transactions,
locks: state.locks,
}
}

const mapDispatchToProps = dispatch => ({
setTransaction: (transaction) => dispatch(setTransaction(transaction)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we actually calling this anywhere in the component?

})

export default connect(mapStateToProps, mapDispatchToProps)(Dashboard)
16 changes: 15 additions & 1 deletion unlock-app/src/components/pages/Home.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import styled from 'styled-components'
import React, { PureComponent } from 'react'
import UnlockPropTypes from '../../propTypes'
import Layout from '../interface/Layout'
import { Section, Headline, SubTitle, CallToAction, ThreeColumns, Column } from './Components'
import { ActionButton } from '../creator/CreatorLocks'

export default class Home extends PureComponent {
constructor(props) {
super(props)
this.dashboardClick = this.dashboardClick.bind(this)
}

dashboardClick() {
this.props.history.push('/dashboard')
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, I would expect react router to handle that for you?


render() {
return (
<Layout forContent={true}>
Expand All @@ -13,7 +23,7 @@ export default class Home extends PureComponent {
Unlock is a protocol which enables creators to monetize their content with a few lines of code in a fully decentralized way.
</Headline>

<Action>
<Action onClick={this.dashboardClick}>
<HomepageButton>Go to Your Dashboard</HomepageButton>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, you should probably use Link from react-router-dom.

<ButtonLabel>Requires a browser with an Ethereum wallet</ButtonLabel>
</Action>
Expand Down Expand Up @@ -51,6 +61,10 @@ export default class Home extends PureComponent {
}
}

Home.propTypes = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably get rid of this ;)

history: UnlockPropTypes.Object,
}

const ImageWithHover = styled.div`
border-style: none;
background: url(${props => (`/images/pages/png/${props.base}.png`)}) no-repeat center/contain;
Expand Down