Open source personal finance application
refactor: comprehensive code quality improvements across 80+ files
Ilya Komichev439a762c4a8d
diff --git a/app/app.vue b/app/app.vueindex b3b8546b..343704ba 100644--- a/app/app.vue+++ b/app/app.vue@@ -13,15 +13,13 @@ const toaster: ToasterProps = {progress: false,}-onMounted(() => {- document.addEventListener('click', (e) => {- const target = e.target as HTMLElement- const toast = target.closest('li[role="alert"][data-slot="base"]')- if (!toast)- return- const closeBtn = toast.querySelector<HTMLButtonElement>('[data-reka-toast-announce-exclude]')- closeBtn?.click()- })+useEventListener(document, 'click', (e) => {+ const target = e.target as HTMLElement+ const toast = target.closest('li[role="alert"][data-slot="base"]')+ if (!toast)+ return+ const closeBtn = toast.querySelector<HTMLButtonElement>('[data-reka-toast-announce-exclude]')+ closeBtn?.click()})const color = computed(() => colorMode.value === 'dark' ? (colors as Record<string, Record<string, string>>)[appConfig.ui.colors.neutral][900] : 'white')diff --git a/app/components/app/useInitApp.ts b/app/components/app/useInitApp.tsindex 0e6020b8..e63f731d 100644--- a/app/components/app/useInitApp.ts+++ b/app/components/app/useInitApp.ts@@ -13,9 +13,8 @@ import { useWalletsStore } from '~/components/wallets/useWalletsStore'import { blockPersist, unblockPersist } from '~/composables/useStoreSync'import { createLogger } from '~/utils/logger'-const isDbLoading = ref(false)-export function useInitApp() {+ const isDbLoading = ref(false)const userStore = useUserStore()const currenciesStore = useCurrenciesStore()const walletsStore = useWalletsStore()diff --git a/app/components/bottomSheet/BottomSheet.vue b/app/components/bottomSheet/BottomSheet.vueindex d1f98f79..a22a600a 100644--- a/app/components/bottomSheet/BottomSheet.vue+++ b/app/components/bottomSheet/BottomSheet.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { useElementSize, useScrollLock, useWindowSize } from '@vueuse/core'-import { useBottomSheetDrag } from './useBottomSheetDrag'const props = defineProps<{diff --git a/app/components/bottomSheet/BottomSheetOrDropdown.vue b/app/components/bottomSheet/BottomSheetOrDropdown.vueindex d1e6e69d..6d045677 100644--- a/app/components/bottomSheet/BottomSheetOrDropdown.vue+++ b/app/components/bottomSheet/BottomSheetOrDropdown.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { usePointer, useWindowSize } from '@vueuse/core'-const props = defineProps<{bottomSheetStyle?: Record<string, string>drugClassesCustom?: stringdiff --git a/app/components/bottomSheet/useBottomSheetDrag.ts b/app/components/bottomSheet/useBottomSheetDrag.tsindex 56346449..eb3af84f 100644--- a/app/components/bottomSheet/useBottomSheetDrag.ts+++ b/app/components/bottomSheet/useBottomSheetDrag.ts@@ -1,7 +1,5 @@import type { Ref } from 'vue'-import { useEventListener } from '@vueuse/core'-type Event = TouchEvent | MouseEventconst PERCENT_BASE = 100diff --git a/app/components/categories/CommandPalette.vue b/app/components/categories/CommandPalette.vueindex 34515220..f90df96b 100644--- a/app/components/categories/CommandPalette.vue+++ b/app/components/categories/CommandPalette.vue@@ -5,7 +5,7 @@ import { useCategoriesStore } from '~/components/categories/useCategoriesStore'const props = defineProps<{activeItemId?: CategoryId- hide?: () => null+ hide?: () => void}>()const emit = defineEmits<{@@ -36,7 +36,7 @@ const cats = computed(() => {const category = categoriesStore.items[id]!const items = category?.childIds?.length- ? categoriesStore.getChildsIds(id).map(childId => ({+ ? categoriesStore.getChildrenIds(id).map(childId => ({id: childId,...categoriesStore.items[childId],suffix: category.name,diff --git a/app/components/categories/Form.vue b/app/components/categories/Form.vueindex 2b4103f1..e4e9b023 100644--- a/app/components/categories/Form.vue+++ b/app/components/categories/Form.vue@@ -23,7 +23,7 @@ const categoriesStore = useCategoriesStore()const editCategoryId = props.categoryId ?? generateId()const isUpdateChildCategoriesColor = ref(true)-const childIds = computed(() => categoriesStore.getChildsIds(props.categoryId!))+const childIds = computed(() => categoriesStore.getChildrenIds(props.categoryId!))const hasChildren = computed(() => childIds.value.length > 0)const isAllowChangeParent = computed(() =>!hasChildren.value && categoriesStore.categoriesForBeParent.length > 0,@@ -51,7 +51,7 @@ function onParentSelect(parentId: CategoryId | false, close: () => void) {}emit('update', 'parentId', parentId)- // Change category color when patent category changed+ // Change category color when parent category changedconst parentCategoryColor = categoriesStore.items?.[parentId]?.colorif (parentCategoryColor)emit('update', 'color', parentCategoryColor)@@ -67,7 +67,7 @@ async function onSave() {return}- for (const id in categoriesStore.items) {+ for (const id of Object.keys(categoriesStore.items)) {if (categoriesStore.items[id].name === parsed.data.name && categoriesStore.items[id].parentId === parsed.data.parentId && id !== editCategoryId) {showErrorToast('categories.form.name.exist')returndiff --git a/app/components/categories/Item.vue b/app/components/categories/Item.vueindex 4e782e4b..1426b56c 100644--- a/app/components/categories/Item.vue+++ b/app/components/categories/Item.vue@@ -9,6 +9,7 @@ export type CategoryItemProps = {category: CategoryItemcategoryId: CategoryIdclass?: string+ contextMenuItems?: any[][]insideClasses?: stringisShowDots?: booleanisShowParent?: boolean@@ -25,37 +26,39 @@ const emit = defineEmits<{const categoriesStore = useCategoriesStore()-const childCategoriesIds = computed(() => categoriesStore.getChildsIds(props.categoryId))+const childCategoriesIds = computed(() => categoriesStore.getChildrenIds(props.categoryId))const parentCategory = computed(() => categoriesStore.items[props.category?.parentId])</script><template>- <UiElement- v-if="props.category"- :isActive="props.activeItemId === props.categoryId"- :class="props.class"- :lineWidth="props.lineWidth"- :insideClasses="`min-h-[46px] ${props.insideClasses}`"- @click="(e: Event) => emit('click', e)"- >- <template #leftIcon>- <UiIconBase- :color="props.category.color"- :name="props.category.icon"- invert- @click="emit('filter', props.categoryId ?? '')"- />- </template>-- <div class="grid grow gap-0.5">- <CategoriesName- :alt="props.alt"- :category="props.category"- :parentCategory="parentCategory"- :hasChildren="childCategoriesIds.length > 0"- :showChildrenCount="childCategoriesIds.length"- :isShowParent="props.isShowParent"- />- </div>- </UiElement>+ <component :is="props.contextMenuItems ? resolveComponent('UContextMenu') : 'div'" v-bind="props.contextMenuItems ? { items: props.contextMenuItems } : {}">+ <UiElement+ v-if="props.category"+ :isActive="props.activeItemId === props.categoryId"+ :class="props.class"+ :lineWidth="props.lineWidth"+ :insideClasses="`min-h-[46px] ${props.insideClasses}`"+ @click="(e: Event) => emit('click', e)"+ >+ <template #leftIcon>+ <UiIconBase+ :color="props.category.color"+ :name="props.category.icon"+ invert+ @click="emit('filter', props.categoryId ?? '')"+ />+ </template>++ <div class="grid grow gap-0.5">+ <CategoriesName+ :alt="props.alt"+ :category="props.category"+ :parentCategory="parentCategory"+ :hasChildren="childCategoriesIds.length > 0"+ :showChildrenCount="childCategoriesIds.length"+ :isShowParent="props.isShowParent"+ />+ </div>+ </UiElement>+ </component></template>diff --git a/app/components/categories/List.vue b/app/components/categories/List.vueindex 2d9a727c..e9487ec4 100644--- a/app/components/categories/List.vue+++ b/app/components/categories/List.vue@@ -7,6 +7,7 @@ import { useCategoriesStore } from '~/components/categories/useCategoriesStore'const props = defineProps<{activeItemId?: string | 0 | false | nullcategoriesItemProps?: Partial<CategoryItemProps>+ getContextMenuItems?: (categoryId: CategoryId) => any[][] | undefinedids: CategoryId[]insideClasses?: stringslider?: object@@ -28,13 +29,14 @@ const categoriesStore = useCategoriesStore():activeItemId="activeItemId":category="categoriesStore.items[categoryId]":categoryId="categoryId"+ :contextMenuItems="props.getContextMenuItems?.(categoryId)":slider="slider":insideClasses="props.insideClasses":lineWidth="1"isShowDotsv-bind="categoriesItemProps"@click="emit('click', categoryId)"- @clickIcon="emit('clickIcon', categoryId)"+ @filter="emit('clickIcon', categoryId)"/></div></template>diff --git a/app/components/categories/SelectorGrid.vue b/app/components/categories/SelectorGrid.vueindex 934428cd..62424407 100644--- a/app/components/categories/SelectorGrid.vue+++ b/app/components/categories/SelectorGrid.vue@@ -5,7 +5,7 @@ import { useCategoriesStore } from '~/components/categories/useCategoriesStore'const props = defineProps<{activeItemId?: CategoryId- hide?: () => null+ hide?: () => voidids: CategoryId[]}>()diff --git a/app/components/categories/SelectorTree.vue b/app/components/categories/SelectorTree.vueindex 5cc278ae..2bd16035 100644--- a/app/components/categories/SelectorTree.vue+++ b/app/components/categories/SelectorTree.vue@@ -4,7 +4,7 @@ import type { CategoryId } from '~/components/categories/types'import { useCategoriesStore } from '~/components/categories/useCategoriesStore'const props = defineProps<{- hide?: () => null+ hide?: () => voidselectedIds?: CategoryId[]}>()@@ -36,19 +36,19 @@ function select(categoryId: CategoryId, isForce: boolean) {}function onFilter(id: CategoryId) {- const childs = categoriesStore.getChildsIds(id)+ const childs = categoriesStore.getChildrenIds(id)emit('setCategories', childs)}function isChildsSelected(categoryId: CategoryId) {- return categoriesStore.getChildsIds(categoryId).some(id => props.selectedIds?.includes(id))+ return categoriesStore.getChildrenIds(categoryId).some(id => props.selectedIds?.includes(id))}function isEveryChildsSelected(categoryId: CategoryId) {- if (!categoriesStore.getChildsIds(categoryId).length)+ if (!categoriesStore.getChildrenIds(categoryId).length)return false- return categoriesStore.getChildsIds(categoryId).every(id => props.selectedIds?.includes(id))+ return categoriesStore.getChildrenIds(categoryId).every(id => props.selectedIds?.includes(id))}onMounted(() => {@@ -85,7 +85,7 @@ onMounted(() => {class="pr-2 pb-2 pl-4"><CategoriesItem- v-for="childCategoryId in categoriesStore.getChildsIds(categoryId)"+ v-for="childCategoryId in categoriesStore.getChildrenIds(categoryId)":key="childCategoryId":activeItemId="props.selectedIds?.includes(childCategoryId) ? childCategoryId : null":category="categoriesStore.items[childCategoryId]"diff --git a/app/components/categories/StatPage.vue b/app/components/categories/StatPage.vueindex 020a9018..4520cbe1 100644--- a/app/components/categories/StatPage.vue+++ b/app/components/categories/StatPage.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { useStorage } from '@vueuse/core'-import type { CategoryId } from '~/components/categories/types'import type { StatTabSlug } from '~/components/stat/types'@@ -25,7 +23,7 @@ provide(filterKey, filter)const categoryId = computed(() => route.params.id) as ComputedRef<CategoryId>const category = ref(categoriesStore.items[categoryId.value])-const categoriesIdsOrParent = computed(() => categoriesStore.getChildsIdsOrParent(categoryId.value))+const categoriesIdsOrParent = computed(() => categoriesStore.getChildrenIdsOrParent(categoryId.value))const activeTab = useStorage<StatTabSlug>(`stat-${categoryId.value}-tab`, 'summary')const storageKey = computed(() => `stat-${categoryId.value}-${activeTab.value}`)@@ -88,10 +86,6 @@ useHead({ title: category.value?.name }):config="{isShowWallets: true,}"- :menu="{- active: activeTab,- click: (id: StatTabSlug) => activeTab = id,- }"><template #title><CategoriesHeader@@ -103,7 +97,7 @@ useHead({ title: category.value?.name })<template #popover><UiHeaderLinkv-if="!categoriesStore.transferCategoriesIds.includes(categoryId)"- icon="mdi:pencil-outline"+ icon="lucide:pencil"@click="router.push(`/categories/${categoryId}/edit`)">{{ t('base.edit') }}diff --git a/app/components/categories/page/List.vue b/app/components/categories/page/List.vueindex af90820c..5afc372f 100644--- a/app/components/categories/page/List.vue+++ b/app/components/categories/page/List.vue@@ -1,19 +1,89 @@<script setup lang="ts">-import { useStorage } from '@vueuse/core'-import type { CategoryId } from '~/components/categories/types'import { useCategoriesStore } from '~/components/categories/useCategoriesStore'+import { useTrnsStore } from '~/components/trns/useTrnsStore'+import { showErrorToast, showSuccessToast } from '~/composables/useStoreSync'const { t } = useI18n()const router = useRouter()const categoriesStore = useCategoriesStore()+const trnsStore = useTrnsStore()useHead({ title: t('categories.title') })const categoriesView = useStorage<'list' | 'grid'>('finapp.categoriesView', 'list', localStorage, {mergeDefaults: true,})++const deleteCategoryId = ref<CategoryId | null>(null)++const deleteTrnsCount = computed(() => {+ if (!deleteCategoryId.value)+ return 0+ return trnsStore.getStoreTrnsIds({+ categoriesIds: categoriesStore.getChildrenIdsOrParent(deleteCategoryId.value),+ }).length+})++const deleteDescText = computed(() =>+ deleteTrnsCount.value > 0 ? t('categories.form.delete.alertWithTrns') : undefined,+)++const deleteHighlight = computed(() =>+ deleteTrnsCount.value > 0 ? t('trns.plural', deleteTrnsCount.value) : undefined,+)++function onClickDelete(categoryId: CategoryId) {+ for (const id of Object.keys(categoriesStore.items)) {+ if (categoriesStore.items[id]?.parentId === categoryId) {+ showErrorToast('categories.form.delete.errorChildren')+ return+ }+ }+ deleteCategoryId.value = categoryId+}++async function onDeleteConfirm() {+ if (!deleteCategoryId.value)+ return++ const categoryId = deleteCategoryId.value+ const trnsIds = [...trnsStore.getStoreTrnsIds({+ categoriesIds: categoriesStore.getChildrenIdsOrParent(categoryId),+ })]++ deleteCategoryId.value = null+ await categoriesStore.deleteCategory(categoryId, trnsIds)++ setTimeout(() => {+ showSuccessToast(trnsIds.length > 0+ ? 'categories.form.delete.okWithTrns'+ : 'categories.form.delete.okWithoutTrns', trnsIds.length > 0+ ? { length: trnsIds.length, trns: t('trns.plural', trnsIds.length) }+ : undefined)+ }, 300)+}++function getContextMenuItems(categoryId: CategoryId) {+ if (categoriesStore.transferCategoriesIds.includes(categoryId))+ return undefined++ return [[+ {+ icon: 'lucide:pencil',+ label: t('base.edit'),+ onSelect: () => router.push(`/categories/${categoryId}/edit`),+ },+ ], [+ {+ color: 'error' as const,+ icon: 'lucide:trash-2',+ label: t('base.delete'),+ onSelect: () => onClickDelete(categoryId),+ },+ ]]+}</script><template>@@ -64,9 +134,19 @@ const categoriesView = useStorage<'list' | 'grid'>('finapp.categoriesView', 'lis:class="{'grid gap-1.5 @sm:grid-cols-2 @2xl/page:grid-cols-3': categoriesView === 'grid',}"+ :getContextMenuItems="getContextMenuItems":insideClasses="categoriesView === 'grid' ? 'bg-item-2' : ''"@click="(categoryId: CategoryId) => router.push(`/categories/${categoryId}`)"/></div>++ <LayoutConfirmModal+ v-if="deleteCategoryId"+ :title="t('categories.form.delete.title')"+ :description="deleteDescText"+ :highlight="deleteHighlight"+ @closed="deleteCategoryId = null"+ @confirm="onDeleteConfirm"+ /></UiPage></template>diff --git a/app/components/categories/page/id/Index.vue b/app/components/categories/page/id/Index.vueindex 1533181e..bb6d6220 100644--- a/app/components/categories/page/id/Index.vue+++ b/app/components/categories/page/id/Index.vue@@ -1,5 +1,4 @@<script setup lang="ts">-import { useStorage } from '@vueuse/core'import { differenceInDays } from 'date-fns'import type { CategoryId } from '~/components/categories/types'@@ -28,8 +27,8 @@ provide(filterKey, filter)const categoryId = computed(() => route.params.id) as ComputedRef<CategoryId>const category = computed(() => categoriesStore.items[categoryId.value])-const preCategoriesIds = computed(() => categoriesStore.getChildsIds(categoryId.value))-const categoriesIdsOrParent = computed(() => categoriesStore.getChildsIdsOrParent(categoryId.value))+const preCategoriesIds = computed(() => categoriesStore.getChildrenIds(categoryId.value))+const categoriesIdsOrParent = computed(() => categoriesStore.getChildrenIdsOrParent(categoryId.value))const activeTab = useStorage<StatTabSlug>(`page-${categoryId.value}-tab`, 'summary')const storageKey = computed(() => `page-${categoryId.value}-${activeTab.value}`)@@ -90,21 +89,23 @@ function onEditClick(close: () => void) {useHead({ title: category.value?.name })-const deleteDescText = computed(() => {- if (trnsIds.value && trnsIds.value.length > 0)- return t('categories.form.delete.alertWithTrns', { trns: t('trns.plural', trnsIds.value.length) })- return undefined-})+const deleteDescText = computed(() =>+ trnsIds.value.length > 0 ? t('categories.form.delete.alertWithTrns') : undefined,+)++const deleteHighlight = computed(() =>+ trnsIds.value.length > 0 ? t('trns.plural', trnsIds.value.length) : undefined,+)const isShowDeleteConfirm = ref(false)function onClickDelete(close: () => void) {close()- for (const id in categoriesStore.items) {+ for (const id of Object.keys(categoriesStore.items)) {if (categoriesStore.items[id]?.parentId === categoryId.value) {- showErrorToast('categories.form.delete.errorChilds')+ showErrorToast('categories.form.delete.errorChildren')- return false+ return}}@@ -112,24 +113,24 @@ function onClickDelete(close: () => void) {}async function onDeleteConfirm() {- const trnsIdsS = [...trnsStore.getStoreTrnsIds({- categoriesIds: categoriesStore.getChildsIdsOrParent(categoryId.value),+ const deleteTrnsIds = [...trnsStore.getStoreTrnsIds({+ categoriesIds: categoriesStore.getChildrenIdsOrParent(categoryId.value),})]router.push('/categories')- await categoriesStore.deleteCategory(categoryId.value, trnsIdsS)+ await categoriesStore.deleteCategory(categoryId.value, deleteTrnsIds)// Give some time to complete redirectsetTimeout(() => {- showSuccessToast(trnsIdsS?.length > 0+ showSuccessToast(deleteTrnsIds.length > 0? 'categories.form.delete.okWithTrns'- : 'categories.form.delete.okWithoutTrns', trnsIdsS?.length > 0- ? { length: trnsIdsS.length, trns: t('trns.plural', trnsIdsS.length) }+ : 'categories.form.delete.okWithoutTrns', deleteTrnsIds.length > 0+ ? { length: deleteTrnsIds.length, trns: t('trns.plural', deleteTrnsIds.length) }: undefined)}, 300)}-const categoriesIds = computed(() => categoriesStore.getChildsIds(categoryId.value))+const categoriesIds = computed(() => categoriesStore.getChildrenIds(categoryId.value))</script><template>@@ -162,14 +163,14 @@ const categoriesIds = computed(() => categoriesStore.getChildsIds(categoryId.val#popover="{ close }"><UiHeaderLink- icon="mdi:pencil-outline"+ icon="lucide:pencil"@click="onEditClick(close)">{{ t('base.edit') }}</UiHeaderLink><UiHeaderLink- icon="mdi:delete-empty-outline"+ icon="lucide:trash-2"@click="onClickDelete(close)">{{ t('base.delete') }}@@ -179,7 +180,9 @@ const categoriesIds = computed(() => categoriesStore.getChildsIds(categoryId.val<LayoutConfirmModalv-if="isShowDeleteConfirm"+ :title="t('categories.form.delete.title')":description="deleteDescText"+ :highlight="deleteHighlight"@closed="isShowDeleteConfirm = false"@confirm="onDeleteConfirm"/>diff --git a/app/components/categories/useCategoriesStore.ts b/app/components/categories/useCategoriesStore.tsindex 31ea95bc..60282c3c 100644--- a/app/components/categories/useCategoriesStore.ts+++ b/app/components/categories/useCategoriesStore.ts@@ -40,8 +40,8 @@ type CategoriesStore = {categoriesRootIds: ComputedRef<CategoryId[]>deleteCategory: (id: CategoryId, trnsIds?: TrnId[]) => Promise<RemapInfo | void> | voidfavoriteCategoriesIds: ComputedRef<CategoryId[]>- getChildsIds: (categoryId: CategoryId) => CategoryId[]- getChildsIdsOrParent: (categoryId: CategoryId) => CategoryId[]+ getChildrenIds: (categoryId: CategoryId) => CategoryId[]+ getChildrenIdsOrParent: (categoryId: CategoryId) => CategoryId[]getTransactibleIds: (ids?: CategoryId[]) => CategoryId[]hasChildren: (categoryId: CategoryId) => booleanhasItems: ComputedRef<boolean>@@ -132,7 +132,7 @@ export const useCategoriesStore = defineStore('categories', (): CategoriesStore// Track most recent date per category (single pass)const latestDateByCategory = new Map<CategoryId, number>()- for (const trnId in trnsItems) {+ for (const trnId of Object.keys(trnsItems)) {const trn = trnsItems[trnId]if (!trn || trn.type === TrnType.Transfer || trn.categoryId === 'adjustment')continue@@ -206,7 +206,7 @@ export const useCategoriesStore = defineStore('categories', (): CategoriesStorereturn !!category.childIds?.length}- function getChildsIds(categoryId: CategoryId) {+ function getChildrenIds(categoryId: CategoryId) {if (!hasItems.value)return []@@ -218,7 +218,7 @@ export const useCategoriesStore = defineStore('categories', (): CategoriesStore.sort((a, b) => compareCategoriesByParentAndName(items.value[a]!, items.value[b]!, items.value))}- function getChildsIdsOrParent(categoryId: CategoryId) {+ function getChildrenIdsOrParent(categoryId: CategoryId) {if (!hasItems.value)return []@@ -258,7 +258,7 @@ export const useCategoriesStore = defineStore('categories', (): CategoriesStorefunction applyOptimisticUpdate(id: CategoryId, categoryValues: CategoryItem, isUpdateChildCategoriesColor: boolean, categoryChildIds: CategoryId[]) {const existingChildIds = items.value?.[id]?.childIdsconst updatedItems: Categories = {- ...items.value,+ ...(items.value ?? {}),[id]: existingChildIds ? { ...categoryValues, childIds: existingChildIds } : categoryValues,}@@ -278,7 +278,7 @@ export const useCategoriesStore = defineStore('categories', (): CategoriesStoreif (id === 'transfer' || id === 'adjustment')return- const categoryChildIds = getChildsIds(id)+ const categoryChildIds = getChildrenIds(id)// Frontend IDs are always treated as new creates (server generates real ID)const isExisting = !isLocalId(id) && items.value && id in items.value@@ -327,7 +327,7 @@ export const useCategoriesStore = defineStore('categories', (): CategoriesStorereturn// Optimistic UI- const categories = { ...items.value }+ const categories = { ...(items.value ?? {}) }const category = categories[id]if (category?.parentId && category.parentId !== 0) {const pId = String(category.parentId)@@ -368,8 +368,8 @@ export const useCategoriesStore = defineStore('categories', (): CategoriesStorecategoriesRootIds,deleteCategory,favoriteCategoriesIds,- getChildsIds,- getChildsIdsOrParent,+ getChildrenIds,+ getChildrenIdsOrParent,getTransactibleIds,hasChildren,hasItems,diff --git a/app/components/currencies/Item.vue b/app/components/currencies/Item.vuenew file mode 100644index 00000000..bb2aadfa--- /dev/null+++ b/app/components/currencies/Item.vue@@ -0,0 +1,60 @@+<script setup lang="ts">+import type { CurrencyCode } from '~/components/currencies/types'++const props = defineProps<{+ code: CurrencyCode+ isBase?: boolean+ name: string+ rate?: number+ symbol?: string+}>()++const emit = defineEmits<{+ setBase: [code: CurrencyCode]+}>()++const { t } = useI18n()++const contextMenuItems = computed(() => [[{+ disabled: props.isBase,+ icon: 'lucide:star',+ label: t('currencies.page.setBase'),+ onSelect: () => emit('setBase', props.code),+}]])+</script>++<template>+ <UContextMenu :items="contextMenuItems">+ <UiElement+ :lineWidth="props.isBase ? 6 : 0"+ class="group"+ insideClasses="!min-h-[44px]"+ >+ <div class="flex items-center justify-between gap-3">+ <div class="flex items-center gap-3">+ <div class="w-12 font-medium">+ {{ props.code }}+ </div>++ <div class="text-muted text-sm">+ {{ props.name }}+ <span v-if="props.symbol" class="ml-1 opacity-60">+ {{ props.symbol }}+ </span>+ </div>+ </div>++ <div class="shrink-0 text-right text-sm tabular-nums">+ <template v-if="props.isBase">+ <span class="text-muted text-xs opacity-60">+ {{ t('currencies.base') }}+ </span>+ </template>+ <template v-else-if="props.rate != null">+ {{ props.rate.toFixed(props.rate < 0.01 ? 6 : props.rate < 1 ? 4 : 2) }}+ </template>+ </div>+ </div>+ </UiElement>+ </UContextMenu>+</template>diff --git a/app/components/currencies/page/List.vue b/app/components/currencies/page/List.vuenew file mode 100644index 00000000..c0f69b05--- /dev/null+++ b/app/components/currencies/page/List.vue@@ -0,0 +1,121 @@+<script setup lang="ts">+import { currencies } from '~/components/currencies/currencies'+import { useCurrenciesStore } from '~/components/currencies/useCurrenciesStore'+import { useUserStore } from '~/components/user/useUserStore'+import { useWalletsStore } from '~/components/wallets/useWalletsStore'++const { t } = useI18n()+const currenciesStore = useCurrenciesStore()+const userStore = useUserStore()+const walletsStore = useWalletsStore()++useHead({ title: t('currencies.page.title') })++const showAll = ref(false)+const searchInput = ref('')++watch(showAll, (value) => {+ if (!value)+ searchInput.value = ''+})++const currencyMap = new Map(+ currencies.map(c => [c.code, { name: c.name, symbol: c.symbol }]),+)++function getRate(code: string): number | undefined {+ const base = currenciesStore.base+ const rates = currenciesStore.rates+ if (!base || !rates || code === base)+ return undefined++ const baseRate = rates[base] || 1+ const codeRate = rates[code] || 1+ return baseRate / codeRate+}++const list = computed(() => {+ const base = currenciesStore.base+ const usedCodes = walletsStore.currenciesUsed++ let items = showAll.value+ ? currencies.map(c => c.code)+ : usedCodes++ if (searchInput.value) {+ const search = searchInput.value.toLowerCase()+ items = items.filter((code) => {+ const info = currencyMap.get(code)+ return code.toLowerCase().includes(search)+ || info?.name.toLowerCase().includes(search)+ })+ }++ // Sort: base currency first, then alphabetically+ return items.toSorted((a, b) => {+ if (a === base)+ return -1+ if (b === base)+ return 1+ return a.localeCompare(b)+ })+})+</script>++<template>+ <UiPage>+ <UiHeader>+ <UiHeaderTitle>{{ t('currencies.page.title') }}</UiHeaderTitle>+ <template #actions>+ <UiActionButton @click="showAll = !showAll">+ <Icon+ :name="showAll ? 'lucide:filter' : 'lucide:globe'"+ size="20"+ />+ </UiActionButton>+ </template>+ </UiHeader>++ <div class="max-w-4xl grow px-2 lg:px-4 2xl:px-8">+ <!-- Toggle label -->+ <div class="flex items-center gap-3 pb-3">+ <button+ class="text-muted text-xs hover:text-(--ui-text-highlighted)"+ @click="showAll = !showAll"+ >+ {{ showAll ? t('currencies.page.showUsed') : t('currencies.page.showAll') }}+ </button>+ </div>++ <!-- Search (only when showing all) -->+ <div v-if="showAll" class="pb-3">+ <FormInput+ v-model="searchInput"+ :placeholder="`${t('currencies.list.search')}...`"+ />+ </div>++ <!-- Empty -->+ <div+ v-if="list.length === 0"+ class="text-muted py-6 text-center text-sm"+ >+ {{ t('currencies.list.notFound') }}+ </div>++ <!-- List -->+ <div v-else>+ <CurrenciesItem+ v-for="code in list"+ :key="code"+ :code="code"+ :isBase="code === currenciesStore.base"+ :name="currencyMap.get(code)?.name ?? code"+ :rate="getRate(code)"+ :symbol="currencyMap.get(code)?.symbol"+ @setBase="userStore.saveUserBaseCurrency"+ />+ </div>+ </div>+ </UiPage>+</template>diff --git a/app/components/date/Ranges.vue b/app/components/date/Ranges.vueindex 058354bb..a2f3a4c7 100644--- a/app/components/date/Ranges.vue+++ b/app/components/date/Ranges.vue@@ -18,7 +18,7 @@ const { t } = useI18n()const items = computed(() => {if (props.view === 'maximum')- return false+ return undefinedconst elements: Record<Exclude<typeof props.view, 'maximum'>, IntervalGroupedLabel[]> = {periods: [{diff --git a/app/components/date/useDateFormats.ts b/app/components/date/useDateFormats.tsindex fbafa751..b09aa7cc 100644--- a/app/components/date/useDateFormats.ts+++ b/app/components/date/useDateFormats.ts@@ -22,7 +22,7 @@ export function useDateFormats() {function formatDate(value: number, type: 'trnItem' | 'full') {if (!value)- return false+ return undefinedconst date = new Date(value)const diff = differenceInDays(new Date(), date)@@ -38,8 +38,6 @@ export function useDateFormats() {}case 'trnItem':- return formatDateToStringWithLast({ by: 'day', duration: 1, end: date, start: date, type: 'start' })-default:return formatDateToStringWithLast({ by: 'day', duration: 1, end: date, start: date, type: 'start' })}diff --git a/app/components/date/useStatDate.ts b/app/components/date/useStatDate.tsindex 9a443de8..f9a518f3 100644--- a/app/components/date/useStatDate.ts+++ b/app/components/date/useStatDate.ts@@ -1,4 +1,3 @@-import { useStorage } from '@vueuse/core'import { differenceInDays } from 'date-fns'import defu from 'defu'import { z } from 'zod/v4'diff --git a/app/components/layout/ConfirmModal.vue b/app/components/layout/ConfirmModal.vueindex 04151801..8a29f7a1 100644--- a/app/components/layout/ConfirmModal.vue+++ b/app/components/layout/ConfirmModal.vue@@ -1,6 +1,7 @@<script setup lang="ts">const props = defineProps<{description?: string+ highlight?: stringtitle?: string}>()@@ -31,12 +32,12 @@ function onClosed() {:ui="{ content: 'max-w-sm', footer: 'justify-between' }"@update:open="(val: boolean) => { if (!val) onClosed() }">- <template #body>- <div- v-if="description"- class="text-muted"- >+ <template v-if="description || highlight" #body>+ <div class="text-muted">{{ description }}+ <span v-if="highlight" class="font-medium text-(--ui-error)">+ {{ highlight }}+ </span></div></template>diff --git a/app/components/layout/Sidebar.vue b/app/components/layout/Sidebar.vueindex 113d4ec7..63cffb4e 100644--- a/app/components/layout/Sidebar.vue+++ b/app/components/layout/Sidebar.vue@@ -1,13 +1,10 @@<script setup lang="ts">-import { useWindowSize } from '@vueuse/core'-import { useDemo } from '~/components/demo/useDemo'import { useUserStore } from '~/components/user/useUserStore'import { useWalletsStore } from '~/components/wallets/useWalletsStore'const props = defineProps<{isShowSidebar?: boolean- isShowTrnForm?: boolean}>()const emit = defineEmits(['toggleSidebar'])diff --git a/app/components/layout/useMenuData.ts b/app/components/layout/useMenuData.tsindex d40c6761..a5018b44 100644--- a/app/components/layout/useMenuData.ts+++ b/app/components/layout/useMenuData.ts@@ -12,9 +12,8 @@ export type MenuItem = {}}-const isMenuOpen = ref(false)-export function useMenuData() {+ const isMenuOpen = ref(false)const { t } = useI18n()const { trnFormCreate } = useTrnsFormStore()const walletsStore = useWalletsStore()@@ -43,6 +42,10 @@ export function useMenuData() {icon: 'hugeicons:folder-library',name: t('categories.name'),},+ currencies: {+ icon: 'hugeicons:money-exchange-01',+ name: t('currencies.page.title'),+ },history: {icon: 'hugeicons:archive-01',name: t('trns.history'),diff --git a/app/components/stat/Average.vue b/app/components/stat/Average.vueindex 91533489..b33263cc 100644--- a/app/components/stat/Average.vue+++ b/app/components/stat/Average.vue@@ -11,6 +11,7 @@ import type { WalletId } from '~/components/wallets/types'import { useAmount } from '~/components/amount/useAmount'import { useCurrenciesStore } from '~/components/currencies/useCurrenciesStore'import { getEndOf, getStartOf } from '~/components/date/utils'+import { TrnType } from '~/components/trns/types'import { useTrnsStore } from '~/components/trns/useTrnsStore'const props = defineProps<{@@ -62,7 +63,7 @@ const total = computed(() => getTotalOfTrnsIds(datedTrnsIds.value))v-if="statTabSlug === 'income'":amount="total.income / props.averageConfig":currencyCode="currenciesStore.base"- :type="1"+ :type="TrnType.Income"align="left"colorize="income"variant="base"@@ -71,7 +72,7 @@ const total = computed(() => getTotalOfTrnsIds(datedTrnsIds.value))v-if="statTabSlug === 'expense'":amount="total.expense / props.averageConfig":currencyCode="currenciesStore.base"- :type="0"+ :type="TrnType.Expense"align="left"colorize="expense"variant="base"@@ -81,7 +82,7 @@ const total = computed(() => getTotalOfTrnsIds(datedTrnsIds.value)):amount="total.sum / props.averageConfig":colorize="total.sum > 0 ? 'income' : 'expense'":currencyCode="currenciesStore.base"- :type="total.sum > 0 ? 1 : 0"+ :type="total.sum > 0 ? TrnType.Income : TrnType.Expense"align="left"variant="base"/>diff --git a/app/components/stat/CategoriesButtons.vue b/app/components/stat/CategoriesButtons.vueindex 1c7ee36f..e74b435f 100644--- a/app/components/stat/CategoriesButtons.vue+++ b/app/components/stat/CategoriesButtons.vue@@ -10,51 +10,6 @@ import { statConfigKey } from '~/components/stat/injectionKeys'const { t } = useI18n()const statConfig = inject(statConfigKey)!-const favorites = computed(() => ({- isShow: computed(() => {- if (statConfig.config.value.catsView === 'list')- return statConfig.config.value.catsList.isShowFavorites-- if (statConfig.config.value.catsView === 'round')- return statConfig.config.value.catsRound.isShowFavorites-- return false- }),- toggle: () => {- if (statConfig.config.value.catsView === 'list')- statConfig.updateConfig('catsList', { isShowFavorites: !statConfig.config.value.catsList.isShowFavorites })-- if (statConfig.config.value.catsView === 'round')- statConfig.updateConfig('catsRound', { isShowFavorites: !statConfig.config.value.catsRound.isShowFavorites })- },-}))--const recent = {- isShow: computed(() => {- if (statConfig.config.value.catsView === 'list')- return statConfig.config.value.catsList.isShowRecent-- if (statConfig.config.value.catsView === 'round')- return statConfig.config.value.catsRound.isShowRecent-- return false- }),- toggle: () => {- if (statConfig.config.value.catsView === 'list') {- statConfig.updateConfig('catsList', {- isShowRecent: !statConfig.config.value.catsList.isShowRecent,- })- }-- if (statConfig.config.value.catsView === 'round') {- statConfig.updateConfig('catsRound', {- ...statConfig.config.value.catsRound,- isShowRecent: !statConfig.config.value.catsRound.isShowRecent,- })- }- },-}-const viewPresets = computed(() => ({minimal: {props: {@@ -149,46 +104,6 @@ function onChangeViewOptions(newViewOptions: Pick<DeepPartial<MiniItemConfig>, '</div></div>- <!-- TODO: use StatConfig -->- <div- v-if="false"- class="border-item-4 border-b pb-2 last:border-0 last:pb-0"- >- <!-- Favorite -->- <UiElement- class="text-sm"- @click="favorites.toggle"- >- <template #leftIcon>- <Icon- name="lucide:heart"- size="18"- />- </template>- <div class="grow">- {{ t('isShowFavorites') }}- </div>- <FormSwitch :value="favorites.isShow.value" />- </UiElement>-- <!-- Recent -->- <UiElement- class="text-sm"- @click="recent.toggle"- >- <template #leftIcon>- <Icon- name="lucide:history"- size="18"- />- </template>- <div class="grow">- {{ t('isShowRecent') }}- </div>- <FormSwitch :value="recent.isShow.value" />- </UiElement>- </div>-<divclass="border-item-4 grid gap-3 border-b pt-3 pb-2 last:border-0">diff --git a/app/components/stat/Header.vue b/app/components/stat/Header.vueindex 2b7424d0..c4d929be 100644--- a/app/components/stat/Header.vue+++ b/app/components/stat/Header.vue@@ -1,5 +1,5 @@<script setup lang="ts">-import type { StatConfigModal, StatTabSlug } from '~/components/stat/types'+import type { StatConfigModal } from '~/components/stat/types'import type { WalletId } from '~/components/wallets/types'import { filterKey, statConfigKey } from '~/components/stat/injectionKeys'@@ -17,10 +17,6 @@ const props = defineProps<{isShowSelected?: booleanisShowWallets?: boolean}- menu?: {- active: StatTabSlug- click: (id: StatTabSlug) => void- }}>()const filter = inject(filterKey)!diff --git a/app/components/stat/Item.vue b/app/components/stat/Item.vueindex 211d6860..de5d424b 100644--- a/app/components/stat/Item.vue+++ b/app/components/stat/Item.vue@@ -57,14 +57,15 @@ const {const quickViewTrns = ref<TrnId[]>([])const isShowTrns = ref(false)+const hasCategoriesData = computed(() => props.hasChildren || (props.preCategoriesIds ?? []).length > 0)function onClickCategory(clickedCategoryId: CategoryId) {if (route.name === 'categories-id') {filter.setCategoryId(clickedCategoryId)const baseParams = {- filterCategories: filter?.categoriesIds?.value.join(','),- filterWallets: props.walletId ? props.walletId : filter?.walletsIds?.value.join(','),+ filterCategories: filter.categoriesIds.value.join(','),+ filterWallets: props.walletId ? props.walletId : filter.walletsIds.value.join(','),storageKey: props.storageKey ?? '',}@@ -79,7 +80,7 @@ function onClickCategory(clickedCategoryId: CategoryId) {}, { includesChildCategories: true })}-function handleClickSumItem(type: SeriesSlugSelected) {+function onClickSumItemWrap(type: SeriesSlugSelected) {if (type === 'netIncome')isShowTrns.value = true@@ -102,7 +103,7 @@ function handleClickSumItem(type: SeriesSlugSelected) {<div class="grid min-w-0 content-start gap-3"><StatDateNavigation><StatFilterSelected- v-if="filter.isShow?.value && filter.categoriesIds.value.length > 0 || filter.walletsIds.value.length > 0"+ v-if="filter.isShow.value"isShowCategoriesisShowWallets/>@@ -123,13 +124,13 @@ function handleClickSumItem(type: SeriesSlugSelected) {:trnsIds:type="selectedTypeForSum":walletId- @click="handleClickSumItem"+ @click="onClickSumItemWrap"@clickAverage="statConfig.updateConfig('statAverage', { isShow: !statConfig.config.value.statAverage.isShow })"/><div class="_min-h-dvh grid min-w-0 content-start items-start gap-4"><StatCategoriesSection- v-if="statConfig.config.value.catsRound.isShow && (props.hasChildren || (props.preCategoriesIds ?? []).length > 0)"+ v-if="statConfig.config.value.catsRound.isShow && hasCategoriesData":filteredCategoriesIds:isOneCategory="props.isOneCategory":preCategoriesIds="props.preCategoriesIds || categoriesStore.favoriteCategoriesIds"@@ -144,7 +145,7 @@ function handleClickSumItem(type: SeriesSlugSelected) {}"><StatCategoriesSection2- v-if="(statConfig.config.value.catsList.isShow || statConfig.config.value.vertical.isShow) && (props.hasChildren || (props.preCategoriesIds ?? []).length > 0)"+ v-if="(statConfig.config.value.catsList.isShow || statConfig.config.value.vertical.isShow) && hasCategoriesData":isOneCategory="props.isOneCategory":preCategoriesIds="props.preCategoriesIds":selectedTrnsIds="selectedAndFilteredTrnsIds"diff --git a/app/components/stat/Menu.vue b/app/components/stat/Menu.vueindex fd15d754..13f7ef6d 100644--- a/app/components/stat/Menu.vue+++ b/app/components/stat/Menu.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { useWindowSize } from '@vueuse/core'-import type { StatTabSlug } from '~/components/stat/types'const props = defineProps<{@@ -17,7 +15,7 @@ const { width } = useWindowSize()const menu = computed(() => {const all: {id: StatTabSlug- name: string | unknown+ name: string}[] = [{id: 'summary',name: t('money.summary'),diff --git a/app/components/stat/Page.vue b/app/components/stat/Page.vueindex 70ef5d2b..067580e9 100644--- a/app/components/stat/Page.vue+++ b/app/components/stat/Page.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { useStorage } from '@vueuse/core'-import type { CategoryId } from '~/components/categories/types'import type { StatTabSlug } from '~/components/stat/types'import type { WalletId } from '~/components/wallets/types'diff --git a/app/components/stat/Wrap.vue b/app/components/stat/Wrap.vueindex 29cec34f..c2d80aef 100644--- a/app/components/stat/Wrap.vue+++ b/app/components/stat/Wrap.vue@@ -5,6 +5,7 @@ import type { StatTabSlug } from '~/components/stat/types'import type { TrnId } from '~/components/trns/types'import type { WalletId } from '~/components/wallets/types'+import { TrnType } from '~/components/trns/types'import { useTrnsStore } from '~/components/trns/useTrnsStore'const props = defineProps<{@@ -30,14 +31,14 @@ const datedTrnsIds = computed(() => trnsStore.getStoreTrnsIds({const expenseTrnsIds = computed(() => trnsStore.getStoreTrnsIds({trnsIds: datedTrnsIds.value,- trnsTypes: [0, 2],+ trnsTypes: [TrnType.Expense, TrnType.Transfer],}, {includesChildCategories: true,}))const incomeTrnsIds = computed(() => trnsStore.getStoreTrnsIds({trnsIds: datedTrnsIds.value,- trnsTypes: [1, 2],+ trnsTypes: [TrnType.Income, TrnType.Transfer],}, {includesChildCategories: true,}))diff --git a/app/components/stat/categories/Line.vue b/app/components/stat/categories/Line.vueindex e92cb5f2..b20e9abd 100644--- a/app/components/stat/categories/Line.vue+++ b/app/components/stat/categories/Line.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { onLongPress } from '@vueuse/core'-import type { CategoryId } from '~/components/categories/types'import type { CategoryWithData } from '~/components/stat/types'@@ -50,7 +48,6 @@ function getBarStyle() {}}-// TODO: addTrnFromSelectedIntervalconst longPressRef = ref(null)onLongPress(longPressRef,@@ -137,7 +134,7 @@ onLongPress(<CategoriesName:category:class="{ '!pb-2': statConfig.config.value.catsList.isLines }"- :hasChildren="categoriesStore.getChildsIds(props.item.id).length > 0"+ :hasChildren="categoriesStore.getChildrenIds(props.item.id).length > 0":isShowParent="props.isShowParent":parentCategory:showChildrenCount="props.item.categories?.length"diff --git a/app/components/stat/categories/Round.vue b/app/components/stat/categories/Round.vueindex 7f2b2d79..29bfeda1 100644--- a/app/components/stat/categories/Round.vue+++ b/app/components/stat/categories/Round.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { onLongPress } from '@vueuse/core'-import type { CategoryId } from '~/components/categories/types'import type { CategoryWithData } from '~/components/stat/types'@@ -25,7 +23,6 @@ const trnsFormStore = useTrnsFormStore()const category = computed(() => categoriesStore.items[props.item.id])-// TODO: addTrnFromSelectedIntervalconst longPressRef = ref(null)onLongPress(longPressRef,diff --git a/app/components/stat/categories/Round2lines.vue b/app/components/stat/categories/Round2lines.vueindex 651a954f..5c3d06e6 100644--- a/app/components/stat/categories/Round2lines.vue+++ b/app/components/stat/categories/Round2lines.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { onLongPress } from '@vueuse/core'-import type { CategoryId } from '~/components/categories/types'import type { CategoryWithData } from '~/components/stat/types'@@ -25,7 +23,6 @@ const trnsFormStore = useTrnsFormStore()const category = computed(() => categoriesStore.items[props.item.id])-// TODO: addTrnFromSelectedIntervalconst longPressRef = ref(null)onLongPress(longPressRef,diff --git a/app/components/stat/categories/Section2.vue b/app/components/stat/categories/Section2.vueindex abf26593..79e8e7a2 100644--- a/app/components/stat/categories/Section2.vue+++ b/app/components/stat/categories/Section2.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { useStorage } from '@vueuse/core'-import type { Categories, CategoryId } from '~/components/categories/types'import type { CategoryWithData, StatTabSlug } from '~/components/stat/types'import type { TrnId } from '~/components/trns/types'@@ -32,7 +30,7 @@ const categoriesWithData = computed<CategoryWithData[]>(() => {const isGrouped = statConfig.config.value[statConfig.config.value.catsView === 'list' ? 'catsList' : 'catsRound'].isGroupedconst cats: CategoryId[] = []- if (statConfig.config.value?.isShowEmptyCategories && props.preCategoriesIds) {+ if (statConfig.config.value.isShowEmptyCategories && props.preCategoriesIds) {cats.push(...props.preCategoriesIds)}@@ -45,6 +43,7 @@ const categoriesStat = computed<{ grouped: CategoryWithData[], ungrouped: Catego}))const verticalCategories = computed<CategoryWithData[]>(() => categoriesStat.value[statConfig.config.value.vertical.isGrouped ? 'grouped' : 'ungrouped'])+const visibleVerticalCategories = computed(() => verticalCategories.value.filter(c => c.value !== 0))const verticalBiggestCatNumber = computed(() => getBiggestCatNumber(verticalCategories.value))const linesCategories = computed<CategoryWithData[]>(() => categoriesStat.value[statConfig.config.value.catsList.isGrouped ? 'grouped' : 'ungrouped'])@@ -53,8 +52,8 @@ const linesBiggestCatNumber = computed(() => getBiggestCatNumber(linesCategoriesconst biggestCatNumber = computed(() => getBiggestCatNumber(categoriesWithData.value))function getBiggestCatNumber(categories: CategoryWithData[]) {- const income = categories.filter(c => c.value > 0).at(0)?.value ?? 0- const expense = categories.filter(c => c.value < 0).at(0)?.value ?? 0+ const income = categories.find(c => c.value > 0)?.value ?? 0+ const expense = categories.find(c => c.value < 0)?.value ?? 0return {expense: Math.abs(expense),@@ -124,7 +123,7 @@ function toggleRoot(id: CategoryId) {<template #header="{ toggle, isShown }"><div class="flex items-center justify-between"><UiTitleCollapse :isShown @click="toggle">- {{ t('stat.config.categories.vertical.title') }} {{ (!isShown && verticalCategories.filter(c => c.value !== 0).length > 0) ? verticalCategories.filter(c => c.value !== 0).length : '' }}+ {{ t('stat.config.categories.vertical.title') }} {{ (!isShown && visibleVerticalCategories.length > 0) ? visibleVerticalCategories.length : '' }}</UiTitleCollapse><div@@ -149,7 +148,7 @@ function toggleRoot(id: CategoryId) {><div class="flex overflow-hidden overflow-x-auto pt-2 pl-1"><StatCategoriesVertical- v-for="item in verticalCategories.filter(c => c.value !== 0)"+ v-for="item in visibleVerticalCategories":key="item.id":item="item":biggestCatNumber="verticalBiggestCatNumber"diff --git a/app/components/stat/categories/Vertical.vue b/app/components/stat/categories/Vertical.vueindex 8ac3be5e..58c10320 100644--- a/app/components/stat/categories/Vertical.vue+++ b/app/components/stat/categories/Vertical.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { onLongPress } from '@vueuse/core'-import type { CategoryId } from '~/components/categories/types'import type { CategoryWithData } from '~/components/stat/types'@@ -54,7 +52,6 @@ const amount = computed(() => {return `${props.item.value.toFixed()}`})-// TODO: addTrnFromSelectedIntervalconst longPressRef = ref(null)onLongPress(longPressRef,diff --git a/app/components/stat/chart/View.vue b/app/components/stat/chart/View.vueindex 3877089c..fd73452e 100644--- a/app/components/stat/chart/View.vue+++ b/app/components/stat/chart/View.vue@@ -24,9 +24,6 @@ const {} = defineProps<{chartType?: ChartTypeisShowDataLabels?: boolean- isShowExpense?: boolean- isShowIncome?: boolean- isShowSummary?: booleanperiod: Periodseries: ChartSeries[]xAxisLabels: number[]diff --git a/app/components/stat/chart/Wrap.vue b/app/components/stat/chart/Wrap.vueindex e45171ad..7db208f3 100644--- a/app/components/stat/chart/Wrap.vue+++ b/app/components/stat/chart/Wrap.vue@@ -48,7 +48,7 @@ function onChangePeriod(period: Period) {<template><div- v-if="statConfig.config.value?.chartShow"+ v-if="statConfig.config.value.chartShow":class="{'@3xl/main:max-w-xl': props.chartView === 'half',}"@@ -58,7 +58,7 @@ function onChangePeriod(period: Period) {<div class="h-7"><StatChartIntervals- :class="{ 'border-item-4 border-l': statConfig.config.value?.date.isShowQuick }"+ :class="{ 'border-item-4 border-l': statConfig.config.value.date.isShowQuick }":period="statDate.params.value.intervalsBy":range="statDate.range.value"@changePeriod="onChangePeriod"@@ -67,7 +67,7 @@ function onChangePeriod(period: Period) {</div><StatChartView- :chartType="statConfig.config.value?.chartType"+ :chartType="statConfig.config.value.chartType":period="statDate.params.value.intervalsBy":series="props.series":xAxisLabels="props.xAxisLabels"diff --git a/app/components/stat/date/Navigation.vue b/app/components/stat/date/Navigation.vueindex b1c4d49d..d26acd5f 100644--- a/app/components/stat/date/Navigation.vue+++ b/app/components/stat/date/Navigation.vue@@ -16,19 +16,13 @@ const isShowNav = computed(() =>const isDayToday = computed(() => statDate.params.value.rangeBy === 'day' && statDate.params.value.rangeDuration === 1 && statDate.range.value.end < getEndOf(new Date(), 'day').getTime())-const isEnd = computed(() => {- if (statDate.range.value.end >= getEndOf(new Date(), statDate.params.value.rangeBy).getTime() && !isDayToday.value)- return true+const isEnd = computed(() =>+ statDate.range.value.end >= getEndOf(new Date(), statDate.params.value.rangeBy).getTime() && !isDayToday.value,+)- return false-})--const isStart = computed(() => {- if (statDate.range.value.start <= statDate.maxRange.value.start)- return true-- return false-})+const isStart = computed(() =>+ statDate.range.value.start <= statDate.maxRange.value.start,+)const isShowNavHome = computed(() => {const start = getStartOf(sub(new Date(), { [`${statDate.params.value.rangeBy}s`]: statDate.params.value.rangeDuration - 1 }), statDate.params.value.rangeBy).getTime()diff --git a/app/components/stat/date/Quick.vue b/app/components/stat/date/Quick.vueindex dbd674f6..205f5af4 100644--- a/app/components/stat/date/Quick.vue+++ b/app/components/stat/date/Quick.vue@@ -10,8 +10,8 @@ const emit = defineEmits<{const statDate = inject(statDateKey)!-const sliderRef = ref<any>(null)-const sliderObj = ref<any>(null)+const sliderRef = ref<HTMLElement | null>(null)+const sliderObj = ref<Swiper | null>(null)onMounted(() => {const initialSlide = 1diff --git a/app/components/stat/filter/useFilter.ts b/app/components/stat/filter/useFilter.tsindex 44655e93..5643989e 100644--- a/app/components/stat/filter/useFilter.ts+++ b/app/components/stat/filter/useFilter.ts@@ -90,15 +90,6 @@ export function useFilter() {})}- function setCategoriesIds(newCategoriesIds: CategoryId[]) {- router.push({- query: {- ...route.query,- filterCategories: newCategoriesIds,- },- })- }-function removeCategoryId(categoryId: CategoryId) {router.push({query: {@@ -133,9 +124,7 @@ export function useFilter() {removeCategoryId,removeWalletId,setCategories,- setCategoriesIds,setCategoryId,- setWalletId,setWallets,toggleCategoryId,toggleWalletId,diff --git a/app/components/stat/sum/Item.vue b/app/components/stat/sum/Item.vueindex d915de46..f87c8b01 100644--- a/app/components/stat/sum/Item.vue+++ b/app/components/stat/sum/Item.vue@@ -62,7 +62,7 @@ const currenciesStore = useCurrenciesStore()><divv-for="(averageItem, slug) in props.averageTotal"- :key="averageItem"+ :key="slug"class="grid gap-1 pb-[2px]"><UiTextSubtitle>{{ t('money.average') }} <br> {{ t(`dates.${slug}.simple`) }}</UiTextSubtitle>diff --git a/app/components/stat/useStatConfig.ts b/app/components/stat/useStatConfig.tsindex 919e00f3..6e4a7753 100644--- a/app/components/stat/useStatConfig.ts+++ b/app/components/stat/useStatConfig.ts@@ -1,6 +1,5 @@import type { DeepPartial } from '~~/utils/types'-import { useStorage } from '@vueuse/core'import defu from 'defu'import { z } from 'zod/v4'diff --git a/app/components/stat/useStatItem.ts b/app/components/stat/useStatItem.tsindex dea02c34..b7112041 100644--- a/app/components/stat/useStatItem.ts+++ b/app/components/stat/useStatItem.ts@@ -1,6 +1,5 @@import type { ComputedRef } from 'vue'-import { useStorage } from '@vueuse/core'import { differenceInDays, differenceInMonths, differenceInWeeks } from 'date-fns'import type { CategoryId } from '~/components/categories/types'@@ -196,8 +195,10 @@ export function useStatItem({)function onSetCategoryFilter(categoryId: CategoryId) {- if (filteredCategoriesIds.value.includes(categoryId))- return filteredCategoriesIds.value = []+ if (filteredCategoriesIds.value.includes(categoryId)) {+ filteredCategoriesIds.value = []+ return+ }filteredCategoriesIds.value = [categoryId]}diff --git a/app/components/trnForm/Bottom.vue b/app/components/trnForm/Bottom.vueindex bd8aabcc..e040cc7c 100644--- a/app/components/trnForm/Bottom.vue+++ b/app/components/trnForm/Bottom.vue@@ -20,14 +20,16 @@ const isShow = computed(() =>/*** Slider*/-const sliderRef = ref<any>(null)-const sliderObj = ref<any>(null)+const sliderRef = ref<HTMLElement | null>(null)+const sliderObj = ref<Swiper | null>(null)const maxHeight = ref('550px')+let resizeObserver: ResizeObserver | null = null+function setTrnFormHeight() {const el = document.querySelector('.getHeight')- const observer = new ResizeObserver((entries) => {+ resizeObserver = new ResizeObserver((entries) => {for (const entry of entries) {const height = entry.contentRect.heightmaxHeight.value = `${height}px`@@ -35,9 +37,13 @@ function setTrnFormHeight() {})if (el)- observer.observe(el)+ resizeObserver.observe(el)}+onBeforeUnmount(() => {+ resizeObserver?.disconnect()+})+function init() {if (!sliderObj.value) {sliderObj.value = new Swiper(sliderRef.value, {diff --git a/app/components/trnForm/EditedTrn.vue b/app/components/trnForm/EditedTrn.vueindex 57b48cf7..44cfd237 100644--- a/app/components/trnForm/EditedTrn.vue+++ b/app/components/trnForm/EditedTrn.vue@@ -29,7 +29,7 @@ const items = computed(() => ({click: () => {showModalConfirm.value = true},- icon: 'mdi:delete-empty-outline',+ icon: 'lucide:trash-2',label: t('base.delete'),},}))diff --git a/app/components/trnForm/Main.vue b/app/components/trnForm/Main.vueindex 672e7f23..4dc42a74 100644--- a/app/components/trnForm/Main.vue+++ b/app/components/trnForm/Main.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { usePointer, useWindowSize } from '@vueuse/core'-import type { CategoryId } from '~/components/categories/types'import type { WalletId } from '~/components/wallets/types'@@ -23,8 +21,8 @@ const isLaptop = computed(() => width.value >= 766 && pointerType.value === 'mouconst walletId = computed(() => {const walletsIds = Object.keys(walletsStore.items ?? {})- const walletId = walletsIds[0]- return trnsFormStore.values.walletId ?? walletId+ const firstWalletId = walletsIds[0]+ return trnsFormStore.values.walletId ?? firstWalletId})const isShow = ref(false)diff --git a/app/components/trnForm/Selection.vue b/app/components/trnForm/Selection.vueindex 1cce7b11..d522c919 100644--- a/app/components/trnForm/Selection.vue+++ b/app/components/trnForm/Selection.vue@@ -24,8 +24,8 @@ const { t } = useI18n()const categoriesStore = useCategoriesStore()const trnsFormStore = useTrnsFormStore()-const sliderRef = ref<any>(null)-const sliderObj = ref<any>(null)+const sliderRef = ref<HTMLElement | null>(null)+const sliderObj = ref<Swiper | null>(null)onMounted(() => {if (!sliderObj.value) {sliderObj.value = new Swiper(sliderRef.value, {diff --git a/app/components/trnForm/SelectionCategoriesFast.vue b/app/components/trnForm/SelectionCategoriesFast.vueindex 402cb343..4f4aad28 100644--- a/app/components/trnForm/SelectionCategoriesFast.vue+++ b/app/components/trnForm/SelectionCategoriesFast.vue@@ -13,6 +13,12 @@ const emit = defineEmits<{const { t } = useI18n()const categoriesStore = useCategoriesStore()const trnsFormStore = useTrnsFormStore()++const isShowAllCategoriesFallback = computed(() =>+ categoriesStore.favoriteCategoriesIds.length === 0+ && categoriesStore.recentCategoriesIds.length === 0+ && categoriesStore.categoriesIdsForTrnValues.length > 0,+)</script><template>@@ -27,7 +33,7 @@ const trnsFormStore = useTrnsFormStore()<CategoriesSelectorGrid:activeItemId="trnsFormStore.values.categoryId"- :hide="emit('close')"+ :hide="() => emit('close')":ids="categoriesStore.favoriteCategoriesIds"@clickParent="id => emit('selectParentCategory', id)"@selected="id => emit('selectCategory', id)"@@ -42,7 +48,7 @@ const trnsFormStore = useTrnsFormStore()<CategoriesSelectorGrid:activeItemId="trnsFormStore.values.categoryId"- :hide="emit('close')"+ :hide="() => emit('close')":ids="categoriesStore.recentCategoriesIds"@clickParent="id => emit('selectParentCategory', id)"@selected="id => emit('selectCategory', id)"@@ -50,10 +56,10 @@ const trnsFormStore = useTrnsFormStore()</div><!-- All categories fallback when no favorites and no recent -->- <div v-if="categoriesStore.favoriteCategoriesIds.length === 0 && categoriesStore.recentCategoriesIds.length === 0 && categoriesStore.categoriesIdsForTrnValues.length > 0">+ <div v-if="isShowAllCategoriesFallback"><CategoriesSelectorGrid:activeItemId="trnsFormStore.values.categoryId"- :hide="emit('close')"+ :hide="() => emit('close')":ids="categoriesStore.categoriesIdsForTrnValues"@clickParent="id => emit('selectParentCategory', id)"@selected="id => emit('selectCategory', id)"diff --git a/app/components/trnForm/Sidebar.vue b/app/components/trnForm/Sidebar.vueindex a0668ff9..c0ecc891 100644--- a/app/components/trnForm/Sidebar.vue+++ b/app/components/trnForm/Sidebar.vue@@ -13,8 +13,8 @@ const isShow = computed(() => trnsFormStore.ui.isShow)/*** Slider*/-const sliderRef = ref<any>(null)-const sliderObj = ref<any>(null)+const sliderRef = ref<HTMLElement | null>(null)+const sliderObj = ref<Swiper | null>(null)function init() {if (!sliderObj.value) {@@ -34,9 +34,10 @@ function init() {}}-watch(isShow, (v) => {+watch(isShow, async (v) => {if (v) {- setTimeout(() => init(), 10)+ await nextTick()+ init()}else {sliderObj.value?.destroy()diff --git a/app/components/trnForm/TrnsSlide.vue b/app/components/trnForm/TrnsSlide.vueindex 82af96d8..44cf32c2 100644--- a/app/components/trnForm/TrnsSlide.vue+++ b/app/components/trnForm/TrnsSlide.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { useStorage } from '@vueuse/core'-import type { CategoryId } from '~/components/categories/types'import type { WalletId } from '~/components/wallets/types'@@ -37,7 +35,7 @@ const trnsIds = computed(() => {if (trnsFormStore.values.walletId)walletsIds.push(trnsFormStore.values.walletId)- categoriesIds = categoriesStore.getChildsIdsOrParent(trnsFormStore.values.categoryId!)+ categoriesIds = categoriesStore.getChildrenIdsOrParent(trnsFormStore.values.categoryId!)}return trnsStore.getStoreTrnsIds({@@ -75,7 +73,6 @@ const tabs = computed<{ id: FilterBy, name: string }[]>(() => [<div class="grid-rows-[1fr_auto] gap-2"><TrnsList:trnsIds="trnsIds"- isHideDatesisShowDatesisShowExpenseisShowFilterByDescdiff --git a/app/components/trnForm/main/ActionSide.vue b/app/components/trnForm/main/ActionSide.vueindex 64c734d4..bf8e9b40 100644--- a/app/components/trnForm/main/ActionSide.vue+++ b/app/components/trnForm/main/ActionSide.vue@@ -5,7 +5,6 @@ import { useTrnsStore } from '~/components/trns/useTrnsStore'const trnsStore = useTrnsStore()const trnsFormStore = useTrnsFormStore()-// TODO: check for 0const isMath = computed(() => trnsFormStore.getIsShowSum())const isSubmittable = computed(() => trnsFormStore.values.amount[trnsFormStore.activeAmountIdx] > 0)diff --git a/app/components/trnForm/main/AmountTransfer.vue b/app/components/trnForm/main/AmountTransfer.vueindex 983616d7..c3ecd0bb 100644--- a/app/components/trnForm/main/AmountTransfer.vue+++ b/app/components/trnForm/main/AmountTransfer.vue@@ -36,7 +36,7 @@ const incomeWalletId = computed<WalletId | undefined>()const expenseWalletId = computed<WalletId | undefined>(- () => trnsFormStore.values.expenseWalletId ?? walletsStore.sortedIds[1],+ () => trnsFormStore.values.expenseWalletId ?? walletsStore.sortedIds[1] ?? walletsStore.sortedIds[0],)watch(diff --git a/app/components/trnForm/main/Calculator.vue b/app/components/trnForm/main/Calculator.vueindex d8cf1a46..9986d630 100644--- a/app/components/trnForm/main/Calculator.vue+++ b/app/components/trnForm/main/Calculator.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { onLongPress } from '@vueuse/core'-import type { CalculatorKey } from '~/components/trnForm/utils/calculate'import { useTrnsFormStore } from '~/components/trnForm/useTrnsFormStore'diff --git a/app/components/trnForm/main/Description.vue b/app/components/trnForm/main/Description.vueindex 659502ce..087e5679 100644--- a/app/components/trnForm/main/Description.vue+++ b/app/components/trnForm/main/Description.vue@@ -33,7 +33,7 @@ function onSave(close: () => void) {<TrnFormMainCalculatorButton class="relative"><Icon name="lucide:message-square" size="26" /><div- v-if="!!trnsFormStore.values.desc"+ v-if="trnsFormStore.values.desc"class="absolute top-1 right-1 aspect-square w-2 rounded-full bg-(--ui-primary)"/></TrnFormMainCalculatorButton>diff --git a/app/components/trnForm/useTrnsFormStore.ts b/app/components/trnForm/useTrnsFormStore.tsindex 1d32129a..441c17db 100644--- a/app/components/trnForm/useTrnsFormStore.ts+++ b/app/components/trnForm/useTrnsFormStore.ts@@ -149,7 +149,7 @@ export const useTrnsFormStore = defineStore('trnForm', () => {values.categoryId = props.trn?.categoryId ?? props.categoriesIds[0]values.incomeWalletId = props.walletsIds[0]- values.expenseWalletId = props.walletsIds[1]+ values.expenseWalletId = props.walletsIds[1] ?? props.walletsIds[0]}if (props.action === 'edit')diff --git a/app/components/trns/Item.vue b/app/components/trns/Item.vueindex bf70a817..fddc5c90 100644--- a/app/components/trns/Item.vue+++ b/app/components/trns/Item.vue@@ -110,7 +110,7 @@ const emit = defineEmits<{:amount="trnItem.expenseAmount || trnItem.amount":colorize="trnItem.incomeAmount === trnItem.expenseAmount ? '' : 'expense'":currencyCode="trnItem.expenseWallet.currency"- :type="0"+ :type="TrnType.Expense"class="!flex items-center gap-2"variant="sm"/>@@ -122,7 +122,7 @@ const emit = defineEmits<{'opacity-0': trnItem.incomeAmount === trnItem.expenseAmount,}":currencyCode="trnItem.incomeWallet.currency"- :type="1"+ :type="TrnType.Income"colorize="income"class="!flex items-center gap-2"variant="sm"diff --git a/app/components/trns/List.vue b/app/components/trns/List.vueindex 3878b1ab..1ec86132 100644--- a/app/components/trns/List.vue+++ b/app/components/trns/List.vue@@ -26,7 +26,6 @@ const {} = defineProps<{alt?: booleaninitTrnType?: TrnsViewType- isHideDates?: booleanisShowDates?: booleanisShowExpense?: booleanisShowFilterByDesc?: boolean@@ -94,41 +93,28 @@ const selectedTypeFilter = computed(() => {return typeFilters.value.find(item => item.slug === filterBy.value)})-const isTrnsWithDesc = computed(() => {- let ids = trnsIds ?? []+const filteredByTypeIds = computed(() => {+ if (filterBy.value === 'all')+ return trnsIds ?? []- if (filterBy.value !== 'all') {- ids = trnsIds.filter((id) => {- if (filterBy.value === 'adjustment')- return trnsStore.items[id]?.categoryId === 'adjustment'- return trnsStore.items[id].type === selectedTypeFilter.value?.type- })- }-- return (ids).some(id => trnsStore.items[id]?.desc)-})+ return (trnsIds ?? []).filter((id) => {+ if (filterBy.value === 'adjustment')+ return trnsStore.items[id]?.categoryId === 'adjustment'-const selectedIds = computed(() => {- let ids = trnsIds ?? []+ if (filterBy.value === 'transfer')+ return trnsStore.items[id]?.type === selectedTypeFilter.value?.type || categoriesStore.transferCategoriesIds.includes(trnsStore.items[id]?.categoryId)- if (filterBy.value !== 'all') {- ids = trnsIds.filter((id) => {- if (filterBy.value === 'adjustment')- return trnsStore.items[id]?.categoryId === 'adjustment'-- if (filterBy.value === 'transfer') {- return trnsStore.items[id]?.type === selectedTypeFilter.value?.type || categoriesStore.transferCategoriesIds.includes(trnsStore.items[id]?.categoryId)- }+ return trnsStore.items[id]?.type === selectedTypeFilter.value?.type+ })+})- return trnsStore.items[id]?.type === selectedTypeFilter.value?.type- })- }+const isTrnsWithDesc = computed(() => filteredByTypeIds.value.some(id => trnsStore.items[id]?.desc))- if (isShowWithDesc.value && isTrnsWithDesc.value) {- ids = ids.filter(id => trnsStore.items[id].desc)- }+const selectedIds = computed(() => {+ if (isShowWithDesc.value && isTrnsWithDesc.value)+ return filteredByTypeIds.value.filter(id => trnsStore.items[id]?.desc)- return ids+ return filteredByTypeIds.value})const paginatedTrnsIds = computed(() => selectedIds.value.slice(0, pageNumber.value * size))@@ -162,6 +148,16 @@ const groupedTrns = computed(() => paginatedTrnsIds.valuereturn acc}, {} as Record<string, TrnId[]>))+const paginatedTotal = computed(() => getTotalOfTrnsIds(paginatedTrnsIds.value))++const trnItemsMap = computed(() => {+ const map = new Map<TrnId, ReturnType<typeof trnsStore.computeTrnItem>>()+ for (const trnId of paginatedTrnsIds.value) {+ map.set(trnId, trnsStore.computeTrnItem(trnId))+ }+ return map+})+function onOpenTrnForm(date: number) {trnsFormStore.trnFormCreate()trnsFormStore.$patch((state) => {@@ -229,21 +225,21 @@ function onOpenTrnForm(date: number) {class="border-item-4 border-b pr-3 pb-2 opacity-60"><Amount- v-if="getTotalOfTrnsIds(paginatedTrnsIds).income !== 0"- :amount="getTotalOfTrnsIds(paginatedTrnsIds).income"+ v-if="paginatedTotal.income !== 0"+ :amount="paginatedTotal.income":currencyCode="currenciesStore.base":isShowBaseRate="false"- :type="1"+ :type="TrnType.Income"colorize="income"variant="sm"/><Amount- v-if="getTotalOfTrnsIds(paginatedTrnsIds).expense !== 0"- :amount="getTotalOfTrnsIds(paginatedTrnsIds).expense"+ v-if="paginatedTotal.expense !== 0"+ :amount="paginatedTotal.expense":currencyCode="currenciesStore.base":isShowBaseRate="false"- :type="0"+ :type="TrnType.Expense"isShowMinusvariant="sm"/>@@ -251,11 +247,11 @@ function onOpenTrnForm(date: number) {<template v-for="trnId in paginatedTrnsIds" :key="trnId"><TrnsItemWrap- v-if="trnsStore.computeTrnItem(trnId)"+ v-if="trnItemsMap.get(trnId)":alt="alt"- :date="formatDate(trnsStore.computeTrnItem(trnId)?.date, 'trnItem')"+ :date="formatDate(trnItemsMap.get(trnId)?.date, 'trnItem')":trnId="trnId"- :trnItem="trnsStore.computeTrnItem(trnId)"+ :trnItem="trnItemsMap.get(trnId)"class="group/trn group"@click="emit('click')"/>@@ -292,7 +288,7 @@ function onOpenTrnForm(date: number) {:amount="getTotalOfTrnsIds(groupTrnsIds).income":currencyCode="currenciesStore.base":isShowBaseRate="false"- :type="1"+ :type="TrnType.Income"colorize="income"variant="sm"/>@@ -302,7 +298,7 @@ function onOpenTrnForm(date: number) {:amount="getTotalOfTrnsIds(groupTrnsIds).expense":currencyCode="currenciesStore.base":isShowBaseRate="false"- :type="0"+ :type="TrnType.Expense"isShowMinusvariant="sm"/>@@ -312,11 +308,11 @@ function onOpenTrnForm(date: number) {<div><template v-for="trnId in groupTrnsIds" :key="trnId"><TrnsItemWrap- v-if="trnsStore.computeTrnItem(trnId)"+ v-if="trnItemsMap.get(trnId)":alt="alt":trnId="trnId"- :trnItem="trnsStore.computeTrnItem(trnId)"- :date="formatDate(trnsStore.computeTrnItem(trnId)?.date, 'trnItem')"+ :trnItem="trnItemsMap.get(trnId)"+ :date="formatDate(trnItemsMap.get(trnId)?.date, 'trnItem')"class="group"@click="emit('click')"/>diff --git a/app/components/trns/itemWrap.vue b/app/components/trns/itemWrap.vueindex 91808d65..c7c8e8cd 100644--- a/app/components/trns/itemWrap.vue+++ b/app/components/trns/itemWrap.vue@@ -2,6 +2,7 @@import type { TrnId, TrnItemFull } from '~/components/trns/types'import { useTrnsFormStore } from '~/components/trnForm/useTrnsFormStore'+import { useTrnsStore } from '~/components/trns/useTrnsStore'const props = defineProps<{alt?: boolean@@ -14,19 +15,57 @@ const emit = defineEmits<{click: []}>()-const { trnFormEdit } = useTrnsFormStore()+const { t } = useI18n()+const trnsStore = useTrnsStore()+const { trnFormDuplicate, trnFormEdit } = useTrnsFormStore()++const showDeleteConfirm = ref(false)++const contextMenuItems = computed(() => [[+ {+ icon: 'lucide:pencil',+ label: t('base.edit'),+ onSelect: () => click(),+ },+ {+ icon: 'lucide:copy',+ label: t('base.duplicate'),+ onSelect: () => trnFormDuplicate(props.trnId),+ },+], [+ {+ color: 'error' as const,+ icon: 'lucide:trash-2',+ label: t('base.delete'),+ onSelect: () => { showDeleteConfirm.value = true },+ },+]])function click() {emit('click')trnFormEdit(props.trnId)}++function handleDeleteConfirm() {+ trnsStore.deleteTrn(props.trnId)+ showDeleteConfirm.value = false+}</script><template>- <TrnsItem- :alt="props.alt"- :trnItem- :date- @click="click"+ <UContextMenu :items="contextMenuItems">+ <TrnsItem+ :alt="props.alt"+ :trnItem+ :date+ @click="click"+ />+ </UContextMenu>++ <LayoutConfirmModal+ v-if="showDeleteConfirm"+ :title="t('trnForm.delete.alert')"+ @closed="showDeleteConfirm = false"+ @confirm="handleDeleteConfirm"/></template>diff --git a/app/components/trns/pages/History.vue b/app/components/trns/pages/History.vueindex 81fb980e..1dc8c5ab 100644--- a/app/components/trns/pages/History.vue+++ b/app/components/trns/pages/History.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { useStorage } from '@vueuse/core'-import type { CategoryId } from '~/components/categories/types'import type { WalletId } from '~/components/wallets/types'diff --git a/app/components/trns/types.ts b/app/components/trns/types.tsindex a5d901a4..09b601ca 100644--- a/app/components/trns/types.ts+++ b/app/components/trns/types.ts@@ -79,11 +79,9 @@ export type TrnsGetterProps = {}export type TrnFormValues = {- // ['Transaction', 'expenseTransfer', 'incomeTransfer']+ // [transaction, expenseTransfer, incomeTransfer]amount: [number, number, number]- // TODO: is better way to show array meaning?- // TODO: is better way to show array meaning?- // ['Transaction', 'expenseTransfer', 'incomeTransfer']+ // [transaction, expenseTransfer, incomeTransfer]amountRaw: [string, string, string]categoryId: CategoryId | nulldiff --git a/app/components/trns/useTrnsStore.ts b/app/components/trns/useTrnsStore.tsindex 4ecda7df..6fdf9753 100644--- a/app/components/trns/useTrnsStore.ts+++ b/app/components/trns/useTrnsStore.ts@@ -86,15 +86,15 @@ export const useTrnsStore = defineStore('trns', () => {const hasItems = computed(() => Object.keys(items.value ?? {}).length > 0)- const lastCreatedTrnId = computed(() => {+ const lastCreatedTrnId = computed<TrnId | undefined>(() => {if (!hasItems.value)- return false+ return undefinedconst transferIds = new Set(categoriesStore.transferCategoriesIds)- let latestId: TrnId | false = false+ let latestId: TrnId | undefinedlet latestDate = -1- for (const trnId in items.value) {+ for (const trnId of Object.keys(items.value)) {const trn = items.value[trnId]if (!trn || trn.type === TrnType.Transfer || trn.categoryId === 'adjustment' || transferIds.has(trn.categoryId))continue@@ -107,7 +107,7 @@ export const useTrnsStore = defineStore('trns', () => {return latestId})- const lastCreatedTrnItem = computed<TrnItem | false>(() => items.value?.[lastCreatedTrnId.value])+ const lastCreatedTrnItem = computed<TrnItem | undefined>(() => lastCreatedTrnId.value ? items.value?.[lastCreatedTrnId.value] : undefined)type TrnsSyncMeta = {idsHash: string@@ -238,7 +238,7 @@ export const useTrnsStore = defineStore('trns', () => {const isExisting = !isLocalId(id) && items.value && id in items.value// Optimistic UI- setTrns({ ...items.value, [id]: valuesWithEditDate })+ setTrns({ ...(items.value ?? {}), [id]: valuesWithEditDate })if (!pushSaveOp({ entity: 'trns', id, isDemo: isDemo.value, isExisting: !!isExisting, values: values as unknown as Record<string, unknown> }))return@@ -286,7 +286,7 @@ export const useTrnsStore = defineStore('trns', () => {function deleteTrn(id: TrnId) {// Optimistic UI- const trns = { ...items.value }+ const trns = { ...(items.value ?? {}) }delete trns[id]setTrns(trns)@@ -311,7 +311,7 @@ export const useTrnsStore = defineStore('trns', () => {return// Single optimistic update- const trns = { ...items.value }+ const trns = { ...(items.value ?? {}) }for (const id of trnsIds)delete trns[id]setTrns(trns)@@ -359,7 +359,7 @@ export const useTrnsStore = defineStore('trns', () => {}function computeTrnItem(id: TrnId): TrnItemFull | null {- if (!items.value || !walletsStore?.items || !categoriesStore?.items)+ if (!items.value || !walletsStore.items || !categoriesStore.items)return null// Trndiff --git a/app/components/ui/SwitchItem.vue b/app/components/ui/SwitchItem.vueindex 41741681..f9c8fadf 100644--- a/app/components/ui/SwitchItem.vue+++ b/app/components/ui/SwitchItem.vue@@ -6,12 +6,10 @@ const props = defineProps<{const emit = defineEmits<{click: [e: boolean]- close: []}>()function handleClick() {emit('click', props.checkboxValue)- emit('close')}</script>diff --git a/app/components/ui/TitleCollapse.vue b/app/components/ui/TitleCollapse.vueindex 5681579d..bb06b5a7 100644--- a/app/components/ui/TitleCollapse.vue+++ b/app/components/ui/TitleCollapse.vue@@ -2,7 +2,6 @@const props = defineProps<{arrow?: 'left' | 'right'isHideArrow?: boolean- isOpen?: booleanisShown?: boolean}>()const emit = defineEmits<{@@ -13,8 +12,7 @@ const emit = defineEmits<{<template><div:class="cn(- 'flex items-center rounded-sm min-h-[38px] min-w-[42px]',- 'flex grow items-center gap-2 pb-0 !font-tertiary !text-base font-semibold leading-none tracking-wide',+ 'flex grow items-center gap-2 rounded-sm min-h-[38px] min-w-[42px] pb-0 !font-tertiary !text-base font-semibold leading-none tracking-wide',props.arrow === 'right' ? 'justify-between px-4' : 'px-3',!props.isHideArrow && 'interactive',)"diff --git a/app/components/ui/Toggle.vue b/app/components/ui/Toggle.vueindex 8bf1b675..60dc5463 100644--- a/app/components/ui/Toggle.vue+++ b/app/components/ui/Toggle.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { useStorage } from '@vueuse/core'-const props = defineProps<{initStatus?: booleanopenPadding?: stringdiff --git a/app/components/ui/ToggleWithStorage.vue b/app/components/ui/ToggleWithStorage.vueindex 14dd08c0..8ba3f67f 100644--- a/app/components/ui/ToggleWithStorage.vue+++ b/app/components/ui/ToggleWithStorage.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { useStorage } from '@vueuse/core'-const props = defineProps<{initStatus?: booleanlineWidth?: numberdiff --git a/app/components/wallets/Form.vue b/app/components/wallets/Form.vueindex 4c3e78f6..4d9cdb7c 100644--- a/app/components/wallets/Form.vue+++ b/app/components/wallets/Form.vue@@ -193,7 +193,7 @@ async function onSave() {<div><UiTitleModal>{{ t('color.label') }}</UiTitleModal><WalletsItem- :walletId="props.walletId ?? 'editWalletId'"+ :walletId="props.walletId ?? editWalletId":wallet="walletPlaceholder"isShowIcon/>diff --git a/app/components/wallets/Item.vue b/app/components/wallets/Item.vueindex 2b4d0563..847bfab8 100644--- a/app/components/wallets/Item.vue+++ b/app/components/wallets/Item.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { onLongPress, useStorage } from '@vueuse/core'-import type { WalletId, WalletItemComputed } from '~/components/wallets/types'import { useCurrenciesStore } from '~/components/currencies/useCurrenciesStore'@@ -8,6 +6,7 @@ import { useCurrenciesStore } from '~/components/currencies/useCurrenciesStore'const props = defineProps<{activeItemId?: WalletId | nullalt?: boolean+ contextMenuItems?: any[][]insideClasses?: stringisShowBaseRate?: booleanisShowCreditLimit?: boolean@@ -35,12 +34,12 @@ const classes = computed(() => ([},]))-const creditViews = ['dept', 'summary'] as const-const activeCreditView = useStorage<typeof creditViews[number]>(props.walletId, 'dept')+const creditViews = ['debt', 'summary'] as const+const activeCreditView = useStorage<typeof creditViews[number]>(props.walletId, 'debt')const creditAmount = computed(() => {switch (activeCreditView.value) {- case 'dept':+ case 'debt':return props.wallet?.amountcase 'summary':return Math.abs(props.wallet.creditLimit ?? 0) - Math.abs(props.wallet.amount)@@ -61,131 +60,133 @@ if (!props.isSort) {</script><template>- <UiElement- v-if="wallet"- ref="longPressRef"- :isActive="activeItemId === props.walletId"- :insideClasses="`${props.insideClasses ? props.insideClasses : ''} min-h-[46px]`"- :lineWidth="props.lineWidth"- :class="classes"- @click="emit('click', props.walletId)"- >- <!-- Icon -->- <template v-if="props.isShowIcon" #leftIcon>- <WalletsIcon- :name="wallet.name"- :color="wallet.color"- />- </template>-- <!-- Main -->- <template v-if="!props.alt">- <div class="grid grow gap-1">- <div class="text-muted text-sm leading-none font-medium tracking-wide text-nowrap">- {{ wallet.name }}- </div>-- <!-- Rate -->- <div- v-if="props.isShowRate && wallet.currency !== currenciesStore.base && wallet.rate"- class="opacity-90"- >- <Amount- :amount="wallet.rate"- :precision="2"- :currencyCode="currenciesStore.base"- :isShowBaseRate="false"- align="left"- variant="2xs"- class="text-xs opacity-70"- />- </div>+ <component :is="props.contextMenuItems ? resolveComponent('UContextMenu') : 'div'" v-bind="props.contextMenuItems ? { items: props.contextMenuItems } : {}">+ <UiElement+ v-if="wallet"+ ref="longPressRef"+ :isActive="activeItemId === props.walletId"+ :insideClasses="`${props.insideClasses ?? ''} min-h-[46px]`"+ :lineWidth="props.lineWidth"+ :class="classes"+ @click="emit('click', props.walletId)"+ >+ <!-- Icon -->+ <template v-if="props.isShowIcon" #leftIcon>+ <WalletsIcon+ :name="wallet.name"+ :color="wallet.color"+ />+ </template>- <div- v-if="props.isShowCreditLimit && wallet.type === 'credit' && wallet.creditLimit"- class="flex items-center gap-0.5 opacity-70"- >- <Amount- :amount="wallet.creditLimit - Math.abs(wallet.amount)"- :currencyCode="wallet.currency"- :isShowBaseRate="false"- :isShowSymbol="false"- align="left"- variant="2xs"- />+ <!-- Main -->+ <template v-if="!props.alt">+ <div class="grid grow gap-1">+ <div class="text-muted text-sm leading-none font-medium tracking-wide text-nowrap">+ {{ wallet.name }}+ </div>+ <!-- Rate --><div- v-if="wallet.amount !== 0"- class="text-2xs leading-none opacity-70"+ v-if="props.isShowRate && wallet.currency !== currenciesStore.base && wallet.rate"+ class="opacity-90">- /+ <Amount+ :amount="wallet.rate"+ :precision="2"+ :currencyCode="currenciesStore.base"+ :isShowBaseRate="false"+ align="left"+ variant="2xs"+ class="text-xs opacity-70"+ /></div>- <Amount- v-if="wallet.amount !== 0"- :amount="wallet.creditLimit"- :currencyCode="wallet.currency"- :isShowBaseRate="false"- :isShowSymbol="false"- align="left"- variant="2xs"- />- </div>- </div>-- <div class="pr-1">- <Amount- v-if="wallet.creditLimit"- :amount="creditAmount"- :currencyCode="wallet.currency"- :isShowBaseRate="props.isShowBaseRate"- variant="sm"- />- <Amount- v-else- :amount="wallet.amount"- :currencyCode="wallet.currency"- :isShowBaseRate="props.isShowBaseRate"- variant="sm"- />- </div>- </template>-- <!-- Alternative -->- <template v-if="props.alt">- <div class="grid grow gap-0.5">- <div class="text-2 text-xs leading-none whitespace-nowrap">- {{ wallet.name }}+ <div+ v-if="props.isShowCreditLimit && wallet.type === 'credit' && wallet.creditLimit"+ class="flex items-center gap-0.5 opacity-70"+ >+ <Amount+ :amount="wallet.creditLimit - Math.abs(wallet.amount)"+ :currencyCode="wallet.currency"+ :isShowBaseRate="false"+ :isShowSymbol="false"+ align="left"+ variant="2xs"+ />++ <div+ v-if="wallet.amount !== 0"+ class="text-2xs leading-none opacity-70"+ >+ /+ </div>++ <Amount+ v-if="wallet.amount !== 0"+ :amount="wallet.creditLimit"+ :currencyCode="wallet.currency"+ :isShowBaseRate="false"+ :isShowSymbol="false"+ align="left"+ variant="2xs"+ />+ </div></div>- <div v-if="!isSort">+ <div class="pr-1"><Amountv-if="wallet.creditLimit":amount="creditAmount":currencyCode="wallet.currency"- :isShowBaseRate="false"- :isShowMinus="false"- align="left"- variant="2xs"+ :isShowBaseRate="props.isShowBaseRate"+ variant="sm"/><Amountv-else:amount="wallet.amount":currencyCode="wallet.currency":isShowBaseRate="props.isShowBaseRate"- :isShowMinus="false"- align="left"- variant="2xs"+ variant="sm"/></div>- </div>-- <div- v-if="isSort"- class="sortHandle flex-center absolute right-0 h-full rounded-md px-3 group-hover:bg-(--item-6)"- >- <Icon name="lucide:grip-vertical" size="20" />- </div>- </template>- </UiElement>+ </template>++ <!-- Alternative -->+ <template v-if="props.alt">+ <div class="grid grow gap-0.5">+ <div class="text-2 text-xs leading-none whitespace-nowrap">+ {{ wallet.name }}+ </div>++ <div v-if="!isSort">+ <Amount+ v-if="wallet.creditLimit"+ :amount="creditAmount"+ :currencyCode="wallet.currency"+ :isShowBaseRate="false"+ :isShowMinus="false"+ align="left"+ variant="2xs"+ />+ <Amount+ v-else+ :amount="wallet.amount"+ :currencyCode="wallet.currency"+ :isShowBaseRate="props.isShowBaseRate"+ :isShowMinus="false"+ align="left"+ variant="2xs"+ />+ </div>+ </div>++ <div+ v-if="isSort"+ class="sortHandle flex-center absolute right-0 h-full rounded-md px-3 group-hover:bg-(--item-6)"+ >+ <Icon name="lucide:grip-vertical" size="20" />+ </div>+ </template>+ </UiElement>+ </component></template>diff --git a/app/components/wallets/Selector.vue b/app/components/wallets/Selector.vueindex e069b9f5..6527e435 100644--- a/app/components/wallets/Selector.vue+++ b/app/components/wallets/Selector.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { useStorage } from '@vueuse/core'-import type { CurrencyCode } from '~/components/currencies/types'import type { WalletId } from '~/components/wallets/types'@@ -8,7 +6,7 @@ import { useWalletsStore } from '~/components/wallets/useWalletsStore'const props = defineProps<{activeItemId?: WalletId- hide?: () => null+ hide?: () => voidselectedIds?: WalletId[]}>()diff --git a/app/components/wallets/page/List.vue b/app/components/wallets/page/List.vueindex 52d5d926..195cd518 100644--- a/app/components/wallets/page/List.vue+++ b/app/components/wallets/page/List.vue@@ -1,11 +1,12 @@<script setup lang="ts">-import { useStorage } from '@vueuse/core'--import type { WalletsGroupedBy } from '~/components/wallets/types'+import type { TrnId } from '~/components/trns/types'+import type { WalletId, WalletsGroupedBy } from '~/components/wallets/types'import { useCurrenciesStore } from '~/components/currencies/useCurrenciesStore'+import { useTrnsStore } from '~/components/trns/useTrnsStore'import { useUserStore } from '~/components/user/useUserStore'import { useWalletsStore } from '~/components/wallets/useWalletsStore'+import { showSuccessToast } from '~/composables/useStoreSync'import { useWalletsPageCounts } from './useWalletsPageCounts'import { useWalletsPageFilter } from './useWalletsPageFilter'@@ -22,11 +23,68 @@ useSeoMeta({const walletsStore = useWalletsStore()const currenciesStore = useCurrenciesStore()const userStore = useUserStore()+const trnsStore = useTrnsStore()const isSortModalOpen = ref(false)const isShowBaseCurrencyModal = ref(false)const isOpen = ref(false)+const deleteWalletId = ref<WalletId | null>(null)++const deleteTrnsCount = computed(() => {+ if (!deleteWalletId.value)+ return 0+ return trnsStore.getStoreTrnsIds({+ walletsIds: [deleteWalletId.value],+ }).length+})++const deleteDescText = computed(() =>+ deleteTrnsCount.value > 0 ? t('wallets.form.delete.alertWithTrns') : undefined,+)++const deleteHighlight = computed(() =>+ deleteTrnsCount.value > 0 ? t('trns.plural', deleteTrnsCount.value) : undefined,+)++async function onDeleteConfirm() {+ if (!deleteWalletId.value)+ return++ const walletId = deleteWalletId.value+ const trnsIds: TrnId[] = [...trnsStore.getStoreTrnsIds({+ walletsIds: [walletId],+ })]++ deleteWalletId.value = null+ await walletsStore.deleteWallet(walletId, trnsIds)++ setTimeout(() => {+ showSuccessToast(trnsIds.length > 0+ ? 'wallets.form.delete.okWithTrns'+ : 'wallets.form.delete.okWithoutTrns', trnsIds.length > 0+ ? { length: trnsIds.length, trns: t('trns.plural', trnsIds.length) }+ : undefined)+ }, 300)+}++function getWalletContextMenuItems(walletId: WalletId) {+ return [[+ {+ icon: 'lucide:pencil',+ label: t('base.edit'),+ onSelect: () => router.push(`/wallets/${walletId}/edit`),+ },+ ], [+ {+ color: 'error' as const,+ icon: 'lucide:trash-2',+ label: t('base.delete'),+ onSelect: () => { deleteWalletId.value = walletId },+ },+ ]]+}+const groupedBy = useStorage<WalletsGroupedBy>('finapp-wallets-groupedBy', 'none')const {@@ -53,6 +111,18 @@ const {typeGroupsStatus,walletsToggledMap,} = useWalletsPageGrouping(selectedWalletsIds, groupedBy)++function toggleSecondaryGrouping() {+ if (groupedBy.value === 'currency')+ groupedBySecondary.currency = !groupedBySecondary.currency+ else if (groupedBy.value === 'type')+ groupedBySecondary.type = !groupedBySecondary.type+}++const isSecondaryGroupingActive = computed(() =>+ (groupedBy.value === 'currency' && groupedBySecondary.currency)+ || (groupedBy.value === 'type' && groupedBySecondary.type),+)</script><template>@@ -169,21 +239,10 @@ const {class="ml-auto flex items-center gap-1"><UiActionButton- @click="- groupedBy === 'currency'- ? groupedBySecondary.currency = !groupedBySecondary.currency- : groupedBy === 'type'- ? groupedBySecondary.type = !groupedBySecondary.type- : null- "+ @click="toggleSecondaryGrouping"><Icon- :name="- (groupedBy === 'currency' && groupedBySecondary.currency)- || (groupedBy === 'type' && groupedBySecondary.type)- ? 'lucide:network'- : 'lucide:folder-tree'- "+ :name="isSecondaryGroupingActive ? 'lucide:network' : 'lucide:folder-tree'"size="18"/></UiActionButton>@@ -217,6 +276,7 @@ const {:key="walletId":wallet="walletsStore.itemsComputed[walletId]!":walletId+ :contextMenuItems="getWalletContextMenuItems(walletId)":lineWidth="2"class="group"isShowBaseRate@@ -309,6 +369,7 @@ const {<WalletsItemv-for="walletId in ids":key="walletId"+ :contextMenuItems="getWalletContextMenuItems(walletId)":lineWidth="2":wallet="walletsStore.itemsComputed[walletId]!":walletId@@ -326,6 +387,7 @@ const {<WalletsItemv-for="walletId in content.ids":key="walletId"+ :contextMenuItems="getWalletContextMenuItems(walletId)":lineWidth="2":wallet="walletsStore.itemsComputed[walletId]!":walletId@@ -344,6 +406,15 @@ const {</div></UiPage>+ <LayoutConfirmModal+ v-if="deleteWalletId"+ :title="t('wallets.form.delete.title')"+ :description="deleteDescText"+ :highlight="deleteHighlight"+ @closed="deleteWalletId = null"+ @confirm="onDeleteConfirm"+ />+<!-- Sort Modal --><WalletsSortModal v-if="isSortModalOpen" @close="isSortModalOpen = false" />diff --git a/app/components/wallets/page/id/Index.vue b/app/components/wallets/page/id/Index.vueindex 0b4eef1e..519ea2b2 100644--- a/app/components/wallets/page/id/Index.vue+++ b/app/components/wallets/page/id/Index.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { useStorage } from '@vueuse/core'-import type { StatTabSlug } from '~/components/stat/types'import type { TrnId } from '~/components/trns/types'import type { WalletId } from '~/components/wallets/types'@@ -72,7 +70,13 @@ function onClickEdit() {const deleteDescText = computed(() => {if (trnsIds.value.length > 0)- return t('wallets.form.delete.alertWithTrns', { trns: t('trns.plural', trnsIds.value.length) })+ return t('wallets.form.delete.alertWithTrns')+ return undefined+})++const deleteHighlight = computed(() => {+ if (trnsIds.value.length > 0)+ return t('trns.plural', trnsIds.value.length)return undefined})@@ -83,19 +87,19 @@ function onClickDelete(close: () => void) {}async function onDeleteConfirm() {- const trnsIdsS: TrnId[] = [...trnsStore.getStoreTrnsIds({+ const deleteTrnsIds: TrnId[] = [...trnsStore.getStoreTrnsIds({walletsIds: [walletId.value],})]router.push('/wallets')- await walletsStore.deleteWallet(walletId.value, trnsIdsS)+ await walletsStore.deleteWallet(walletId.value, deleteTrnsIds)// Give some time to complete redirectsetTimeout(() => {- showSuccessToast(trnsIdsS?.length > 0+ showSuccessToast(deleteTrnsIds.length > 0? 'wallets.form.delete.okWithTrns'- : 'wallets.form.delete.okWithoutTrns', trnsIdsS?.length > 0- ? { length: trnsIdsS.length, trns: t('trns.plural', trnsIdsS.length) }+ : 'wallets.form.delete.okWithoutTrns', deleteTrnsIds.length > 0+ ? { length: deleteTrnsIds.length, trns: t('trns.plural', deleteTrnsIds.length) }: undefined)}, 300)}@@ -127,14 +131,14 @@ async function onDeleteConfirm() {<template #popover="{ close }"><UiHeaderLink- icon="mdi:pencil-outline"+ icon="lucide:pencil"@click="onClickEdit">{{ t('base.edit') }}</UiHeaderLink><UiHeaderLink- icon="mdi:delete-empty-outline"+ icon="lucide:trash-2"@click="onClickDelete(close)">{{ t('base.delete') }}@@ -144,7 +148,9 @@ async function onDeleteConfirm() {<LayoutConfirmModalv-if="isShowDeleteConfirm"+ :title="t('wallets.form.delete.title')":description="deleteDescText"+ :highlight="deleteHighlight"@closed="isShowDeleteConfirm = false"@confirm="onDeleteConfirm"/>diff --git a/app/components/wallets/page/useWalletsPageFilter.ts b/app/components/wallets/page/useWalletsPageFilter.tsindex bfa24de2..c1f98c02 100644--- a/app/components/wallets/page/useWalletsPageFilter.ts+++ b/app/components/wallets/page/useWalletsPageFilter.ts@@ -1,7 +1,5 @@import type { Ref } from 'vue'-import { useStorage } from '@vueuse/core'-import type { CurrencyCode } from '~/components/currencies/types'import type { WalletId, WalletsCurrencyFiltered, WalletsGroupedBy, WalletType, WalletViewTypes } from '~/components/wallets/types'@@ -19,10 +17,7 @@ export function useWalletsPageFilter(groupedBy: Ref<WalletsGroupedBy>) {const selectedWalletsIdsWithCurrency = computed<WalletId[]>(() => {return Object.keys(walletsStore.itemsComputed).filter((id) => {- const wallet = walletsStore.itemsComputed[id]- if (groupedBy.value === 'currency')- return true- return currencyFiltered.value === 'all' || currencyFiltered.value === wallet?.currency+ return groupedBy.value === 'currency' || currencyFiltered.value === 'all' || currencyFiltered.value === walletsStore.itemsComputed[id]?.currency})})diff --git a/app/components/wallets/page/useWalletsPageGrouping.ts b/app/components/wallets/page/useWalletsPageGrouping.tsindex c87d19bf..b8b6f498 100644--- a/app/components/wallets/page/useWalletsPageGrouping.ts+++ b/app/components/wallets/page/useWalletsPageGrouping.ts@@ -1,7 +1,5 @@import type { ComputedRef, Ref } from 'vue'-import { useStorage } from '@vueuse/core'-import type { WalletId, WalletItem, WalletsGroupedBy } from '~/components/wallets/types'import { useWalletsStore } from '~/components/wallets/useWalletsStore'@@ -157,11 +155,11 @@ export function useWalletsPageGrouping(const newShow = !hasSecondaryGrouping ? !isAllOpen : !(isAllOpen && isAllOpenInside)const updateSecondary = hasSecondaryGrouping && isAllOpen && !isAllOpenInside- for (const groupPrimary of Object.keys(groupedWallets)) {+ for (const [groupPrimary, walletGroup] of Object.entries(groupedWallets)) {const primaryGroup = currentToggleMap[currentGroup]![groupPrimary] || { groups: {} }if (updateSecondary) {- const secondaryKeys = Object.keys(groupedWallets[groupPrimary]?.groups ?? {})+ const secondaryKeys = Object.keys(walletGroup.groups ?? {})currentToggleMap[currentGroup]![groupPrimary] = {...primaryGroup,groups: Object.fromEntries(secondaryKeys.map(k => [k, true])),@@ -169,7 +167,7 @@ export function useWalletsPageGrouping(}}else if (hasSecondaryGrouping && !newShow) {- const secondaryKeys = Object.keys(groupedWallets[groupPrimary]?.groups ?? {})+ const secondaryKeys = Object.keys(walletGroup.groups ?? {})currentToggleMap[currentGroup]![groupPrimary] = {...primaryGroup,groups: Object.fromEntries(secondaryKeys.map(k => [k, false])),diff --git a/app/components/wallets/useWalletsStore.ts b/app/components/wallets/useWalletsStore.tsindex 2c214235..989101ca 100644--- a/app/components/wallets/useWalletsStore.ts+++ b/app/components/wallets/useWalletsStore.ts@@ -69,7 +69,7 @@ export const useWalletsStore = defineStore('wallets', () => {// Optimistic UIsetWallets({- ...items.value,+ ...(items.value ?? {}),[id]: values,})@@ -110,7 +110,7 @@ export const useWalletsStore = defineStore('wallets', () => {function saveWalletsOrder(ids: WalletId[]) {// Optimistic update- const updated = { ...items.value } as Wallets+ const updated = { ...(items.value ?? {}) } as Walletsfor (let i = 0; i < ids.length; i++) {if (updated[ids[i]])updated[ids[i]] = { ...updated[ids[i]], order: i }@@ -189,7 +189,7 @@ export const useWalletsStore = defineStore('wallets', () => {function deleteWallet(id: WalletId, trnsIds?: TrnId[]) {// Optimistic UI- const wallets = { ...items.value }+ const wallets = { ...(items.value ?? {}) }delete wallets[id]setWallets(wallets)diff --git a/app/composables/useStoreSync.ts b/app/composables/useStoreSync.tsindex f7c0efeb..f20a0d0e 100644--- a/app/composables/useStoreSync.ts+++ b/app/composables/useStoreSync.ts@@ -1,6 +1,5 @@import type { ShallowRef } from 'vue'-import { useDebounceFn } from '@vueuse/core'import localforage from 'localforage'import { deepUnref } from 'vue-deepunref'@@ -99,7 +98,7 @@ export async function mergeOfflineOps<T>(if (hasUpdates || hasDeletes) {const merged = { ...data }- for (const id in pendingUpdates)+ for (const id of Object.keys(pendingUpdates))merged[id] = pendingUpdates[id]for (const id of pendingDeleteIds)delete merged[id]diff --git a/app/layouts/default.vue b/app/layouts/default.vueindex c2749fde..f6789c9e 100644--- a/app/layouts/default.vue+++ b/app/layouts/default.vue@@ -1,6 +1,4 @@<script setup lang="ts">-import { useWindowSize } from '@vueuse/core'-import { useInitApp } from '~/components/app/useInitApp'import { useCategoriesStore } from '~/components/categories/useCategoriesStore'import { useDemo } from '~/components/demo/useDemo'@@ -20,7 +18,6 @@ const trnsStore = useTrnsStore()const { isDemo } = useDemo()const { isMenuOpen } = useMenuData()const { loadDataFromCache, loadDataFromDB } = useInitApp()-const { t } = useI18n()const { width } = useWindowSize()const isShowSidebar = useCookie('finapp.isShowSidebar', { default: () => true })@@ -88,7 +85,6 @@ defineShortcuts({<template v-else-if="status === 'success'"><template v-if="isOnboarded"><LayoutSidebar- :isShowTrnForm="trnsFormStore.ui.isShow":isShowSidebar@toggleSidebar="isShowSidebar = !isShowSidebar"/>diff --git a/app/layouts/error.vue b/app/layouts/error.vueindex 9b17c3e2..9e230d76 100644--- a/app/layouts/error.vue+++ b/app/layouts/error.vue@@ -1,9 +1,9 @@<script setup lang="ts">-// TODO: Add localedefineProps<{error: unknown}>()+const { t } = useI18n()const route = useRoute()const router = useRouter()@@ -13,10 +13,10 @@ if (Object.keys(route.query).length > 0)<template><div class="p-4">- <h1>Error</h1>+ <h1>{{ t('actionError.title') }}</h1><pre>{{ error }}</pre><h1 @click="router.push('/')">- Go to home+ {{ t('actionError.goHome') }}</h1><slot /></div>diff --git a/app/pages/currencies.vue b/app/pages/currencies.vuenew file mode 100644index 00000000..d0ce595d--- /dev/null+++ b/app/pages/currencies.vue@@ -0,0 +1,3 @@+<template>+ <CurrenciesPageList />+</template>diff --git a/app/plugins/theme.ts b/app/plugins/theme.tsindex e62e140a..5e8b3a3c 100644--- a/app/plugins/theme.ts+++ b/app/plugins/theme.ts@@ -74,6 +74,8 @@ export default defineNuxtPlugin({document.querySelector('style#nuxt-ui-black-as-primary').innerHTML = '';}`.replace(/\s+/g, ' '),+ tagPriority: -1,+ type: 'text/javascript',}],})}diff --git a/app/sw.ts b/app/sw.tsindex 9bf6f006..aeae429e 100644--- a/app/sw.ts+++ b/app/sw.ts@@ -1,5 +1,5 @@import { clientsClaim } from 'workbox-core'-import { PrecacheController, PrecacheRoute, cleanupOutdatedCaches } from 'workbox-precaching'+import { cleanupOutdatedCaches, PrecacheController, PrecacheRoute } from 'workbox-precaching'import { registerRoute } from 'workbox-routing'import { CacheFirst } from 'workbox-strategies'diff --git a/convex/trns.ts b/convex/trns.tsindex 7b893e62..348b922f 100644--- a/convex/trns.ts+++ b/convex/trns.ts@@ -159,8 +159,7 @@ export const update = mutation({handler: async (ctx, { id, ...args }) => {const user = await requireAuthUser(ctx)const trn = await getOwnEntity(ctx, id, user._id)- if (args.type !== undefined)- await validateTrnFields(ctx, { ...trn, ...args }, user._id)+ await validateTrnFields(ctx, { ...trn, ...args }, user._id)await ctx.db.patch(id, { ...args, updatedAt: Date.now() })},})diff --git a/i18n/locales/en-US.js b/i18n/locales/en-US.jsindex 8086243e..7e6d41c0 100644--- a/i18n/locales/en-US.js+++ b/i18n/locales/en-US.js@@ -5,6 +5,11 @@ export default {title: 'Creators',},+ actionError: {+ goHome: 'Go to home',+ title: 'Error',+ },+alerts: {removedUserData: 'All data removed.',willDeleteEverything: 'All data will be permanently deleted, including wallets, categories and transactions',@@ -51,10 +56,11 @@ export default {form: {childColor: 'Apply color to all child categories',delete: {- alertWithTrns: `This will delete {trns}`,- errorChilds: 'You cannot delete a category with child categories. Delete the child categories first.',+ alertWithTrns: 'This will also delete',+ errorChildren: 'You cannot delete a category with child categories. Delete the child categories first.',okWithoutTrns: 'Category deleted',okWithTrns: `Category and {trns} transactions deleted`,+ title: 'Delete category?',},favoriteCategory: 'Favorite category',icon: {@@ -344,7 +350,7 @@ export default {},createTrn: 'Add transaction',delete: {- alert: 'Are you sure you want to delete this transaction?',+ alert: 'Delete transaction?',},description: {placeholder: 'Write...',@@ -411,9 +417,10 @@ export default {label: 'Currency',},delete: {- alertWithTrns: `This will delete {trns}`,+ alertWithTrns: 'This will also delete',okWithoutTrns: 'Wallet deleted',okWithTrns: `Wallet deleted and {trns}`,+ title: 'Delete wallet?',},description: {label: 'Description (optional)',diff --git a/i18n/locales/ru-RU.js b/i18n/locales/ru-RU.jsindex 6088bc95..b0ba7097 100644--- a/i18n/locales/ru-RU.js+++ b/i18n/locales/ru-RU.js@@ -5,6 +5,11 @@ export default {title: 'Создатели',},+ actionError: {+ goHome: 'На главную',+ title: 'Ошибка',+ },+alerts: {removedUserData: 'Все данные удалены.',willDeleteEverything: 'Все данные будут безвозвратно удалены, включая кошельки, категории и транзакции',@@ -51,10 +56,11 @@ export default {form: {childColor: 'Применить цвет ко всем дочерним категориям',delete: {- alertWithTrns: `Так же будут удалены {trns}`,- errorChilds: 'Вы не можете удалить категорию с дочерними категориям. Сначала удалите дочерние категории.',+ alertWithTrns: 'Также будут удалены',+ errorChildren: 'Вы не можете удалить категорию с дочерними категориям. Сначала удалите дочерние категории.',okWithoutTrns: 'Категория удалена',okWithTrns: `Категория удалена и {trns}`,+ title: 'Удалить категорию?',},favoriteCategory: 'Избранная категория',icon: {@@ -344,7 +350,7 @@ export default {},createTrn: 'Создать транзакцию',delete: {- alert: 'Вы уверены, что хотите удалить эту транзакцию?',+ alert: 'Удалить транзакцию?',},description: {placeholder: 'Напишите...',@@ -411,9 +417,10 @@ export default {label: 'Валюта',},delete: {- alertWithTrns: `Так же будут удалены {trns}`,+ alertWithTrns: 'Также будут удалены',okWithoutTrns: 'Кошелек удален',okWithTrns: `Кошелек удален и {trns}`,+ title: 'Удалить кошелёк?',},description: {label: 'Описание (не обязательно)',diff --git a/nuxt.config.ts b/nuxt.config.tsindex f1fc7120..d9367d06 100644--- a/nuxt.config.ts+++ b/nuxt.config.ts@@ -87,6 +87,7 @@ export default defineNuxtConfig({'@nuxtjs/i18n','@pinia/nuxt','@vite-pwa/nuxt',+ '@vueuse/nuxt','@nuxt/ui','@nuxt/eslint',],