fix(frontend): Fix all type issues
This commit is contained in:
@@ -59,9 +59,12 @@ export const useCommentStore = defineStore('Comment', () => {
|
||||
try {
|
||||
const updatedComment = await commentApi.updateComment(id, commentDto)
|
||||
const formElementId = updatedComment.formElementId
|
||||
const index = comments.value?.[formElementId]?.findIndex((comment) => comment.id === id) ?? -1
|
||||
if (index !== -1 && comments.value?.[formElementId][index]) {
|
||||
comments.value[formElementId][index] = updatedComment
|
||||
const formElementComments = comments.value?.[formElementId]
|
||||
if (formElementComments) {
|
||||
const index = formElementComments.findIndex((comment) => comment.id === id)
|
||||
if (index !== -1 && formElementComments[index]) {
|
||||
formElementComments[index] = updatedComment
|
||||
}
|
||||
}
|
||||
return updatedComment
|
||||
} catch (e: unknown) {
|
||||
@@ -78,10 +81,13 @@ export const useCommentStore = defineStore('Comment', () => {
|
||||
try {
|
||||
await commentApi.deleteCommentById(id)
|
||||
for (const formElementId in comments.value) {
|
||||
const index = comments.value[formElementId].findIndex((comment) => comment.id === id)
|
||||
if (index !== -1) {
|
||||
comments.value[formElementId].splice(index, 1)
|
||||
break
|
||||
const formElementComments = comments.value[formElementId]
|
||||
if (formElementComments) {
|
||||
const index = formElementComments.findIndex((comment) => comment.id === id)
|
||||
if (index !== -1) {
|
||||
formElementComments.splice(index, 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
|
||||
@@ -2,11 +2,21 @@ import type { Organization } from '~~/types/keycloak'
|
||||
|
||||
export const useUserStore = defineStore('Organization', () => {
|
||||
const { user } = useUserSession()
|
||||
const selectedOrganization = computed<Organization | null>(() => {
|
||||
if (!user.value?.organizations || user.value.organizations.length === 0) {
|
||||
return null
|
||||
const _selectedOrganization = ref<Organization | null>(null)
|
||||
|
||||
const selectedOrganization = computed<Organization | null>({
|
||||
get: () => {
|
||||
if (_selectedOrganization.value) {
|
||||
return _selectedOrganization.value
|
||||
}
|
||||
if (!user.value?.organizations || user.value.organizations.length === 0) {
|
||||
return null
|
||||
}
|
||||
return user.value.organizations[0]
|
||||
},
|
||||
set: (value: Organization | null) => {
|
||||
_selectedOrganization.value = value
|
||||
}
|
||||
return user.value.organizations[0]
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user