fix(frontend): Fix all type issues

This commit is contained in:
2025-11-15 08:40:09 +01:00
parent 1c8815d4ce
commit daf619d6eb
16 changed files with 88 additions and 56 deletions

View File

@@ -96,8 +96,11 @@ function getDropdownItems(formElementId: string, formElementPosition: number): D
function updateFormOptions(formOptions: FormOptionDto[], formElementIndex: number) {
console.log('Updating form options for element index:', formElementIndex, formOptions)
const updatedModelValue = [...props.modelValue]
updatedModelValue[formElementIndex] = { ...updatedModelValue[formElementIndex], options: formOptions }
emit('update:modelValue', updatedModelValue)
const currentElement = updatedModelValue[formElementIndex]
if (currentElement) {
updatedModelValue[formElementIndex] = { ...currentElement, options: formOptions }
emit('update:modelValue', updatedModelValue)
}
}
function toggleComments(formElementId: string) {

View File

@@ -91,13 +91,13 @@ const statusLabel = computed(() => {
const badgeColor = computed(() => {
switch (props.status) {
case ComplianceStatus.Critical:
return 'red'
return 'error' as const
case ComplianceStatus.Warning:
return 'yellow'
return 'warning' as const
case ComplianceStatus.NonCritical:
return 'green'
return 'success' as const
default:
return 'green'
return 'success' as const
}
})

View File

@@ -8,6 +8,7 @@
:avatar="{ icon: 'i-lucide-bot' }"
:content="comment.message"
role="user"
:parts="[{ type: 'text', text: comment.message }]"
:side="isCommentByUser(comment) ? 'right' : 'left'"
variant="subtle"
:actions="createChatMessageActions(comment)"

View File

@@ -65,9 +65,9 @@ const userStore = useUserStore()
const { user: keyCloakUser } = storeToRefs(userStore)
const user = ref({
name: keyCloakUser.value.name,
name: keyCloakUser.value?.name ?? 'UNKNOWN',
avatar: {
alt: keyCloakUser.value.name
alt: keyCloakUser.value?.name ?? 'UNKNOWN'
}
})

View File

@@ -137,20 +137,20 @@ async function handleRestore() {
}
}
function getStatusColor(status: ApplicationFormStatus): string {
function getStatusColor(status: ApplicationFormStatus) {
switch (status) {
case 'DRAFT':
return 'gray'
return 'neutral' as const
case 'SUBMITTED':
return 'blue'
return 'info' as const
case 'APPROVED':
return 'green'
return 'success' as const
case 'REJECTED':
return 'red'
return 'error' as const
case 'SIGNED':
return 'primary'
return 'primary' as const
default:
return 'gray'
return 'neutral' as const
}
}

View File

@@ -14,15 +14,16 @@ const emit = defineEmits<{
}>()
const modelValue = computed({
get: () => props.formOptions?.[0].value === 'true',
get: () => props.formOptions[0]?.value === 'true',
set: (val) => {
if (props.formOptions?.[0]) {
const firstOption = props.formOptions[0]
if (firstOption) {
const updatedModelValue = [...props.formOptions]
updatedModelValue[0] = { ...updatedModelValue[0], value: val.toString() }
updatedModelValue[0] = { ...firstOption, value: val.toString() }
emit('update:formOptions', updatedModelValue)
}
}
})
const label = computed(() => props.formOptions?.[0].label ?? '')
const label = computed(() => props.formOptions[0]?.label ?? '')
</script>

View File

@@ -17,11 +17,12 @@ const emit = defineEmits<{
}>()
const modelValue = computed({
get: () => props.formOptions?.[0].value ?? '',
get: () => props.formOptions[0]?.value ?? '',
set: (val) => {
if (val && props.formOptions?.[0].value) {
const firstOption = props.formOptions[0]
if (val && firstOption) {
const updatedModelValue = [...props.formOptions]
updatedModelValue[0] = { ...updatedModelValue[0], value: val.toString() }
updatedModelValue[0] = { ...firstOption, value: val.toString() }
emit('update:formOptions', updatedModelValue)
}
}

View File

@@ -14,15 +14,16 @@ const emit = defineEmits<{
}>()
const modelValue = computed({
get: () => props.formOptions?.[0].value === 'true',
get: () => props.formOptions[0]?.value === 'true',
set: (val) => {
if (props.formOptions?.[0]) {
const firstOption = props.formOptions[0]
if (firstOption) {
const updatedModelValue = [...props.formOptions]
updatedModelValue[0] = { ...updatedModelValue[0], value: val.toString() }
updatedModelValue[0] = { ...firstOption, value: val.toString() }
emit('update:formOptions', updatedModelValue)
}
}
})
const label = computed(() => props.formOptions?.[0].label ?? '')
const label = computed(() => props.formOptions[0]?.label ?? '')
</script>

View File

@@ -23,33 +23,39 @@ const SEPARATOR = '|||'
const title = computed({
get: () => {
const currentValue = props.formOptions?.[0]?.value ?? ''
const currentValue = props.formOptions[0]?.value ?? ''
return splitValue(currentValue).title
},
set: (newTitle: string) => {
const currentValue = props.formOptions?.[0]?.value ?? ''
const { body: currentBody } = splitValue(currentValue)
const combinedValue = joinValue(newTitle, currentBody)
const firstOption = props.formOptions[0]
if (firstOption) {
const currentValue = firstOption.value ?? ''
const { body: currentBody } = splitValue(currentValue)
const combinedValue = joinValue(newTitle, currentBody)
const updatedModelValue = [...props.formOptions]
updatedModelValue[0] = { ...updatedModelValue[0], value: combinedValue }
emit('update:formOptions', updatedModelValue)
const updatedModelValue = [...props.formOptions]
updatedModelValue[0] = { ...firstOption, value: combinedValue }
emit('update:formOptions', updatedModelValue)
}
}
})
const body = computed({
get: () => {
const currentValue = props.formOptions?.[0]?.value ?? ''
const currentValue = props.formOptions[0]?.value ?? ''
return splitValue(currentValue).body
},
set: (newBody: string) => {
const currentValue = props.formOptions?.[0]?.value ?? ''
const { title: currentTitle } = splitValue(currentValue)
const combinedValue = joinValue(currentTitle, newBody)
const firstOption = props.formOptions[0]
if (firstOption) {
const currentValue = firstOption.value ?? ''
const { title: currentTitle } = splitValue(currentValue)
const combinedValue = joinValue(currentTitle, newBody)
const updatedModelValue = [...props.formOptions]
updatedModelValue[0] = { ...updatedModelValue[0], value: combinedValue }
emit('update:formOptions', updatedModelValue)
const updatedModelValue = [...props.formOptions]
updatedModelValue[0] = { ...firstOption, value: combinedValue }
emit('update:formOptions', updatedModelValue)
}
}
})