Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

feat: add INR currency and sort currencies (#141)

Hayden976f68252dcc
diff --git a/backend/internal/data/ent/group/group.go b/backend/internal/data/ent/group/group.go
index c90a04c7..a0269b49 100644
--- a/backend/internal/data/ent/group/group.go
+++ b/backend/internal/data/ent/group/group.go
@@ -129,6 +129,7 @@ const (
CurrencyNok Currency = "nok"
CurrencySek Currency = "sek"
CurrencyDkk Currency = "dkk"
+ CurrencyInr Currency = "inr"
)
func (c Currency) String() string {
@@ -138,7 +139,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:
+ case CurrencyUsd, CurrencyEur, CurrencyGbp, CurrencyJpy, CurrencyZar, CurrencyAud, CurrencyNok, CurrencySek, CurrencyDkk, CurrencyInr:
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 fbaeb3ad..6fd2d9ec 100644
--- a/backend/internal/data/ent/migrate/schema.go
+++ b/backend/internal/data/ent/migrate/schema.go
@@ -127,7 +127,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"}, Default: "usd"},
+ {Name: "currency", Type: field.TypeEnum, Enums: []string{"usd", "eur", "gbp", "jpy", "zar", "aud", "nok", "sek", "dkk", "inr"}, 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 49b358c2..c7c70d04 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"),
+ Values("usd", "eur", "gbp", "jpy", "zar", "aud", "nok", "sek", "dkk", "inr"),
}
}
diff --git a/frontend/lib/data/currency.ts b/frontend/lib/data/currency.ts
index ef44ed0c..7cdbca5e 100644
--- a/frontend/lib/data/currency.ts
+++ b/frontend/lib/data/currency.ts
@@ -1,4 +1,4 @@
-export type Codes = "USD" | "EUR" | "GBP" | "JPY" | "ZAR" | "AUD" | "NOK" | "SEK" | "DKK";
+export type Codes = "USD" | "EUR" | "GBP" | "JPY" | "ZAR" | "AUD" | "NOK" | "SEK" | "DKK" | "INR";
export type Currency = {
code: Codes;
@@ -9,10 +9,22 @@ export type Currency = {
export const currencies: Currency[] = [
{
- code: "USD",
- local: "en-US",
+ code: "AUD",
+ local: "en-AU",
symbol: "$",
- name: "US Dollar",
+ name: "Australian Dollar",
+ },
+ {
+ code: "GBP",
+ local: "en-GB",
+ symbol: "£",
+ name: "British Pound",
+ },
+ {
+ code: "DKK",
+ local: "da-DK",
+ symbol: "kr",
+ name: "Danish Krone",
},
{
code: "EUR",
@@ -21,10 +33,10 @@ export const currencies: Currency[] = [
name: "Euro",
},
{
- code: "GBP",
- local: "en-GB",
- symbol: "£",
- name: "British Pound",
+ code: "INR",
+ local: "en-IN",
+ symbol: "₹",
+ name: "Indian Rupee",
},
{
code: "JPY",
@@ -32,24 +44,18 @@ export const currencies: Currency[] = [
symbol: "¥",
name: "Japanese Yen",
},
- {
- code: "ZAR",
- local: "en-ZA",
- symbol: "R",
- name: "South African Rand",
- },
- {
- code: "AUD",
- local: "en-AU",
- symbol: "$",
- name: "Australian Dollar",
- },
{
code: "NOK",
local: "nb-NO",
symbol: "kr",
name: "Norwegian Krone",
},
+ {
+ code: "ZAR",
+ local: "en-ZA",
+ symbol: "R",
+ name: "South African Rand",
+ },
{
code: "SEK",
local: "sv-SE",
@@ -57,9 +63,9 @@ export const currencies: Currency[] = [
name: "Swedish Krona",
},
{
- code: "DKK",
- local: "da-DK",
- symbol: "kr",
- name: "Danish Krone",
+ code: "USD",
+ local: "en-US",
+ symbol: "$",
+ name: "US Dollar",
},
];