Skip to content

Open source personal finance application

fix: improve type safety across codebase

Ilya Komichevdb9cfaf84130
diff --git a/app/components/categories/Item.vue b/app/components/categories/Item.vue
index 9b725710..f9c1de79 100644
--- a/app/components/categories/Item.vue
+++ b/app/components/categories/Item.vue
@@ -1,16 +1,17 @@
<script setup lang="ts">
+import type { ContextMenuItem } from '#ui/components/ContextMenu.vue'
import type { CategoryId, CategoryItem } from '~/components/categories/types'
export type CategoryItemProps = {
activeItemId?: string | 0 | false | null
- alt?: boolean
category: CategoryItem
categoryId: CategoryId
class?: string
- contextMenuItems?: any[][]
+ contextMenuItems?: ContextMenuItem[][]
insideClasses?: string
isShowParent?: boolean
lineWidth?: number
+ stacked?: boolean
to?: string
}
@@ -26,7 +27,7 @@ const emit = defineEmits<{
<UContextMenu v-if="props.contextMenuItems" :items="props.contextMenuItems">
<CategoriesItemBody
:activeItemId="props.activeItemId"
- :alt="props.alt"
+ :stacked="props.stacked"
:category="props.category"
:categoryId="props.categoryId"
:class="props.class"
@@ -42,7 +43,7 @@ const emit = defineEmits<{
<CategoriesItemBody
v-else
:activeItemId="props.activeItemId"
- :alt="props.alt"
+ :stacked="props.stacked"
:category="props.category"
:categoryId="props.categoryId"
:class="props.class"
diff --git a/app/components/categories/useCategoriesStore.ts b/app/components/categories/useCategoriesStore.ts
index 5e04ca85..dd26a07d 100644
--- a/app/components/categories/useCategoriesStore.ts
+++ b/app/components/categories/useCategoriesStore.ts
@@ -4,7 +4,7 @@ import type { AddCategoryParams, Categories, CategoryId, CategoryItem } from '~/
import type { TrnId } from '~/components/trns/types'
import type { RemapInfo } from '~/composables/useStoreSync'
-import { compareCategoriesByParentAndName, getTransactibleCategoriesIds } from '~/components/categories/utils'
+import { compareCategoryIds, getTransactibleCategoriesIds } from '~/components/categories/utils'
import { useDemo } from '~/components/demo/useDemo'
import { STORAGE_KEYS } from '~/components/offline/storageKeys'
import { TrnType } from '~/components/trns/types'
@@ -68,15 +68,17 @@ export const useCategoriesStore = defineStore('categories', (): CategoriesStore
return categoriesIds.value
.filter(id => items.value[id]?.parentId === 0 && id !== 'transfer' && id !== 'adjustment')
- .sort((a, b) => compareCategoriesByParentAndName(items.value[a]!, items.value[b]!, items.value))
+ .sort((a, b) => compareCategoryIds(a, b, items.value))
})
const usedCategoryIds = computed(() => {
const ids = new Set<string>()
const trns = trnsStore.items
if (trns) {
- for (const id in trns)
- ids.add(trns[id]!.categoryId)
+ for (const id in trns) {
+ const trn = trns[id]
+ if (trn) ids.add(trn.categoryId)
+ }
}
return ids
})
@@ -99,7 +101,7 @@ export const useCategoriesStore = defineStore('categories', (): CategoriesStore
return categoriesIds.value
.filter(id => items.value[id]?.showInQuickSelector)
- .sort((a, b) => compareCategoriesByParentAndName(items.value[a]!, items.value[b]!, items.value))
+ .sort((a, b) => compareCategoryIds(a, b, items.value))
})
const recentCategoriesIds = computed(() => {
@@ -139,7 +141,7 @@ export const useCategoriesStore = defineStore('categories', (): CategoriesStore
}
return recentIds
- .sort((a, b) => compareCategoriesByParentAndName(items.value[a]!, items.value[b]!, items.value))
+ .sort((a, b) => compareCategoryIds(a, b, items.value))
})
const categoriesIdsForTrnValues = computed<CategoryId[]>(() =>
@@ -187,7 +189,7 @@ export const useCategoriesStore = defineStore('categories', (): CategoriesStore
return Object.keys(items.value)
.filter(id => items.value[id]?.parentId === categoryId)
- .sort((a, b) => compareCategoriesByParentAndName(items.value[a]!, items.value[b]!, items.value))
+ .sort((a, b) => compareCategoryIds(a, b, items.value))
}
function getChildrenIdsOrParent(categoryId: CategoryId) {
diff --git a/app/components/categories/utils.ts b/app/components/categories/utils.ts
index 40505b48..f24248fc 100644
--- a/app/components/categories/utils.ts
+++ b/app/components/categories/utils.ts
@@ -55,3 +55,10 @@ export function compareCategoriesByParentAndName(a: CategoryItem, b: CategoryIte
const parentNameB = items[b.parentId]?.name ?? ''
return parentNameA.localeCompare(parentNameB) || a.name.localeCompare(b.name)
}
+
+export function compareCategoryIds(idA: CategoryId, idB: CategoryId, items: Categories): number {
+ const catA = items[idA]
+ const catB = items[idB]
+ if (!catA || !catB) return 0
+ return compareCategoriesByParentAndName(catA, catB, items)
+}
diff --git a/app/components/offline/replay.ts b/app/components/offline/replay.ts
index c046f82d..a79505f2 100644
--- a/app/components/offline/replay.ts
+++ b/app/components/offline/replay.ts
@@ -4,6 +4,8 @@ import { groupOpsByEntity, replayCategoryOps, replaySettingsOps, replayTrnOps, r
import { useTrnsStore } from '~/components/trns/useTrnsStore'
import { useUserStore } from '~/components/user/useUserStore'
import { useWalletsStore } from '~/components/wallets/useWalletsStore'
+import type { LocaleSlug } from '~/components/locale/types'
+
import { isLocalId } from '~/utils/convexId'
import { createLogger } from '~/utils/logger'
@@ -101,7 +103,7 @@ export async function replayOfflineQueue(): Promise<void> {
// Phase 4: Replay settings
await replaySettingsOps(settingsOps, {
saveBaseCurrency: currency => userStore.saveUserBaseCurrency(currency),
- saveLocale: locale => userStore.saveUserLocale(locale),
+ saveLocale: locale => userStore.saveUserLocale(locale as LocaleSlug),
})
if (orphanCount > 0) {
diff --git a/app/components/search/SearchCommandPalette.vue b/app/components/search/SearchCommandPalette.vue
new file mode 100644
index 00000000..1fc34c05
--- /dev/null
+++ b/app/components/search/SearchCommandPalette.vue
@@ -0,0 +1,215 @@
+<script setup lang="ts">
+import type { SearchResultItem } from '~/components/search/useSearch'
+import type { TransactionFull, TransferFull, TrnItemFull } from '~/components/trns/types'
+
+import { useCategoriesStore } from '~/components/categories/useCategoriesStore'
+import { useSearch } from '~/components/search/useSearch'
+import { TrnType } from '~/components/trns/types'
+import { useTrnsStore } from '~/components/trns/useTrnsStore'
+import { useWalletsStore } from '~/components/wallets/useWalletsStore'
+
+const props = defineProps<{
+ class?: string
+}>()
+
+const emit = defineEmits<{
+ select: [item: SearchResultItem]
+}>()
+
+const { t } = useI18n()
+const { groups, searchTerm } = useSearch()
+const categoriesStore = useCategoriesStore()
+const walletsStore = useWalletsStore()
+const trnsStore = useTrnsStore()
+
+function getCategory(item: SearchResultItem) {
+ return categoriesStore.items?.[item.entityId]
+}
+
+function getCategoryParent(item: SearchResultItem) {
+ const cat = getCategory(item)
+ if (cat?.parentId)
+ return categoriesStore.items?.[cat.parentId]
+}
+
+function getWallet(item: SearchResultItem) {
+ return walletsStore.items?.[item.entityId]
+}
+
+function getTrn(item: SearchResultItem) {
+ return trnsStore.computeTrnItem(item.entityId)
+}
+
+function isTransaction(trn: TrnItemFull): trn is TransactionFull {
+ return trn.type !== TrnType.Transfer
+}
+
+function isTransfer(trn: TrnItemFull): trn is TransferFull {
+ return trn.type === TrnType.Transfer
+}
+
+function getTransaction(item: SearchResultItem): TransactionFull | undefined {
+ const trn = getTrn(item)
+ return trn && isTransaction(trn) ? trn : undefined
+}
+
+function getTransfer(item: SearchResultItem): TransferFull | undefined {
+ const trn = getTrn(item)
+ return trn && isTransfer(trn) ? trn : undefined
+}
+</script>
+
+<template>
+ <!-- @vue-ignore -->
+ <UCommandPalette
+ v-model:searchTerm="searchTerm"
+ :groups="groups"
+ :placeholder="t('search.placeholder')"
+ :fuse="{
+ resultLimit: 50,
+ fuseOptions: {
+ threshold: 0.4,
+ keys: ['label', 'suffix', 'search'],
+ },
+ }"
+ :class="props.class"
+ @update:modelValue="emit('select', $event)"
+ >
+ <!-- Menu -->
+ <template #menu-item="{ item: rawItem }">
+ <div class="flex w-full items-center gap-3">
+ <Icon :name="(rawItem as SearchResultItem).icon" size="20" class="text-muted" />
+ <div class="text-sm">
+ {{ (rawItem as SearchResultItem).label }}
+ </div>
+ </div>
+ </template>
+
+ <!-- Category -->
+ <template #category-item="{ item: rawItem }">
+ <div class="flex w-full items-center gap-3">
+ <UiIconBase
+ :color="getCategory(rawItem as SearchResultItem)?.color"
+ :name="getCategory(rawItem as SearchResultItem)?.icon"
+ invert
+ />
+ <CategoriesName
+ :category="getCategory(rawItem as SearchResultItem)"
+ :parentCategory="getCategoryParent(rawItem as SearchResultItem)"
+ isShowParent
+ stacked
+ />
+ </div>
+ </template>
+
+ <!-- Wallet -->
+ <template #wallet-item="{ item: rawItem }">
+ <div class="flex w-full items-center gap-3 text-start">
+ <WalletsIcon
+ :color="getWallet(rawItem as SearchResultItem)?.color ?? ''"
+ :name="getWallet(rawItem as SearchResultItem)?.name ?? ''"
+ />
+ <div class="grid grow gap-1">
+ <div class="text-toned text-sm leading-none font-medium tracking-wide text-nowrap">
+ {{ getWallet(rawItem as SearchResultItem)?.name }}
+ </div>
+ <div
+ v-if="getWallet(rawItem as SearchResultItem)?.desc"
+ class="text-2xs text-4 leading-none"
+ >
+ {{ getWallet(rawItem as SearchResultItem)?.desc }}
+ </div>
+ </div>
+ </div>
+ </template>
+
+ <!-- Transaction -->
+ <template #trn-item="{ item: rawItem }">
+ <div
+ v-if="getTrn(rawItem as SearchResultItem)"
+ class="flex w-full items-start gap-3 text-start"
+ >
+ <div class="flex-center min-w-8">
+ <UiIconBase
+ :name="getTrn(rawItem as SearchResultItem)?.category?.icon"
+ :color="getTrn(rawItem as SearchResultItem)?.category?.color"
+ invert
+ />
+ </div>
+
+ <div class="grid grow gap-1 pr-1">
+ <div class="flex grow items-center gap-3">
+ <!-- Regular transaction -->
+ <template v-if="getTransaction(rawItem as SearchResultItem) as TransactionFull | undefined">
+ <div class="grid grow gap-0.5">
+ <CategoriesName
+ :category="getTransaction(rawItem as SearchResultItem)?.category"
+ :parentCategory="getTransaction(rawItem as SearchResultItem)?.categoryParent"
+ isShowParent
+ />
+ <div class="flex items-center gap-2">
+ <div class="text-2xs text-4 leading-none">
+ {{ getTransaction(rawItem as SearchResultItem)?.wallet?.name }}
+ </div>
+ </div>
+ </div>
+
+ <Amount
+ :amount="getTransaction(rawItem as SearchResultItem)?.amount"
+ :currencyCode="getTransaction(rawItem as SearchResultItem)?.wallet?.currency"
+ :isShowMinus="getTransaction(rawItem as SearchResultItem)?.type === TrnType.Expense"
+ :isShowPlus="getTransaction(rawItem as SearchResultItem)?.type === TrnType.Income"
+ :type="getTransaction(rawItem as SearchResultItem)?.type"
+ align="right"
+ class="grow"
+ colorize="income"
+ variant="sm"
+ />
+ </template>
+
+ <!-- Transfer -->
+ <div
+ v-if="getTransfer(rawItem as SearchResultItem)"
+ class="grid gap-1"
+ >
+ <div class="text-3 flex items-center gap-1 text-sm leading-none">
+ <span class="font-semibold">{{ getTransfer(rawItem as SearchResultItem)?.expenseWallet?.name }}</span>
+ <Icon name="lucide:move-right" size="16" />
+ <span class="font-semibold">{{ getTransfer(rawItem as SearchResultItem)?.incomeWallet?.name }}</span>
+ </div>
+
+ <div class="flex flex-wrap gap-2">
+ <Amount
+ :amount="getTransfer(rawItem as SearchResultItem)?.expenseAmount"
+ :colorize="getTransfer(rawItem as SearchResultItem)?.incomeAmount === getTransfer(rawItem as SearchResultItem)?.expenseAmount ? undefined : 'expense'"
+ :currencyCode="getTransfer(rawItem as SearchResultItem)?.expenseWallet?.currency"
+ :type="TrnType.Expense"
+ class="!flex items-center gap-2"
+ variant="sm"
+ />
+
+ <template v-if="getTransfer(rawItem as SearchResultItem)?.incomeAmount !== getTransfer(rawItem as SearchResultItem)?.expenseAmount">
+ <Amount
+ :amount="getTransfer(rawItem as SearchResultItem)?.incomeAmount"
+ :currencyCode="getTransfer(rawItem as SearchResultItem)?.incomeWallet?.currency"
+ :type="TrnType.Income"
+ colorize="income"
+ class="!flex items-center gap-2"
+ variant="sm"
+ />
+ </template>
+ </div>
+ </div>
+ </div>
+
+ <div
+ v-if="getTrn(rawItem as SearchResultItem)?.desc"
+ class="text-2xs opacity-80"
+ >
+ {{ getTrn(rawItem as SearchResultItem)?.desc }}
+ </div>
+ </div>
+ </div>
+ </template>
+ </UCommandPalette>
+</template>
diff --git a/app/components/search/useSearch.ts b/app/components/search/useSearch.ts
new file mode 100644
index 00000000..0793f1f7
--- /dev/null
+++ b/app/components/search/useSearch.ts
@@ -0,0 +1,219 @@
+import type { CommandPaletteItem } from '@nuxt/ui'
+
+import type { CategoryId } from '~/components/categories/types'
+import type { TransactionFull, TransferFull, TrnId } from '~/components/trns/types'
+import type { WalletId } from '~/components/wallets/types'
+
+import { useCategoriesStore } from '~/components/categories/useCategoriesStore'
+import { useMenuData } from '~/components/layout/useMenuData'
+import { TrnType } from '~/components/trns/types'
+import { useTrnsStore } from '~/components/trns/useTrnsStore'
+import { useWalletsStore } from '~/components/wallets/useWalletsStore'
+
+export type SearchResultItem = CommandPaletteItem & {
+ entityId: string
+ entityType: 'category' | 'menu' | 'trn' | 'wallet'
+}
+
+const RECENT_LIMIT = 10
+
+const isSearchOpen = ref(false)
+
+export function useSearch() {
+ const { t } = useI18n()
+ const categoriesStore = useCategoriesStore()
+ const walletsStore = useWalletsStore()
+ const trnsStore = useTrnsStore()
+ const { items: menuItems, onClick: onMenuClick } = useMenuData()
+ const searchTerm = ref('')
+
+ const menuGroup = computed(() => {
+ const items: SearchResultItem[] = Object.entries(menuItems.value).map(([id, item]) => ({
+ entityId: id,
+ entityType: 'menu' as const,
+ icon: item.icon,
+ id: `menu-${id}`,
+ label: item.name,
+ }))
+ return items
+ })
+
+ const allCategoryItems = computed(() => {
+ const items: SearchResultItem[] = []
+ if (!categoriesStore.items)
+ return items
+
+ for (const id of Object.keys(categoriesStore.items)) {
+ if (id === 'transfer' || id === 'adjustment')
+ continue
+
+ const category = categoriesStore.items[id as CategoryId]
+ if (!category)
+ continue
+
+ let label = category.name
+ if (category.parentId) {
+ const parent = categoriesStore.items[category.parentId as CategoryId]
+ if (parent)
+ label = `${parent.name} - ${category.name}`
+ }
+
+ items.push({
+ entityId: id,
+ entityType: 'category',
+ icon: category.icon,
+ id: `category-${id}`,
+ label,
+ suffix: category.color,
+ })
+ }
+
+ return items
+ })
+
+ const allWalletItems = computed(() => {
+ const items: SearchResultItem[] = []
+ if (!walletsStore.items)
+ return items
+
+ for (const id of walletsStore.sortedIds) {
+ const wallet = walletsStore.items[id as WalletId]
+ if (!wallet)
+ continue
+
+ items.push({
+ entityId: id,
+ entityType: 'wallet',
+ id: `wallet-${id}`,
+ label: wallet.name,
+ search: [wallet.name, wallet.desc].filter(Boolean).join(' '),
+ suffix: wallet.desc,
+ })
+ }
+
+ return items
+ })
+
+ const allTrnItems = computed(() => {
+ const items: SearchResultItem[] = []
+ if (!trnsStore.items)
+ return items
+
+ const trnIds = Object.keys(trnsStore.items) as TrnId[]
+ const sortedIds = trnIds.sort((a, b) => {
+ const trnA = trnsStore.items![a]
+ const trnB = trnsStore.items![b]
+ return (trnB?.date ?? 0) - (trnA?.date ?? 0)
+ })
+
+ for (const id of sortedIds) {
+ const trn = trnsStore.items[id]
+ if (!trn)
+ continue
+
+ const computed = trnsStore.computeTrnItem(id)
+ if (!computed)
+ continue
+
+ const searchParts: string[] = []
+
+ if (computed.category)
+ searchParts.push(computed.category.name)
+ if (computed.categoryParent)
+ searchParts.push(computed.categoryParent.name)
+
+ if (trn.type === TrnType.Transfer) {
+ const transfer = computed as TransferFull
+ if (transfer.expenseWallet)
+ searchParts.push(transfer.expenseWallet.name)
+ if (transfer.incomeWallet)
+ searchParts.push(transfer.incomeWallet.name)
+ }
+ else {
+ const transaction = computed as TransactionFull
+ if (transaction.wallet)
+ searchParts.push(transaction.wallet.name)
+ }
+
+ if (trn.desc)
+ searchParts.push(trn.desc)
+
+ let label = computed.category?.name ?? ''
+ if (trn.desc)
+ label = `${label} - ${trn.desc}`
+
+ items.push({
+ entityId: id,
+ entityType: 'trn',
+ id: `trn-${id}`,
+ label,
+ search: searchParts.join(' '),
+ })
+ }
+
+ return items
+ })
+
+ const recentCategoryItems = computed(() => {
+ const recentIds = categoriesStore.recentCategoriesIds
+ if (!recentIds?.length)
+ return allCategoryItems.value.slice(0, RECENT_LIMIT)
+
+ return recentIds.slice(0, RECENT_LIMIT)
+ .map(id => allCategoryItems.value.find(item => item.entityId === id))
+ .filter((item): item is SearchResultItem => !!item)
+ })
+
+ const recentWalletItems = computed(() => {
+ const recentIds = walletsStore.recentWalletIds
+ if (!recentIds?.length)
+ return allWalletItems.value.slice(0, RECENT_LIMIT)
+
+ const walletItemsById = new Map(allWalletItems.value.map(w => [w.entityId, w]))
+ return recentIds.slice(0, RECENT_LIMIT)
+ .map(id => walletItemsById.get(id))
+ .filter((item): item is SearchResultItem => !!item)
+ })
+
+ const recentTrnItems = computed(() => {
+ return allTrnItems.value.slice(0, RECENT_LIMIT)
+ })
+
+ const groups = computed(() => {
+ const isSearching = searchTerm.value.length > 0
+
+ return [
+ {
+ id: 'menu',
+ items: menuGroup.value,
+ label: t('base.menu'),
+ slot: 'menu-item',
+ },
+ {
+ id: 'categories',
+ items: isSearching ? allCategoryItems.value : recentCategoryItems.value,
+ label: t('categories.name'),
+ slot: 'category-item',
+ },
+ {
+ id: 'wallets',
+ items: isSearching ? allWalletItems.value : recentWalletItems.value,
+ label: t('wallets.name'),
+ slot: 'wallet-item',
+ },
+ {
+ id: 'trns',
+ items: isSearching ? allTrnItems.value : recentTrnItems.value,
+ label: t('trns.history'),
+ slot: 'trn-item',
+ },
+ ]
+ })
+
+ return {
+ groups,
+ isSearchOpen,
+ onMenuClick,
+ searchTerm,
+ }
+}
diff --git a/app/components/stat/ConfigSwitch.vue b/app/components/stat/ConfigSwitch.vue
index 83003e29..a4ba0ddd 100644
--- a/app/components/stat/ConfigSwitch.vue
+++ b/app/components/stat/ConfigSwitch.vue
@@ -11,10 +11,10 @@ const props = defineProps<{
const statConfig = inject(statConfigKey)!
-const isChecked = computed(() => {
+const isChecked = computed((): boolean => {
const val = statConfig.config.value[props.configKey]
if (props.field && typeof val === 'object')
- return (val as Record<string, boolean>)[props.field]
+ return (val as Record<string, boolean>)[props.field] ?? false
return val as boolean
})
@@ -22,7 +22,7 @@ function toggle() {
if (props.field)
statConfig.updateConfig(props.configKey, { [props.field]: !isChecked.value })
else
- statConfig.updateConfig(props.configKey, !isChecked.value as any)
+ statConfig.updateConfig(props.configKey, !isChecked.value)
}
</script>
diff --git a/app/components/trnForm/useTrnsFormStore.ts b/app/components/trnForm/useTrnsFormStore.ts
index fc19eb59..397614fc 100644
--- a/app/components/trnForm/useTrnsFormStore.ts
+++ b/app/components/trnForm/useTrnsFormStore.ts
@@ -17,7 +17,7 @@ import { showErrorToast } from '~/composables/useStoreSync'
type Values = {
categoriesIds: CategoryId[]
- trn: TrnItem
+ trn?: TrnItem
walletId?: WalletId
walletsIds: WalletId[]
} & ({
@@ -74,7 +74,7 @@ export const useTrnsFormStore = defineStore('trnForm', () => {
}
function syncAmountRawAt(idx: number) {
- values.amountRaw[idx] = formatInput(values.amount[idx])
+ values.amountRaw[idx] = formatInput(values.amount[idx] ?? 0)
}
function onChangeAmount(amountRaw: string) {
@@ -159,7 +159,7 @@ export const useTrnsFormStore = defineStore('trnForm', () => {
if (props.action === 'edit')
values.trnId = props.trnId
- if (props.action === 'edit' || props.action === 'duplicate') {
+ if ((props.action === 'edit' || props.action === 'duplicate') && props.trn) {
if (props.trn.type !== TrnType.Transfer) {
values.amount = [props.trn.amount, 0, 0]
values.categoryId = props.trn.categoryId
@@ -243,7 +243,7 @@ export const useTrnsFormStore = defineStore('trnForm', () => {
setValues({
action: 'create',
categoriesIds: categoriesStore.categoriesIdsForTrnValues,
- trn: trnsStore.lastCreatedTrnItem as TrnItem,
+ trn: trnsStore.lastCreatedTrnItem ?? undefined,
walletId: walletsStore.sortedIds[0],
walletsIds: walletsStore.sortedIds,
})
diff --git a/app/components/trns/types.ts b/app/components/trns/types.ts
index 3bbf6a46..2f7fec6b 100644
--- a/app/components/trns/types.ts
+++ b/app/components/trns/types.ts
@@ -55,11 +55,11 @@ type TrnItemFullBase = {
id: TrnId
}
-type TransactionFull = Transaction & TrnItemFullBase & {
+export type TransactionFull = Transaction & TrnItemFullBase & {
wallet: WalletItem
}
-type TransferFull = Transfer & TrnItemFullBase & {
+export type TransferFull = Transfer & TrnItemFullBase & {
expenseWallet: WalletItem
incomeWallet: WalletItem
}
diff --git a/app/components/trns/useTrnsStore.ts b/app/components/trns/useTrnsStore.ts
index 142949af..2c6fa22c 100644
--- a/app/components/trns/useTrnsStore.ts
+++ b/app/components/trns/useTrnsStore.ts
@@ -34,7 +34,7 @@ async function fetchAllPages<T>(
let isDone = false
while (!isDone) {
- const result: any = await client.query(queryFn, {
+ const result: { continueCursor: string, isDone: boolean, page: T[] } | null = await client.query(queryFn, {
...args,
paginationOpts: { cursor, numItems: pageSize },
})
diff --git a/app/components/ui/ContextMenuOptional.vue b/app/components/ui/ContextMenuOptional.vue
index 43f07ded..fd7eb505 100644
--- a/app/components/ui/ContextMenuOptional.vue
+++ b/app/components/ui/ContextMenuOptional.vue
@@ -1,6 +1,8 @@
<script setup lang="ts">
+import type { ContextMenuItem } from '#ui/components/ContextMenu.vue'
+
const props = defineProps<{
- items?: any[][]
+ items?: ContextMenuItem[][]
}>()
</script>
diff --git a/app/components/user/useUserStore.ts b/app/components/user/useUserStore.ts
index 0ff1fb01..d1e937b1 100644
--- a/app/components/user/useUserStore.ts
+++ b/app/components/user/useUserStore.ts
@@ -197,7 +197,7 @@ export const useUserStore = defineStore('user', () => {
setUser(null)
clearAuthCookie()
setSessionInitialized(false)
- useCookie('finapp.isOnboarded').value = false
+ useCookie<boolean>('finapp.isOnboarded').value = false
await localforage.clear()
await authClient.signOut()
}
@@ -225,7 +225,7 @@ export const useUserStore = defineStore('user', () => {
walletsStore.setWallets(null)
useTrnsFormStore().$reset()
- useCookie('finapp.isOnboarded').value = false
+ useCookie<boolean>('finapp.isOnboarded').value = false
const { clearOfflineQueue, setOfflineQueueUserId } = await import('~/components/offline/helpers')
await clearOfflineQueue()
diff --git a/app/components/wallets/Item.vue b/app/components/wallets/Item.vue
index 44fa48e3..cc348cab 100644
--- a/app/components/wallets/Item.vue
+++ b/app/components/wallets/Item.vue
@@ -1,10 +1,11 @@
<script setup lang="ts">
+import type { ContextMenuItem } from '#ui/components/ContextMenu.vue'
import type { WalletId, WalletItemComputed } from '~/components/wallets/types'
const props = defineProps<{
activeItemId?: WalletId | null
- alt?: boolean
- contextMenuItems?: any[][]
+ compact?: boolean
+ contextMenuItems?: ContextMenuItem[][]
insideClasses?: string
isShowBaseRate?: boolean
isShowCreditLimit?: boolean
@@ -26,7 +27,7 @@ const emit = defineEmits<{
<UContextMenu v-if="props.contextMenuItems" :items="props.contextMenuItems">
<WalletsItemBody
:activeItemId="props.activeItemId"
- :alt="props.alt"
+ :compact="props.compact"
:insideClasses="props.insideClasses"
:isShowBaseRate="props.isShowBaseRate"
:isShowCreditLimit="props.isShowCreditLimit"
@@ -44,7 +45,7 @@ const emit = defineEmits<{
<WalletsItemBody
v-else
:activeItemId="props.activeItemId"
- :alt="props.alt"
+ :compact="props.compact"
:insideClasses="props.insideClasses"
:isShowBaseRate="props.isShowBaseRate"
:isShowCreditLimit="props.isShowCreditLimit"