From 8b0d40b16d725d80e6e91ee3c2f5fdd888022408 Mon Sep 17 00:00:00 2001 From: Ulises M Date: Thu, 7 Dec 2023 19:31:19 -0600 Subject: [PATCH] Makes `prettify-balance` more flexible --- src/quo/components/wallet/account_card/view.cljs | 4 ++-- src/status_im2/contexts/wallet/common/utils.cljs | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/quo/components/wallet/account_card/view.cljs b/src/quo/components/wallet/account_card/view.cljs index 7f86daa5aa3..d15b2e1b254 100644 --- a/src/quo/components/wallet/account_card/view.cljs +++ b/src/quo/components/wallet/account_card/view.cljs @@ -93,7 +93,7 @@ :end {:x 1 :y 0}}]) (defn- user-account - [] + [_] (let [pressed? (reagent/atom false) on-press-in #(reset! pressed? true) on-press-out #(reset! pressed? false)] @@ -147,7 +147,7 @@ [gradient-overview theme customization-color])]))))) (defn- add-account-view - [] + [_] (let [pressed? (reagent/atom false)] (fn [{:keys [on-press customization-color theme metrics?]}] [rn/pressable diff --git a/src/status_im2/contexts/wallet/common/utils.cljs b/src/status_im2/contexts/wallet/common/utils.cljs index 628468ef4f7..9d0070fbeeb 100644 --- a/src/status_im2/contexts/wallet/common/utils.cljs +++ b/src/status_im2/contexts/wallet/common/utils.cljs @@ -10,7 +10,12 @@ (defn prettify-balance [balance] - (str "$" (.toFixed (if (number? balance) balance 0) 2))) + (let [valid-balance? (and balance + (or (number? balance) (.-toFixed balance)))] + (as-> balance $ + (if valid-balance? $ 0) + (.toFixed $ 2) + (str "$" $)))) (defn get-derivation-path [number-of-accounts]