From 2d768e2b9c005e1a1decd89b50789019bedae3eb Mon Sep 17 00:00:00 2001 From: zodac Date: Thu, 23 Mar 2023 17:26:51 +1300 Subject: [PATCH] feat Adding NZD currency (#360) * Adding NZD as currency option * Updating frontend * Sorting alphabetically * Fixing typo --- backend/internal/data/ent/group/group.go | 3 ++- backend/internal/data/ent/migrate/schema.go | 2 +- backend/internal/data/ent/schema/group.go | 2 +- frontend/lib/data/currency.ts | 7 +++++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/backend/internal/data/ent/group/group.go b/backend/internal/data/ent/group/group.go index 97a425a..835bd96 100644 --- a/backend/internal/data/ent/group/group.go +++ b/backend/internal/data/ent/group/group.go @@ -136,6 +136,7 @@ const ( CurrencyZar Currency = "zar" CurrencyAud Currency = "aud" CurrencyNok Currency = "nok" + CurrencyNzd Currency = "nzd" CurrencySek Currency = "sek" CurrencyDkk Currency = "dkk" CurrencyInr Currency = "inr" @@ -155,7 +156,7 @@ func (c Currency) String() string { // CurrencyValidator is a validator for the "currency" field enum values. It is called by the builders before save. func CurrencyValidator(c Currency) error { switch c { - case CurrencyUsd, CurrencyEur, CurrencyGbp, CurrencyJpy, CurrencyZar, CurrencyAud, CurrencyNok, CurrencySek, CurrencyDkk, CurrencyInr, CurrencyRmb, CurrencyBgn, CurrencyChf, CurrencyPln, CurrencyTry, CurrencyRon, CurrencyCzk: + case CurrencyUsd, CurrencyEur, CurrencyGbp, CurrencyJpy, CurrencyZar, CurrencyAud, CurrencyNok, CurrencyNzd, CurrencySek, CurrencyDkk, CurrencyInr, CurrencyRmb, CurrencyBgn, CurrencyChf, CurrencyPln, CurrencyTry, CurrencyRon, CurrencyCzk: return nil default: return fmt.Errorf("group: invalid enum value for currency field: %q", c) diff --git a/backend/internal/data/ent/migrate/schema.go b/backend/internal/data/ent/migrate/schema.go index 8d57b5c..0d11507 100644 --- a/backend/internal/data/ent/migrate/schema.go +++ b/backend/internal/data/ent/migrate/schema.go @@ -116,7 +116,7 @@ var ( {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "name", Type: field.TypeString, Size: 255}, - {Name: "currency", Type: field.TypeEnum, Enums: []string{"usd", "eur", "gbp", "jpy", "zar", "aud", "nok", "sek", "dkk", "inr", "rmb", "bgn", "chf", "pln", "try", "ron", "czk"}, Default: "usd"}, + {Name: "currency", Type: field.TypeEnum, Enums: []string{"usd", "eur", "gbp", "jpy", "zar", "aud", "nok", "nzd", "sek", "dkk", "inr", "rmb", "bgn", "chf", "pln", "try", "ron", "czk"}, Default: "usd"}, } // GroupsTable holds the schema information for the "groups" table. GroupsTable = &schema.Table{ diff --git a/backend/internal/data/ent/schema/group.go b/backend/internal/data/ent/schema/group.go index ce40726..0d143a3 100644 --- a/backend/internal/data/ent/schema/group.go +++ b/backend/internal/data/ent/schema/group.go @@ -29,7 +29,7 @@ func (Group) Fields() []ent.Field { NotEmpty(), field.Enum("currency"). Default("usd"). - Values("usd", "eur", "gbp", "jpy", "zar", "aud", "nok", "sek", "dkk", "inr", "rmb", "bgn", "chf", "pln", "try", "ron", "czk"), + Values("usd", "eur", "gbp", "jpy", "zar", "aud", "nok", "nzd", "sek", "dkk", "inr", "rmb", "bgn", "chf", "pln", "try", "ron", "czk"), } } diff --git a/frontend/lib/data/currency.ts b/frontend/lib/data/currency.ts index eeedcdd..90b56fb 100644 --- a/frontend/lib/data/currency.ts +++ b/frontend/lib/data/currency.ts @@ -9,6 +9,7 @@ export type Codes = | "INR" | "JPY" | "NOK" + | "NZD" | "PLN" | "RMB" | "RON" @@ -73,6 +74,12 @@ export const currencies: Currency[] = [ symbol: "kr", name: "Norwegian Krone", }, + { + code: "NZD", + local: "en-NZ", + symbol: "NZ$", + name: "New Zealand Dollar", + }, { code: "PLN", local: "pl-PL",