From 33d500b6fc532e24a09cf023fef8c0ed2c632134 Mon Sep 17 00:00:00 2001
From: Alicia Sykes <=>
Date: Sat, 25 Dec 2021 22:15:42 +0000
Subject: [PATCH] :art: Adds method to round price data to apprpriate decimal
---
src/components/Widgets/CryptoWatchList.vue | 17 +++++++++--------
src/utils/MiscHelpers.js | 14 ++++++++++++++
2 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/src/components/Widgets/CryptoWatchList.vue b/src/components/Widgets/CryptoWatchList.vue
index 891721e9..2bf3c635 100644
--- a/src/components/Widgets/CryptoWatchList.vue
+++ b/src/components/Widgets/CryptoWatchList.vue
@@ -9,9 +9,9 @@
>
{{ asset.name }}
-{{ asset.price | currency }}
+{{ asset.price | formatPrice }}
- {{ asset.percentChange | percentage }} + {{ asset.percentChange | formatPercentage }}
@@ -22,7 +22,7 @@ import axios from 'axios'; import WidgetMixin from '@/mixins/WidgetMixin'; import { widgetApiEndpoints } from '@/utils/defaults'; -import { findCurrencySymbol, timestampToDate } from '@/utils/MiscHelpers'; +import { findCurrencySymbol, timestampToDate, roundPrice } from '@/utils/MiscHelpers'; export default { mixins: [WidgetMixin], @@ -68,11 +68,11 @@ export default { }, filters: { /* Append currency symbol to price */ - currency(price) { - return `${findCurrencySymbol('usd')}${price}`; + formatPrice(price) { + return `${findCurrencySymbol('usd')}${roundPrice(price)}`; }, /* Append percentage symbol, and up/ down arrow */ - percentage(change) { + formatPercentage(change) { if (!change) return ''; const symbol = change > 0 ? '↑' : '↓'; return `${symbol} ${change.toFixed(2)}%`; @@ -118,7 +118,7 @@ export default { tooltip(info) { const maxSupply = info.maxSupply ? ` out of max supply of ${info.maxSupply}` : ''; const content = `Rank: ${info.rank} with market cap of ` - + `${this.$options.filters.currency(info.marketCap)}` + + `${this.$options.filters.formatPrice(info.marketCap)}` + `