Open source personal finance application
fix(wallets): update WalletForm type definition and related emit handlers
Ilya Komicheve87489ed1467
diff --git a/app/components/layout/ConfirmModal.vue b/app/components/layout/ConfirmModal.vueindex d54be95b..b8076c46 100644--- a/app/components/layout/ConfirmModal.vue+++ b/app/components/layout/ConfirmModal.vue@@ -33,9 +33,9 @@ const items = computed(() => ({<template><Teleport to="body"><BottomSheet- isShow:isScrollerBlock="false"drugClassesCustom="bottomSheetDrugClassesCustom"+ isShow@closed="emit('closed')"><template #handler="{ close }">diff --git a/app/components/wallets/Form.vue b/app/components/wallets/Form.vueindex 44ba29bc..f07c838d 100644--- a/app/components/wallets/Form.vue+++ b/app/components/wallets/Form.vue@@ -1,7 +1,8 @@<script setup lang="ts">import { generateId } from '~~/utils/generateId'-import type { WalletForm, WalletId, WalletItem, WalletType } from '~/components/wallets/types'+import type { CurrencyCode } from '~/components/currencies/types'+import type { WalletForm, WalletId, WalletType } from '~/components/wallets/types'import { errorEmo, random } from '~/assets/js/emo'import UiToastContent from '~/components/ui/ToastContent.vue'@@ -15,7 +16,7 @@ const props = defineProps<{const emit = defineEmits<{afterSave: []- updateValue: [key: keyof WalletItem, value: string | number | boolean]+ updateValue: [key: keyof WalletForm, value: string | number | boolean]}>()const { $toast } = useNuxtApp()@@ -220,7 +221,7 @@ async function onSave() {<CurrenciesModalv-if="modals.currencies":activeCode="props.walletForm.currency"- @onSelect="c => emit('updateValue', 'currency', c)"+ @onSelect="(c: CurrencyCode) => emit('updateValue', 'currency', c)"@onClose="modals.currencies = false"/>@@ -252,7 +253,7 @@ async function onSave() {<ColorPalette:activeColor="props.walletForm.color"isWallet- @click="color => emit('updateValue', 'color', color)"+ @click="(color: string) => emit('updateValue', 'color', color)"/></div>diff --git a/app/components/wallets/page/New.vue b/app/components/wallets/page/New.vueindex 5d4f7949..49b3ae9a 100644--- a/app/components/wallets/page/New.vue+++ b/app/components/wallets/page/New.vue@@ -1,5 +1,5 @@<script setup lang="ts">-import type { WalletId, WalletItem } from '~/components/wallets/types'+import type { WalletForm, WalletItem } from '~/components/wallets/types'import { normalizeWalletItem } from '~/components/wallets/utils'@@ -7,14 +7,6 @@ const { t } = useI18n()const router = useRouter()const walletForm = ref(normalizeWalletItem())-function updateValue(id: WalletId, value: WalletItem[keyof WalletItem]) {- walletForm.value[id] = value-}--function afterSave() {- router.replace('/wallets')-}-useHead({title: `${t('base.add')}: ${walletForm.value.name ? walletForm.value.name : t('wallets.form.name.label')}`,})@@ -28,8 +20,8 @@ useHead({<WalletsForm:walletForm="walletForm"- @afterSave="afterSave"- @updateValue="updateValue"+ @afterSave="() => router.replace('/wallets')"+ @updateValue="(id: keyof WalletForm, value: WalletItem[keyof WalletItem]) => walletForm[id] = value"/></UiPage></template>diff --git a/app/components/wallets/page/id/Edit.vue b/app/components/wallets/page/id/Edit.vueindex 073f11b3..eba4a1f9 100644--- a/app/components/wallets/page/id/Edit.vue+++ b/app/components/wallets/page/id/Edit.vue@@ -1,5 +1,5 @@<script setup lang="ts">-import type { WalletItem } from '~/components/wallets/types'+import type { WalletForm, WalletId } from '~/components/wallets/types'import { useWalletsStore } from '~/components/wallets/useWalletsStore'import { normalizeWalletItem } from '~/components/wallets/utils'@@ -9,25 +9,11 @@ const route = useRoute()const router = useRouter()const walletsStore = useWalletsStore()-const walletId = computed(() => route.params.id)+const walletId = computed(() => route.params.id) as Ref<WalletId>const wallet = computed(() => walletsStore.items?.[walletId.value])const walletForm = ref(normalizeWalletItem(wallet.value))-function updateValue(id: keyof WalletItem, value: WalletItem[keyof WalletItem]) {- walletForm.value[id] = value-}--function afterSave() {- return router.replace(`/wallets/${walletId.value}`)-}--useHead({- title: `${t('base.edit')}: ${- walletForm.value?.name- ? walletForm.value?.name- : t('wallets.form.name.label')- }`,-})+useHead({ title: `${t('base.edit')}: ${walletForm.value?.name || t('wallets.form.name.label')}` })</script><template>@@ -43,10 +29,10 @@ useHead({</UiHeader><WalletsForm- :walletId="walletId"- :walletForm="walletForm"- @afterSave="afterSave"- @updateValue="updateValue"+ :walletId+ :walletForm+ @afterSave="() => router.replace(`/wallets/${walletId}`)"+ @updateValue="(key: keyof WalletForm, newValue: any) => walletForm[key] = newValue"/></UiPage></template>diff --git a/app/components/wallets/types.ts b/app/components/wallets/types.tsindex 5e3776d4..820ee290 100644--- a/app/components/wallets/types.ts+++ b/app/components/wallets/types.ts@@ -70,7 +70,7 @@ export type WalletItemDirty = WalletItem & Partial<{withdrawal: boolean}>-export type WalletForm = DeepPartial<WalletItemDirty> & {+export type WalletForm = DeepPartial<WalletItem> & {creditLimit?: number | nulldescription?: string | null}