import { makeStyles, Box } from '@material-ui/core' import BigNumber from 'bignumber.js' import moment from 'moment' import React, { memo } from 'react' import { IDButton } from 'src/components/buttons' import { Label1 } from 'src/components/typography' import { ReactComponent as CardIdInverseIcon } from 'src/styling/icons/ID/card/white.svg' import { ReactComponent as CardIdIcon } from 'src/styling/icons/ID/card/zodiac.svg' import { ReactComponent as PhoneIdInverseIcon } from 'src/styling/icons/ID/phone/white.svg' import { ReactComponent as PhoneIdIcon } from 'src/styling/icons/ID/phone/zodiac.svg' import { ReactComponent as CamIdInverseIcon } from 'src/styling/icons/ID/photo/white.svg' import { ReactComponent as CamIdIcon } from 'src/styling/icons/ID/photo/zodiac.svg' import { ReactComponent as TxInIcon } from 'src/styling/icons/direction/cash-in.svg' import { ReactComponent as TxOutIcon } from 'src/styling/icons/direction/cash-out.svg' import { URI } from 'src/utils/apollo' import { toUnit, formatCryptoAddress } from 'src/utils/coin' import { onlyFirstToUpper } from 'src/utils/string' import CopyToClipboard from './CopyToClipboard' import styles from './DetailsCard.styles' import { getStatus } from './helper' const useStyles = makeStyles(styles) const formatAddress = (cryptoCode = '', address = '') => formatCryptoAddress(cryptoCode, address).replace(/(.{5})/g, '$1 ') const Label = ({ children }) => { const classes = useStyles() return {children} } const DetailsRow = ({ it: tx }) => { const classes = useStyles() const fiat = Number.parseFloat(tx.fiat) const crypto = toUnit(new BigNumber(tx.cryptoAtoms), tx.cryptoCode) const commissionPercentage = Number.parseFloat(tx.commissionPercentage, 2) const commission = Number(fiat * commissionPercentage).toFixed(2) const exchangeRate = Number(fiat / crypto).toFixed(3) const displayExRate = `1 ${tx.cryptoCode} = ${exchangeRate} ${tx.fiatCode}` const customer = tx.customerIdCardData && { name: `${onlyFirstToUpper( tx.customerIdCardData.firstName )} ${onlyFirstToUpper(tx.customerIdCardData.lastName)}`, age: moment().diff(moment(tx.customerIdCardData.dateOfBirth), 'years'), country: tx.customerIdCardData.country, idCardNumber: tx.customerIdCardData.documentNumber, idCardExpirationDate: moment(tx.customerIdCardData.expirationDate).format( 'DD-MM-YYYY' ) } return (
{tx.txClass === 'cashOut' ? : } {tx.txClass === 'cashOut' ? 'Cash-out' : 'Cash-in'}
{tx.customerPhone && ( {tx.customerPhone} )} {tx.customerIdCardPhotoPath && !tx.customerIdCardData && ( )} {tx.customerIdCardData && (
{customer.name}
{customer.age}
{customer.country}
{customer.idCardNumber}
{customer.idCardExpirationDate}
)} {tx.customerFrontCameraPath && ( )}
{crypto > 0 ? displayExRate : '-'}
{`${commission} ${tx.fiatCode} (${commissionPercentage * 100} %)`}
{tx.txClass === 'cashIn' ? `${Number.parseFloat(tx.cashInFee)} ${tx.fiatCode}` : 'N/A'}
{formatAddress(tx.cryptoCode, tx.toAddress)}
{tx.txClass === 'cashOut' ? ( 'N/A' ) : ( {tx.txHash} )}
{tx.id}
{getStatus(tx)}
) } export default memo(DetailsRow, (prev, next) => prev.id === next.id)