useBreadcrumb.ts 605 B

123456789101112131415161718192021222324
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import type { BreadcrumbItem } from '#desktop/components/CommonBreadcrumb/types.ts'
  3. export const useBreadcrumb = (currentItem: string | BreadcrumbItem) => {
  4. const baseBreadcrumbItem: BreadcrumbItem = {
  5. label: __('Profile'),
  6. route: '/personal-setting',
  7. }
  8. const breadcrumbItems: BreadcrumbItem[] = [baseBreadcrumbItem]
  9. if (typeof currentItem === 'string') {
  10. breadcrumbItems.push({
  11. label: currentItem,
  12. })
  13. } else {
  14. breadcrumbItems.push(currentItem)
  15. }
  16. return {
  17. breadcrumbItems,
  18. }
  19. }