mirror of
https://github.com/hay-kot/homebox.git
synced 2025-07-08 11:38:36 +00:00
feat: user defined currencies (#700)
* basic currency service for loading at runtime
* api endpoint for currencies
* sort slice before return
* remove currency validation
* validate using currency service
* implement selecting dynamic currency options
* bump go version
* fix type definition
* specify explicit type
* change go versions
* proper types for assetId
* log/return currency error
* make case insensative
* use ToUpper instead
* feat: adding new currencies (#715)
* fix: task swag (#710)
Co-authored-by: Quoing <pavel.cadersky@mavenir.com>
* [feat] Adding new currencies
---------
Co-authored-by: quoing <quoing@users.noreply.github.com>
Co-authored-by: Quoing <pavel.cadersky@mavenir.com>
Co-authored-by: Bradley <41597815+userbradley@users.noreply.github.com>
* remove ts file and consoldate new values into json
* move flag to options namespace
* add env config for currencies
* basic documentaion
* remove in sync test
---------
Co-authored-by: quoing <quoing@users.noreply.github.com>
Co-authored-by: Quoing <pavel.cadersky@mavenir.com>
Co-authored-by: Bradley <41597815+userbradley@users.noreply.github.com>
Former-commit-id: c4b923847a
This commit is contained in:
parent
ce923a5b4c
commit
2b79788fbe
39 changed files with 1226 additions and 328 deletions
|
@ -2,7 +2,6 @@ import { faker } from "@faker-js/faker";
|
|||
import { describe, test, expect } from "vitest";
|
||||
import { factories } from "../factories";
|
||||
import { sharedUserClient } from "../test-utils";
|
||||
import { currencies } from "~~/lib/data/currency";
|
||||
|
||||
describe("first time user workflow (register, login, join group)", () => {
|
||||
test("user should be able to update group", async () => {
|
||||
|
@ -29,20 +28,6 @@ describe("first time user workflow (register, login, join group)", () => {
|
|||
expect(group.currency).toBe("USD");
|
||||
});
|
||||
|
||||
test("currencies should be in sync with backend", async () => {
|
||||
const { client } = await factories.client.singleUse();
|
||||
|
||||
for (const currency of currencies) {
|
||||
const { response, data: group } = await client.group.update({
|
||||
name: faker.person.firstName(),
|
||||
currency: currency.code,
|
||||
});
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(group.currency).toBe(currency.code);
|
||||
}
|
||||
});
|
||||
|
||||
test("user should be able to join create join token and have user signup", async () => {
|
||||
const api = factories.client.public();
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import { sharedUserClient } from "../test-utils";
|
|||
describe("user should be able to create an item and add an attachment", () => {
|
||||
let increment = 0;
|
||||
/**
|
||||
* useLocatio sets up a location resource for testing, and returns a function
|
||||
* useLocation sets up a location resource for testing, and returns a function
|
||||
* that can be used to delete the location from the backend server.
|
||||
*/
|
||||
async function useLocation(api: UserClient): Promise<[LocationOut, () => Promise<void>]> {
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
import { BaseAPI, route } from "../base";
|
||||
import { Group, GroupInvitation, GroupInvitationCreate, GroupUpdate } from "../types/data-contracts";
|
||||
import {
|
||||
CurrenciesCurrency,
|
||||
Group,
|
||||
GroupInvitation,
|
||||
GroupInvitationCreate,
|
||||
GroupUpdate,
|
||||
} from "../types/data-contracts";
|
||||
|
||||
export class GroupApi extends BaseAPI {
|
||||
createInvitation(data: GroupInvitationCreate) {
|
||||
|
@ -21,4 +27,10 @@ export class GroupApi extends BaseAPI {
|
|||
url: route("/groups"),
|
||||
});
|
||||
}
|
||||
|
||||
currencies() {
|
||||
return this.http.get<CurrenciesCurrency[]>({
|
||||
url: route("/currencies"),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { BaseAPI, route } from "./base";
|
||||
import { ApiSummary, LoginForm, TokenResponse, UserRegistration } from "./types/data-contracts";
|
||||
import { APISummary, LoginForm, TokenResponse, UserRegistration } from "./types/data-contracts";
|
||||
|
||||
export type StatusResult = {
|
||||
health: boolean;
|
||||
|
@ -10,7 +10,7 @@ export type StatusResult = {
|
|||
|
||||
export class PublicApi extends BaseAPI {
|
||||
public status() {
|
||||
return this.http.get<ApiSummary>({ url: route("/status") });
|
||||
return this.http.get<APISummary>({ url: route("/status") });
|
||||
}
|
||||
|
||||
public login(username: string, password: string, stayLoggedIn = false) {
|
||||
|
|
|
@ -10,6 +10,13 @@
|
|||
* ---------------------------------------------------------------
|
||||
*/
|
||||
|
||||
export interface CurrenciesCurrency {
|
||||
code: string;
|
||||
local: string;
|
||||
name: string;
|
||||
symbol: string;
|
||||
}
|
||||
|
||||
export interface DocumentOut {
|
||||
id: string;
|
||||
path: string;
|
||||
|
@ -81,7 +88,6 @@ export interface ItemOut {
|
|||
/** @example "0" */
|
||||
assetId: string;
|
||||
attachments: ItemAttachment[];
|
||||
children: ItemSummary[];
|
||||
createdAt: Date | string;
|
||||
description: string;
|
||||
fields: ItemField[];
|
||||
|
@ -141,7 +147,6 @@ export interface ItemSummary {
|
|||
|
||||
export interface ItemUpdate {
|
||||
archived: boolean;
|
||||
/** @example "0" */
|
||||
assetId: string;
|
||||
description: string;
|
||||
fields: ItemField[];
|
||||
|
@ -364,11 +369,7 @@ export interface UserRegistration {
|
|||
token: string;
|
||||
}
|
||||
|
||||
export interface ActionAmountResult {
|
||||
completed: number;
|
||||
}
|
||||
|
||||
export interface ApiSummary {
|
||||
export interface APISummary {
|
||||
allowRegistration: boolean;
|
||||
build: Build;
|
||||
demo: boolean;
|
||||
|
@ -378,6 +379,10 @@ export interface ApiSummary {
|
|||
versions: string[];
|
||||
}
|
||||
|
||||
export interface ActionAmountResult {
|
||||
completed: number;
|
||||
}
|
||||
|
||||
export interface Build {
|
||||
buildTime: string;
|
||||
commit: string;
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
export type Codes =
|
||||
| "AED"
|
||||
| "AUD"
|
||||
| "BGN"
|
||||
| "BRL"
|
||||
| "CAD"
|
||||
| "CHF"
|
||||
| "CZK"
|
||||
| "DKK"
|
||||
| "EUR"
|
||||
| "GBP"
|
||||
| "HKD"
|
||||
| "IDR"
|
||||
| "INR"
|
||||
| "JPY"
|
||||
| "KRW"
|
||||
| "MXN"
|
||||
| "NOK"
|
||||
| "NZD"
|
||||
| "PLN"
|
||||
| "RMB"
|
||||
| "RUB"
|
||||
| "RON"
|
||||
| "SAR"
|
||||
| "SEK"
|
||||
| "SGD"
|
||||
| "THB"
|
||||
| "TRY"
|
||||
| "USD"
|
||||
| "XAG"
|
||||
| "XAU"
|
||||
| "ZAR";
|
||||
|
||||
export type Currency = {
|
||||
code: Codes;
|
||||
local: string;
|
||||
symbol: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
export const currencies: Currency[] = [
|
||||
{ code: "AED", local: "United Arab Emirates", symbol: "د.إ", name: "United Arab Emirates Dirham" },
|
||||
{ code: "AUD", local: "Australia", symbol: "A$", name: "Australian Dollar" },
|
||||
{ code: "BGN", local: "bg-BG", symbol: "lv", name: "Bulgarian lev" },
|
||||
{ code: "BRL", local: "Brazil", symbol: "R$", name: "Brazilian Real" },
|
||||
{ code: "CAD", local: "Canada", symbol: "C$", name: "Canadian Dollar" },
|
||||
{ code: "CHF", local: "Switzerland", symbol: "CHF", name: "Swiss Franc" },
|
||||
{ code: "CZK", local: "cs-CZ", symbol: "Kč", name: "Czech Koruna" },
|
||||
{ code: "DKK", local: "da-DK", symbol: "kr", name: "Danish Krone" },
|
||||
{ code: "EUR", local: "Eurozone", symbol: "€", name: "Euro" },
|
||||
{ code: "GBP", local: "United Kingdom", symbol: "£", name: "British Pound Sterling" },
|
||||
{ code: "HKD", local: "Hong Kong", symbol: "HK$", name: "Hong Kong Dollar" },
|
||||
{ code: "IDR", local: "Indonesia", symbol: "Rp", name: "Indonesian Rupiah" },
|
||||
{ code: "INR", local: "India", symbol: "₹", name: "Indian Rupee" },
|
||||
{ code: "JPY", local: "Japan", symbol: "¥", name: "Japanese Yen" },
|
||||
{ code: "KRW", local: "South Korea", symbol: "₩", name: "South Korean Won" },
|
||||
{ code: "MXN", local: "Mexico", symbol: "Mex$", name: "Mexican Peso" },
|
||||
{ code: "NOK", local: "Norway", symbol: "kr", name: "Norwegian Krone" },
|
||||
{ code: "NZD", local: "New Zealand", symbol: "NZ$", name: "New Zealand Dollar" },
|
||||
{ code: "PLN", local: "Poland", symbol: "zł", name: "Polish Zloty" },
|
||||
{ code: "RMB", local: "zh-CN", symbol: "¥", name: "Chinese Yuan" },
|
||||
{ code: "RON", local: "ro-RO", symbol: "lei", name: "Romanian Leu" },
|
||||
{ code: "RUB", local: "Russia", symbol: "₽", name: "Russian Ruble" },
|
||||
{ code: "SAR", local: "Saudi Arabia", symbol: "﷼", name: "Saudi Riyal" },
|
||||
{ code: "SEK", local: "Sweden", symbol: "kr", name: "Swedish Krona" },
|
||||
{ code: "SGD", local: "Singapore", symbol: "S$", name: "Singapore Dollar" },
|
||||
{ code: "THB", local: "Thailand", symbol: "฿", name: "Thai Baht" },
|
||||
{ code: "TRY", local: "Turkey", symbol: "₺", name: "Turkish Lira" },
|
||||
{ code: "USD", local: "United States", symbol: "$", name: "United States Dollar" },
|
||||
{ code: "XAG", local: "Global", symbol: "XAG", name: "Silver Troy Ounce" },
|
||||
{ code: "XAU", local: "Global", symbol: "XAU", name: "Gold Troy Ounce" },
|
||||
{ code: "ZAR", local: "South Africa", symbol: "R", name: "South African Rand" },
|
||||
];
|
Loading…
Add table
Add a link
Reference in a new issue