Open source personal finance application
refactor: replace router.push with NuxtLink for navigation
Ilya Komichevcaf6f954153d
diff --git a/app/components/app/Onboarding.vue b/app/components/app/Onboarding.vueindex 18b716f2..a845087b 100644--- a/app/components/app/Onboarding.vue+++ b/app/components/app/Onboarding.vue@@ -4,7 +4,6 @@ import { useTrnsFormStore } from '~/components/trnForm/useTrnsFormStore'import { useWalletsStore } from '~/components/wallets/useWalletsStore'const { t } = useI18n()-const router = useRouter()const walletsStore = useWalletsStore()const categoriesStore = useCategoriesStore()const trnsFormStore = useTrnsFormStore()@@ -33,18 +32,18 @@ const introText = computed(() => {<UButtonv-if="!walletsStore.hasItems"+ to="/wallets/new?onboarding"size="xl"class="min-w-52 justify-center rounded-full px-8 py-3"- @click="router.push('/wallets/new?onboarding')">{{ t('onboarding.actionWallet') }}</UButton><UButtonv-else-if="!categoriesStore.hasItems"+ to="/categories/new?onboarding"size="xl"class="min-w-52 justify-center rounded-full px-8 py-3"- @click="router.push('/categories/new?onboarding')">{{ t('onboarding.actionCategory') }}</UButton>diff --git a/app/components/categories/Header.vue b/app/components/categories/Header.vueindex 6ca9a635..d6379980 100644--- a/app/components/categories/Header.vue+++ b/app/components/categories/Header.vue@@ -5,12 +5,6 @@ const props = defineProps<{category: CategoryItemparentCategory?: CategoryItem}>()--const router = useRouter()--function onParentClick() {- router.push(`/categories/${props.category.parentId}`)-}</script><template>@@ -38,12 +32,12 @@ function onParentClick() {•</div>- <div- class="flex items-center gap-2 rounded-lg px-3 py-1 hover:bg-(--item-5)"- @click="onParentClick"+ <NuxtLink+ :to="`/categories/${props.category.parentId}`"+ class="flex items-center gap-2 rounded-lg px-3 py-1 no-underline text-inherit hover:bg-(--item-5)">{{ props.parentCategory.name }}- </div>+ </NuxtLink></div></div></UiHeaderTitle>diff --git a/app/components/categories/Item.vue b/app/components/categories/Item.vueindex a0d79c56..4ccd201b 100644--- a/app/components/categories/Item.vue+++ b/app/components/categories/Item.vue@@ -11,6 +11,7 @@ export type CategoryItemProps = {insideClasses?: stringisShowParent?: booleanlineWidth?: number+ to?: string}const props = defineProps<CategoryItemProps>()@@ -32,6 +33,7 @@ const emit = defineEmits<{:insideClasses="props.insideClasses":isShowParent="props.isShowParent":lineWidth="props.lineWidth"+ :to="props.to"@click="emit('click', $event)"@filter="emit('filter', $event)"/>diff --git a/app/components/categories/ItemBody.vue b/app/components/categories/ItemBody.vueindex 2a9d8d72..a3eb90f8 100644--- a/app/components/categories/ItemBody.vue+++ b/app/components/categories/ItemBody.vue@@ -12,6 +12,7 @@ const props = defineProps<{insideClasses?: stringisShowParent?: booleanlineWidth?: number+ to?: string}>()const emit = defineEmits<{@@ -32,6 +33,7 @@ const parentCategory = computed(() => categoriesStore.items[props.category?.pare:class="props.class":lineWidth="props.lineWidth":insideClasses="`min-h-[46px] ${props.insideClasses}`"+ :to="props.to"@click="(e: Event) => emit('click', e)"><template #leftIcon>diff --git a/app/components/categories/List.vue b/app/components/categories/List.vueindex 03358d3c..48686a62 100644--- a/app/components/categories/List.vue+++ b/app/components/categories/List.vue@@ -8,6 +8,7 @@ const props = defineProps<{activeItemId?: string | 0 | false | nullcategoriesItemProps?: Partial<CategoryItemProps>getContextMenuItems?: (categoryId: CategoryId) => any[][] | undefined+ getTo?: (categoryId: CategoryId) => stringids: CategoryId[]insideClasses?: string}>()@@ -29,6 +30,7 @@ const categoriesStore = useCategoriesStore():categoryId="categoryId":contextMenuItems="props.getContextMenuItems?.(categoryId)":insideClasses="props.insideClasses"+ :to="props.getTo?.(categoryId)":lineWidth="1"v-bind="categoriesItemProps"@click="emit('click', categoryId)"diff --git a/app/components/categories/page/List.vue b/app/components/categories/page/List.vueindex 879e1043..ba406ff9 100644--- a/app/components/categories/page/List.vue+++ b/app/components/categories/page/List.vue@@ -9,7 +9,6 @@ import { useTrnsStore } from '~/components/trns/useTrnsStore'import { showErrorToast, showSuccessToast } from '~/composables/useStoreSync'const { t } = useI18n()-const router = useRouter()const categoriesStore = useCategoriesStore()const trnsStore = useTrnsStore()@@ -85,9 +84,11 @@ const { getCategoryContextMenuItems } = useCategoryContextMenu({/></UiActionButton>- <UiActionButton :ariaLabel="$t('categories.new')" @click="router.push('/categories/new')">- <Icon name="lucide:plus" size="24" />- </UiActionButton>+ <NuxtLink to="/categories/new">+ <UiActionButton :ariaLabel="$t('categories.new')">+ <Icon name="lucide:plus" size="24" />+ </UiActionButton>+ </NuxtLink></template></UiHeader>@@ -99,12 +100,11 @@ const { getCategoryContextMenuItems } = useCategoryContextMenu({<UiTitleSection class="pb-4">{{ t('categories.new') }}</UiTitleSection>- <UiButtonAccent- rounded- @click="router.push('/categories/new')"- >- {{ t('categories.new') }}- </UiButtonAccent>+ <NuxtLink to="/categories/new">+ <UiButtonAccent rounded>+ {{ t('categories.new') }}+ </UiButtonAccent>+ </NuxtLink></div><!-- List -->@@ -123,7 +123,7 @@ const { getCategoryContextMenuItems } = useCategoryContextMenu({}":getContextMenuItems="getCategoryContextMenuItems":insideClasses="categoriesView === 'grid' ? 'bg-item-2' : ''"- @click="(categoryId: CategoryId) => router.push(`/categories/${categoryId}`)"+ :getTo="(categoryId: CategoryId) => `/categories/${categoryId}`"/></div>diff --git a/app/components/categories/page/id/Index.vue b/app/components/categories/page/id/Index.vueindex ff407935..f2793acd 100644--- a/app/components/categories/page/id/Index.vue+++ b/app/components/categories/page/id/Index.vue@@ -193,7 +193,7 @@ const categoriesIds = computed(() => categoriesStore.getChildrenIds(categoryId.v:categoriesItemProps="{class: 'group',}"- @click="(categoryId: CategoryId) => router.push(`/categories/${categoryId}`)"+ :getTo="(categoryId: CategoryId) => `/categories/${categoryId}`"/></div>diff --git a/app/components/layout/Sidebar.vue b/app/components/layout/Sidebar.vueindex 956e545d..8f63cd08 100644--- a/app/components/layout/Sidebar.vue+++ b/app/components/layout/Sidebar.vue@@ -13,7 +13,6 @@ const props = defineProps<{const emit = defineEmits(['toggleSidebar'])const route = useRoute()-const router = useRouter()const userStore = useUserStore()const { isDemo } = useDemo()const { t } = useI18n()@@ -94,19 +93,18 @@ const { getWalletContextMenuItems } = useWalletContextMenu()isShowCreditLimitisShowRateisShowIcon- @click="() => walletId === route.params.id ? router.push('/dashboard') : router.push(`/wallets/${walletId}`)"+ :to="walletId === route.params.id ? '/dashboard' : `/wallets/${walletId}`"/><divv-if="walletsIdsSorted.length === 0"class="flex-center flex-col py-4">- <UiButtonAccent- rounded- @click="router.push('/wallets/new')"- >- {{ t('wallets.new') }}- </UiButtonAccent>+ <NuxtLink to="/wallets/new">+ <UiButtonAccent rounded>+ {{ t('wallets.new') }}+ </UiButtonAccent>+ </NuxtLink></div></template></WalletsList>diff --git a/app/components/ui/Element.vue b/app/components/ui/Element.vueindex 2b33aa2b..ca714c09 100644--- a/app/components/ui/Element.vue+++ b/app/components/ui/Element.vue@@ -3,6 +3,7 @@ const props = defineProps<{insideClasses?: stringisActive?: booleanlineWidth?: number+ to?: string}>()const emit = defineEmits<{@@ -19,7 +20,12 @@ const elementClasses = computed(() => cn(</script><template>- <div @click="(e: Event) => emit('click', e)">+ <component+ :is="props.to ? resolveComponent('NuxtLink') : 'div'"+ :to="props.to"+ :class="{ uiElementLink: props.to }"+ @click="(e: Event) => emit('click', e)"+ ><div :class="elementClasses"><divv-if="slots.leftIcon"@@ -43,12 +49,16 @@ const elementClasses = computed(() => cn(}"class="mx-2 h-px bg-(--item-5)"/>- </div>+ </component></template><style>@reference '../../assets/css/main.css';+a.uiElementLink {+ @apply no-underline text-inherit;+}+[data-state='open'] > .uiElement {@apply !bg-item-4;}diff --git a/app/components/wallets/Item.vue b/app/components/wallets/Item.vueindex 292c510a..44fa48e3 100644--- a/app/components/wallets/Item.vue+++ b/app/components/wallets/Item.vue@@ -12,6 +12,7 @@ const props = defineProps<{isShowRate?: booleanisSort?: booleanlineWidth?: number+ to?: stringwallet: WalletItemComputedwalletId: WalletId}>()@@ -33,6 +34,7 @@ const emit = defineEmits<{:isShowRate="props.isShowRate":isSort="props.isSort":lineWidth="props.lineWidth"+ :to="props.to":wallet="props.wallet":walletId="props.walletId"@click="emit('click', $event)"diff --git a/app/components/wallets/ItemBody.vue b/app/components/wallets/ItemBody.vueindex e0e8418e..b754f4fc 100644--- a/app/components/wallets/ItemBody.vue+++ b/app/components/wallets/ItemBody.vue@@ -17,6 +17,7 @@ const props = defineProps<{isShowRate?: booleanisSort?: booleanlineWidth?: number+ to?: stringwallet: WalletItemComputedwalletId: WalletId}>()@@ -74,6 +75,7 @@ if (!props.isSort) {:isActive="activeItemId === props.walletId":insideClasses="`${props.insideClasses ?? ''} min-h-[46px]`":lineWidth="props.lineWidth"+ :to="props.to":class="classes"@click="emit('click', props.walletId)">diff --git a/app/components/wallets/page/List.vue b/app/components/wallets/page/List.vueindex 7c187798..de7fcba2 100644--- a/app/components/wallets/page/List.vue+++ b/app/components/wallets/page/List.vue@@ -12,7 +12,6 @@ import { useWalletsGrouping } from '~/components/wallets/useWalletsGrouping'import { useWalletsStore } from '~/components/wallets/useWalletsStore'const { t } = useI18n()-const router = useRouter()useSeoMeta({ogTitle: t('wallets.name'),@@ -70,9 +69,11 @@ function hasGroups(groups: Record<string, unknown> | undefined) {<UiHeaderTitle>{{ t('wallets.name') }}</UiHeaderTitle><template #actions>- <UiActionButton :ariaLabel="$t('wallets.new')" @click="router.push('/wallets/new')">- <Icon name="lucide:plus" size="24" />- </UiActionButton>+ <NuxtLink to="/wallets/new">+ <UiActionButton :ariaLabel="$t('wallets.new')">+ <Icon name="lucide:plus" size="24" />+ </UiActionButton>+ </NuxtLink><BottomSheetOrDropdownv-if="walletsStore.sortedIds.length > 1"@@ -109,12 +110,11 @@ function hasGroups(groups: Record<string, unknown> | undefined) {<UiTitleSection class="pb-4">{{ t('wallets.new') }}</UiTitleSection>- <UiButtonAccent- rounded- @click="router.push('/wallets/new')"- >- {{ t('wallets.new') }}- </UiButtonAccent>+ <NuxtLink to="/wallets/new">+ <UiButtonAccent rounded>+ {{ t('wallets.new') }}+ </UiButtonAccent>+ </NuxtLink></div><!-- Content -->diff --git a/app/components/wallets/page/ListItem.vue b/app/components/wallets/page/ListItem.vueindex 6d42d0d6..7de6c85e 100644--- a/app/components/wallets/page/ListItem.vue+++ b/app/components/wallets/page/ListItem.vue@@ -12,7 +12,6 @@ const emit = defineEmits<{delete: [walletId: WalletId]}>()-const router = useRouter()const walletsStore = useWalletsStore()const { getWalletContextMenuItems } = useWalletContextMenu({@@ -31,6 +30,6 @@ const { getWalletContextMenuItems } = useWalletContextMenu({isShowCreditLimitisShowIconisShowRate- @click="router.push(`/wallets/${props.walletId}`)"+ :to="`/wallets/${props.walletId}`"/></template>diff --git a/app/layouts/error.vue b/app/layouts/error.vueindex 9e230d76..9a5c5dd5 100644--- a/app/layouts/error.vue+++ b/app/layouts/error.vue@@ -15,9 +15,9 @@ if (Object.keys(route.query).length > 0)<div class="p-4"><h1>{{ t('actionError.title') }}</h1><pre>{{ error }}</pre>- <h1 @click="router.push('/')">- {{ t('actionError.goHome') }}- </h1>+ <NuxtLink to="/" class="text-inherit">+ <h1>{{ t('actionError.goHome') }}</h1>+ </NuxtLink><slot /></div></template>