From efecc2eead2703d9c5c7c5447e453117c413365e Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 26 Nov 2021 08:40:31 +1100 Subject: [PATCH] Make it clear what the payout is Fixes #557. --- taker-frontend/src/components/History.tsx | 33 ++++++++++++----------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/taker-frontend/src/components/History.tsx b/taker-frontend/src/components/History.tsx index 7261984..18207a6 100644 --- a/taker-frontend/src/components/History.tsx +++ b/taker-frontend/src/components/History.tsx @@ -66,9 +66,12 @@ const CfdDetails = ({ cfd }: CfdDetailsProps) => { const quantity = `$${cfd.quantity_usd}`; const margin = `₿${Math.round((cfd.margin) * 1_000_000) / 1_000_000}`; const liquidationPrice = `$${cfd.liquidation_price}`; - const pAndL = Math.round((cfd.profit_btc) * 1_000_000) / 1_000_000; + + const pAndLNumber = Math.round((cfd.profit_btc) * 1_000_000) / 1_000_000; + const pAndL = pAndLNumber < 0 ? `-₿${Math.abs(pAndLNumber)}` : `₿${Math.abs(pAndLNumber)}`; + const expiry = cfd.expiry_timestamp; - const profit = Math.round((cfd.margin + cfd.profit_btc) * 1_000_000) / 1_000_000; + const payout = `₿${Math.round((cfd.margin + cfd.profit_btc) * 1_000_000) / 1_000_000}`; const txLock = cfd.details.tx_url_list.find((tx) => tx.label === TxLabel.Lock); const txCommit = cfd.details.tx_url_list.find((tx) => tx.label === TxLabel.Commit); @@ -82,36 +85,41 @@ const CfdDetails = ({ cfd }: CfdDetailsProps) => { || !(cfd.state.key === StateKey.OPEN); return ( - -
+ +
- + {/*TODO: Fix textAlign right hacks by using a grid instead ... */} + - + - + - + - + + + + +
Quantity{quantity}{quantity}
Opening price{initialPrice}{initialPrice}
Liquidation{liquidationPrice}{liquidationPrice}
Margin{margin}{margin}
Unrealized P/L{pAndL.toString()}{pAndL}
Payout{payout}
{cfd.state.getLabel()} - + Lock @@ -149,11 +157,6 @@ const CfdDetails = ({ cfd }: CfdDetailsProps) => { } - - - At the current rate you would receive ₿ {profit} - -