useDashboard.ts 872 Bytes
import { createSharedComposable } from '@vueuse/core'

const _useDashboard = () => {
  const route = useRoute()
  const router = useRouter()
  const isNotificationsSlideoverOpen = ref(false)

  defineShortcuts({
    'g-h': () => router.push('/'),
    'g-w': () => router.push('/work-orders'),
    'g-n': () => router.push('/sn-management'),
    'g-o': () => router.push('/operations'),
    'g-i': () => router.push('/inbox'),
    'g-c': () => router.push('/customers'),
    'g-d': () => router.push('/base-info/device-types'),
    'g-s': () => router.push('/settings'),
    'n': () => isNotificationsSlideoverOpen.value = !isNotificationsSlideoverOpen.value
  })

  watch(() => route.fullPath, () => {
    isNotificationsSlideoverOpen.value = false
  })

  return {
    isNotificationsSlideoverOpen
  }
}

export const useDashboard = createSharedComposable(_useDashboard)