diff --git a/src/models/Bot.js b/src/models/Bot.js index 10de14d63..14b383c55 100644 --- a/src/models/Bot.js +++ b/src/models/Bot.js @@ -1,4 +1,5 @@ import Vue from 'vue'; +import getCountryCode from '../utils/getCountryCode'; const timeSpanRegex = /(?:(\d+).)?(\d{2}):(\d{2}):(\d{2})(?:.?(\d{7}))?/; @@ -16,6 +17,8 @@ export class Bot { this.steamid = data.s_SteamID; this.avatarHash = data.AvatarHash || '0b46945851b3d26da93a6ddba3ac961206cc191d'; this.bgrCount = data.GamesToRedeemInBackgroundCount; + this.walletBalance = data.WalletBalance; + this.walletCurrency = data.WalletCurrency; this.active = data.KeepRunning; this.config = data.BotConfig; @@ -86,4 +89,12 @@ export class Bot { if (this.status === BotStatus.FARMING && selectedBots.includes('farming')) return true; return false; } + + get walletInfo() { + if (this.walletCurrency === 0) return null; + const currency = this.walletBalance / 100; + const currencyCode = getCountryCode(this.walletCurrency); + if (typeof currencyCode === 'undefined') return null; + return currency.toLocaleString(Vue.i18n.locale, { style: 'currency', currency: currencyCode }); + } } diff --git a/src/utils/getCountryCode.js b/src/utils/getCountryCode.js new file mode 100644 index 000000000..bfc741a9d --- /dev/null +++ b/src/utils/getCountryCode.js @@ -0,0 +1,48 @@ +// Todo: Read ECurrencyCode from api +const codes = { + "Invalid": 0, + "USD": 1, + "GBP": 2, + "EUR": 3, + "CHF": 4, + "RUB": 5, + "PLN": 6, + "BRL": 7, + "JPY": 8, + "NOK": 9, + "IDR": 10, + "MYR": 11, + "PHP": 12, + "SGD": 13, + "THB": 14, + "VND": 15, + "KRW": 16, + "TRY": 17, + "UAH": 18, + "MXN": 19, + "CAD": 20, + "AUD": 21, + "NZD": 22, + "CNY": 23, + "INR": 24, + "CLP": 25, + "PEN": 26, + "COP": 27, + "ZAR": 28, + "HKD": 29, + "TWD": 30, + "SAR": 31, + "AED": 32, + "ARS": 34, + "ILS": 35, + "BYN": 36, + "KZT": 37, + "KWD": 38, + "QAR": 39, + "CRC": 40, + "UYU": 41 +}; + +export default function getCountryCode(id) { + return Object.keys(codes)[id]; +} \ No newline at end of file diff --git a/src/views/modals/Bot.vue b/src/views/modals/Bot.vue index cc0401900..8c08cf0d3 100644 --- a/src/views/modals/Bot.vue +++ b/src/views/modals/Bot.vue @@ -9,12 +9,19 @@