Skip to content

Commit 3f7c7ff

Browse files
committed
frontend: align send-to-self tx display with other txs
Keep the first row in BTC/sats and switch the second row to fiat for consistency. Since the sent amount is no longer shown on the right for send-to-self transactions, the left-side label now includes amount to keep it visible.
1 parent 8f63abc commit 3f7c7ff

File tree

5 files changed

+71
-32
lines changed

5 files changed

+71
-32
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Portfolio: reduce waiting time to display the chart
66
- iOS: Add haptic feedback on toggle component
77
- Apply rounded corners in several places and components of the app
8+
- Update send-to-self transactions in the transaction list
89

910
## v4.50.1
1011
- Fix a bug that would delay showing watch-only accounts.

frontends/web/src/components/amount/conversion-amount.tsx

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import { useContext } from 'react';
44
import type { TAmountWithConversions, TTransactionType } from '@/api/account';
55
import { RatesContext } from '@/contexts/RatesContext';
6-
import { Arrow } from '@/components/transactions/components/arrows';
76
import { Amount } from '@/components/amount/amount';
87
import { getTxSign } from '@/utils/transaction';
98
import styles from './conversion-amount.module.css';
@@ -25,33 +24,27 @@ export const ConversionAmount = ({
2524
type,
2625
}: TConversionAmountProps) => {
2726
const { defaultCurrency } = useContext(RatesContext);
28-
const conversion = amount?.conversions && amount?.conversions[defaultCurrency];
2927

3028
const sign = getTxSign(type);
3129
const estimatedPrefix = '\u2248'; // ≈
32-
const sendToSelf = type === 'send_to_self';
3330
const recv = type === 'receive';
34-
const amountToShow = recv || sendToSelf ? amount : deductedAmount;
35-
const conversionUnit = sendToSelf ? amountToShow.unit : defaultCurrency;
31+
const amountToShow = recv ? amount : deductedAmount;
32+
const conversionUnit = defaultCurrency;
33+
const conversion = amountToShow?.conversions && amountToShow?.conversions[defaultCurrency];
3634

37-
// we skip the estimated conversion prefix when the Tx is send to self, or both coin and conversion are in BTC units.
38-
const skipEstimatedPrefix = sendToSelf || (btcUnits.includes(conversionUnit) && btcUnits.includes(amountToShow.unit));
35+
// we skip the estimated conversion prefix when both coin and conversion are in BTC units.
36+
const skipEstimatedPrefix = btcUnits.includes(conversionUnit) && btcUnits.includes(amountToShow.unit);
3937

4038
return (
4139
<span className={styles.txConversionAmount}>
42-
{(conversion || sendToSelf) && amountToShow ? (
40+
{conversion && amountToShow ? (
4341
<>
44-
{sendToSelf && (
45-
<span className={styles.txSmallInlineIcon}>
46-
<Arrow type="send_to_self" />
47-
</span>
48-
)}
4942
{amountToShow.estimated && !skipEstimatedPrefix && (
5043
<span className={styles.txPrefix}>{estimatedPrefix}{' '}</span>
5144
)}
52-
{conversion && conversion !== '0' && !sendToSelf ? sign : null}
45+
{conversion !== '0' ? sign : null}
5346
<Amount
54-
amount={sendToSelf ? amountToShow.amount : conversion || ''}
47+
amount={conversion || ''}
5548
unit={conversionUnit}
5649
/>
5750
<span className={styles.txUnit}>

frontends/web/src/components/transactions/transaction.tsx

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0
22

3-
import { useTranslation } from 'react-i18next';
3+
import { Trans, useTranslation } from 'react-i18next';
44
import type { TAmountWithConversions, TTransactionStatus, TTransactionType, TTransaction } from '@/api/account';
55
import { useMediaQuery } from '@/hooks/mediaquery';
66
import { Loupe } from '@/components/icon/icon';
@@ -44,6 +44,7 @@ export const Transaction = ({
4444
</span>
4545
<Status
4646
addresses={addresses}
47+
amount={amountAtTime}
4748
note={note}
4849
numConfirmations={numConfirmations}
4950
numConfirmationsComplete={numConfirmationsComplete}
@@ -70,6 +71,7 @@ export const Transaction = ({
7071

7172
type TStatus = {
7273
addresses: string[];
74+
amount: TAmountWithConversions;
7375
note?: TTransaction['note'];
7476
numConfirmations: number;
7577
numConfirmationsComplete: number;
@@ -80,6 +82,7 @@ type TStatus = {
8082

8183
const Status = ({
8284
addresses,
85+
amount,
8386
note,
8487
numConfirmations,
8588
numConfirmationsComplete,
@@ -102,6 +105,7 @@ const Status = ({
102105
) : (
103106
<Addresses
104107
addresses={addresses}
108+
amount={amount}
105109
status={status}
106110
type={type}
107111
/>
@@ -151,10 +155,13 @@ const Amounts = ({
151155
const displayAmount = recv ? amount : deductedAmount;
152156

153157
return (
154-
<span className={`
158+
<span
159+
className={`
155160
${styles.txAmountsColumn || ''}
156161
${styles[txTypeClass] || ''}
157-
`}>
162+
`}
163+
data-testid="tx-amounts"
164+
>
158165
<span className={styles.txAmount}>
159166
{displayAmount.amount !== '0' && getTxSign(type)}
160167
<AmountWithUnit
@@ -171,6 +178,22 @@ type TDateProps = {
171178
time: string | null;
172179
};
173180

181+
type TAddressListProps = {
182+
values: string[];
183+
};
184+
185+
const AddressList = ({ values }: TAddressListProps) => (
186+
<span className={styles.addresses}>
187+
{values[0]}
188+
{values.length > 1 && (
189+
<span>
190+
{' '}
191+
(+{values.length - 1})
192+
</span>
193+
)}
194+
</span>
195+
);
196+
174197
const Date = ({
175198
time,
176199
}: TDateProps) => {
@@ -192,39 +215,55 @@ const Date = ({
192215

193216
type TAddresses = {
194217
addresses: TTransaction['addresses'];
218+
amount: TAmountWithConversions;
195219
status: TTransactionStatus;
196220
type: TTransactionType;
197221
};
198222

199223
const Addresses = ({
200224
addresses,
225+
amount,
201226
status,
202227
type,
203228
}: TAddresses) => {
204229
const { t } = useTranslation();
205230
const isMobile = useMediaQuery('(max-width: 768px)');
231+
232+
if (type === 'send_to_self') {
233+
const labelKey = `transaction.tx.send_to_self_${status}`;
234+
return (
235+
<span className={styles.txNoteWithAddress}>
236+
<span className={styles.txType}>
237+
<Trans
238+
i18nKey={labelKey}
239+
components={[
240+
<AmountWithUnit
241+
amount={amount}
242+
unitClassName={styles.txUnit}
243+
/>
244+
]}
245+
/>
246+
</span>
247+
{' '}
248+
<AddressList values={addresses} />
249+
</span>
250+
);
251+
}
252+
206253
const label = isMobile
207254
? (type === 'receive' ? t('generic.received') : t('generic.sent'))
208255
: (type === 'receive'
209256
? t('transaction.tx.receive', { context: status })
210257
: t('transaction.tx.send', { context: status })
211-
// send_to_self will currently show the send message
212258
);
213259

214260
return (
215261
<span className={styles.txNoteWithAddress}>
216262
<span className={styles.txType}>
217263
{label}
218264
</span>
219-
<span className={styles.addresses}>
220-
{addresses[0]}
221-
{addresses.length > 1 && (
222-
<span>
223-
{' '}
224-
(+{addresses.length - 1})
225-
</span>
226-
)}
227-
</span>
265+
{' '}
266+
<AddressList values={addresses} />
228267
</span>
229268
);
230269
};

frontends/web/src/locales/en/app.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1961,7 +1961,10 @@
19611961
"receive_pending": "Received to",
19621962
"send_complete": "Sent to",
19631963
"send_failed": "Failed sending to",
1964-
"send_pending": "Sent to"
1964+
"send_pending": "Sent to",
1965+
"send_to_self_complete": "Sent <0></0> to self",
1966+
"send_to_self_failed": "Failed sending <0></0> to self",
1967+
"send_to_self_pending": "Sent <0></0> to self"
19651968
},
19661969
"vsize": "Virtual size",
19671970
"weight": "Weight"

frontends/web/tests/send.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,14 @@ test('Send BTC', async ({ page, host, frontendPort, servewalletPort }, testInfo)
193193
await page.getByTestId('close-button').click();
194194

195195
// Verify that the values displayed are correctly
196-
const shownDetractedAmount = await newTx.getByTestId('amountBlocks').nth(0).textContent();
197-
const shownSentToSelfAmount = await newTx.getByTestId('amountBlocks').nth(1).textContent();
196+
const labelAmount = await newTx
197+
.getByTestId('amountBlocks').first()
198+
.textContent();
199+
const amountsColumn = newTx.getByTestId('tx-amounts');
200+
const shownDetractedAmount = await amountsColumn.getByTestId('amountBlocks').nth(0).textContent();
198201

202+
expect(labelAmount).toBe(amount);
199203
expect(shownDetractedAmount).toBe(fee);
200-
expect(shownSentToSelfAmount).toBe(amount);
201204

202205
});
203206

0 commit comments

Comments
 (0)