ilp-core
Version:
ILP core module managing ledger abstraction
79 lines (62 loc) • 1.66 kB
JavaScript
import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
import { Link } from 'react-router'
import classNames from 'classnames/bind'
import styles from './SettlementInfo.scss'
const cx = classNames.bind(styles)
import { get } from 'redux/actions/settlement'
(state => ({
info: state.settlement.info
}), { get })
export default class SettlementInfo extends Component {
static propTypes = {
get: PropTypes.func.isRequired,
info: PropTypes.object
}
state = {}
componentWillMount() {
this.props.get(this.props.params.id)
}
componentDidMount() {
this.setState({
hostname: location.hostname
})
}
renderUser() {
const { info } = this.props
return (
<div>
<h3>
You've successfully deposited <b>{info.amount} {info.currency}</b> into your account.
</h3>
<Link to="/" className={cx('goBack')}>
Back to home
</Link>
</div>
)
}
renderPeer() {
const { info } = this.props
const { hostname } = this.state
return (
<div>
<h3>
<b>{info.amount} {info.currency}</b> settlement between <b>{hostname}</b> and <b>{info.peer}</b> has been completed!
</h3>
<a href={`http://${info.peer}`} className={cx('goBack')}>
Back to {info.peer}
</a>
</div>
)
}
render() {
const { info } = this.props
return (
<div className={cx('SettlementInfo')}>
<i className={cx('fa', 'fa-check', 'icon')} />
{info.peer && this.renderPeer()}
{info.user && this.renderUser()}
</div>
)
}
}