Open source personal finance application
improvements: refactor
ilkomea2ddac2fc3f0
diff --git a/components/categories/Form.vue b/components/categories/Form.vueindex 26def1e5..8bf75c5b 100644--- a/components/categories/Form.vue+++ b/components/categories/Form.vue@@ -108,7 +108,7 @@ async function onSave() {const uid = $store.state.user.user.uidconst categoryChildIds = $store.getters['categories/getChildCategoriesIds'](editCategoryId)- const categoryValues = getPreparedFormData(categoryForm.value, categoryChildIds)+ const categoryValues = getPreparedFormData(categoryForm.value)// Update categoryawait saveData(`users/${uid}/categories/${editCategoryId}`, categoryValues)@@ -212,7 +212,6 @@ div//- Parent//---------------------------------template(v-if="activeTab === 'parent'")- pre {{ isAllowChangeParent }}template(v-if="!isAllowChangeParent")//- TODO: translate.p-4 You can not change parent category because edited category has childs categories.diff --git a/components/categories/getCategories.ts b/components/categories/getCategories.tsindex 4bffa4a5..2baaa144 100644--- a/components/categories/getCategories.ts+++ b/components/categories/getCategories.ts@@ -1,6 +1,5 @@import type { CategoryID, CategoryItem } from '~/components/categories/types'-// TODO: need a proper name, maybe getTransactibleCategoriesIdsexport function getTransactibleCategoriesIds(catsIds: CategoryID[],categoriesItems: Record<CategoryID, CategoryItem>,diff --git a/components/categories/getForm.ts b/components/categories/getForm.tsindex 117a21f4..2c3da170 100644--- a/components/categories/getForm.ts+++ b/components/categories/getForm.ts@@ -1,9 +1,9 @@import icons from '~/assets/js/icons'-import type { CategoryForm, CategoryID } from '~/components/categories/types'+import type { CategoryForm } from '~/components/categories/types'import { allColors } from '~/assets/js/colors'import { random } from '~/assets/js/emo'-export function getPreparedFormData(values?: any, childIds?: CategoryID[]): CategoryForm {+export function getPreparedFormData(values?: any): CategoryForm {return {color: values?.color ?? random(allColors),icon: values?.icon ?? random(random(icons)),@@ -13,6 +13,5 @@ export function getPreparedFormData(values?: any, childIds?: CategoryID[]): CateshowInLastUsed: values?.showInLastUsed ?? true,showInQuickSelector: values?.showInQuickSelector ?? false,showStat: values?.showStat ?? true,- childIds: childIds ?? false,}}diff --git a/components/categories/types.ts b/components/categories/types.tsindex 513d63ea..deb2dd24 100644--- a/components/categories/types.ts+++ b/components/categories/types.ts@@ -21,5 +21,4 @@ export interface CategoryForm {showInLastUsed: booleanshowInQuickSelector: booleanshowStat: boolean- childIds: string[] | false}diff --git a/components/stat/Date.vue b/components/stat/Date.vueindex 2cd39f56..623445f2 100644--- a/components/stat/Date.vue+++ b/components/stat/Date.vue@@ -5,10 +5,10 @@ const isShowDateSelector = ref(false)<template lang="pug">.z-10.hocus_bg-skin-item-main-hover//- Date- .cursor-pointer.px-3.flex.items-center.text-lg(+ .cursor-pointer.px-2.flex.items-center.text-lg(@click="isShowDateSelector = true")- .py-3.font-nunito.text-neutral-800.dark_text-white.text-xl.lg_text-2xl.leading-none.font-semibold+ .py-3.text-skin-item-base-up.font-semibold.font-nunito.leading-noneSharedDate(:date="$store.state.filter.date":period="$store.state.filter.period"diff --git a/components/stat/View.vue b/components/stat/View.vueindex 0f1a488e..61b0a531 100644--- a/components/stat/View.vue+++ b/components/stat/View.vue@@ -116,11 +116,11 @@ onDeactivated(async () => {template(v-if="isMobileView").my-6.px-2(v-if="statPage.activeTab === 'details'")StatViewConfig- StatSumTotal+ StatSumTotal(v-if="(statPage.average.income !== 0 && statPage.average.expense !== 0) || (statPage.current.income.total !== 0 && statPage.current.expense.total !== 0)")//- Loop throw income / expense.mb-8.md_mb-4.px-2- .grid.grid-cols-1.gap-y-5(class="md_grid-cols-2 md_gap-x-20")+ .grid.grid-cols-1.gap-y-5.md_grid-cols-2.md_gap-x-20div(v-for="item in moneyTypes"v-show="isShowGroup(item.id)"diff --git a/components/stat/sum/Group.vue b/components/stat/sum/Group.vueindex 72caaef9..f1997103 100644--- a/components/stat/sum/Group.vue+++ b/components/stat/sum/Group.vue@@ -12,7 +12,7 @@ const typeNumber = computed(() => moneyTypes.find(t => t.id === `${props.typeTex</script><template lang="pug">-.my-4.px-2.bg-white.dark_bg-dark3+.my-4.px-1.bg-white.dark_bg-dark3.pb-2.text-lg.leading-none.font-nunito.font-semibold.text-skin-item-base {{ $t(`money.${typeText}`) }}.overflow-hidden.overflow-x-auto.scrollbar.flex.items-centerdiff --git a/components/stat/sum/Total.vue b/components/stat/sum/Total.vueindex dc8e7b88..3c65ff71 100644--- a/components/stat/sum/Total.vue+++ b/components/stat/sum/Total.vue@@ -5,7 +5,7 @@ const statAverage = computed(() => $store.getters['stat/statAverage'])</script><template lang="pug">-.my-4.px-2.bg-white.dark_bg-dark3+.my-4.px-1.bg-white.dark_bg-dark3.pb-2.text-lg.leading-none.font-nunito.font-semibold.text-skin-item-base {{ $t('money.total') }}.overflow-hidden.overflow-x-auto.scrollbar.flex.items-centerdiff --git a/components/trnForm/Index.vue b/components/trnForm/Index.vueindex 9bbbc382..c3283140 100644--- a/components/trnForm/Index.vue+++ b/components/trnForm/Index.vue@@ -234,7 +234,7 @@ function handleSubmitForm() {.scroll.scrollerBlock//- Wallets.pt-5.pb-7- .px-3.pb-2.text-sm.font-medium(+ .px-3.pb-2.text-skin-item-base.text-sm.font-semibold.font-nunito(@click="$store.commit('trnForm/showTrnFormModal', 'wallets')") {{ $t('wallets.title') }}@@ -272,7 +272,7 @@ function handleSubmitForm() {//- Favorite categories.pb-7(v-if="$store.getters['categories/favoriteCategoriesIds'].length > 0")- .px-3.pb-2.text-sm.font-medium(+ .px-3.pb-2.text-skin-item-base.text-sm.font-semibold.font-nunito(@click="$store.commit('trnForm/showTrnFormModal', 'categories')") {{ $t('categories.favoriteTitle') }} {{ $t('categories.title') }}@@ -288,7 +288,7 @@ function handleSubmitForm() {//- Recent categories.pb-7(v-if="$store.getters['categories/recentCategoriesIds'].length > 0")- .px-3.pb-2.text-sm.font-medium(+ .px-3.pb-2.text-skin-item-base.text-sm.font-semibold.font-nunito(@click="$store.commit('trnForm/showTrnFormModal', 'categories')") {{ $t('categories.lastUsedTitle') }} {{ $t('categories.title') }}diff --git a/components/ui/HeaderTitle.vue b/components/ui/HeaderTitle.vueindex ea7875be..ca9fb685 100644--- a/components/ui/HeaderTitle.vue+++ b/components/ui/HeaderTitle.vue@@ -3,6 +3,6 @@</script><template lang="pug">-.grow.py-1.px-2.font-nunito.text-neutral-800.dark_text-white.text-xl.leading-none.font-semibold+.grow.py-1.px-2.text-skin-item-base-up.font-semibold.font-nunito.leading-noneslot</template>diff --git a/store/trnForm/actions.js b/store/trnForm/actions.jsindex 186abf9b..3d7c0743 100644--- a/store/trnForm/actions.js+++ b/store/trnForm/actions.js@@ -14,7 +14,7 @@ export default {switch (action) {case 'create':- // get data from last trn+ // Get data from last trnif (lastTrn) {commit('setTrnFormValues', {amount: '0',@@ -31,7 +31,10 @@ export default {}else {const categoriesIds = rootGetters['categories/categoriesIds']- const childs = categoriesIds.filter(cId => cId !== 'transfer' && (!rootState.categories.items[cId].childIds || rootState.categories.items[cId].childIds.length === 0))+ const childs = categoriesIds.filter(id =>+ id !== 'transfer'+ && (!rootState.categories.items[id].childIds || rootState.categories.items[id].childIds.length === 0))+const categoryId = childs[0]const walletsIds = Object.keys(rootState.wallets.items)const walletId = walletsIds[0]