diff --git a/src/components/ui/CurrencyDisplay.vue b/src/components/ui/CurrencyDisplay.vue
index 642b060..556f09e 100644
--- a/src/components/ui/CurrencyDisplay.vue
+++ b/src/components/ui/CurrencyDisplay.vue
@@ -9,19 +9,19 @@
-
{{ currency.gold }}
+
{{ formattedCurrency.gold }}
-
{{ currency.silver }}
+
{{ formattedCurrency.silver }}
-
{{ currency.copper }}
+
{{ formattedCurrency.copper }}
@@ -40,4 +40,14 @@ const currency = computed(() => {
const satoshis = Math.floor(props.balanceMsat / 1000)
return satoshisToEverQuest(satoshis)
})
+
+// Format currency values to always show 2 digits with leading zeros
+const formattedCurrency = computed(() => {
+ return {
+ platinum: currency.value.platinum,
+ gold: currency.value.gold.toString().padStart(2, '0'),
+ silver: currency.value.silver.toString().padStart(2, '0'),
+ copper: currency.value.copper.toString().padStart(2, '0')
+ }
+})
diff --git a/src/lib/utils/currency.ts b/src/lib/utils/currency.ts
index b889ec2..89b0a76 100644
--- a/src/lib/utils/currency.ts
+++ b/src/lib/utils/currency.ts
@@ -43,20 +43,20 @@ export function formatEverQuestCurrency(currency: EverQuestCurrency): string {
}
if (currency.gold > 0) {
- parts.push(`${currency.gold}g`)
+ parts.push(`${currency.gold.toString().padStart(2, '0')}g`)
}
if (currency.silver > 0) {
- parts.push(`${currency.silver}s`)
+ parts.push(`${currency.silver.toString().padStart(2, '0')}s`)
}
if (currency.copper > 0) {
- parts.push(`${currency.copper}c`)
+ parts.push(`${currency.copper.toString().padStart(2, '0')}c`)
}
// If no currency, show 0c
if (parts.length === 0) {
- return '0c'
+ return '00c'
}
return parts.join(' ')