Skip to content

Commit

Permalink
frontend: change transaction info for send-to-self
Browse files Browse the repository at this point in the history
Until now a send-to-self transaction looked more like an outgoing
transaction with the amount sent.

Changed to only show the fee paid as outgoing and the amount of
coin as conversion amount.
  • Loading branch information
thisconnect committed Nov 26, 2024
1 parent 37ab166 commit c635b55
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Unreleased
- Improve send-to-self transactions in account overview

# 4.46.0
- Android: enable export logs feature
Expand Down
2 changes: 1 addition & 1 deletion backend/coins/btc/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ func (handlers *Handlers) getTxInfoJSON(txInfo *accounts.TransactionData, detail
Time: formattedTime,
Addresses: addresses,
Note: handlers.account.TxNote(txInfo.InternalID),
Fee: feeString,
}

if detail {
txInfoJSON.Fee = feeString
switch handlers.account.Coin().(type) {
case *btc.Coin:
txInfoJSON.VSize = txInfo.VSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type { TTransactionStatus, TTransactionType } from '@/api/account';
import { ArrowFloorDownGreen, ArrowUTurn, ArrowFloorUpRed, Warning } from '@/components/icon/icon';

type TProps = {
status: TTransactionStatus;
status?: TTransactionStatus;
type: TTransactionType;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@
font-size: 12px;
}

.txSmallInlineIcon img {
max-height: 15px;
max-width: 15px;
vertical-align: text-bottom;
}
.txConversionAmount .txSmallInlineIcon {
padding-right: var(--space-eight);
}

.txNote {
display: block;
padding: 3px 0;
Expand Down
31 changes: 23 additions & 8 deletions frontends/web/src/components/transactions/transaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ import { getTxSign } from './utils';
import styles from './transaction.module.css';

type TTransactionProps = ITransaction & {
onShowDetail: (internalID: ITransaction['internalID']) => void
onShowDetail: (internalID: ITransaction['internalID']) => void;
}

export const Transaction = ({
addresses,
amountAtTime,
fee,
onShowDetail,
internalID,
note,
Expand Down Expand Up @@ -65,7 +66,11 @@ export const Transaction = ({
time={time}
type={type}
/>
<Amounts amount={amountAtTime} type={type} />
<Amounts
amount={amountAtTime}
fee={fee}
type={type}
/>
<button
className={styles.txShowDetailBtn}
onClick={() => !isMobile && onShowDetail(internalID)}
Expand Down Expand Up @@ -146,48 +151,58 @@ const Status = ({

type TAmountsProps = {
amount: IAmount;
fee: IAmount;
type: TTransactionType;
}

const Amounts = ({
amount,
fee,
type,
}: TAmountsProps) => {
const { defaultCurrency } = useContext(RatesContext);
const conversion = amount?.conversions && amount?.conversions[defaultCurrency];
const sign = getTxSign(type);
const txTypeClass = `txAmount-${type}`;
const conversionPrefix = amount.estimated ? '\u2248' : null; // ≈
const sendToSelf = type === 'send_to_self';
const conversionUnit = sendToSelf ? amount.unit : defaultCurrency;

return (
<span className={`${styles.txAmountsColumn} ${styles[txTypeClass]}`}>
{/* <data value={amount.amount}> */}
<span className={styles.txAmount}>
{sign}
<Amount
amount={amount.amount}
amount={sendToSelf ? fee.amount : amount.amount}
unit={amount.unit}
/>
<span className={styles.txUnit}>
{' '}
{amount.unit}
{sendToSelf ? fee.unit : amount.unit}
</span>
</span>
{/* </data> */}
<span className={styles.txConversionAmount}>
{sendToSelf && (
<span className={styles.txSmallInlineIcon}>
<Arrow type="send_to_self" />
</span>
)}
{conversionPrefix && (
<span className={styles.txPrefix}>
{conversionPrefix}
{' '}
</span>
)}
{conversion && sign}
{conversion && !sendToSelf ? sign : null}
<Amount
amount={conversion || ''}
unit={defaultCurrency}
amount={sendToSelf ? amount.amount : conversion || ''}
unit={conversionUnit}
/>
<span className={styles.txUnit}>
{' '}
{defaultCurrency}
{conversionUnit}
</span>
</span>
</span>
Expand Down
1 change: 1 addition & 0 deletions frontends/web/src/components/transactions/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

export const getTxSign = (type: string) => {
switch (type) {
case 'send_to_self':
case 'send':
return '−';
case 'receive':
Expand Down

0 comments on commit c635b55

Please sign in to comment.