You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
3.4 KiB
118 lines
3.4 KiB
7 years ago
|
import React from 'react'
|
||
|
import PropTypes from 'prop-types'
|
||
|
|
||
|
import Moment from 'react-moment'
|
||
|
|
||
|
import QRCode from 'qrcode.react'
|
||
|
import copy from 'copy-to-clipboard'
|
||
7 years ago
|
import { showNotification } from 'lib/utils/notifications'
|
||
7 years ago
|
|
||
7 years ago
|
import FaAngleDown from 'react-icons/lib/fa/angle-down'
|
||
7 years ago
|
|
||
|
import Value from 'components/Value'
|
||
6 years ago
|
import Countdown from '../Countdown'
|
||
7 years ago
|
|
||
|
import styles from './InvoiceModal.scss'
|
||
|
|
||
|
const InvoiceModal = ({
|
||
6 years ago
|
item: invoice,
|
||
7 years ago
|
ticker,
|
||
|
currentTicker,
|
||
|
|
||
7 years ago
|
toggleCurrencyProps: {
|
||
|
setActivityModalCurrencyFilters,
|
||
|
showCurrencyFilters,
|
||
|
currencyName,
|
||
|
currentCurrencyFilters,
|
||
|
onCurrencyFilterClick
|
||
|
}
|
||
7 years ago
|
}) => {
|
||
|
const copyPaymentRequest = () => {
|
||
|
copy(invoice.payment_request)
|
||
|
showNotification('Noice', 'Successfully copied to clipboard')
|
||
|
}
|
||
|
|
||
7 years ago
|
const countDownDate = parseInt(invoice.creation_date, 10) + parseInt(invoice.expiry, 10)
|
||
7 years ago
|
|
||
7 years ago
|
return (
|
||
|
<div className={styles.container}>
|
||
|
<div className={styles.content}>
|
||
|
<section className={styles.left}>
|
||
7 years ago
|
<h2>Payment Request</h2>
|
||
7 years ago
|
<QRCode
|
||
|
value={invoice.payment_request}
|
||
7 years ago
|
renderAs="svg"
|
||
7 years ago
|
size={150}
|
||
6 years ago
|
bgColor="white"
|
||
|
fgColor="#252832"
|
||
7 years ago
|
level="L"
|
||
7 years ago
|
className={styles.qrcode}
|
||
7 years ago
|
/>
|
||
7 years ago
|
<Countdown countDownDate={countDownDate} />
|
||
7 years ago
|
</section>
|
||
|
<section className={styles.right}>
|
||
|
<div className={styles.details}>
|
||
|
<section className={styles.amount}>
|
||
|
<h1>
|
||
7 years ago
|
<Value
|
||
6 years ago
|
value={invoice.finalAmount}
|
||
7 years ago
|
currency={ticker.currency}
|
||
|
currentTicker={currentTicker}
|
||
7 years ago
|
fiatTicker={ticker.fiatTicker}
|
||
7 years ago
|
/>
|
||
7 years ago
|
</h1>
|
||
7 years ago
|
<section
|
||
|
className={styles.currentCurrency}
|
||
|
onClick={() => setActivityModalCurrencyFilters(!showCurrencyFilters)}
|
||
|
>
|
||
7 years ago
|
<span>{currencyName}</span>
|
||
|
<span>
|
||
|
<FaAngleDown />
|
||
|
</span>
|
||
7 years ago
|
</section>
|
||
7 years ago
|
<ul className={showCurrencyFilters ? styles.active : undefined}>
|
||
7 years ago
|
{currentCurrencyFilters.map(filter => (
|
||
|
<li key={filter.key} onClick={() => onCurrencyFilterClick(filter.key)}>
|
||
|
{filter.name}
|
||
|
</li>
|
||
|
))}
|
||
7 years ago
|
</ul>
|
||
|
</section>
|
||
|
<section className={styles.date}>
|
||
|
<p>
|
||
7 years ago
|
<Moment format="MM/DD/YYYY">{invoice.creation_date * 1000}</Moment>
|
||
7 years ago
|
</p>
|
||
7 years ago
|
{!invoice.settled && <p className={styles.notPaid}>Not Paid</p>}
|
||
6 years ago
|
{invoice.settled && <p className={styles.paid}>Paid</p>}
|
||
7 years ago
|
</section>
|
||
|
</div>
|
||
|
|
||
|
<div className={styles.memo}>
|
||
|
<h4>Memo</h4>
|
||
|
<p>{invoice.memo}</p>
|
||
|
</div>
|
||
|
|
||
|
<div className={styles.request}>
|
||
|
<h4>Request</h4>
|
||
|
<p>{invoice.payment_request}</p>
|
||
|
</div>
|
||
|
</section>
|
||
|
</div>
|
||
|
|
||
|
<div className={styles.actions}>
|
||
|
<div>Save as image</div>
|
||
7 years ago
|
<div onClick={copyPaymentRequest}>Copy Request</div>
|
||
7 years ago
|
</div>
|
||
|
</div>
|
||
|
)
|
||
|
}
|
||
|
|
||
|
InvoiceModal.propTypes = {
|
||
6 years ago
|
item: PropTypes.object.isRequired,
|
||
7 years ago
|
ticker: PropTypes.object.isRequired,
|
||
|
currentTicker: PropTypes.object.isRequired,
|
||
|
toggleCurrencyProps: PropTypes.object.isRequired
|
||
7 years ago
|
}
|
||
|
|
||
|
export default InvoiceModal
|