Skip to content

Commit

Permalink
revert formatCurrency in uiStore (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc authored Aug 16, 2024
1 parent 217f083 commit 4158c88
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/stores/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,30 @@ export const useUiStore = defineStore("ui", {
this.tab = tab;
},
formatSat: function (value: number) {
// convert value to integer
return new Intl.NumberFormat(navigator.language).format(value) + " sat";
},
fromMsat: function (value: number) {
return new Intl.NumberFormat(navigator.language).format(value) + " msat";
},
formatCurrency: function (value: number, currency: string, showBalance = false) {
if (currency == undefined) {
currency = "sat";
}
if (useUiStore().hideBalance && !showBalance) {
return "****";
}
if (currency == "sat") return this.formatSat(value);
if (currency == "msat") return this.fromMsat(value);
if (currency == "usd") value = value / 100;
if (currency == "eur") value = value / 100;
return new Intl.NumberFormat(navigator.language, {
style: "currency",
currency: currency,
}).format(value);
// + " " +
// currency.toUpperCase()
},
},
getters: {
tickerShort() {
Expand Down

0 comments on commit 4158c88

Please sign in to comment.