Fix type errors
This commit is contained in:
@ -11,11 +11,11 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, toRef, watch, onMounted } from 'vue'
|
||||
import { assertSdkResponseOk } from '@/api/AssertSdkResponseOk'
|
||||
import { ValidationError } from '@/api/errors'
|
||||
import { assertSdkResponseOk } from '@/api/assertSdkResponseOk'
|
||||
import { ApiError, ValidationError } from '@/api/errors'
|
||||
import ClientSkeleton from '@/components/clients/ClientSkeleton.vue'
|
||||
import ClientDetail from '@/components/clients/ClientDetail.vue'
|
||||
import type { ClientCreate } from '@/client'
|
||||
import type { ClientCreate, Client } from '@/client'
|
||||
import { idKey } from '@/api/paths'
|
||||
import { SshecretAdmin } from '@/client'
|
||||
import { useTreeState } from '@/store/useTreeState'
|
||||
@ -32,7 +32,7 @@ const treeState = useTreeState()
|
||||
const emit = defineEmits<{ (e: 'clientDeleted', data: string): void }>()
|
||||
const alerts = useAlertsStore()
|
||||
|
||||
const updateErrors = ref([])
|
||||
const updateErrors = ref<any[]>([])
|
||||
|
||||
async function loadClient() {
|
||||
if (!props.id) return
|
||||
@ -56,9 +56,10 @@ function clearUpdateErrors() {
|
||||
}
|
||||
|
||||
async function updateClient(updated: ClientCreate) {
|
||||
if (!client.value) return
|
||||
const response = await SshecretAdmin.updateClientApiV1ClientsIdPut({
|
||||
path: { id: idKey(localClient.value.id) },
|
||||
body: data,
|
||||
path: { id: idKey(client.value.id) },
|
||||
body: updated,
|
||||
})
|
||||
try {
|
||||
const responseData = assertSdkResponseOk(response)
|
||||
@ -67,9 +68,12 @@ async function updateClient(updated: ClientCreate) {
|
||||
} catch (err) {
|
||||
if (err instanceof ValidationError) {
|
||||
updateErrors.value = err.errors
|
||||
} else {
|
||||
} else if (err instanceof ApiError) {
|
||||
const errorMessage = err.message ?? 'Unknown error'
|
||||
alerts.showAlert(`Error from backend: ${errorMessage}`, 'error')
|
||||
} else {
|
||||
console.error(err)
|
||||
alerts.showAlert('Unexpected error from backend', 'error')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user