From 92cb1657341aed920aab789888550840b29698a0 Mon Sep 17 00:00:00 2001 From: Dmytro Svyrydenko Date: Thu, 8 Aug 2024 19:38:25 +0200 Subject: [PATCH] feat: Allow to create accounts with specific category --- src/api/accounts.ts | 10 ++--- .../const/account-categories-verbose.ts | 2 +- .../components/account-field.vue | 13 ++++++- .../fields/components/field-label.vue | 39 +++++-------------- src/components/forms/create-account-form.vue | 29 +++++++++++++- .../components/account-details-tab.vue | 10 ++++- .../investment-account/investment-account.vue | 4 +- src/stores/accounts.ts | 23 ++++------- 8 files changed, 68 insertions(+), 62 deletions(-) diff --git a/src/api/accounts.ts b/src/api/accounts.ts index 42c11bbd..8d907db2 100644 --- a/src/api/accounts.ts +++ b/src/api/accounts.ts @@ -1,4 +1,4 @@ -import { ACCOUNT_CATEGORIES, AccountModel, endpointsTypes } from "shared-types"; +import { AccountModel, endpointsTypes } from "shared-types"; import { api } from "@/api/_api"; import { fromSystemAmount, toSystemAmount } from "@/api/helpers"; @@ -19,18 +19,14 @@ export const loadAccounts = async (): Promise => { }; export const createAccount = async ( - payload: Omit, + payload: endpointsTypes.CreateAccountBody, ): Promise => { const params = payload; if (params.creditLimit) params.creditLimit = toSystemAmount(Number(params.creditLimit)); if (params.initialBalance) params.initialBalance = toSystemAmount(Number(params.initialBalance)); - const result = await api.post("/accounts", { - ...params, - // For now we just doesn't allow users to select account category on UI - accountCategory: ACCOUNT_CATEGORIES.general, - }); + const result = await api.post("/accounts", params); return result; }; diff --git a/src/common/const/account-categories-verbose.ts b/src/common/const/account-categories-verbose.ts index 4581523c..a2f3d98a 100644 --- a/src/common/const/account-categories-verbose.ts +++ b/src/common/const/account-categories-verbose.ts @@ -13,4 +13,4 @@ export const ACCOUNT_CATEGORIES_VERBOSE = Object.freeze({ [ACCOUNT_CATEGORIES.mortgage]: "Mortgage", [ACCOUNT_CATEGORIES.overdraft]: "Overdraft", [ACCOUNT_CATEGORIES.crypto]: "Crypto", -}); +}) as Record; diff --git a/src/components/dialogs/manage-transaction/components/account-field.vue b/src/components/dialogs/manage-transaction/components/account-field.vue index 7d18e05a..f41f7286 100644 --- a/src/components/dialogs/manage-transaction/components/account-field.vue +++ b/src/components/dialogs/manage-transaction/components/account-field.vue @@ -52,7 +52,12 @@