diff --git a/app/renderer/components/SwapDetails.js b/app/renderer/components/SwapDetails.js index 0a9a74900f..0cc81d32ef 100644 --- a/app/renderer/components/SwapDetails.js +++ b/app/renderer/components/SwapDetails.js @@ -1,8 +1,10 @@ import {remote, clipboard} from 'electron'; import title from 'title'; import React from 'react'; +import {Subscribe} from 'unstated'; import PropTypes from 'prop-types'; import formatDate from 'date-fns/format'; +import exchangeContainer from 'containers/Exchange'; import Modal from 'components/Modal'; import Progress from 'components/Progress'; import CurrencyIcon from 'components/CurrencyIcon'; @@ -43,11 +45,12 @@ const getOverview = swap => { class SwapDetails extends React.Component { static propTypes = { - swap: PropTypes.object, + swapId: PropTypes.string, + open: PropTypes.bool, + didClose: PropTypes.func, } state = { - isOpen: false, showAdvanced: config.get('swapModalShowAdvanced'), }; @@ -56,16 +59,19 @@ class SwapDetails extends React.Component { config.set('swapModalShowAdvanced', showAdvanced); }; - open = () => { - this.setState({isOpen: true}); - }; - - close = () => { - this.setState({isOpen: false}); - }; - render() { - const {swap} = this.props; + const { + exchangeContainer, + swapId, + open, + didClose, + } = this.props; + + if (!swapId) { + return null; + } + + const swap = exchangeContainer.state.swapHistory.find(swap => swap.uuid === swapId); const {baseCurrency, quoteCurrency} = swap; const transactions = swap.transactions.map(tx => ( @@ -132,8 +138,8 @@ class SwapDetails extends React.Component { className="SwapDetails" title={titleComponent} icon="/assets/swap-icon.svg" - open={this.state.isOpen} - onClose={this.close} + open={open} + didClose={didClose} width="660px" > <> @@ -225,10 +231,15 @@ class SwapDetails extends React.Component { )} - ); } } -export default SwapDetails; +export default props => ( + + {container => ( + + )} + +); diff --git a/app/renderer/components/SwapList.js b/app/renderer/components/SwapList.js index 5cf7fd7fb3..c3b317fd06 100644 --- a/app/renderer/components/SwapList.js +++ b/app/renderer/components/SwapList.js @@ -83,7 +83,7 @@ const SwapHeader = props => ( ); -const SwapItem = ({style, swap, showCancel}) => ( +const SwapItem = ({style, swap, showCancel, openSwap}) => (
{formatDate(swap.timeStarted, 'HH:mm DD/MM/YY')}
{swap.baseCurrency}/{swap.quoteCurrency}
@@ -99,7 +99,7 @@ const SwapItem = ({style, swap, showCancel}) => (
)}
- +
@@ -109,6 +109,15 @@ class SwapList extends React.Component { state = { sortBy: this.props.sortBy, sortDirection: this.props.sortDirection, + openedSwapId: null, + }; + + openSwap = swapId => { + this.setState({openedSwapId: swapId}); + }; + + closeSwap = () => { + this.setState({openedSwapId: null}); }; cache = new CellMeasurerCache({ @@ -146,20 +155,35 @@ class SwapList extends React.Component { renderRow = swaps => ({index, key, parent, style}) => { const {showCancel} = this.props; const swap = swaps[index]; + const openSwap = () => this.openSwap(swap.uuid); return ( - + ); }; + Details = () => ( + + ); + render() { + const {Details} = this; let {showHeader, swaps, limit} = this.props; const {sortBy, sortDirection} = this.state; if (swaps.length === 0) { - return ; + return ( + <> +
+ + + ); } const shouldLimit = limit && limit < swaps.length; @@ -177,7 +201,14 @@ class SwapList extends React.Component { return (
- {showHeader && } +
+ {showHeader && ( + + )}
{({width, height}) => (