feat(frontend): Close notification slider over on click, fix types, delete dead code

This commit is contained in:
2025-10-04 08:17:22 +02:00
parent 03f3369cd7
commit 80592167c8
4 changed files with 14 additions and 13 deletions

View File

@@ -11,7 +11,7 @@
:key="notification.id" :key="notification.id"
:to="notification.clickTarget" :to="notification.clickTarget"
class="px-3 py-2.5 rounded-md hover:bg-elevated/50 flex items-center gap-3 relative -mx-3 first:-mt-3 last:-mb-3" class="px-3 py-2.5 rounded-md hover:bg-elevated/50 flex items-center gap-3 relative -mx-3 first:-mt-3 last:-mb-3"
@click="handleNotificationClick(notification)" @click="onNotificationClick(notification)"
> >
<UChip <UChip
:color="notification.type === 'ERROR' ? 'error' : notification.type === 'WARNING' ? 'warning' : 'primary'" :color="notification.type === 'ERROR' ? 'error' : notification.type === 'WARNING' ? 'warning' : 'primary'"
@@ -54,7 +54,7 @@
{{ notification.type }} {{ notification.type }}
</UBadge> </UBadge>
<UBadge color="neutral" variant="subtle" size="xs"> <UBadge color="neutral" variant="subtle" size="xs">
{{ notification.targetGroup }} {{ notification.role }}
</UBadge> </UBadge>
</div> </div>
</div> </div>
@@ -65,6 +65,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { formatTimeAgo } from '@vueuse/core' import { formatTimeAgo } from '@vueuse/core'
import type { NotificationDto } from '~/.api-client'
const emit = defineEmits<{ const emit = defineEmits<{
'update:modelValue': [value: boolean] 'update:modelValue': [value: boolean]
@@ -86,4 +87,9 @@ watch(isOpen, async (newValue) => {
await fetchNotifications() await fetchNotifications()
} }
}) })
function onNotificationClick(notification: NotificationDto) {
handleNotificationClick(notification)
emit('update:modelValue', false)
}
</script> </script>

View File

@@ -92,7 +92,7 @@ export const useNotification = () => {
const startPeriodicRefresh = (intervalMs: number = 30000) => { const startPeriodicRefresh = (intervalMs: number = 30000) => {
const interval = setInterval(() => { const interval = setInterval(() => {
fetchUnreadCount() void fetchUnreadCount()
}, intervalMs) }, intervalMs)
onUnmounted(() => { onUnmounted(() => {
@@ -103,10 +103,10 @@ export const useNotification = () => {
} }
return { return {
notifications: readonly(notifications), notifications,
unreadNotifications: readonly(unreadNotifications), unreadNotifications,
unreadCount: readonly(unreadCount), unreadCount,
isLoading: readonly(isLoading), isLoading,
fetchNotifications, fetchNotifications,
fetchUnreadNotifications, fetchUnreadNotifications,
fetchUnreadCount, fetchUnreadCount,

View File

@@ -40,7 +40,6 @@
v-model="currentFormElementSection.formElements" v-model="currentFormElementSection.formElements"
:application-form-id="applicationForm.id" :application-form-id="applicationForm.id"
:disabled="isReadOnly" :disabled="isReadOnly"
@click:comments="openComments"
/> />
<div class="flex gap-2 justify-between mt-4"> <div class="flex gap-2 justify-between mt-4">
<UButton <UButton
@@ -160,8 +159,4 @@ async function onSubmit() {
toast.add({ title: 'Success', description: 'Application form submitted', color: 'success' }) toast.add({ title: 'Success', description: 'Application form submitted', color: 'success' })
} }
} }
function openComments(formElementId: string) {
console.log('open comments for', formElementId)
}
</script> </script>

View File

@@ -80,7 +80,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ComplianceStatus, type FormElementSectionDto, type PagedApplicationFormDto } from '~/.api-client' import { ComplianceStatus, type FormElementSectionDto, type PagedApplicationFormDto } from '~/.api-client'
import { useApplicationFormValidator } from '~/composables/useApplicationFormValidator' import { useApplicationFormValidator } from '~/composables/useApplicationFormValidator'
import type { FormElementId } from '~/types/FormElement' import type { FormElementId } from '~/types/formElement'
import type { StepperItem } from '@nuxt/ui' import type { StepperItem } from '@nuxt/ui'
const { getAllApplicationFormTemplates } = useApplicationFormTemplate() const { getAllApplicationFormTemplates } = useApplicationFormTemplate()