Skip to content

Open source personal finance application

improvements: refactor

ilkomea4847745bf40
diff --git a/assets/stylus/index.styl b/assets/stylus/index.styl
index 7563ff69..28411712 100644
--- a/assets/stylus/index.styl
+++ b/assets/stylus/index.styl
@@ -8,3 +8,10 @@
html
--c-income-opacity rgba(44, 173, 34, .5)
--c-expense-opacity rgba(249, 33, 52, .5)
+
+
+.firefoxBackdropFix
+ @supports (not (-webkit-backdrop-filter: none)) and (not (backdrop-filter: none))
+ background theme('colors.dark3') !important
+ /.light &
+ background theme('colors.white') !important
diff --git a/components/base/BottomSheet.vue b/components/base/BottomSheet.vue
index e6ec050c..04a98b67 100644
--- a/components/base/BottomSheet.vue
+++ b/components/base/BottomSheet.vue
@@ -190,7 +190,7 @@ export default defineComponent({
return
}
- // drug on pc only by nadler drug on mobile everywhere
+ // drug on pc only by handler drug on mobile everywhere
// if (isDragging.value && ((!isHandler.value && event.type.includes('touch') || isHandler.value)))
// clientY.value = getClientY(event)
diff --git a/components/categories/Form.vue b/components/categories/Form.vue
index 544bdc45..b7906330 100644
--- a/components/categories/Form.vue
+++ b/components/categories/Form.vue
@@ -1,22 +1,13 @@
<script setup lang="ts">
-import { allColors } from '~/assets/js/colors'
-import { saveData } from '~/services/firebase/api'
import generateId from '~/utils/id'
import icons from '~/assets/js/icons'
-import type { CategoryID } from '~/components/categories/types'
+import type { CategoryForm, CategoryID, CategoryItem } from '~/components/categories/types'
+import { allColors } from '~/assets/js/colors'
+import { saveData } from '~/services/firebase/api'
const props = defineProps<{
categoryId?: CategoryID
- categoryForm: {
- color: string
- icon: string
- name: string
- order: number
- parentId: string | 0
- showInLastUsed: boolean
- showInQuickSelector: boolean
- showStat: boolean
- }
+ categoryForm: CategoryForm
}>()
const emit = defineEmits(['updateValue', 'afterSave'])
@@ -27,27 +18,34 @@ const editCategoryId = categoryId.value ?? generateId()
const activeTab = ref('data')
const isUpdateChildCategoriesColor = ref(true)
-
-const isAllowChangeParent = computed(() => {
- const childs = getChildCategoriesIds(categoryId.value)
- return !childs
-})
+const isAllowChangeParent = computed(() => !getChildCategoriesIds(categoryId.value))
+
+const tabs = computed(() => [{
+ id: 'data',
+ name: i18n.t('categories.form.data.label'),
+}, {
+ id: 'parent',
+ name: i18n.t('categories.form.parent.label'),
+ isHidden: !$store.getters['categories/hasCategories'],
+}, {
+ id: 'colors',
+ name: i18n.t('categories.form.colors.label'),
+}, {
+ id: 'icon',
+ name: i18n.t('categories.form.icon.label'),
+}])
/**
* Find category with color
- *
- * @param color
*/
-function findCategoryWithThisColor(color) {
- const categoriesItems = $store.state.categories.items
+function findCategoryIconByColor(color) {
+ const categoriesItems: Record<CategoryID, CategoryItem> = $store.state.categories.items
if (!categoriesItems)
- return false
+ return
- const categoryIdWithThisColor = $store.getters['categories/categoriesRootIds']
+ return $store.getters['categories/categoriesRootIds']
?.find(id => categoriesItems[id]?.color === color)
-
- if (categoryIdWithThisColor)
- return categoriesItems[categoryIdWithThisColor]?.icon
+ ?.icon
}
/**
@@ -56,31 +54,19 @@ function findCategoryWithThisColor(color) {
function getChildCategoriesIds(categoryId: CategoryID) {
// TODO: always return array
if (!categoryId)
- return false
-
- const category = $store.state.categories.items[categoryId]
- const categoriesItems = $store.state.categories.items
- const ids = []
-
- if (category?.parentId === 0) {
- // TODO: filter
- for (const id in categoriesItems) {
- if (categoriesItems[id].parentId === categoryId)
- ids.push(id)
- }
- }
+ return
- if (ids.length === 0)
- return false
+ const category: CategoryItem = $store.state.categories.items[categoryId]
+ const categoriesItems: Record<CategoryID, CategoryItem> = $store.state.categories.items
- return ids
+ if (category?.parentId === 0)
+ return Object.keys(categoriesItems).filter(id => categoriesItems[id]?.parentId === categoryId)
}
/**
* Select parent
- * @param parentId
*/
-function onParentSelect(parentId) {
+function onParentSelect(parentId: CategoryID) {
emit('updateValue', 'parentId', parentId)
// Change category color when patent category changed
@@ -98,9 +84,10 @@ function validate({ values, categoriesItems }) {
title: '😮',
text: i18n.t('categories.form.name.error'),
})
- return false
+ return
}
+ // TODO: refactor
for (const id in categoriesItems) {
if (categoriesItems[id].name === values.name && categoriesItems[id].parentId === values.parentId) {
if (editCategoryId) {
@@ -109,7 +96,7 @@ function validate({ values, categoriesItems }) {
title: '😮',
text: i18n.t('categories.form.name.exist'),
})
- return false
+ return
}
}
else {
@@ -117,7 +104,7 @@ function validate({ values, categoriesItems }) {
title: '😮',
text: i18n.t('categories.form.name.exist'),
})
- return false
+ return
}
}
}
@@ -125,7 +112,7 @@ function validate({ values, categoriesItems }) {
return true
}
-function prepareForm({ values, categoryChildIds }) {
+function prepareForm({ values, categoryChildIds }): CategoryForm {
return {
color: values.color,
icon: values.icon,
@@ -164,32 +151,22 @@ async function onSave() {
<template lang="pug">
div
- .pb-8.px-2
- UiTabs
- UiTabsItem(
- :isActive="activeTab === 'data'"
- @click="activeTab = 'data'"
- ) {{ $t('categories.form.data.label') }}
-
- UiTabsItem(
- v-if="$store.getters['categories/hasCategories']"
- :isActive="activeTab === 'parent'"
- @click="activeTab = 'parent'"
- ) {{ $t('categories.form.parent.label') }}
-
- UiTabsItem(
- :isActive="activeTab === 'colors'"
- @click="activeTab = 'colors'"
- ) {{ $t('categories.form.colors.label') }}
-
- UiTabsItem(
- :isActive="activeTab === 'icon'"
- @click="activeTab = 'icon'"
- ) {{ $t('categories.form.icon.label') }}
+ .sticky.z-20.backdrop-blur.firefoxBackdropFix(
+ class="top-[60px] bg-white/70 dark_bg-dark3/70"
+ )
+ .px-2
+ UiTabs2
+ UiTabsItem2.md_text-lg(
+ v-for="tab in tabs"
+ v-if="!tab.isHidden"
+ :key="tab.id"
+ :isActive="activeTab === tab.id"
+ @click="activeTab = tab.id"
+ ) {{ tab.name }}
//- Content
//-----------------------------------
- .px-2.max-w-md
+ .pt-8.px-2.max-w-md
//- Data
//-----------------------------------
template(v-if="activeTab === 'data'")
@@ -240,9 +217,9 @@ div
:style="{ background: color === categoryForm.color ? color : 'transparent' }"
@click="emit('updateValue', 'color', color)"
)
- template(v-if="findCategoryWithThisColor(color)")
+ template(v-if="findCategoryIconByColor(color)")
Icon(
- :icon="color === categoryForm.color ? categoryForm.icon : findCategoryWithThisColor(color)"
+ :icon="color === categoryForm.color ? categoryForm.icon : findCategoryIconByColor(color)"
:background="color"
round
)
diff --git a/components/categories/Item.vue b/components/categories/Item.vue
index 79fbad35..a6444ee8 100644
--- a/components/categories/Item.vue
+++ b/components/categories/Item.vue
@@ -1,4 +1,5 @@
<script>
+// TODO: setup
import useFilter from '~/components/filter/useFilter'
export default defineComponent({
@@ -57,9 +58,8 @@ export default defineComponent({
): div(:class="category.icon")
.grow.truncate
- .text-xs.text-skin-item-base-down(
+ .text-xs.text-skin-item-base-down.dark_text-neutral-400(
v-if="parentCategory && !isHideParentCategory"
- class="dark_text-neutral-400"
) {{ parentCategory.name }}
.leading-none.text-sm.text-skin-item-base {{ category.name }}
diff --git a/components/categories/getCategories.ts b/components/categories/getCategories.ts
index 547c0ced..4bffa4a5 100644
--- a/components/categories/getCategories.ts
+++ b/components/categories/getCategories.ts
@@ -1,7 +1,7 @@
import type { CategoryID, CategoryItem } from '~/components/categories/types'
// TODO: need a proper name, maybe getTransactibleCategoriesIds
-export function getCategoriesIds(
+export function getTransactibleCategoriesIds(
catsIds: CategoryID[],
categoriesItems: Record<CategoryID, CategoryItem>,
): CategoryID[] {
@@ -16,3 +16,13 @@ export function getTransferCategoriesIds(items: Record<CategoryID, CategoryItem>
return [...categoriesIdsByName, 'transfer']
}
+
+export function getParentCategory(
+ items: Record<CategoryID, CategoryItem>,
+ parentId: CategoryID | 0,
+): CategoryItem | false {
+ if (parentId === 0)
+ return false
+
+ return items[parentId]
+}
diff --git a/components/categories/getForm.ts b/components/categories/getForm.ts
new file mode 100644
index 00000000..2c3da170
--- /dev/null
+++ b/components/categories/getForm.ts
@@ -0,0 +1,17 @@
+import icons from '~/assets/js/icons'
+import type { CategoryForm } from '~/components/categories/types'
+import { allColors } from '~/assets/js/colors'
+import { random } from '~/assets/js/emo'
+
+export function getPreparedFormData(values?: any): CategoryForm {
+ return {
+ color: values?.color ?? random(allColors),
+ icon: values?.icon ?? random(random(icons)),
+ name: values?.name ?? '',
+ order: values?.order ?? 1,
+ parentId: values?.parentId ?? 0,
+ showInLastUsed: values?.showInLastUsed ?? true,
+ showInQuickSelector: values?.showInQuickSelector ?? false,
+ showStat: values?.showStat ?? true,
+ }
+}
diff --git a/components/categories/page/New.vue b/components/categories/page/New.vue
index 9a85b466..fd9c7c81 100644
--- a/components/categories/page/New.vue
+++ b/components/categories/page/New.vue
@@ -1,36 +1,16 @@
<script setup lang="ts">
-import { allColors } from '~/assets/js/colors'
-import { random } from '~/assets/js/emo'
-import icons from '~/assets/js/icons'
+import { getPreparedFormData } from '~/components/categories/getForm'
+import { getParentCategory } from '~/components/categories/getCategories'
const { $store } = useNuxtApp()
const router = useRouter()
-const categoryForm = ref({
- color: random(random(allColors)),
- icon: random(random(icons)),
- name: null,
- order: 1,
- parentId: 0,
- showInLastUsed: true,
- showInQuickSelector: false,
- showStat: true,
-})
-
-const parentCategory = computed(() => {
- if (categoryForm.value.parentId === 0)
- return false
-
- return $store.state.categories.items[categoryForm.value.parentId]
-})
-
-function updateValue(id, value) {
- categoryForm.value[id] = value
-}
+const categoryForm = ref(getPreparedFormData())
+const parentCategory = computed(() =>
+ getParentCategory($store.state.categories.items, categoryForm.value.parentId))
-function afterSave() {
- router.push('/categories')
-}
+const updateValue = (id, value) => categoryForm.value[id] = value
+const afterSave = () => router.replace('/categories/')
</script>
<script lang="ts">
@@ -46,18 +26,27 @@ export default defineComponent({
<template lang="pug">
UiPage
UiHeader
- router-link(v-slot="{ href, navigate }" to="/categories" custom)
- a.grow.hocus_bg-skin-item-main-hover(:href="href" @click="navigate")
+ router-link(
+ v-slot="{ href, navigate }"
+ to="/categories"
+ custom
+ )
+ a.grow.hocus_bg-skin-item-main-hover(
+ :href="href"
+ @click="navigate"
+ )
UiHeaderTitle
- .pb-1.text-xs.font-medium.text-skin-item-base-down
+ .pt-1.text-xs.font-medium.text-skin-item-base-down
| {{ $t('categories.createNewTitle') }}
template(v-if="parentCategory")
|
- | in {{ parentCategory.name }}
+ | {{ $t('common.in')}} {{ parentCategory.name }}
- .flex.items-center.gap-4
+ .pb-1.flex.items-center.gap-4
| {{ categoryForm.name ? categoryForm.name : $t("categories.form.name.label") }}
- .w-8.h-8.rounded-full.flex-center.text-xl.text-skin-icon-base(:style="{ background: categoryForm.color }")
+ .w-8.h-8.rounded-full.flex-center.text-xl.text-skin-icon-base(
+ :style="{ background: categoryForm.color }"
+ )
div(:class="categoryForm.icon")
CategoriesForm(
diff --git a/components/categories/page/id/Edit.vue b/components/categories/page/id/Edit.vue
index bec6fc17..3c324abf 100644
--- a/components/categories/page/id/Edit.vue
+++ b/components/categories/page/id/Edit.vue
@@ -1,40 +1,20 @@
<script setup lang="ts">
-import { allColors } from '~/assets/js/colors'
-import { random } from '~/assets/js/emo'
-import icons from '~/assets/js/icons'
+import type { CategoryID, CategoryItem } from '~/components/categories/types'
+import { getPreparedFormData } from '~/components/categories/getForm'
+import { getParentCategory } from '~/components/categories/getCategories'
const { $store } = useNuxtApp()
const router = useRouter()
const route = useRoute()
-const categoryId = computed(() => route.params.id)
-const category = computed(() => $store.state.categories.items[categoryId.value])
+const categoryId = computed<CategoryID>(() => route.params.id)
+const category = computed<CategoryItem>(() => $store.state.categories.items[categoryId.value])
+const categoryForm = ref(getPreparedFormData(category.value))
+const parentCategory = computed(() =>
+ getParentCategory($store.state.categories.items, categoryForm.value.parentId))
-const categoryForm = ref({
- color: category.value?.color || random(allColors),
- icon: category.value?.icon || random(random(icons)),
- name: category.value?.name || null,
- order: category.value?.order ?? 1,
- parentId: category.value?.parentId ?? 0,
- showInLastUsed: category.value?.showInLastUsed ?? true,
- showInQuickSelector: category.value?.showInQuickSelector ?? false,
- showStat: category.value?.showStat ?? true,
-})
-
-const parentCategory = computed(() => {
- if (category.value.parentId === 0)
- return false
-
- return $store.state.categories.items[categoryForm.value.parentId]
-})
-
-function updateValue(id, value) {
- categoryForm.value[id] = value
-}
-
-function afterSave() {
- router.replace(`/categories/${categoryId.value}`)
-}
+const updateValue = (id, value) => categoryForm.value[id] = value
+const afterSave = () => router.replace(`/categories/${categoryId.value}`)
</script>
<script lang="ts">
@@ -50,7 +30,11 @@ export default defineComponent({
<template lang="pug">
UiPage(v-if="category")
UiHeader
- router-link(v-slot="{ href, navigate }" :to='`/categories/${categoryId}`' custom)
+ router-link(
+ v-slot="{ href, navigate }"
+ to="/categories"
+ custom
+ )
a.grow.hocus_bg-skin-item-main-hover(
:href='href'
@click='navigate'
@@ -60,7 +44,7 @@ UiPage(v-if="category")
| {{ $t('categories.title') }}
template(v-if="parentCategory")
|
- | • {{ parentCategory.name }}
+ | {{ $t('common.in')}} {{ parentCategory.name }}
.pb-1.flex.items-center.gap-4
| {{ categoryForm.name }}
diff --git a/components/categories/page/id/Index.vue b/components/categories/page/id/Index.vue
index fdc99807..1c6dd760 100644
--- a/components/categories/page/id/Index.vue
+++ b/components/categories/page/id/Index.vue
@@ -1,6 +1,6 @@
<script setup lang="ts">
-import useFilter from '~/components/filter/useFilter'
import { getTrnsIds } from '~/components/trns/getTrns'
+import useFilter from '~/components/filter/useFilter'
const { $store } = useNuxtApp()
const { setFilterCatsId } = useFilter()
@@ -14,10 +14,12 @@ if (!category.value)
router.replace('/categories')
const trnsItems = computed(() => $store.state.trns.items)
-const backLink = computed(() => category.value?.parentId ? `/categories/${category.value.parentId}` : '/categories')
+const backLink = computed(() => category.value?.parentId
+ ? `/categories/${category.value.parentId}`
+ : '/categories')
-const categoryChildIds = computed(() => category.value.childIds
- ?.sort((a, b) => $store.state.categories.items[a].name.localeCompare($store.state.categories.items[b].name)))
+const categoryChildIds = computed(() => category.value.childIds?.sort((a, b) =>
+ $store.state.categories.items[a].name.localeCompare($store.state.categories.items[b].name)))
const trnsIds = computed(() =>
getTrnsIds({
@@ -34,9 +36,7 @@ function handleSetFilterCategory() {
$store.dispatch('ui/setActiveTabStat', 'details')
}
-function handleEditClick() {
- router.push(`/categories/${categoryId.value}/edit`)
-}
+const onClickEdit = () => router.push(`/categories/${categoryId.value}/edit`)
</script>
<template lang="pug">
@@ -59,7 +59,7 @@ UiPage(v-if="category")
div(:class="category.icon")
template(#actions v-if="categoryId !== 'transfer'")
- UiHeaderLink(@click="handleEditClick")
+ UiHeaderLink(@click="onClickEdit")
.mdi.mdi-pencil-outline.group-hover_text-white.text-xl
UiHeaderLink(@click="$router.push('/categories/new')")
UiIconAdd.group-hover_text-white.w-6.h-6
diff --git a/components/categories/types.ts b/components/categories/types.ts
index 6d358108..deb2dd24 100644
--- a/components/categories/types.ts
+++ b/components/categories/types.ts
@@ -11,3 +11,14 @@ export interface CategoryItem {
export interface CategoryStore {
items: Record<CategoryID, CategoryItem>
}
+
+export interface CategoryForm {
+ color: string
+ icon: string
+ name: string
+ order: number
+ parentId: string | 0
+ showInLastUsed: boolean
+ showInQuickSelector: boolean
+ showStat: boolean
+}
diff --git a/components/layout/MenuBottomModal.vue b/components/layout/MenuBottomModal.vue
index b474a881..9762d6b4 100644
--- a/components/layout/MenuBottomModal.vue
+++ b/components/layout/MenuBottomModal.vue
@@ -1,6 +1,11 @@
<script setup lang="ts">
const { $store } = useNuxtApp()
const activeTab = computed(() => $store.state.ui.activeTab)
+const onClickTheme = (close) => {
+ $store.dispatch('ui/changeTheme')
+ console.log(close)
+ close && close()
+}
</script>
<template lang="pug">
@@ -13,34 +18,29 @@ Portal(to="modal")
.handler
BaseBottomSheetClose(@onClick="close")
- .content(class="!overflow-hidden !pt-8 !pb-2")
- //- User
- .mb-4.pb-4.border-b(
- class="border-neutral-300 dark_border-neutral-800"
- )
- .mx-6.mb-2(
- class="dark_text-neutral-300"
- )
- .text-xl.font-nunito.font-semibold {{ $store.state.user.user.displayName }}
- .text-sm.text-gray-900(class="dark_text-neutral-500") {{ $store.state.user.user.email }}
+ template(#default="{ close }")
+ .content(class="!overflow-hidden !pt-8 !pb-2")
+ //- User
+ .mb-4.pb-4.border-b.border-neutral-300.dark_border-neutral-800
+ .mx-6.mb-2.dark_text-neutral-300
+ .text-xl.font-nunito.font-semibold {{ $store.state.user.user.displayName }}
+ .text-sm.text-gray-900.dark_text-neutral-500 {{ $store.state.user.user.email }}
- .cursor-pointer.py-3.px-6.space-x-5.flex.items-center(
- class="hocus_bg-white2 dark_hocus_bg-custom1"
- @click="$store.dispatch('user/signOut')"
- )
- .text-xl.mdi.mdi-logout
- .text-sm {{ $t('userLogout') }}
+ .cursor-pointer.py-3.px-6.space-x-5.flex.items-center.hocus_bg-white2.dark_hocus_bg-custom1(
+ @click="$store.dispatch('user/signOut')"
+ )
+ .text-xl.mdi.mdi-logout
+ .text-sm {{ $t('userLogout') }}
- //- Main Menu
- LayoutSidebarMenu
+ //- Main Menu
+ LayoutSidebarMenu
- //- Theme
- .cursor-pointer.flex.items-center.py-3.px-6.space-x-5(
- class="text-slate-600 dark_text-neutral-400 hocus_bg-zinc-100 dark_hocus_bg-neutral-800"
- @click="$store.dispatch('ui/changeTheme')"
- )
- .text-xl.mdi.mdi-palette
- .text-sm {{ $t('theme.change') }}
+ //- Theme
+ .cursor-pointer.flex.items-center.py-3.px-6.space-x-5.text-slate-600.dark_text-neutral-400.hocus_bg-zinc-100.dark_hocus_bg-neutral-800(
+ @click="onClickTheme(close)"
+ )
+ .text-xl.mdi.mdi-palette
+ .text-sm {{ $t('theme.change') }}
</template>
<style lang="stylus" scoped>
diff --git a/components/shared/spiner/Spiner.vue b/components/shared/Spinier.vue
similarity index 97%
rename from components/shared/spiner/Spiner.vue
rename to components/shared/Spinier.vue
index bbc253da..ccf60583 100644
--- a/components/shared/spiner/Spiner.vue
+++ b/components/shared/Spinier.vue
@@ -1,4 +1,5 @@
<script>
+// TODO: setup
export default {
props: {
theme: {
@@ -31,6 +32,7 @@ export default {
</template>
<style lang="stylus" scoped>
+// TODO: style
@import "~assets/stylus/variables/margins"
.spinner
diff --git a/components/shared/appName/AppName.vue b/components/shared/appName/AppName.vue
index a5895791..e1a3a0dc 100644
--- a/components/shared/appName/AppName.vue
+++ b/components/shared/appName/AppName.vue
@@ -1,6 +1,5 @@
<template lang="pug">
-.appName.text-gray-600.font-nunito(
- class="dark_text-neutral-200"
+.appName.text-gray-600.dark_text-neutral-200.font-nunito(
) {{ $t('appName') }}
</template>
diff --git a/components/shared/button/Button.vue b/components/shared/button/Button.vue
index 0c2cc136..244aa78d 100644
--- a/components/shared/button/Button.vue
+++ b/components/shared/button/Button.vue
@@ -1,4 +1,5 @@
<script lang="ts">
+// TODO: setup
export default defineComponent({
props: {
background: { type: String, default: null },
@@ -44,6 +45,7 @@ export default defineComponent({
</template>
<style lang="stylus">
+// TODO: style
@import '~assets/stylus/variables/animations'
@import '~assets/stylus/variables/media'
diff --git a/components/shared/copyright/Copyright.vue b/components/shared/copyright/Copyright.vue
index 2d914b33..e706a2df 100644
--- a/components/shared/copyright/Copyright.vue
+++ b/components/shared/copyright/Copyright.vue
@@ -1,13 +1,6 @@
-<script>
-export default {
- name: 'SharedCopyright',
-}
-</script>
-
<template lang="pug">
-a.copyright.py-3.px-5.rounded-md(
+a.copyright.py-3.px-5.rounded-md.hocus_bg-white2.dark_hocus_bg-custom1(
href="https://ilko.me"
- class="hocus_bg-white2 dark_hocus_bg-custom1"
)
| {{ $t('app.madeBy.text') }}
.copyright__heart.mdi.mdi-heart
@@ -15,6 +8,7 @@ a.copyright.py-3.px-5.rounded-md(
</template>
<style lang="stylus" scoped>
+// TODO: style
@import '~assets/stylus/variables/animations'
@import '~assets/stylus/variables/fonts'
@import '~assets/stylus/variables/margins'
diff --git a/components/shared/loader/Loader.vue b/components/shared/loader/Loader.vue
index 9bc1a70f..73106717 100644
--- a/components/shared/loader/Loader.vue
+++ b/components/shared/loader/Loader.vue
@@ -7,8 +7,8 @@ export default {
.loader
.loader__wrap
SharedAppName
- .loader__spiner
- SharedSpiner(theme="dark" size="lg")
+ .loader__spinier
+ SharedSpinier(theme="dark" size="lg")
</template>
<style lang="stylus" scoped>
@@ -32,7 +32,7 @@ export default {
flex-flow column nowrap
align-items center
- &__spiner
+ &__spinier
height 48px
margin-top 40px
</style>
diff --git a/components/stat/Date.vue b/components/stat/Date.vue
index 32888366..2cd39f56 100644
--- a/components/stat/Date.vue
+++ b/components/stat/Date.vue
@@ -1,8 +1,4 @@
<script setup lang="ts">
-defineProps<{
- dateClasses?: null
- wrapClasses?: null
-}>()
const isShowDateSelector = ref(false)
</script>
@@ -11,11 +7,8 @@ const isShowDateSelector = ref(false)
//- Date
.cursor-pointer.px-3.flex.items-center.text-lg(
@click="isShowDateSelector = true"
- class="wrapClasses"
)
- .py-3.font-nunito.text-neutral-800.dark_text-white.text-xl.lg_text-2xl.leading-none.font-semibold(
- :class="dateClasses"
- )
+ .py-3.font-nunito.text-neutral-800.dark_text-white.text-xl.lg_text-2xl.leading-none.font-semibold
SharedDate(
:date="$store.state.filter.date"
:period="$store.state.filter.period"
diff --git a/components/stat/Menu.vue b/components/stat/Menu.vue
index abea1fe5..085213b8 100644
--- a/components/stat/Menu.vue
+++ b/components/stat/Menu.vue
@@ -32,11 +32,3 @@ function onClickStatMenu(tabName) {
@click="onClickStatMenu(item.id)"
) {{ item.name }}
</template>
-
-<style lang="stylus">
-.firefoxBackdropFix
- @supports (not (-webkit-backdrop-filter: none)) and (not (backdrop-filter: none))
- background theme('colors.dark3') !important
- /.light &
- background theme('colors.white') !important
-</style>
diff --git a/components/stat/chart/View.vue b/components/stat/chart/View.vue
index 3a762ec4..63efbbf9 100644
--- a/components/stat/chart/View.vue
+++ b/components/stat/chart/View.vue
@@ -2,7 +2,7 @@
import { Chart } from 'highcharts-vue'
import { getTrnsIds } from '~/components/trns/getTrns'
import { getTotal } from '~/components/amount/getTotal'
-import { getCategoriesIds, getTransferCategoriesIds } from '~/components/categories/getCategories'
+import { getTransactibleCategoriesIds, getTransferCategoriesIds } from '~/components/categories/getCategories'
import { formatAmount, getCurrencySymbol } from '~/components/amount/formatAmount'
import useFilter from '~/components/filter/useFilter'
import useChart from '~/components/chart/useChart'
@@ -113,7 +113,7 @@ export default defineComponent({
// TODO: move it to a separate function getFilterParams
const categoriesIds = storeFilter.catsIds.length > 0
- ? getCategoriesIds(storeFilter.catsIds, categoriesItems)
+ ? getTransactibleCategoriesIds(storeFilter.catsIds, categoriesItems)
: null
const walletsIds = storeFilter.walletsIds.length > 0
? storeFilter.walletsIds
diff --git a/components/stat/group/HorizontalItemCat.vue b/components/stat/group/HorizontalItemCat.vue
deleted file mode 100644
index edb178fa..00000000
--- a/components/stat/group/HorizontalItemCat.vue
+++ /dev/null
@@ -1,77 +0,0 @@
-<script>
-import { getTotal } from '~/components/amount/getTotal'
-
-export default {
- props: {
- categoryId: { type: String, required: true },
- type: { type: Number, required: true },
- },
-
- computed: {
- statCategories() {
- const categoriesIds = this.$store.getters['categories/getChildCategoriesIds'](this.categoryId)
- const stat = []
-
- // TODO: reduce
- for (const categoryId of categoriesIds) {
- const trnsIds = this.getTrnsByCategoryId(categoryId)
- if (trnsIds.length > 0) {
- const categoryStat = this.getCategoryStat({ categoryId, trnsIds })
- stat.push(categoryStat)
- }
- }
-
- return stat.sort((a, b) => b[this.typeName] - a[this.typeName])
- },
-
- typeName() {
- return this.type === 1 ? 'income' : 'expense'
- },
- },
-
- methods: {
- getTrnsByCategoryId(categoryId) {
- const trns = this.$store.state.trns.items
- let trnsIds = this.$store.getters['trns/selectedTrnsIdsWithDate']
- trnsIds = trnsIds.filter(id => trns[id].categoryId === categoryId)
- trnsIds = trnsIds.filter(id => trns[id].type === this.type)
- return trnsIds
- },
-
- getCategoryStat({ categoryId, trnsIds }) {
- const trnsItems = this.$store.state.trns.items
- const walletsItems = this.$store.state.wallets.items
- const baseCurrencyCode = this.$store.state.currencies.base
- const rates = this.$store.state.currencies.rates
-
- const total = getTotal({
- baseCurrencyCode,
- rates,
- trnsIds,
- trnsItems,
- walletsItems,
- })
-
- return {
- categoryId,
- total: total.sumTransactions,
- income: total.incomeTransactions,
- expense: total.expenseTransactions,
- }
- },
- },
-}
-</script>
-
-<template lang="pug">
-div
- StatGroupHorizontalItemCatItem(
- v-for="category in statCategories"
- :key="category.categoryId"
- :biggest="$store.getters['stat/statCurrentPeriod'][typeName].biggest"
- :category="$store.state.categories.items[category.categoryId]"
- :categoryId="category.categoryId"
- :total="category[typeName]"
- :type="type"
- )
-</template>
diff --git a/components/stat/group/HorizontalItem.vue b/components/stat/group/horizontal/Item.vue
similarity index 75%
rename from components/stat/group/HorizontalItem.vue
rename to components/stat/group/horizontal/Item.vue
index 80e6b930..546eefe9 100644
--- a/components/stat/group/HorizontalItem.vue
+++ b/components/stat/group/horizontal/Item.vue
@@ -3,6 +3,7 @@ import type { CategoryID, CategoryItem } from '~/components/categories/types'
import type { TrnType } from '~/components/trns/types'
import useFilter from '~/components/filter/useFilter'
import useStatPage from '~/components/stat/useStatPage'
+import { getWidthPercent } from '~/components/stat/helpers'
const props = defineProps<{
biggest: number
@@ -17,28 +18,27 @@ const { statPage } = useStatPage()
const { setFilterCatsId } = useFilter()
const isShowInside = ref(false)
-const isCategoryHasChildren = computed(() =>
- $store.getters['categories/isCategoryHasChildren'](props.categoryId))
-
const styles = computed(() => ({
- width: `${Math.abs(props.total) / Math.abs(props.biggest) * 100}%`,
+ width: getWidthPercent(props.total, props.biggest),
background: props.category.color,
}))
-function toggleShowInside() {
- isShowInside.value = !isShowInside.value
-}
+// TODO: same HorizontalItem, HorizontalItemCatItem
+const isCategoryHasChildren = computed(() =>
+ $store.getters['categories/isCategoryHasChildren'](props.categoryId))
+
+// TODO: same HorizontalItem, HorizontalItemCatItem
+const toggleShowInside = () => isShowInside.value = !isShowInside.value
+// TODO: same HorizontalItem, HorizontalItemCatItem
const trnsIds = computed(() => {
if (isCategoryHasChildren.value)
return []
const trnsItems = $store.state.trns.items
- const trnsIds = statPage.current.trnsIds
+ return statPage.current.trnsIds
.filter(id => trnsItems[id].type === props.type && trnsItems[id].categoryId === props.categoryId)
.sort((a, b) => trnsItems[b].date - trnsItems[a].date)
-
- return trnsIds
})
</script>
@@ -58,8 +58,8 @@ const trnsIds = computed(() => {
.grow
.space-x-3.flex
- .overflow-hidden.truncate.grow.space-x-2.flex.items-baseline.text-neutral-700(class="dark_text-neutral-400")
- .overflow-hidden.text-sm {{ category.name }}{{ isCategoryHasChildren ? '...' : '' }}
+ .overflow-hidden.truncate.grow.space-x-2.flex.items-baseline.text-neutral-700.dark_text-neutral-400.text-sm
+ | {{ category.name }}{{ isCategoryHasChildren ? '...' : '' }}
.statItem__amount.text-skin-item-base
Amount(
@@ -71,7 +71,7 @@ const trnsIds = computed(() => {
.pt-1.statItem__graph.mt-1: .statItem__graph__in(:style="styles")
//- Inside
- .overflow-hidden.ins2.rounded-b-md.border.border-t-0(
+ .overflow-hidden.bg-skin-item-main-bg.border.border-t-0.rounded-b-md(
v-if="isShowInside"
class="mt-[-1px] dark_border-neutral-800"
@click.stop=""
@@ -92,30 +92,7 @@ const trnsIds = computed(() => {
)
</template>
-<style lang="stylus">
-.statItem
- &__icon
- .icon
- width 36px !important
- height 36px !important
- background var(--c-bg-4)
-
- .icon__image
- font-size 22px
-
- .trnItem._stat
- padding-right $m6
- padding-left $m6
-</style>
-
<style lang="stylus" scoped>
-.ins2
- position relative
- background var(--c-item2-bg-hover)
-
-.ins
- position relative
-
.statItem
&__graph
&__in
@@ -123,14 +100,6 @@ const trnsIds = computed(() => {
min-width 2px
border-radius 3px
- &__name
- overflow hidden
- align-self center
- color var(--c-font-4)
- font-size 14px
- white-space nowrap
- text-overflow ellipsis
-
&__icon
width 32px
</style>
diff --git a/components/stat/group/horizontal/ItemCat.vue b/components/stat/group/horizontal/ItemCat.vue
new file mode 100644
index 00000000..f39f4f1e
--- /dev/null
+++ b/components/stat/group/horizontal/ItemCat.vue
@@ -0,0 +1,68 @@
+<script setup lang="ts">
+// TODO: setup
+import type { CategoryID } from '~/components/categories/types'
+import { getTotal } from '~/components/amount/getTotal'
+import type { TrnType } from '~/components/trns/types'
+
+const props = defineProps<{
+ type: TrnType
+ categoryId: CategoryID
+}>()
+
+const { $store } = useNuxtApp()
+const typeName = computed(() => props.type === 1 ? 'income' : 'expense')
+
+const statCategories = computed(() => {
+ return $store.getters['categories/getChildCategoriesIds'](props.categoryId)
+ .reduce((acc, id) => {
+ const trnsIds = getTrnsByCategoryId(id)
+ if (trnsIds.length > 0)
+ acc.push(getCategoryStat({ categoryId: id, trnsIds }))
+ return acc
+ }, [])
+ .sort((a, b) => b[typeName.value] - a[typeName.value])
+})
+
+function getTrnsByCategoryId(categoryId) {
+ const trnsItems = $store.state.trns.items
+ // Note: same performance as in one filter but better readability
+ return $store.getters['trns/selectedTrnsIdsWithDate']
+ .filter(id => trnsItems[id].categoryId === categoryId)
+ .filter(id => trnsItems[id].type === props.type)
+}
+
+function getCategoryStat({ categoryId, trnsIds }) {
+ const trnsItems = $store.state.trns.items
+ const walletsItems = $store.state.wallets.items
+ const baseCurrencyCode = $store.state.currencies.base
+ const rates = $store.state.currencies.rates
+
+ const total = getTotal({
+ baseCurrencyCode,
+ rates,
+ trnsIds,
+ trnsItems,
+ walletsItems,
+ })
+
+ return {
+ categoryId,
+ total: total.sumTransactions,
+ income: total.incomeTransactions,
+ expense: total.expenseTransactions,
+ }
+}
+</script>
+
+<template lang="pug">
+div
+ StatGroupHorizontalItemCatItem(
+ v-for="category in statCategories"
+ :key="category.categoryId"
+ :biggest="$store.getters['stat/statCurrentPeriod'][typeName].biggest"
+ :category="$store.state.categories.items[category.categoryId]"
+ :categoryId="category.categoryId"
+ :total="category[typeName]"
+ :type="type"
+ )
+</template>
diff --git a/components/stat/group/HorizontalItemCatItem.vue b/components/stat/group/horizontal/ItemCatItem.vue
similarity index 78%
rename from components/stat/group/HorizontalItemCatItem.vue
rename to components/stat/group/horizontal/ItemCatItem.vue
index 5e1c72c9..284eb39e 100644
--- a/components/stat/group/HorizontalItemCatItem.vue
+++ b/components/stat/group/horizontal/ItemCatItem.vue
@@ -17,26 +17,22 @@ const { statPage } = useStatPage()
const { setFilterCatsId } = useFilter()
const isShowInside = ref(false)
+// TODO: same HorizontalItem, HorizontalItemCatItem
const isCategoryHasChildren = computed(() =>
$store.getters['categories/isCategoryHasChildren'](props.categoryId))
-function toggleShowInside() {
- isShowInside.value = !isShowInside.value
-}
+// TODO: same HorizontalItem, HorizontalItemCatItem
+const toggleShowInside = () => isShowInside.value = !isShowInside.value
+// TODO: same HorizontalItem, HorizontalItemCatItem
const trnsIds = computed(() => {
if (isCategoryHasChildren.value)
return []
const trnsItems = $store.state.trns.items
- const trnsIds = statPage.current.trnsIds
- .filter((id) => {
- const trn = trnsItems[id]
- return trn.type === props.type && trn.categoryId === props.categoryId
- })
+ return statPage.current.trnsIds
+ .filter(id => trnsItems[id].type === props.type && trnsItems[id].categoryId === props.categoryId)
.sort((a, b) => trnsItems[b].date - trnsItems[a].date)
-
- return trnsIds
})
</script>
@@ -65,7 +61,7 @@ const trnsIds = computed(() => {
:isShowBaseRate="false"
)
- .statItemChild__trns(
+ div(
v-if="isShowInside"
@click.stop=""
)
@@ -76,28 +72,7 @@ const trnsIds = computed(() => {
)
</template>
-<style lang="stylus">
-// TODO: style
-.statItemChild
- .trnItem._stat
- padding-right $m5
- padding-left $m6
-
- &__icon
- .icon
- width 36px !important
- height 36px !important
- background var(--c-bg-4)
-
- .icon__image
- font-size 22px
-</style>
-
<style lang="stylus" scoped>
-.ins2
- position relative
- background var(--c-item2-bg-hover)
-
.ins
position relative
background var(--c-item2-bg-hover)
diff --git a/components/stat/group/Horizontal.vue b/components/stat/group/horizontal/index.vue
similarity index 98%
rename from components/stat/group/Horizontal.vue
rename to components/stat/group/horizontal/index.vue
index fc165634..70e9b542 100644
--- a/components/stat/group/Horizontal.vue
+++ b/components/stat/group/horizontal/index.vue
@@ -4,7 +4,7 @@ import useStatPage from '~/components/stat/useStatPage'
import useUIView from '~/components/layout/useUIView'
const props = defineProps<{
- typeText: String
+ typeText: string
}>()
const { statPage } = useStatPage()
diff --git a/components/stat/group/horizontal/types.ts b/components/stat/group/horizontal/types.ts
new file mode 100644
index 00000000..a565d54f
--- /dev/null
+++ b/components/stat/group/horizontal/types.ts
@@ -0,0 +1,10 @@
+import type { TrnType } from '~/components/trns/types'
+import type { CategoryID, CategoryItem } from '~/components/categories/types'
+
+export interface StatGroupHorizontalItemProps {
+ biggest: number
+ total: number
+ type: TrnType
+ category: CategoryItem
+ categoryId: CategoryID
+}
diff --git a/components/stat/helpers.ts b/components/stat/helpers.ts
new file mode 100644
index 00000000..25ca286a
--- /dev/null
+++ b/components/stat/helpers.ts
@@ -0,0 +1,3 @@
+export function getWidthPercent(value: number, biggest: number): string {
+ return `${Math.abs(value) / Math.abs(biggest) * 100}%`
+}
diff --git a/components/stat/types.ts b/components/stat/types.ts
new file mode 100644
index 00000000..e69de29b
diff --git a/components/trnForm/SelectedCategory.vue b/components/trnForm/SelectedCategory.vue
index a75bc711..baf8371a 100644
--- a/components/trnForm/SelectedCategory.vue
+++ b/components/trnForm/SelectedCategory.vue
@@ -1,18 +1,7 @@
-<script>
-export default {
- // TODO: add check for valid category
-
- computed: {
- category() {
- const categoryId = this.$store.state.trnForm.values.categoryId
- return this.$store.state.categories.items[categoryId]
- },
-
- parentCategory() {
- return this.$store.state.categories.items[this.category.parentId]
- },
- },
-}
+<script setup lang="ts">
+const { $store } = useNuxtApp()
+const category = computed(() => $store.state.categories.items[$store.state.trnForm.values.categoryId])
+const parentCategory = computed(() => $store.state.categories.items[category.value.parentId])
</script>
<template lang="pug">
@@ -25,9 +14,8 @@ export default {
): div(:class="category.icon")
.grow.truncate
- .text-xs.text-skin-item-base-down(
+ .text-xs.text-skin-item-base-down.dark_text-neutral-400(
v-if="parentCategory"
- class="dark_text-neutral-400"
) {{ parentCategory.name }}
.leading-none.text-sm.text-neutral-700.dark_text-neutral-300 {{ category.name }}
diff --git a/components/trns/List.vue b/components/trns/List.vue
index 285970a5..05d2e1c4 100644
--- a/components/trns/List.vue
+++ b/components/trns/List.vue
@@ -117,10 +117,9 @@ div(v-if="trnsIds && trnsIds.length > 0")
.grid(
:class="{ 'gap-2': uiHistory }"
)
- .overflow-hidden.rounded-md.bg-white2(
+ .overflow-hidden.rounded-md.bg-white2.dark_bg-dark4(
v-for="(trnsIds, date) in groupedTrns"
:key="date"
- class="dark_bg-dark4"
)
.pt-4.pb-2.px-3(
v-if="isShowGroupDate"
diff --git a/components/trns/ListWithControl.vue b/components/trns/ListWithControl.vue
index d1f20775..7db35329 100644
--- a/components/trns/ListWithControl.vue
+++ b/components/trns/ListWithControl.vue
@@ -88,7 +88,7 @@ div
UiTabsItem(
:isActive="filterTrnsType === 2"
@click="setFilterTrnsType(2)"
- ) {{ $t('transfer.titleMany') }}
+ ) {{ $t('transfer.titleMoney') }}
//- Nothing
.py-6.text-center(v-if="trnsCount === 0")
diff --git a/components/trns/item/Base.vue b/components/trns/item/Base.vue
index 7ba6369e..ae34ab79 100644
--- a/components/trns/item/Base.vue
+++ b/components/trns/item/Base.vue
@@ -6,7 +6,7 @@ import useTrn from '~/components/trns/item/useTrn'
const props = defineProps<{
trnId: TrnID
- slider: any
+ slider?: any
}>()
const emit = defineEmits(['onClickEdit'])
@@ -63,10 +63,10 @@ const actions = {
.grow
.items-center.flex
- .grow.text-neutral-500(class="dark_text-neutral-500")
+ .grow.text-neutral-500.dark_text-neutral-500
//- Category
.pb-1.space-x-2.items-baseline.flex.flex-wrap
- .text-sm.text-neutral-700(class="dark_text-neutral-300") {{ trnItem.category.name }}
+ .text-sm.text-neutral-700.dark_text-neutral-300 {{ trnItem.category.name }}
.text-xs.space-x-2.items-baseline.flex(v-if="trnItem.category.parentId")
div •
@@ -84,7 +84,7 @@ const actions = {
div
.space-x-1.items-center.flex
div {{ $t('trnForm.transfer.from') }}:
- .text-neutral-500(class="dark_text-neutral-400") {{ trnItem.expenseWallet.name }}
+ .text-neutral-500.dark_text-neutral-400 {{ trnItem.expenseWallet.name }}
.text-base(
@click="actions.onOpenEdit"
@@ -93,7 +93,6 @@ const actions = {
:amount="trnItem.expenseAmount || trnItem.amount"
:currencyCode="trnItem.expenseWallet.currency"
:type="0"
- verti
colorize="expense"
)
@@ -101,7 +100,7 @@ const actions = {
div
.space-x-1.items-center.flex
div {{ $t('trnForm.transfer.to') }}:
- .text-neutral-500(class="dark_text-neutral-400") {{ trnItem.incomeWallet.name }}
+ .text-neutral-500.dark_text-neutral-400 {{ trnItem.incomeWallet.name }}
.text-base(
@click="actions.onOpenEdit"
diff --git a/components/trns/item/WithoutCat.vue b/components/trns/item/WithoutCat.vue
index 64c1d8aa..6bd39dcd 100644
--- a/components/trns/item/WithoutCat.vue
+++ b/components/trns/item/WithoutCat.vue
@@ -26,8 +26,7 @@ export default defineComponent({
</script>
<template lang="pug">
-.cursor-context-menu.space-x-4.flex.text-neutral-500(
- class="dark_text-neutral-400 hocus_bg-neutral-100 dark_hocus_bg-neutral-800"
+.cursor-context-menu.space-x-4.flex.text-neutral-500.dark_text-neutral-400.hocus_bg-neutral-100.dark_hocus_bg-neutral-800(
@click="onOpenDetails"
)
.truncate.shrink-0.text-xs.leading-none(
@@ -46,11 +45,11 @@ export default defineComponent({
//- Transfer info
.text-sm(v-if="trnItem.type === 2")
.space-x-1.items-center.flex
- .text-neutral-600(class="dark_text-neutral-500") {{ $t('trnForm.transfer.from') }}:
- .text-neutral-500(class="dark_text-neutral-400") {{ trnItem.walletFrom.name }}
+ .text-neutral-600.dark_text-neutral-500 {{ $t('trnForm.transfer.from') }}:
+ .text-neutral-500.dark_text-neutral-400 {{ trnItem.walletFrom.name }}
.space-x-1.items-center.flex
- .text-neutral-600(class="dark_text-neutral-500") {{ $t('trnForm.transfer.to') }}:
- .text-neutral-500(class="dark_text-neutral-400") {{ trnItem.walletTo.name }}
+ .text-neutral-600.dark_text-neutral-500 {{ $t('trnForm.transfer.to') }}:
+ .text-neutral-500.dark_text-neutral-400 {{ trnItem.walletTo.name }}
//- Amount
.cursor-pointer
diff --git a/components/trns/useTrns.ts b/components/trns/useTrns.ts
index ec01bf92..878bb3c0 100644
--- a/components/trns/useTrns.ts
+++ b/components/trns/useTrns.ts
@@ -1,4 +1,4 @@
-import { getCategoriesIds } from '~/components/categories/getCategories'
+import { getTransactibleCategoriesIds } from '~/components/categories/getCategories'
import { getTrnsIds } from '~/components/trns/getTrns'
export default function useTrns() {
@@ -11,7 +11,7 @@ export default function useTrns() {
// TODO: move it to a separate function getFilterParams
const categoriesIds = storeFilter.value.catsIds.length > 0
- ? getCategoriesIds(storeFilter.value.catsIds, categoriesItems.value)
+ ? getTransactibleCategoriesIds(storeFilter.value.catsIds, categoriesItems.value)
: null
const walletsIds = storeFilter.value.walletsIds.length > 0
? storeFilter.value.walletsIds
diff --git a/components/ui/Header.vue b/components/ui/Header.vue
index d3135d88..fa3958a5 100644
--- a/components/ui/Header.vue
+++ b/components/ui/Header.vue
@@ -8,6 +8,6 @@
)
slot
- .flex.gap-2.py-1.pr-0
+ .flex.gap-2.py-1.pr-0(v-if="$slots.actions")
slot(name="actions")
</template>
diff --git a/components/wallets/CurrenciesChanger.vue b/components/wallets/CurrenciesChanger.vue
index 3a527e23..cb3fe08a 100644
--- a/components/wallets/CurrenciesChanger.vue
+++ b/components/wallets/CurrenciesChanger.vue
@@ -3,9 +3,7 @@ import useWallets from '~/components/wallets/useWallets'
const { walletsCurrencies } = useWallets()
const { $store } = useNuxtApp()
-function onSelect(value) {
- $store.dispatch('currencies/changeBaseCurrency', value)
-}
+const onSelect = value => $store.dispatch('currencies/changeBaseCurrency', value)
</script>
<template lang="pug">
diff --git a/components/wallets/Item.vue b/components/wallets/Item.vue
index 4c5ddd16..866e6b06 100644
--- a/components/wallets/Item.vue
+++ b/components/wallets/Item.vue
@@ -40,7 +40,7 @@ export default defineComponent({
) {{ wallet.name.substring(0, 2) }}
div
- .text-sm.text-neutral-500(class="dark_text-neutral-400") {{ wallet.name }}
+ .text-sm.text-neutral-500.dark_text-neutral-400 {{ wallet.name }}
template(v-if="isShowAmount")
Amount(
:amount="wallet.total"
diff --git a/components/wallets/Sort.vue b/components/wallets/Sort.vue
index aea876b4..214cff57 100644
--- a/components/wallets/Sort.vue
+++ b/components/wallets/Sort.vue
@@ -66,7 +66,7 @@ export default {
:style="{ background: $store.state.wallets.items[walletId].color }"
class="mt-[2px]"
) {{ $store.state.wallets.items[walletId].name.substring(0, 2) }}
- .grow.text-sm.text-neutral-500(class="dark_text-neutral-400") {{ $store.state.wallets.items[walletId].name }}
+ .grow.text-sm.text-neutral-500.dark_text-neutral-400 {{ $store.state.wallets.items[walletId].name }}
.cursor-grab.flex-center.w-11.h-11.handle.doNotCloseModal.hocus_bg-skin-item-main-hover
svg.w-6.h-6(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24")
@@ -96,7 +96,7 @@ export default {
//- :style="{ background: $store.state.wallets.items[walletId].color }"
//- class="mt-[2px]"
//- ) {{ $store.state.wallets.items[walletId].name.substring(0, 2) }}
-//- .grow.text-sm.text-neutral-500(class="dark_text-neutral-400") {{ $store.state.wallets.items[walletId].name }}
+//- .grow.text-sm.text-neutral-500.dark_text-neutral-400 {{ $store.state.wallets.items[walletId].name }}
//- .cursor-grab.flex-center.w-11.h-11.handle.doNotCloseModal.hocus_bg-gray-100.dark_hocus_bg-neutral-800
//- svg.w-6.h-6(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24")
diff --git a/components/welcome/CategoryForm.vue b/components/welcome/CategoryForm.vue
index ac385e18..b9d0efa1 100644
--- a/components/welcome/CategoryForm.vue
+++ b/components/welcome/CategoryForm.vue
@@ -1,36 +1,16 @@
<script setup lang="ts">
-import { allColors } from '~/assets/js/colors'
-import { random } from '~/assets/js/emo'
-import icons from '~/assets/js/icons'
+import { getPreparedFormData } from '~/components/categories/getForm'
+import { getParentCategory } from '~/components/categories/getCategories'
const emit = defineEmits(['afterSave'])
-
const { $store } = useNuxtApp()
-const categoryForm = ref({
- color: random(random(allColors)),
- icon: random(random(icons)),
- name: null,
- order: 1,
- parentId: 0,
- showInLastUsed: true,
- showInQuickSelector: false,
- showStat: true,
-})
-
-const parentCategory = computed(() => {
- if (categoryForm.value.parentId === 0)
- return false
- return $store.state.categories.items[categoryForm.value.parentId]
-})
-
-function updateValue(id, value) {
- categoryForm.value[id] = value
-}
+const categoryForm = ref(getPreparedFormData())
+const parentCategory = computed(() =>
+ getParentCategory($store.state.categories.items, categoryForm.value.parentId))
-function afterSave() {
- emit('afterSave')
-}
+const updateValue = (id, value) => categoryForm.value[id] = value
+const afterSave = () => emit('afterSave')
</script>
<script lang="ts">
@@ -46,19 +26,19 @@ export default defineComponent({
<template lang="pug">
UiPage
UiHeader
- router-link(v-slot="{ href, navigate }" to="/categories" custom)
- a.grow.hocus_bg-skin-item-main-hover(:href="href" @click="navigate")
- UiHeaderTitle
- .pb-1.text-xs.font-medium.text-skin-item-base-down
- | {{ $t('categories.createNewTitle') }}
- template(v-if="parentCategory")
- |
- | in {{ parentCategory.name }}
-
- .flex.items-center.gap-4
- | {{ categoryForm.name ? categoryForm.name : $t("categories.form.name.label") }}
- .w-8.h-8.rounded-full.flex-center.text-xl.text-skin-icon-base(:style="{ background: categoryForm.color }")
- div(:class="categoryForm.icon")
+ UiHeaderTitle
+ .pt-1.text-xs.font-medium.text-skin-item-base-down
+ | {{ $t('categories.createNewTitle') }}
+ template(v-if="parentCategory")
+ |
+ | {{ $t('common.in')}} {{ parentCategory.name }}
+
+ .pb-1.flex.items-center.gap-4
+ | {{ categoryForm.name ? categoryForm.name : $t("categories.form.name.label") }}
+ .w-8.h-8.rounded-full.flex-center.text-xl.text-skin-icon-base(
+ :style="{ background: categoryForm.color }"
+ )
+ div(:class="categoryForm.icon")
.pb-12
CategoriesForm(
:categoryForm="categoryForm"
diff --git a/layouts/error.vue b/layouts/error.vue
index 8acbaba6..5f38d75d 100644
--- a/layouts/error.vue
+++ b/layouts/error.vue
@@ -1,6 +1,5 @@
<script lang="ts">
export default defineComponent({
- // eslint-disable-next-line vue/require-prop-types
props: ['error'],
fetch() {
diff --git a/locales/en-US.js b/locales/en-US.js
index f15156d2..f5c2ab11 100644
--- a/locales/en-US.js
+++ b/locales/en-US.js
@@ -3,6 +3,7 @@ export default {
date: 'Date',
open: 'Open',
all: 'All',
+ in: 'in',
},
analytics: {
@@ -11,8 +12,6 @@ export default {
appName: 'Finapp',
- for: 'for',
-
locale: {
toggle: 'Toggle locale',
},
@@ -22,11 +21,10 @@ export default {
change: 'Change theme',
},
- backTo: 'Back to ',
close: 'Close',
transfer: {
- titleMany: 'Transfers',
+ titleMoney: 'Transfers',
},
trnForm: {
diff --git a/locales/ru-RU.js b/locales/ru-RU.js
index 87198428..fb4adecf 100644
--- a/locales/ru-RU.js
+++ b/locales/ru-RU.js
@@ -3,6 +3,7 @@ export default {
date: 'Дата',
open: 'Открыть',
all: 'Все',
+ in: 'в',
},
analytics: {
@@ -11,8 +12,6 @@ export default {
appName: 'Финапка',
- for: 'за',
-
locale: {
toggle: 'Сменить язык',
},
@@ -22,11 +21,10 @@ export default {
change: 'Сменить цвет оформления',
},
- backTo: 'Назад к ',
close: 'Закрыть',
transfer: {
- titleMany: 'Переводы',
+ titleMoney: 'Переводы',
},
trnForm: {
diff --git a/pages/login.vue b/pages/login.vue
index 089524d7..c9825b39 100644
--- a/pages/login.vue
+++ b/pages/login.vue
@@ -1,4 +1,5 @@
<script lang="ts">
+// TODO: setup
import { GoogleAuthProvider, signInWithRedirect } from 'firebase/auth'
import { auth } from '~/services/firebase/api'
@@ -69,8 +70,7 @@ export default defineComponent({
.flex.gap-3.top-3.right-5(
class="lg_top-7 lg_right-7"
)
- .linkItem.py-2.px-3.rounded-md(
- class="hocus_bg-white2 dark_hocus_bg-custom1"
+ .linkItem.py-2.px-3.rounded-md.hocus_bg-white2.dark_hocus_bg-custom1(
@click="$store.dispatch('ui/changeTheme')"
) {{ $t('changeTheme') }}
@@ -84,7 +84,7 @@ export default defineComponent({
@click.prevent="signInWithGoogle"
)
transition(name="fadeIn")
- .loginButton__spiner(v-if="isLoading"): SharedSpiner
+ .loginButton__spinier(v-if="isLoading"): SharedSpinier
.loginButton__text.text-white {{ $t('loginWithGoogle') }}
</template>
@@ -138,7 +138,7 @@ export default defineComponent({
^[0]._loading &
opacity 0
- &__spiner
+ &__spinier
position absolute
top 0
left 0
diff --git a/store/stat/getters.ts b/store/stat/getters.ts
index 6aa1515f..21f14815 100644
--- a/store/stat/getters.ts
+++ b/store/stat/getters.ts
@@ -1,7 +1,7 @@
import dayjs from 'dayjs'
import type { CategoryID } from '~/components/categories/types'
import type { TrnID } from '~/components/trns/types'
-import { getCategoriesIds, getTransferCategoriesIds } from '~/components/categories/getCategories'
+import { getTransactibleCategoriesIds, getTransferCategoriesIds } from '~/components/categories/getCategories'
import { getTotal } from '~/components/amount/getTotal'
import { getTrnsIds } from '~/components/trns/getTrns'
@@ -20,7 +20,7 @@ export default {
// TODO: move it to a separate function getFilterParams
const categoriesIds = rootState.filter.catsIds.length > 0
- ? getCategoriesIds(rootState.filter.catsIds, categoriesItems)
+ ? getTransactibleCategoriesIds(rootState.filter.catsIds, categoriesItems)
: null
const walletsIds = storeFilter.walletsIds.length > 0
? storeFilter.walletsIds
diff --git a/store/trns/getters.js b/store/trns/getters.js
index 95a61818..2eac78d0 100644
--- a/store/trns/getters.js
+++ b/store/trns/getters.js
@@ -1,5 +1,5 @@
import dayjs from 'dayjs'
-import { getCategoriesIds, getTransferCategoriesIds } from '~/components/categories/getCategories'
+import { getTransactibleCategoriesIds, getTransferCategoriesIds } from '~/components/categories/getCategories'
import { getTrnsIds } from '~/components/trns/getTrns'
export default {
@@ -48,7 +48,7 @@ export default {
// TODO: move it to a separate function getFilterParams
const categoriesIds = rootState.filter.catsIds.length > 0
- ? getCategoriesIds(rootState.filter.catsIds, categoriesItems)
+ ? getTransactibleCategoriesIds(rootState.filter.catsIds, categoriesItems)
: null
const walletsIds = storeFilter.walletsIds.length > 0
? storeFilter.walletsIds