A continuation of HomeBox the inventory and organization system built for the Home User
feat: more-currency-support (#316)
Hayden70297b9d273f
diff --git a/backend/go.sum b/backend/go.sumindex eb146f22..b6b11e77 100644--- a/backend/go.sum+++ b/backend/go.sum@@ -101,8 +101,6 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVgithub.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=-github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=-github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=github.com/swaggo/files v1.0.0 h1:1gGXVIeUFCS/dta17rnP0iOpr6CXFwKD7EO5ID233e4=diff --git a/backend/internal/data/ent/group/group.go b/backend/internal/data/ent/group/group.goindex c527707f..284e1206 100644--- a/backend/internal/data/ent/group/group.go+++ b/backend/internal/data/ent/group/group.go@@ -133,6 +133,9 @@ const (CurrencyRmb Currency = "rmb"CurrencyBgn Currency = "bgn"CurrencyChf Currency = "chf"+ CurrencyPln Currency = "pln"+ CurrencyTry Currency = "try"+ CurrencyRon Currency = "ron")func (c Currency) String() string {@@ -142,7 +145,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:+ case CurrencyUsd, CurrencyEur, CurrencyGbp, CurrencyJpy, CurrencyZar, CurrencyAud, CurrencyNok, CurrencySek, CurrencyDkk, CurrencyInr, CurrencyRmb, CurrencyBgn, CurrencyChf, CurrencyPln, CurrencyTry, CurrencyRon:return nildefault: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.goindex ed66810b..df67cbf7 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"}, 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"}, 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.goindex 054f8184..db5dd545 100644--- a/backend/internal/data/ent/schema/group.go+++ b/backend/internal/data/ent/schema/group.go@@ -27,7 +27,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"),+ Values("usd", "eur", "gbp", "jpy", "zar", "aud", "nok", "sek", "dkk", "inr", "rmb", "bgn", "chf", "pln", "try", "ron"),}}diff --git a/frontend/lib/data/currency.ts b/frontend/lib/data/currency.tsindex a0bda226..f76b04ad 100644--- a/frontend/lib/data/currency.ts+++ b/frontend/lib/data/currency.ts@@ -1,17 +1,20 @@export type Codes =- | "USD"+ | "AUD"+ | "BGN"+ | "CHF"+ | "DKK"| "EUR"| "GBP"+ | "INR"| "JPY"- | "ZAR"- | "AUD"| "NOK"- | "SEK"- | "DKK"- | "INR"+ | "PLN"| "RMB"- | "BGN"- | "CHF";+ | "RON"+ | "SEK"+ | "TRY"+ | "USD"+ | "ZAR";export type Currency = {code: Codes;@@ -69,6 +72,18 @@ export const currencies: Currency[] = [symbol: "kr",name: "Norwegian Krone",},+ {+ code: "PLN",+ local: "pl-PL",+ symbol: "zł",+ name: "Polish Zloty",+ },+ {+ code: "RON",+ local: "ro-RO",+ symbol: "lei",+ name: "Romanian Leu",+ },{code: "ZAR",local: "en-ZA",@@ -81,6 +96,12 @@ export const currencies: Currency[] = [symbol: "kr",name: "Swedish Krona",},+ {+ code: "TRY",+ local: "tr-TR",+ symbol: "₺",+ name: "Turkish Lira",+ },{code: "USD",local: "en-US",