-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #17
- Loading branch information
Showing
9 changed files
with
131 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react' | ||
|
||
import { connect } from 'react-redux' | ||
|
||
import ShowPayment from '../../views/payments/show' | ||
|
||
import { | ||
getPaymentById | ||
} from '../../reducers' | ||
|
||
const render = props => { | ||
return <ShowPayment {...props} /> | ||
} | ||
|
||
const mapStateToProps = (state, { match }) => ({ | ||
payment: getPaymentById(state, match.params.id) | ||
}) | ||
|
||
const mapDispatchToProps = (dispatch, { history, match }) => ({ | ||
}) | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(render) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.c-header { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import Big from 'big.js' | ||
|
||
import { format } from 'date-fns' | ||
|
||
import React, { Fragment } from 'react' | ||
|
||
import Icon from '../../components/Icon' | ||
|
||
export default ({payment: { | ||
address, convertedAmount, createdAt, fiatCurrency, height, id, integratedAddress, | ||
paymentId, rate, receipt, receivedAmount, requestedAmount, updatedAt, uri }} | ||
) => ( | ||
<Fragment> | ||
<div className='o-app__content u-margin-horizontal' style={{margin: '54px 0'}}> | ||
<table className='o-table o-table--tiny u-margin-top'> | ||
<tbody> | ||
<tr> | ||
<th scope='row'>Exchange Rate</th> | ||
<td className='u-align-right'>{rate} {fiatCurrency}/XMR</td> | ||
</tr> | ||
<tr> | ||
<th scope='row'>Amount Requested</th> | ||
<td className='u-align-right'> | ||
{formatCurrency(requestedAmount, fiatCurrency)}<br /> | ||
<small>{formatCurrency(convertedAmount)}</small> | ||
</td> | ||
</tr> | ||
<tr> | ||
<th scope='row'>Amount Received</th> | ||
<td className='u-align-right'> | ||
{formatCurrency(receivedAmount, fiatCurrency, rate)}<br /> | ||
<small>{formatCurrency(receivedAmount)}</small> | ||
</td> | ||
</tr> | ||
<tr> | ||
<th scope='row'>Tip</th> | ||
<td className='u-align-right'> | ||
{(receivedAmount && formatCurrency(new Big(receivedAmount).times(rate).minus(requestedAmount), fiatCurrency)) || '—'}<br /> | ||
<small>{(receivedAmount && formatCurrency(new Big(receivedAmount).minus(convertedAmount))) || '—'}</small> | ||
</td> | ||
</tr> | ||
<tr> | ||
<th scope='row'>Created</th> | ||
<td className='u-align-right'> | ||
{format(createdAt, 'MM/DD/YYYY – HH:MM')} | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
<div className='o-app__top-left'> | ||
<Icon href='/payments' name='back' /> | ||
</div> | ||
<div className='o-app__header'>Payment Details</div> | ||
</Fragment> | ||
) | ||
|
||
export const formatCurrency = (amount, fiatCurrency = null, rate = 1) => { | ||
try { | ||
const decimals = fiatCurrency === null ? 12 : 2 | ||
return `${new Big(amount).times(rate).toFixed(decimals)} ${fiatCurrency || 'XMR'}` | ||
} catch (e) { | ||
return '—' | ||
} | ||
} |