/* eslint-disable react/prop-types */
/* eslint-disable jsx-a11y/click-events-have-key-events */
/* eslint-disable jsx-a11y/no-static-element-interactions */
import React, { Component } from 'react';
import Modal from 'react-modal';
import dateformat from 'dateformat';
import { shell } from 'electron';
import { withRouter } from 'react-router';
import { BalanceBlockHighlight } from './BalanceBlocks';
import styles from './Transactions.css';
import cstyles from './Common.css';
import { Transaction, Info } from './AppState';
import ScrollPane from './ScrollPane';
import Utils from '../utils/utils';
import AddressBook from './Addressbook';
import routes from '../constants/routes.json';
const TxModalInternal = ({ modalIsOpen, tx, closeModal, currencyName, zecPrice, setSendTo, history }) => {
let txid = '';
let type = '';
let typeIcon = '';
let typeColor = '';
let confirmations = 0;
let detailedTxns = [];
let amount = 0;
let datePart = '';
let timePart = '';
if (tx) {
txid = tx.txid;
type = tx.type;
if (tx.type === 'receive') {
typeIcon = 'fa-arrow-circle-down';
typeColor = 'green';
} else {
typeIcon = 'fa-arrow-circle-up';
typeColor = 'red';
}
datePart = dateformat(tx.time * 1000, 'mmm dd, yyyy');
timePart = dateformat(tx.time * 1000, 'hh:MM tt');
confirmations = tx.confirmations;
detailedTxns = tx.detailedTxns;
amount = Math.abs(tx.amount);
}
const openTxid = () => {
if (currencyName === 'TAZ') {
shell.openExternal(`https://chain.so/tx/ZECTEST/${txid}`);
} else {
shell.openExternal(`https://zcha.in/transactions/${txid}`);
}
};
const doReply = (address: string) => {
setSendTo(address, 0.0001, null);
closeModal();
history.push(routes.SEND);
};
return (
{detailedTxns.map(txdetail => {
const { bigPart, smallPart } = Utils.splitZecAmountIntoBigSmall(Math.abs(txdetail.amount));
let { address } = txdetail;
const { memo } = txdetail;
if (!address) {
address = '(Shielded)';
}
let replyTo = null;
if (tx.type === 'receive' && memo) {
const split = memo.split(/[ :\n\r\t]+/);
console.log(split);
if (split && split.length > 0 && Utils.isSapling(split[split.length - 1])) {
replyTo = split[split.length - 1];
}
}
console.log('replyto is', replyTo);
return (