85
85
<v-divider />
86
86
87
87
<TransactionListItem :title =" t('transaction.commission')" >
88
- {{
89
- typeof fee === 'number' ? formatAmount(fee) + ` ${feeCrypto ?? crypto}` : placeholder
90
- }}
88
+ {{ calculatedFee }}
91
89
</TransactionListItem >
92
90
93
91
<v-divider />
@@ -279,7 +277,7 @@ export default defineComponent({
279
277
if (! transaction .value ) return
280
278
281
279
return store .getters [' rate/historyRate' ](
282
- timestampInSec ( props . crypto , transaction . value . timestamp ) ,
280
+ calculatedTimestampInSec . value ,
283
281
transaction .value .amount ,
284
282
props .crypto
285
283
)
@@ -290,6 +288,39 @@ export default defineComponent({
290
288
return store .getters [' rate/rate' ](transaction .value .amount , props .crypto )
291
289
})
292
290
291
+ const calculatedTimestampInSec = computed (() => {
292
+ if (! transaction .value ) {
293
+ return null ;
294
+ }
295
+
296
+ return timestampInSec (props .crypto , transaction .value .timestamp ! )
297
+ })
298
+
299
+ const calculatedFee = computed (() => {
300
+ const commissionTokenLabel = (props .feeCrypto ?? props .crypto ) as CryptoSymbol ;
301
+
302
+ const { cryptoTransferDecimals, decimals } = CryptosInfo [commissionTokenLabel ]
303
+
304
+ const tokenFee = typeof props .fee === ' number'
305
+ ? ` ${formatAmount (props .fee , cryptoTransferDecimals ?? decimals )} ${commissionTokenLabel } `
306
+ : placeholder .value ;
307
+
308
+ if (! props .fee || ! calculatedTimestampInSec .value ) return tokenFee ;
309
+
310
+
311
+ const commissionUsdAmount = store .getters [' rate/historyRate' ](
312
+ calculatedTimestampInSec .value ,
313
+ props .fee ,
314
+ commissionTokenLabel ,
315
+ );
316
+
317
+
318
+ if (! commissionUsdAmount ) return tokenFee ;
319
+
320
+ return tokenFee + ` ~${commissionUsdAmount } ` ;
321
+ });
322
+
323
+
293
324
const handleCopyToClipboard = (text ? : string ) => {
294
325
if (! text ) return
295
326
@@ -318,24 +349,24 @@ export default defineComponent({
318
349
}
319
350
320
351
const getHistoryRates = () => {
321
- if (! transaction .value ) return
352
+ if (! calculatedTimestampInSec .value ) return
322
353
323
354
store .dispatch (' rate/getHistoryRates' , {
324
- timestamp: timestampInSec ( props . crypto , transaction . value . timestamp ! )
355
+ timestamp: calculatedTimestampInSec . value
325
356
})
326
357
}
327
358
328
359
watch (
329
- () => props . transaction ,
360
+ calculatedTimestampInSec ,
330
361
() => {
331
362
getHistoryRates ()
332
363
},
333
364
{ immediate: true }
334
365
)
335
366
336
- const formatAmount = (amount : number ) => {
367
+ const formatAmount = (amount : number , decimals = CryptosInfo [ props . crypto ]. decimals ) => {
337
368
return BigNumber (amount )
338
- .decimalPlaces (CryptosInfo [ props . crypto ]. decimals , BigNumber .ROUND_DOWN )
369
+ .decimalPlaces (decimals , BigNumber .ROUND_DOWN )
339
370
.toFixed ()
340
371
}
341
372
@@ -357,6 +388,7 @@ export default defineComponent({
357
388
statusUpdatable ,
358
389
historyRate ,
359
390
rate ,
391
+ calculatedFee ,
360
392
formatAmount ,
361
393
mdiAlertOutline ,
362
394
mdiChevronRight ,
0 commit comments