From 5fe5fac4d44093d1880af9807d119663ea08edf8 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Sun, 25 Feb 2024 15:16:15 -0600 Subject: [PATCH] fix missing currencies and profile errors --- .../internal/core/currencies/currencies.go | 23 +++++++++++-------- .../internal/core/currencies/currencies.json | 6 +++++ frontend/pages/profile.vue | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/backend/internal/core/currencies/currencies.go b/backend/internal/core/currencies/currencies.go index b6a12c0..4cc8766 100644 --- a/backend/internal/core/currencies/currencies.go +++ b/backend/internal/core/currencies/currencies.go @@ -74,18 +74,23 @@ func (cs *CurrencyRegistry) Slice() []Currency { cs.mu.RLock() defer cs.mu.RUnlock() - keys := make([]string, 0, len(cs.registry)) - for key := range cs.registry { - keys = append(keys, key) - } - - slices.Sort(keys) - out := make([]Currency, 0, len(cs.registry)) - for i := range keys { - out = append(out, cs.registry[keys[i]]) + for key := range cs.registry { + out = append(out, cs.registry[key]) } + slices.SortFunc(out, func(a, b Currency) int { + if a.Name < b.Name { + return -1 + } + + if a.Name > b.Name { + return 1 + } + + return 0 + }) + return out } diff --git a/backend/internal/core/currencies/currencies.json b/backend/internal/core/currencies/currencies.json index ffd39b4..f6c6c75 100644 --- a/backend/internal/core/currencies/currencies.json +++ b/backend/internal/core/currencies/currencies.json @@ -1,4 +1,10 @@ [ + { + "code": "USD", + "local": "United States", + "symbol": "$", + "name": "United States Dollar" + }, { "code": "AED", "local": "United Arab Emirates", diff --git a/frontend/pages/profile.vue b/frontend/pages/profile.vue index fffdf12..cf03995 100644 --- a/frontend/pages/profile.vue +++ b/frontend/pages/profile.vue @@ -420,7 +420,7 @@ -
Example: {{ currencyExample }}