From dc08dbbd7a7145195b183c315dc4a36d49747911 Mon Sep 17 00:00:00 2001 From: Vitalij Dovhanyc <45185420+vdovhanych@users.noreply.github.com> Date: Tue, 21 Mar 2023 03:42:11 +0100 Subject: [PATCH] feat: add czech currency (#323) --- 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 527737c..97a425a 100644 --- a/backend/internal/data/ent/group/group.go +++ b/backend/internal/data/ent/group/group.go @@ -145,6 +145,7 @@ const ( CurrencyPln Currency = "pln" CurrencyTry Currency = "try" CurrencyRon Currency = "ron" + CurrencyCzk Currency = "czk" ) func (c Currency) String() string { @@ -154,7 +155,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: + case CurrencyUsd, CurrencyEur, CurrencyGbp, CurrencyJpy, CurrencyZar, CurrencyAud, CurrencyNok, 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 63f734e..8d57b5c 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"}, Default: "usd"}, + {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"}, } // 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 40c4143..ce40726 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"), + Values("usd", "eur", "gbp", "jpy", "zar", "aud", "nok", "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 f76b04a..eeedcdd 100644 --- a/frontend/lib/data/currency.ts +++ b/frontend/lib/data/currency.ts @@ -2,6 +2,7 @@ export type Codes = | "AUD" | "BGN" | "CHF" + | "CZK" | "DKK" | "EUR" | "GBP" @@ -120,4 +121,10 @@ export const currencies: Currency[] = [ symbol: "chf", name: "Swiss Francs", }, + { + code: "CZK", + local: "cs-CZ", + symbol: "Kč", + name: "Czech Koruna", + }, ];