fix: eliminate all TypeScript any usage across Vue components
Replace 24 `err: any` error handler types with proper `AxiosError<ApiErrorResponse>` typing. Fix additional `as any` casts and `Record<string, any>` patterns in registration field components, event settings, and portal layout. Create shared `ApiErrorResponse` type for portal app. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,8 @@ import { VForm } from 'vuetify/components/VForm'
|
||||
import { useCreateCompany, useUpdateCompany } from '@/composables/api/useCompanies'
|
||||
import { requiredValidator, emailValidator } from '@core/utils/validators'
|
||||
import type { Company } from '@/types/organisation'
|
||||
import type { AxiosError } from 'axios'
|
||||
import type { ApiErrorResponse } from '@/types/auth'
|
||||
|
||||
const props = defineProps<{
|
||||
orgId: string
|
||||
@@ -90,8 +92,8 @@ function onSubmit() {
|
||||
emit('saved')
|
||||
}
|
||||
|
||||
const onError = (err: any) => {
|
||||
const data = err.response?.data
|
||||
const onError = (err: Error) => {
|
||||
const data = (err as AxiosError<ApiErrorResponse>).response?.data
|
||||
if (data?.errors) {
|
||||
errors.value = Object.fromEntries(
|
||||
Object.entries(data.errors).map(([k, v]) => [k, (v as string[])[0]]),
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
import { VForm } from 'vuetify/components/VForm'
|
||||
import { useEmailSettings, useUpdateEmailSettings } from '@/composables/api/useEmail'
|
||||
import { emailValidator } from '@core/utils/validators'
|
||||
import type { AxiosError } from 'axios'
|
||||
import type { ApiErrorResponse } from '@/types/auth'
|
||||
|
||||
const props = defineProps<{
|
||||
orgId: string
|
||||
@@ -68,9 +70,10 @@ async function onSubmit() {
|
||||
onSuccess: () => {
|
||||
snackbar.value = true
|
||||
},
|
||||
onError: (error: any) => {
|
||||
if (error.response?.status === 422 && error.response?.data?.errors) {
|
||||
serverErrors.value = error.response.data.errors
|
||||
onError: (error: Error) => {
|
||||
const axiosError = error as AxiosError<ApiErrorResponse>
|
||||
if (axiosError.response?.status === 422 && axiosError.response?.data?.errors) {
|
||||
serverErrors.value = axiosError.response.data.errors
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -11,6 +11,8 @@ import { useAuthStore } from '@/stores/useAuthStore'
|
||||
import { TEMPLATE_VARIABLES } from '@/types/email'
|
||||
import type { EmailTemplate, UpdateEmailTemplatePayload } from '@/types/email'
|
||||
import { emailValidator, requiredValidator } from '@core/utils/validators'
|
||||
import type { AxiosError } from 'axios'
|
||||
import type { ApiErrorResponse } from '@/types/auth'
|
||||
|
||||
const props = defineProps<{
|
||||
orgId: string
|
||||
@@ -89,9 +91,10 @@ function onEditSubmit() {
|
||||
snackbarMessage.value = 'Template opgeslagen'
|
||||
snackbar.value = true
|
||||
},
|
||||
onError: (error: any) => {
|
||||
if (error.response?.status === 422 && error.response?.data?.errors) {
|
||||
editErrors.value = error.response.data.errors
|
||||
onError: (error: Error) => {
|
||||
const axiosError = error as AxiosError<ApiErrorResponse>
|
||||
if (axiosError.response?.status === 422 && axiosError.response?.data?.errors) {
|
||||
editErrors.value = axiosError.response.data.errors
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
} from '@/composables/api/usePersonTags'
|
||||
import { requiredValidator } from '@core/utils/validators'
|
||||
import type { PersonTag } from '@/types/person-tag'
|
||||
import type { AxiosError } from 'axios'
|
||||
import type { ApiErrorResponse } from '@/types/auth'
|
||||
|
||||
const props = defineProps<{
|
||||
orgId: string
|
||||
@@ -139,8 +141,8 @@ function onSubmit() {
|
||||
})
|
||||
}
|
||||
|
||||
function handleError(err: any) {
|
||||
const data = err.response?.data
|
||||
function handleError(err: Error) {
|
||||
const data = (err as AxiosError<ApiErrorResponse>).response?.data
|
||||
if (data?.errors) {
|
||||
errors.value = Object.fromEntries(
|
||||
Object.entries(data.errors).map(([k, v]) => [k, (v as string[])[0]]),
|
||||
|
||||
@@ -8,8 +8,10 @@ import {
|
||||
} from '@/composables/api/useRegistrationFieldTemplates'
|
||||
import { usePersonTagCategories } from '@/composables/api/usePersonTags'
|
||||
import { requiredValidator } from '@core/utils/validators'
|
||||
import type { RegistrationFieldTemplate } from '@/types/registration-field-template'
|
||||
import type { RegistrationFieldTemplate, RegistrationFieldTemplateCreateDTO, RegistrationFieldType } from '@/types/registration-field-template'
|
||||
import { FIELD_TYPE_LABELS, FIELD_TYPES_WITH_OPTIONS } from '@/types/registration-field-template'
|
||||
import type { AxiosError } from 'axios'
|
||||
import type { ApiErrorResponse } from '@/types/auth'
|
||||
|
||||
const props = defineProps<{
|
||||
orgId: string
|
||||
@@ -67,7 +69,7 @@ const dialogTitle = computed(() =>
|
||||
const isSaving = computed(() => isCreating.value || isUpdating.value)
|
||||
|
||||
const showOptions = computed(() =>
|
||||
FIELD_TYPES_WITH_OPTIONS.includes(form.value.field_type as any),
|
||||
(FIELD_TYPES_WITH_OPTIONS as readonly string[]).includes(form.value.field_type),
|
||||
)
|
||||
|
||||
const showTagCategory = computed(() => form.value.field_type === 'tag_picker')
|
||||
@@ -115,7 +117,7 @@ function onSubmit() {
|
||||
if (!valid) return
|
||||
|
||||
errors.value = {}
|
||||
const payload: Record<string, any> = {
|
||||
const payload: Partial<RegistrationFieldTemplateCreateDTO> = {
|
||||
label: form.value.label,
|
||||
is_required: form.value.is_required,
|
||||
is_filterable: form.value.is_filterable,
|
||||
@@ -127,7 +129,7 @@ function onSubmit() {
|
||||
}
|
||||
|
||||
if (!editingTemplate.value) {
|
||||
payload.field_type = form.value.field_type
|
||||
payload.field_type = form.value.field_type as RegistrationFieldType
|
||||
}
|
||||
|
||||
if (showOptions.value) {
|
||||
@@ -155,7 +157,7 @@ function onSubmit() {
|
||||
)
|
||||
}
|
||||
else {
|
||||
createTemplate(payload as any, {
|
||||
createTemplate(payload as RegistrationFieldTemplateCreateDTO, {
|
||||
onSuccess: () => {
|
||||
isDialogOpen.value = false
|
||||
successMessage.value = `${form.value.label} aangemaakt`
|
||||
@@ -167,8 +169,8 @@ function onSubmit() {
|
||||
})
|
||||
}
|
||||
|
||||
function handleError(err: any) {
|
||||
const data = err.response?.data
|
||||
function handleError(err: Error) {
|
||||
const data = (err as AxiosError<ApiErrorResponse>).response?.data
|
||||
if (data?.errors) {
|
||||
errors.value = Object.fromEntries(
|
||||
Object.entries(data.errors).map(([k, v]) => [k, (v as string[])[0]]),
|
||||
|
||||
Reference in New Issue
Block a user