@goplusvn/core 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/src/assets/erp_wallpaper.png +0 -0
- package/src/assets/goeat_logo.png +0 -0
- package/src/audit/audit-manager.ts +139 -0
- package/src/audit/index.ts +11 -0
- package/src/audit/memory-audit-logger.ts +86 -0
- package/src/audit/types.ts +50 -0
- package/src/auth/auth-service.ts +97 -0
- package/src/auth/index.ts +266 -0
- package/src/code-generation/index.ts +69 -0
- package/src/configs/auth-routes.ts +17 -0
- package/src/configs/crud.ts +136 -0
- package/src/configs/data/navigations.ts +781 -0
- package/src/configs/data/oauth-links.ts +10 -0
- package/src/configs/entities/material-categories.config.ts +125 -0
- package/src/configs/i18n.ts +12 -0
- package/src/configs/index.ts +26 -0
- package/src/configs/status.ts +25 -0
- package/src/configs/themes.ts +100 -0
- package/src/crud/components/crud-bulk-actions.tsx +91 -0
- package/src/crud/components/crud-card-view.tsx +241 -0
- package/src/crud/components/crud-context.tsx +122 -0
- package/src/crud/components/crud-delete-dialog.tsx +145 -0
- package/src/crud/components/crud-dialog.tsx +406 -0
- package/src/crud/components/crud-empty-state.tsx +104 -0
- package/src/crud/components/crud-export-button.tsx +170 -0
- package/src/crud/components/crud-field-renderer.tsx +653 -0
- package/src/crud/components/crud-filter-chips.tsx +102 -0
- package/src/crud/components/crud-filters/checkbox-filter.tsx +97 -0
- package/src/crud/components/crud-filters/datetime-filter.tsx +83 -0
- package/src/crud/components/crud-filters/filter-builder.tsx +66 -0
- package/src/crud/components/crud-filters/index.tsx +76 -0
- package/src/crud/components/crud-filters/radio-filter.tsx +86 -0
- package/src/crud/components/crud-filters/select-filter.tsx +141 -0
- package/src/crud/components/crud-filters/text-filter.tsx +86 -0
- package/src/crud/components/crud-form.tsx +642 -0
- package/src/crud/components/crud-import-dialog.tsx +440 -0
- package/src/crud/components/crud-infinite-scroll.tsx +116 -0
- package/src/crud/components/crud-page.tsx +1017 -0
- package/src/crud/components/crud-provider.tsx +277 -0
- package/src/crud/components/crud-row-actions.tsx +189 -0
- package/src/crud/components/crud-search.tsx +82 -0
- package/src/crud/components/crud-sheet.tsx +336 -0
- package/src/crud/components/crud-table-skeleton.tsx +26 -0
- package/src/crud/components/crud-table-toolbar.tsx +91 -0
- package/src/crud/components/crud-table.tsx +352 -0
- package/src/crud/components/crud-virtual-table.tsx +55 -0
- package/src/crud/components/index.tsx +20 -0
- package/src/crud/crud-filters/checkbox-filter.tsx +87 -0
- package/src/crud/crud-filters/datetime-filter.tsx +82 -0
- package/src/crud/crud-filters/filter-builder.tsx +64 -0
- package/src/crud/crud-filters/index.tsx +78 -0
- package/src/crud/crud-filters/radio-filter.tsx +79 -0
- package/src/crud/crud-filters/select-filter.tsx +148 -0
- package/src/crud/crud-filters/text-filter.tsx +81 -0
- package/src/crud/index.ts +43 -0
- package/src/crud/lib/crud-service.test.ts +334 -0
- package/src/crud/lib/crud-service.ts +358 -0
- package/src/crud/lib/crud-utils.test.ts +354 -0
- package/src/crud/lib/crud-utils.ts +299 -0
- package/src/crud/lib/crud-validator.ts +247 -0
- package/src/crud/lib/data-loader.ts +234 -0
- package/src/crud/lib/field-calculator.ts +241 -0
- package/src/crud/lib/field-formatter.ts +240 -0
- package/src/crud/lib/import-export-service.test.ts +290 -0
- package/src/crud/lib/import-export-service.ts +352 -0
- package/src/crud/lib/import-server-utils.ts +109 -0
- package/src/crud/lib/lazy-loader.ts +241 -0
- package/src/crud/lib/parse-filters.ts +85 -0
- package/src/crud/lib/permissions.ts +52 -0
- package/src/crud/lib/serialize-config.ts +60 -0
- package/src/crud/lib/stream-loader.ts +145 -0
- package/src/crud/lib/translate-config.ts +335 -0
- package/src/crud/lib/types.ts +11 -0
- package/src/crud/pages/entity-crud-page.tsx +144 -0
- package/src/crud/server.ts +8 -0
- package/src/home/constants.tsx +142 -0
- package/src/home/feature-showcase.tsx +171 -0
- package/src/home/home-page.tsx +191 -0
- package/src/home/hooks/index.ts +1 -0
- package/src/home/hooks/useWidgetPreferences.ts +167 -0
- package/src/home/index.ts +33 -0
- package/src/home/quick-access-dialog.tsx +271 -0
- package/src/home/quick-access-menu.tsx +267 -0
- package/src/home/types.ts +140 -0
- package/src/home/welcome-card.tsx +92 -0
- package/src/home/widget-container.tsx +258 -0
- package/src/home/widgets/base-widget.tsx +200 -0
- package/src/home/widgets/customers-widget.tsx +74 -0
- package/src/home/widgets/index.ts +6 -0
- package/src/home/widgets/orders-widget.tsx +87 -0
- package/src/home/widgets/revenue-widget.tsx +71 -0
- package/src/home/widgets/stock-widget.tsx +109 -0
- package/src/hooks/index.tsx +598 -0
- package/src/hooks/use-tenant.test.tsx +30 -0
- package/src/hooks/use-tenant.ts +5 -0
- package/src/index.ts +17 -0
- package/src/infrastructure/__tests__/architecture-verification.spec.ts +103 -0
- package/src/infrastructure/api-service.ts +317 -0
- package/src/infrastructure/cache/cache-manager.ts +107 -0
- package/src/infrastructure/cache/cache.ts +120 -0
- package/src/infrastructure/cache/index.ts +8 -0
- package/src/infrastructure/cache/types.ts +48 -0
- package/src/infrastructure/cron/cron-manager.ts +239 -0
- package/src/infrastructure/cron/index.ts +6 -0
- package/src/infrastructure/cron/types.ts +41 -0
- package/src/infrastructure/event-bus/event-bus.ts +145 -0
- package/src/infrastructure/event-bus/index.ts +2 -0
- package/src/infrastructure/event-bus/types.ts +22 -0
- package/src/infrastructure/index.ts +32 -0
- package/src/infrastructure/lock/decorators.ts +67 -0
- package/src/infrastructure/lock/index.ts +2 -0
- package/src/infrastructure/lock/lock-manager.ts +33 -0
- package/src/infrastructure/logger/index.ts +2 -0
- package/src/infrastructure/logger/logger.ts +96 -0
- package/src/infrastructure/logger/types.ts +25 -0
- package/src/layout/index.tsx +185 -0
- package/src/navigation/index.ts +91 -0
- package/src/notification/index.ts +14 -0
- package/src/notification/notification-service.ts +120 -0
- package/src/notification/storage/in-memory.ts +56 -0
- package/src/notification/storage/index.ts +1 -0
- package/src/notification/types.ts +51 -0
- package/src/organization/branch-service.ts +299 -0
- package/src/organization/branches.config.ts +154 -0
- package/src/organization/index.ts +5 -0
- package/src/plugin/apps-registry.ts +97 -0
- package/src/plugin/index.ts +5 -0
- package/src/plugin/types.ts +41 -0
- package/src/providers/index.tsx +109 -0
- package/src/providers/tenant-provider.tsx +45 -0
- package/src/rbac/components/roles/role-card.tsx +158 -0
- package/src/rbac/components/roles/role-stats-cards.tsx +29 -0
- package/src/rbac/components/roles/role-toolbar.tsx +123 -0
- package/src/rbac/hooks/use-role-operations.ts +159 -0
- package/src/rbac/hooks/use-roles-data.ts +59 -0
- package/src/rbac/index.ts +297 -0
- package/src/rbac/lib/permission-helpers.ts +63 -0
- package/src/rbac/pages/action-list-page.tsx +25 -0
- package/src/rbac/pages/resource-list-page.tsx +25 -0
- package/src/rbac/pages/role-list-page.tsx +378 -0
- package/src/rbac/permission-service.ts +140 -0
- package/src/rbac/permissions.ts +135 -0
- package/src/rbac/resource-service.ts +115 -0
- package/src/rbac/resource-validator.ts +119 -0
- package/src/rbac/role-service.ts +165 -0
- package/src/rbac/server.ts +16 -0
- package/src/rbac/types.ts +38 -0
- package/src/schemas/action.schema.ts +66 -0
- package/src/schemas/branch.schema.ts +52 -0
- package/src/schemas/coming-soon-schema.ts +9 -0
- package/src/schemas/company.schema.ts +44 -0
- package/src/schemas/forgot-passward-schema.ts +9 -0
- package/src/schemas/index.ts +30 -0
- package/src/schemas/material-category.schema.ts +43 -0
- package/src/schemas/material-pricing.schema.ts +74 -0
- package/src/schemas/material.schema.ts +76 -0
- package/src/schemas/materials.ts +52 -0
- package/src/schemas/new-passward-schema.ts +15 -0
- package/src/schemas/partner-company.schema.ts +149 -0
- package/src/schemas/register-schema.ts +36 -0
- package/src/schemas/resource.schema.ts +133 -0
- package/src/schemas/role.schema.ts +11 -0
- package/src/schemas/sign-in-schema.ts +24 -0
- package/src/schemas/supplier-pricing.schema.ts +15 -0
- package/src/schemas/supplier.schema.ts +120 -0
- package/src/schemas/system-category-group.schema.ts +67 -0
- package/src/schemas/system-category.schema.ts +77 -0
- package/src/schemas/system-config.schema.ts +118 -0
- package/src/schemas/uom.schema.ts +75 -0
- package/src/schemas/user-supplier.schema.ts +179 -0
- package/src/schemas/user.schema.ts +18 -0
- package/src/schemas/verify-email-schema.ts +9 -0
- package/src/schemas/warehouse.schema.ts +49 -0
- package/src/system/components/categories/category-list.tsx +529 -0
- package/src/system/components/categories/category-manager.tsx +89 -0
- package/src/system/components/categories/group-sidebar.tsx +308 -0
- package/src/system/components/settings/setting-dialogs.tsx +197 -0
- package/src/system/components/settings/setting-field.tsx +291 -0
- package/src/system/components/settings/setting-form-dialog.tsx +308 -0
- package/src/system/components/settings/settings-groups.ts +80 -0
- package/src/system/components/settings/settings-search.tsx +71 -0
- package/src/system/components/settings/settings-section.tsx +74 -0
- package/src/system/components/settings/settings-sidebar.tsx +81 -0
- package/src/system/constants.ts +3 -0
- package/src/system/index.ts +150 -0
- package/src/system/job-manager.ts +176 -0
- package/src/system/pages/components/categories/category-list.tsx +537 -0
- package/src/system/pages/components/categories/category-manager.tsx +90 -0
- package/src/system/pages/components/categories/group-sidebar.tsx +311 -0
- package/src/system/pages/components/settings/sales-rules-settings.tsx +222 -0
- package/src/system/pages/components/settings/setting-dialogs.tsx +197 -0
- package/src/system/pages/components/settings/setting-field.tsx +292 -0
- package/src/system/pages/components/settings/setting-form-dialog.tsx +308 -0
- package/src/system/pages/components/settings/settings-groups.ts +87 -0
- package/src/system/pages/components/settings/settings-page.tsx +372 -0
- package/src/system/pages/components/settings/settings-search.tsx +71 -0
- package/src/system/pages/components/settings/settings-section.tsx +74 -0
- package/src/system/pages/components/settings/settings-sidebar.tsx +81 -0
- package/src/system/pages/components/settings/system-settings.tsx +244 -0
- package/src/system/pages/system-category-page.tsx +15 -0
- package/src/system/pages/system-settings-page.tsx +380 -0
- package/src/system/schemas/system-category-group.schema.ts +46 -0
- package/src/system/schemas/system-category.schema.ts +56 -0
- package/src/system/services/settings-service.ts +127 -0
- package/src/system/services/system-category-service.ts +63 -0
- package/src/system/types.ts +45 -0
- package/src/types/index.ts +703 -0
- package/src/ui/auth/auth-layout.tsx +135 -0
- package/src/ui/auth/forgot-password-form.tsx +98 -0
- package/src/ui/auth/index.tsx +7 -0
- package/src/ui/auth/new-password-form.tsx +107 -0
- package/src/ui/auth/oauth-links.tsx +30 -0
- package/src/ui/auth/register-form.tsx +202 -0
- package/src/ui/auth/sign-in-form.tsx +238 -0
- package/src/ui/auth/verify-email-form.tsx +104 -0
- package/src/ui/crud/index.tsx +10 -0
- package/src/ui/data-display/accordion.tsx +65 -0
- package/src/ui/data-display/aspect-ratio.tsx +11 -0
- package/src/ui/data-display/avatar.tsx +163 -0
- package/src/ui/data-display/bento-grid.tsx +77 -0
- package/src/ui/data-display/carousel.tsx +249 -0
- package/src/ui/data-display/chart.tsx +363 -0
- package/src/ui/data-display/code-block-highlight.tsx +54 -0
- package/src/ui/data-display/collapsible.tsx +42 -0
- package/src/ui/data-display/compact-stat-bar.tsx +149 -0
- package/src/ui/data-display/data-table/data-table-context.tsx +255 -0
- package/src/ui/data-display/data-table/data-table-empty-state.tsx +133 -0
- package/src/ui/data-display/data-table/data-table-skeleton.tsx +145 -0
- package/src/ui/data-display/data-table/data-table-toolbar.tsx +353 -0
- package/src/ui/data-display/data-table/data-table.tsx +597 -0
- package/src/ui/data-display/data-table/index.ts +44 -0
- package/src/ui/data-display/data-table-column-header.tsx +75 -0
- package/src/ui/data-display/data-table-pagination.tsx +130 -0
- package/src/ui/data-display/data-table-view-options.tsx +59 -0
- package/src/ui/data-display/formatted-number-input.tsx +210 -0
- package/src/ui/data-display/highlight.tsx +20 -0
- package/src/ui/data-display/hover-card.tsx +48 -0
- package/src/ui/data-display/index.tsx +50 -0
- package/src/ui/data-display/iphone-15-pro.tsx +114 -0
- package/src/ui/data-display/kanban/index.ts +4 -0
- package/src/ui/data-display/kanban/kanban-board.tsx +192 -0
- package/src/ui/data-display/kanban/kanban-column.tsx +74 -0
- package/src/ui/data-display/kanban/kanban-item.tsx +50 -0
- package/src/ui/data-display/kanban/kanban-types.ts +21 -0
- package/src/ui/data-display/kpi-card.tsx +68 -0
- package/src/ui/data-display/media-grid.tsx +110 -0
- package/src/ui/data-display/safari.tsx +175 -0
- package/src/ui/data-display/show-more-text.tsx +55 -0
- package/src/ui/data-display/tabs.tsx +68 -0
- package/src/ui/data-display/timeline.tsx +256 -0
- package/src/ui/feedback/alert.tsx +60 -0
- package/src/ui/feedback/context-menu.tsx +245 -0
- package/src/ui/feedback/drawer.tsx +132 -0
- package/src/ui/feedback/error-dialog.tsx +273 -0
- package/src/ui/feedback/index.tsx +183 -0
- package/src/ui/feedback/progress.tsx +32 -0
- package/src/ui/feedback/sheet.tsx +148 -0
- package/src/ui/feedback/sonner.tsx +36 -0
- package/src/ui/forms/command.tsx +157 -0
- package/src/ui/forms/date-picker.tsx +73 -0
- package/src/ui/forms/date-range-picker.tsx +76 -0
- package/src/ui/forms/date-time-picker.tsx +109 -0
- package/src/ui/forms/editor/editor-menu-bar.tsx +394 -0
- package/src/ui/forms/editor/index.tsx +130 -0
- package/src/ui/forms/editor/multi-select-example.tsx +1234 -0
- package/src/ui/forms/emoji-picker.tsx +109 -0
- package/src/ui/forms/file-dropzone.tsx +169 -0
- package/src/ui/forms/file-thumbnail.tsx +29 -0
- package/src/ui/forms/index.tsx +201 -0
- package/src/ui/forms/input-file.tsx +99 -0
- package/src/ui/forms/input-group.tsx +46 -0
- package/src/ui/forms/input-otp.tsx +81 -0
- package/src/ui/forms/input-phone.tsx +172 -0
- package/src/ui/forms/input-spin.tsx +116 -0
- package/src/ui/forms/input-tags.tsx +219 -0
- package/src/ui/forms/input-time.tsx +42 -0
- package/src/ui/forms/multi-select.tsx +629 -0
- package/src/ui/forms/multiple-date-picker.tsx +74 -0
- package/src/ui/forms/radio-group.tsx +42 -0
- package/src/ui/forms/rating.tsx +158 -0
- package/src/ui/forms/time-picker.tsx +57 -0
- package/src/ui/index.tsx +17 -0
- package/src/ui/layout/animated-list.tsx +77 -0
- package/src/ui/layout/animated-sidebar.tsx +294 -0
- package/src/ui/layout/command-menu.tsx +355 -0
- package/src/ui/layout/customizer.tsx +324 -0
- package/src/ui/layout/footer.tsx +43 -0
- package/src/ui/layout/full-screen-toggle.tsx +52 -0
- package/src/ui/layout/header-breadcrumb.tsx +77 -0
- package/src/ui/layout/horizontal-layout-header.tsx +83 -0
- package/src/ui/layout/horizontal-layout.tsx +50 -0
- package/src/ui/layout/index.tsx +25 -0
- package/src/ui/layout/language-dropdown.tsx +103 -0
- package/src/ui/layout/logo.tsx +63 -0
- package/src/ui/layout/main-layout.tsx +57 -0
- package/src/ui/layout/mode-dropdown.tsx +58 -0
- package/src/ui/layout/notification-dropdown.tsx +127 -0
- package/src/ui/layout/page-tabs.tsx +306 -0
- package/src/ui/layout/route-cache.tsx +214 -0
- package/src/ui/layout/sidebar-group-icon-menu.tsx +195 -0
- package/src/ui/layout/sidebar.tsx +279 -0
- package/src/ui/layout/tab-content-cache.tsx +201 -0
- package/src/ui/layout/tab-navigation-provider.tsx +536 -0
- package/src/ui/layout/toggle-mobile-sidebar.tsx +33 -0
- package/src/ui/layout/top-bar-header-menubar.tsx +412 -0
- package/src/ui/layout/user-dropdown.tsx +188 -0
- package/src/ui/layout/vertical-layout-header.tsx +65 -0
- package/src/ui/layout/vertical-layout.tsx +47 -0
- package/src/ui/management/audit-log-page.tsx +209 -0
- package/src/ui/management/cache-management.tsx +349 -0
- package/src/ui/management/index.ts +3 -0
- package/src/ui/management/job-management.tsx +308 -0
- package/src/ui/pages/not-found.tsx +30 -0
- package/src/ui/primitives/badge.tsx +66 -0
- package/src/ui/primitives/breadcrumb.tsx +103 -0
- package/src/ui/primitives/button.tsx +129 -0
- package/src/ui/primitives/calendar.tsx +74 -0
- package/src/ui/primitives/card.tsx +86 -0
- package/src/ui/primitives/checkbox.tsx +31 -0
- package/src/ui/primitives/client.ts +30 -0
- package/src/ui/primitives/combobox.tsx +290 -0
- package/src/ui/primitives/dialog.tsx +121 -0
- package/src/ui/primitives/dropdown-menu.tsx +239 -0
- package/src/ui/primitives/dynamic-icon.tsx +24 -0
- package/src/ui/primitives/index.tsx +134 -0
- package/src/ui/primitives/input-number.tsx +131 -0
- package/src/ui/primitives/input.tsx +22 -0
- package/src/ui/primitives/keyboard.tsx +23 -0
- package/src/ui/primitives/label.tsx +24 -0
- package/src/ui/primitives/menubar.tsx +262 -0
- package/src/ui/primitives/navigation-menu.tsx +157 -0
- package/src/ui/primitives/pagination.tsx +118 -0
- package/src/ui/primitives/popover.tsx +56 -0
- package/src/ui/primitives/prefetch-link.tsx +60 -0
- package/src/ui/primitives/resizable.tsx +59 -0
- package/src/ui/primitives/scroll-area.tsx +63 -0
- package/src/ui/primitives/select.tsx +172 -0
- package/src/ui/primitives/separator.tsx +51 -0
- package/src/ui/primitives/sidebar.tsx +844 -0
- package/src/ui/primitives/slider.tsx +27 -0
- package/src/ui/primitives/status-badge.tsx +47 -0
- package/src/ui/primitives/sticky-layout.tsx +50 -0
- package/src/ui/primitives/switch.tsx +29 -0
- package/src/ui/primitives/table.tsx +116 -0
- package/src/ui/primitives/tabs.tsx +55 -0
- package/src/ui/primitives/toggle-group.tsx +70 -0
- package/src/ui/primitives/toggle.tsx +47 -0
- package/src/ui/primitives/tooltip.tsx +59 -0
- package/src/user/components/dangerous-zone.tsx +34 -0
- package/src/user/components/delete-account-form.tsx +40 -0
- package/src/user/components/index.ts +4 -0
- package/src/user/components/profile-info-form.tsx +390 -0
- package/src/user/components/profile-info.tsx +32 -0
- package/src/user/components/unified-profile-dialog.tsx +1019 -0
- package/src/user/components/user-stats.tsx +27 -0
- package/src/user/components/user-toolbar.tsx +137 -0
- package/src/user/components/users-card-view.tsx +253 -0
- package/src/user/index.ts +11 -0
- package/src/user/pages/user-list-page.tsx +234 -0
- package/src/user/pages/users-client-page.tsx +385 -0
- package/src/user/profile-page.tsx +19 -0
- package/src/user/schemas.ts +68 -0
- package/src/user/types.ts +34 -0
- package/src/user/user-service.ts +538 -0
- package/src/utils/index.ts +906 -0
- package/src/workflow/activity-timeline.tsx +412 -0
- package/src/workflow/approval-workflow.tsx +31 -0
- package/src/workflow/index.ts +2 -0
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Fragment } from "react";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import { useParams, usePathname } from "next/navigation";
|
|
6
|
+
|
|
7
|
+
import type { DictionaryType } from "../../hooks";
|
|
8
|
+
import type {
|
|
9
|
+
LocaleType,
|
|
10
|
+
NavigationNestedItem,
|
|
11
|
+
NavigationRootItem,
|
|
12
|
+
NavigationType,
|
|
13
|
+
} from "../../types";
|
|
14
|
+
|
|
15
|
+
import { navigationsData as defaultNavigationsData } from "../../configs/data/navigations";
|
|
16
|
+
|
|
17
|
+
import { ensureLocalizedPathname } from "../../utils";
|
|
18
|
+
import { i18n } from "../../configs";
|
|
19
|
+
import {
|
|
20
|
+
cn,
|
|
21
|
+
getDictionaryValue,
|
|
22
|
+
isActivePathname,
|
|
23
|
+
titleCaseToCamelCase,
|
|
24
|
+
} from "../../utils";
|
|
25
|
+
|
|
26
|
+
import { Badge } from "../index";
|
|
27
|
+
import {
|
|
28
|
+
Menubar,
|
|
29
|
+
MenubarContent,
|
|
30
|
+
MenubarItem,
|
|
31
|
+
MenubarMenu,
|
|
32
|
+
MenubarSub,
|
|
33
|
+
MenubarSubContent,
|
|
34
|
+
MenubarSubTrigger,
|
|
35
|
+
MenubarTrigger,
|
|
36
|
+
} from "../primitives/client";
|
|
37
|
+
import { DynamicIcon } from "../primitives/client";
|
|
38
|
+
|
|
39
|
+
export function TopBarHeaderMenubar({
|
|
40
|
+
dictionary,
|
|
41
|
+
navigation,
|
|
42
|
+
}: {
|
|
43
|
+
dictionary: DictionaryType;
|
|
44
|
+
navigation?: NavigationType[];
|
|
45
|
+
}) {
|
|
46
|
+
const pathname = usePathname();
|
|
47
|
+
const params = useParams();
|
|
48
|
+
|
|
49
|
+
const locale = (params.lang as LocaleType) || i18n.defaultLocale;
|
|
50
|
+
|
|
51
|
+
// Use app-provided navigation, fall back to core default if not provided
|
|
52
|
+
const navItems = navigation ?? defaultNavigationsData;
|
|
53
|
+
|
|
54
|
+
// SAP Fiori Logic: Show first 5 items, group rest under "More"
|
|
55
|
+
const MAX_VISIBLE_ITEMS = 5;
|
|
56
|
+
const visibleItems = navItems.slice(0, MAX_VISIBLE_ITEMS);
|
|
57
|
+
const overflowItems = navItems.slice(MAX_VISIBLE_ITEMS);
|
|
58
|
+
|
|
59
|
+
const renderMenuItem = (item: NavigationRootItem | NavigationNestedItem) => {
|
|
60
|
+
const title = getDictionaryValue(
|
|
61
|
+
titleCaseToCamelCase(item.title),
|
|
62
|
+
dictionary.navigation,
|
|
63
|
+
item.title, // Fallback to original title if not found
|
|
64
|
+
);
|
|
65
|
+
const label =
|
|
66
|
+
item.label &&
|
|
67
|
+
getDictionaryValue(
|
|
68
|
+
titleCaseToCamelCase(item.label),
|
|
69
|
+
dictionary.label,
|
|
70
|
+
item.label, // Fallback to original label if not found
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
// If the item has nested items, render it with a MenubarSub.
|
|
74
|
+
if (item.items) {
|
|
75
|
+
return (
|
|
76
|
+
<MenubarSub>
|
|
77
|
+
<MenubarSubTrigger className="gap-2.5 py-2 cursor-pointer rounded-sm focus:bg-accent/50 focus:text-accent-foreground data-[state=open]:bg-accent/50 data-[state=open]:text-accent-foreground transition-colors">
|
|
78
|
+
{"iconName" in item && (
|
|
79
|
+
<DynamicIcon
|
|
80
|
+
name={item.iconName}
|
|
81
|
+
className="me-1 h-4 w-4 text-muted-foreground/70 group-hover:text-foreground transition-colors"
|
|
82
|
+
/>
|
|
83
|
+
)}
|
|
84
|
+
<span className="text-sm font-medium">{title}</span>
|
|
85
|
+
{"label" in item && (
|
|
86
|
+
<Badge
|
|
87
|
+
variant="secondary"
|
|
88
|
+
className="ml-auto text-[10px] h-5 px-1.5 font-normal bg-muted/40 text-muted-foreground border-0"
|
|
89
|
+
>
|
|
90
|
+
{label}
|
|
91
|
+
</Badge>
|
|
92
|
+
)}
|
|
93
|
+
</MenubarSubTrigger>
|
|
94
|
+
<MenubarSubContent className="max-h-[80vh] overflow-y-auto p-1 shadow-md border-border/40 bg-popover rounded-xl">
|
|
95
|
+
<div className="grid grid-cols-1 gap-0.5 min-w-[180px]">
|
|
96
|
+
{item.items.map((subItem: NavigationNestedItem) => {
|
|
97
|
+
return (
|
|
98
|
+
<MenubarItem key={subItem.title} className="p-0" asChild>
|
|
99
|
+
{renderMenuItem(subItem)}
|
|
100
|
+
</MenubarItem>
|
|
101
|
+
);
|
|
102
|
+
})}
|
|
103
|
+
</div>
|
|
104
|
+
</MenubarSubContent>
|
|
105
|
+
</MenubarSub>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Otherwise, render the item with a link.
|
|
110
|
+
if ("href" in item) {
|
|
111
|
+
const localizedPathname = ensureLocalizedPathname(item.href, locale);
|
|
112
|
+
const isActive = isActivePathname(localizedPathname, pathname);
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<MenubarItem asChild className="cursor-pointer outline-none">
|
|
116
|
+
<Link
|
|
117
|
+
href={localizedPathname}
|
|
118
|
+
className={cn(
|
|
119
|
+
"w-full gap-2.5 py-2 px-3 rounded-sm transition-colors group flex items-center",
|
|
120
|
+
isActive
|
|
121
|
+
? "bg-primary/5 text-primary font-semibold"
|
|
122
|
+
: "text-muted-foreground hover:bg-accent/40 hover:text-foreground",
|
|
123
|
+
)}
|
|
124
|
+
>
|
|
125
|
+
{"iconName" in item ? (
|
|
126
|
+
<DynamicIcon
|
|
127
|
+
name={item.iconName}
|
|
128
|
+
className={cn(
|
|
129
|
+
"h-4 w-4 transition-colors",
|
|
130
|
+
isActive
|
|
131
|
+
? "text-primary"
|
|
132
|
+
: "text-muted-foreground/70 group-hover:text-foreground",
|
|
133
|
+
)}
|
|
134
|
+
/>
|
|
135
|
+
) : (
|
|
136
|
+
<DynamicIcon
|
|
137
|
+
name="Circle"
|
|
138
|
+
className={cn(
|
|
139
|
+
"h-1.5 w-1.5",
|
|
140
|
+
isActive
|
|
141
|
+
? "fill-primary text-primary"
|
|
142
|
+
: "text-muted-foreground/40 group-hover:text-muted-foreground",
|
|
143
|
+
)}
|
|
144
|
+
/>
|
|
145
|
+
)}
|
|
146
|
+
<span className="text-sm">{title}</span>
|
|
147
|
+
{"label" in item && (
|
|
148
|
+
<Badge
|
|
149
|
+
variant="secondary"
|
|
150
|
+
className="ml-auto text-[10px] h-5 px-1.5 font-normal bg-muted/40 text-muted-foreground border-0"
|
|
151
|
+
>
|
|
152
|
+
{label}
|
|
153
|
+
</Badge>
|
|
154
|
+
)}
|
|
155
|
+
</Link>
|
|
156
|
+
</MenubarItem>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const renderRootItem = (nav: NavigationType) => {
|
|
162
|
+
const title = getDictionaryValue(
|
|
163
|
+
titleCaseToCamelCase(nav.title),
|
|
164
|
+
dictionary.navigation,
|
|
165
|
+
nav.title,
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
// Check if any child is active to highlight the parent trigger
|
|
169
|
+
// nav is NavigationType, so it always has items.
|
|
170
|
+
const isChildActive = nav.items.some((item) => {
|
|
171
|
+
if ("href" in item && item.href) {
|
|
172
|
+
return isActivePathname(
|
|
173
|
+
ensureLocalizedPathname(item.href, locale),
|
|
174
|
+
pathname,
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
if ("items" in item && item.items) {
|
|
178
|
+
// Check if item has nested items
|
|
179
|
+
return item.items.some(
|
|
180
|
+
(subItem) =>
|
|
181
|
+
"href" in subItem &&
|
|
182
|
+
subItem.href &&
|
|
183
|
+
isActivePathname(
|
|
184
|
+
ensureLocalizedPathname(subItem.href, locale),
|
|
185
|
+
pathname,
|
|
186
|
+
),
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
return false;
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// Special handling for "Apps" Mega Menu
|
|
193
|
+
if (nav.title === "Apps") {
|
|
194
|
+
return (
|
|
195
|
+
<MenubarMenu key={nav.title}>
|
|
196
|
+
<MenubarTrigger
|
|
197
|
+
className={cn(
|
|
198
|
+
"cursor-pointer px-3 py-2 rounded-md font-medium text-[14px] transition-all duration-200 flex items-center gap-2 select-none whitespace-nowrap",
|
|
199
|
+
"data-[state=open]:bg-accent/20",
|
|
200
|
+
isChildActive
|
|
201
|
+
? "border-[#0064d9] text-foreground font-bold"
|
|
202
|
+
: "border-transparent text-muted-foreground hover:text-foreground hover:bg-accent/10",
|
|
203
|
+
)}
|
|
204
|
+
>
|
|
205
|
+
{nav.iconName && (
|
|
206
|
+
<DynamicIcon
|
|
207
|
+
name={nav.iconName}
|
|
208
|
+
className={cn(
|
|
209
|
+
"h-4 w-4",
|
|
210
|
+
isChildActive
|
|
211
|
+
? "text-[#0064d9]"
|
|
212
|
+
: "text-muted-foreground group-hover:text-foreground",
|
|
213
|
+
)}
|
|
214
|
+
/>
|
|
215
|
+
)}
|
|
216
|
+
{title}
|
|
217
|
+
<DynamicIcon
|
|
218
|
+
name="ChevronDown"
|
|
219
|
+
className={cn(
|
|
220
|
+
"h-3 w-3 transition-transform duration-200 opacity-50 ml-0.5",
|
|
221
|
+
"group-data-[state=open]:rotate-180",
|
|
222
|
+
)}
|
|
223
|
+
/>
|
|
224
|
+
</MenubarTrigger>
|
|
225
|
+
<MenubarContent
|
|
226
|
+
className="w-[520px] p-4 shadow-xl border-border/40 bg-popover rounded-xl animate-in fade-in-0 zoom-in-95 slide-in-from-top-1"
|
|
227
|
+
align="start"
|
|
228
|
+
sideOffset={0}
|
|
229
|
+
>
|
|
230
|
+
<div className="grid grid-cols-3 gap-4">
|
|
231
|
+
{nav.items.map((item) => {
|
|
232
|
+
const itemTitle = getDictionaryValue(
|
|
233
|
+
titleCaseToCamelCase(item.title),
|
|
234
|
+
dictionary.navigation,
|
|
235
|
+
item.title,
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
if ("href" in item && item.href) {
|
|
239
|
+
const localizedPathname = ensureLocalizedPathname(
|
|
240
|
+
item.href,
|
|
241
|
+
locale,
|
|
242
|
+
);
|
|
243
|
+
const isActive = isActivePathname(
|
|
244
|
+
localizedPathname,
|
|
245
|
+
pathname,
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
return (
|
|
249
|
+
<MenubarItem
|
|
250
|
+
asChild
|
|
251
|
+
key={item.title}
|
|
252
|
+
className="p-0 focus:bg-transparent"
|
|
253
|
+
>
|
|
254
|
+
<Link
|
|
255
|
+
href={localizedPathname}
|
|
256
|
+
className={cn(
|
|
257
|
+
"flex flex-col items-center justify-center gap-2 p-4 rounded-lg border border-transparent transition-all hover:bg-accent/50 hover:border-border/50 group",
|
|
258
|
+
isActive
|
|
259
|
+
? "bg-primary/5 border-primary/20"
|
|
260
|
+
: "bg-muted/20",
|
|
261
|
+
)}
|
|
262
|
+
>
|
|
263
|
+
<div
|
|
264
|
+
className={cn(
|
|
265
|
+
"p-2.5 rounded-full transition-colors",
|
|
266
|
+
isActive
|
|
267
|
+
? "bg-primary/10 text-primary"
|
|
268
|
+
: "bg-background text-muted-foreground group-hover:text-foreground group-hover:bg-background shadow-sm",
|
|
269
|
+
)}
|
|
270
|
+
>
|
|
271
|
+
{"iconName" in item ? (
|
|
272
|
+
<DynamicIcon
|
|
273
|
+
name={item.iconName}
|
|
274
|
+
className="h-6 w-6"
|
|
275
|
+
/>
|
|
276
|
+
) : (
|
|
277
|
+
<DynamicIcon name="AppWindow" className="h-6 w-6" />
|
|
278
|
+
)}
|
|
279
|
+
</div>
|
|
280
|
+
<span className="font-medium text-sm text-center">
|
|
281
|
+
{itemTitle}
|
|
282
|
+
</span>
|
|
283
|
+
</Link>
|
|
284
|
+
</MenubarItem>
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
return null;
|
|
288
|
+
})}
|
|
289
|
+
</div>
|
|
290
|
+
</MenubarContent>
|
|
291
|
+
</MenubarMenu>
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return (
|
|
296
|
+
<MenubarMenu key={nav.title}>
|
|
297
|
+
<MenubarTrigger
|
|
298
|
+
className={cn(
|
|
299
|
+
"cursor-pointer px-3 py-2 rounded-md font-medium text-[14px] transition-all duration-200 flex items-center gap-2 select-none whitespace-nowrap",
|
|
300
|
+
"data-[state=open]:bg-accent/20",
|
|
301
|
+
isChildActive
|
|
302
|
+
? "text-foreground font-bold"
|
|
303
|
+
: "text-muted-foreground hover:text-foreground hover:bg-accent/10",
|
|
304
|
+
)}
|
|
305
|
+
>
|
|
306
|
+
{nav.iconName && (
|
|
307
|
+
<DynamicIcon
|
|
308
|
+
name={nav.iconName}
|
|
309
|
+
className={cn(
|
|
310
|
+
"h-4 w-4",
|
|
311
|
+
isChildActive
|
|
312
|
+
? "text-[#0064d9]"
|
|
313
|
+
: "text-muted-foreground group-hover:text-foreground",
|
|
314
|
+
)}
|
|
315
|
+
/>
|
|
316
|
+
)}
|
|
317
|
+
{title}
|
|
318
|
+
<DynamicIcon
|
|
319
|
+
name="ChevronDown"
|
|
320
|
+
className={cn(
|
|
321
|
+
"h-3 w-3 transition-transform duration-200 opacity-50 ml-0.5",
|
|
322
|
+
"group-data-[state=open]:rotate-180",
|
|
323
|
+
)}
|
|
324
|
+
/>
|
|
325
|
+
</MenubarTrigger>
|
|
326
|
+
<MenubarContent
|
|
327
|
+
className="min-w-[220px] p-1 shadow-md border-border/40 bg-popover rounded-xl animate-in fade-in-0 zoom-in-95 slide-in-from-top-1"
|
|
328
|
+
align="start"
|
|
329
|
+
sideOffset={0}
|
|
330
|
+
>
|
|
331
|
+
<div
|
|
332
|
+
className={cn(
|
|
333
|
+
"grid gap-0.5",
|
|
334
|
+
nav.items.length > 8
|
|
335
|
+
? "grid-cols-2 min-w-[400px] gap-x-2"
|
|
336
|
+
: "grid-cols-1",
|
|
337
|
+
)}
|
|
338
|
+
>
|
|
339
|
+
{nav.items.map((item) => (
|
|
340
|
+
<Fragment key={item.title}>{renderMenuItem(item)}</Fragment>
|
|
341
|
+
))}
|
|
342
|
+
</div>
|
|
343
|
+
</MenubarContent>
|
|
344
|
+
</MenubarMenu>
|
|
345
|
+
);
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
return (
|
|
349
|
+
<div className="w-full overflow-hidden">
|
|
350
|
+
<Menubar className="border-none bg-transparent shadow-none h-auto min-h-9 p-0 gap-1 rounded-none">
|
|
351
|
+
{visibleItems.map((nav) => renderRootItem(nav))}
|
|
352
|
+
|
|
353
|
+
{overflowItems.length > 0 && (
|
|
354
|
+
<MenubarMenu>
|
|
355
|
+
<MenubarTrigger
|
|
356
|
+
className={cn(
|
|
357
|
+
"cursor-pointer px-3 py-2 rounded-md font-medium text-[14px] transition-all duration-200 flex items-center gap-1.5 select-none whitespace-nowrap",
|
|
358
|
+
"data-[state=open]:bg-accent/20 text-muted-foreground hover:text-foreground hover:bg-accent/10",
|
|
359
|
+
)}
|
|
360
|
+
>
|
|
361
|
+
<DynamicIcon name="Ellipsis" className="h-5 w-5" />
|
|
362
|
+
</MenubarTrigger>
|
|
363
|
+
<MenubarContent
|
|
364
|
+
className="min-w-[200px] p-1 shadow-md border-border/40 bg-popover rounded-xl"
|
|
365
|
+
align="end"
|
|
366
|
+
sideOffset={0}
|
|
367
|
+
>
|
|
368
|
+
<div className="grid grid-cols-1 gap-1">
|
|
369
|
+
{overflowItems.map((nav) => {
|
|
370
|
+
const title = getDictionaryValue(
|
|
371
|
+
titleCaseToCamelCase(nav.title),
|
|
372
|
+
dictionary.navigation,
|
|
373
|
+
nav.title,
|
|
374
|
+
);
|
|
375
|
+
return (
|
|
376
|
+
<MenubarSub key={nav.title}>
|
|
377
|
+
<MenubarSubTrigger className="w-full cursor-pointer rounded-lg py-2">
|
|
378
|
+
{nav.iconName && (
|
|
379
|
+
<DynamicIcon
|
|
380
|
+
name={nav.iconName}
|
|
381
|
+
className="me-2 h-4 w-4 text-muted-foreground/70"
|
|
382
|
+
/>
|
|
383
|
+
)}
|
|
384
|
+
{title}
|
|
385
|
+
</MenubarSubTrigger>
|
|
386
|
+
<MenubarSubContent className="min-w-[200px] p-1 shadow-md border-border/40 bg-popover rounded-xl">
|
|
387
|
+
<div
|
|
388
|
+
className={cn(
|
|
389
|
+
"grid gap-0.5",
|
|
390
|
+
nav.items.length > 8
|
|
391
|
+
? "grid-cols-2 min-w-[400px] gap-x-2"
|
|
392
|
+
: "grid-cols-1",
|
|
393
|
+
)}
|
|
394
|
+
>
|
|
395
|
+
{nav.items.map((item) => (
|
|
396
|
+
<Fragment key={item.title}>
|
|
397
|
+
{renderMenuItem(item)}
|
|
398
|
+
</Fragment>
|
|
399
|
+
))}
|
|
400
|
+
</div>
|
|
401
|
+
</MenubarSubContent>
|
|
402
|
+
</MenubarSub>
|
|
403
|
+
);
|
|
404
|
+
})}
|
|
405
|
+
</div>
|
|
406
|
+
</MenubarContent>
|
|
407
|
+
</MenubarMenu>
|
|
408
|
+
)}
|
|
409
|
+
</Menubar>
|
|
410
|
+
</div>
|
|
411
|
+
);
|
|
412
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import Link from "next/link";
|
|
4
|
+
import { signOut, useSession } from "next-auth/react";
|
|
5
|
+
import { LogOut, User, UserCog } from "lucide-react";
|
|
6
|
+
|
|
7
|
+
import type { DictionaryType } from "../../hooks";
|
|
8
|
+
import type { LocaleType } from "../../types";
|
|
9
|
+
|
|
10
|
+
import { ensureLocalizedPathname } from "../../utils";
|
|
11
|
+
import { getInitials } from "../../utils";
|
|
12
|
+
|
|
13
|
+
import { Avatar, AvatarFallback, AvatarImage } from "../data-display/avatar";
|
|
14
|
+
import { Button } from "../primitives/button";
|
|
15
|
+
import { useTabContentCache } from "./tab-content-cache";
|
|
16
|
+
import { useTabNavigation } from "./tab-navigation-provider";
|
|
17
|
+
|
|
18
|
+
// Safe wrapper to prevent crashing when useSession is called outside of SessionProvider
|
|
19
|
+
// This often happens during Error Boundary or Hydration failures.
|
|
20
|
+
function useSafeSession() {
|
|
21
|
+
try {
|
|
22
|
+
return useSession();
|
|
23
|
+
} catch (error) {
|
|
24
|
+
return { data: null, status: "unauthenticated" as const };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
import {
|
|
29
|
+
DropdownMenu,
|
|
30
|
+
DropdownMenuContent,
|
|
31
|
+
DropdownMenuGroup,
|
|
32
|
+
DropdownMenuItem,
|
|
33
|
+
DropdownMenuLabel,
|
|
34
|
+
DropdownMenuSeparator,
|
|
35
|
+
DropdownMenuTrigger,
|
|
36
|
+
} from "../primitives/dropdown-menu";
|
|
37
|
+
import {
|
|
38
|
+
Tooltip,
|
|
39
|
+
TooltipContent,
|
|
40
|
+
TooltipProvider,
|
|
41
|
+
TooltipTrigger,
|
|
42
|
+
} from "../primitives/client";
|
|
43
|
+
|
|
44
|
+
interface ExtendedUser {
|
|
45
|
+
id: string;
|
|
46
|
+
name?: string | null;
|
|
47
|
+
email?: string | null;
|
|
48
|
+
image?: string | null;
|
|
49
|
+
avatar?: string | null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface UserDropdownProps {
|
|
53
|
+
dictionary: DictionaryType;
|
|
54
|
+
locale: LocaleType;
|
|
55
|
+
user?: ExtendedUser | null | undefined;
|
|
56
|
+
onSignOut?: () => void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function UserDropdown({
|
|
60
|
+
dictionary,
|
|
61
|
+
locale,
|
|
62
|
+
user: userProp,
|
|
63
|
+
onSignOut,
|
|
64
|
+
}: UserDropdownProps) {
|
|
65
|
+
const { data: session } = useSafeSession();
|
|
66
|
+
const { clearAllCache } = useTabContentCache();
|
|
67
|
+
const { clearTabs } = useTabNavigation();
|
|
68
|
+
|
|
69
|
+
// Use provided user prop or fall back to session user
|
|
70
|
+
const user = userProp ?? (session?.user as ExtendedUser | undefined);
|
|
71
|
+
|
|
72
|
+
const handleSignOut = async () => {
|
|
73
|
+
// Clear client-side caches that can leak UI/data between users
|
|
74
|
+
try {
|
|
75
|
+
clearAllCache();
|
|
76
|
+
clearTabs();
|
|
77
|
+
|
|
78
|
+
// Remove persisted tab state explicitly to avoid stale sessions after re-login
|
|
79
|
+
if (typeof window !== "undefined") {
|
|
80
|
+
sessionStorage.removeItem("tab-content-cache");
|
|
81
|
+
sessionStorage.removeItem("tab-navigation-state");
|
|
82
|
+
}
|
|
83
|
+
} catch {
|
|
84
|
+
// Best-effort cleanup only
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (onSignOut) {
|
|
88
|
+
await onSignOut();
|
|
89
|
+
} else {
|
|
90
|
+
await signOut({ callbackUrl: "/sign-in" });
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<DropdownMenu>
|
|
96
|
+
<TooltipProvider>
|
|
97
|
+
<Tooltip>
|
|
98
|
+
<TooltipTrigger asChild>
|
|
99
|
+
<DropdownMenuTrigger asChild>
|
|
100
|
+
<Button
|
|
101
|
+
variant="outline"
|
|
102
|
+
size="icon"
|
|
103
|
+
className="rounded-full bg-primary border-primary hover:bg-primary/90 focus-visible:ring-0 focus-visible:ring-offset-0"
|
|
104
|
+
aria-label="User"
|
|
105
|
+
>
|
|
106
|
+
<Avatar className="size-6">
|
|
107
|
+
<AvatarImage
|
|
108
|
+
src={user?.avatar || undefined}
|
|
109
|
+
alt={user?.name || ""}
|
|
110
|
+
className="object-cover"
|
|
111
|
+
/>
|
|
112
|
+
<AvatarFallback className="bg-primary text-white text-[10px] font-bold uppercase">
|
|
113
|
+
{user?.name && getInitials(user.name)}
|
|
114
|
+
</AvatarFallback>
|
|
115
|
+
</Avatar>
|
|
116
|
+
</Button>
|
|
117
|
+
</DropdownMenuTrigger>
|
|
118
|
+
</TooltipTrigger>
|
|
119
|
+
<TooltipContent>
|
|
120
|
+
<p>Profile</p>
|
|
121
|
+
</TooltipContent>
|
|
122
|
+
</Tooltip>
|
|
123
|
+
</TooltipProvider>
|
|
124
|
+
|
|
125
|
+
<DropdownMenuContent
|
|
126
|
+
className="w-56 p-1 bg-background/80 backdrop-blur-xl border border-border/40 shadow-xl rounded-xl animate-in fade-in zoom-in-95 duration-200"
|
|
127
|
+
align="end"
|
|
128
|
+
forceMount
|
|
129
|
+
>
|
|
130
|
+
<DropdownMenuLabel className="flex gap-2 p-2">
|
|
131
|
+
<Avatar className="size-8 border border-border/20 shadow-sm">
|
|
132
|
+
<AvatarImage src={user?.avatar || undefined} alt="Avatar" />
|
|
133
|
+
<AvatarFallback className="bg-transparent">
|
|
134
|
+
{user?.name && getInitials(user.name)}
|
|
135
|
+
</AvatarFallback>
|
|
136
|
+
</Avatar>
|
|
137
|
+
<div className="flex flex-col min-w-0 space-y-0.5 overflow-hidden">
|
|
138
|
+
<p className="text-sm font-semibold text-foreground truncate leading-none">
|
|
139
|
+
{user?.name}
|
|
140
|
+
</p>
|
|
141
|
+
<p className="text-[11px] text-muted-foreground truncate font-medium opacity-80 leading-none">
|
|
142
|
+
{user?.email}
|
|
143
|
+
</p>
|
|
144
|
+
</div>
|
|
145
|
+
</DropdownMenuLabel>
|
|
146
|
+
|
|
147
|
+
<DropdownMenuSeparator className="my-1 bg-border/40 -mx-1" />
|
|
148
|
+
|
|
149
|
+
<DropdownMenuGroup>
|
|
150
|
+
<DropdownMenuItem
|
|
151
|
+
asChild
|
|
152
|
+
className="h-8 px-2 rounded-md cursor-pointer focus:bg-primary/10 focus:text-primary transition-colors duration-200 group text-sm"
|
|
153
|
+
>
|
|
154
|
+
<Link
|
|
155
|
+
href={ensureLocalizedPathname("/user/profile", locale)}
|
|
156
|
+
className="flex items-center w-full"
|
|
157
|
+
>
|
|
158
|
+
<User className="me-2 size-4 text-muted-foreground group-hover:text-primary group-focus:text-primary transition-colors" />
|
|
159
|
+
<span>{dictionary.navigation.userNav.profile}</span>
|
|
160
|
+
</Link>
|
|
161
|
+
</DropdownMenuItem>
|
|
162
|
+
{/* <DropdownMenuItem
|
|
163
|
+
asChild
|
|
164
|
+
className="h-8 px-2 rounded-md cursor-pointer focus:bg-primary/10 focus:text-primary transition-colors duration-200 group text-sm"
|
|
165
|
+
>
|
|
166
|
+
<Link
|
|
167
|
+
href={ensureLocalizedPathname("/user", locale)}
|
|
168
|
+
className="flex items-center w-full"
|
|
169
|
+
>
|
|
170
|
+
<UserCog className="me-2 size-4 text-muted-foreground group-hover:text-primary group-focus:text-primary transition-colors" />
|
|
171
|
+
<span>{dictionary.navigation.userNav.settings}</span>
|
|
172
|
+
</Link>
|
|
173
|
+
</DropdownMenuItem> */}
|
|
174
|
+
</DropdownMenuGroup>
|
|
175
|
+
|
|
176
|
+
<DropdownMenuSeparator className="my-1 bg-border/40 -mx-1" />
|
|
177
|
+
|
|
178
|
+
<DropdownMenuItem
|
|
179
|
+
onClick={handleSignOut}
|
|
180
|
+
className="h-8 px-2 rounded-md cursor-pointer text-red-600 focus:bg-red-50 focus:text-red-700 dark:text-red-400 dark:focus:bg-red-950/30 dark:focus:text-red-300 transition-colors duration-200 group text-sm"
|
|
181
|
+
>
|
|
182
|
+
<LogOut className="me-2 size-4 group-hover:text-red-700 dark:group-hover:text-red-300 transition-colors" />
|
|
183
|
+
<span>{dictionary.navigation.userNav.signOut}</span>
|
|
184
|
+
</DropdownMenuItem>
|
|
185
|
+
</DropdownMenuContent>
|
|
186
|
+
</DropdownMenu>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useParams } from "next/navigation";
|
|
4
|
+
import { Settings } from "lucide-react";
|
|
5
|
+
|
|
6
|
+
import type { DictionaryType } from "../../hooks";
|
|
7
|
+
import type { LocaleType } from "../../types";
|
|
8
|
+
|
|
9
|
+
import { Button } from "../index";
|
|
10
|
+
import { SidebarTrigger } from "../primitives/sidebar"; // Primitive
|
|
11
|
+
import { Customizer } from "./customizer";
|
|
12
|
+
import { FullScreenToggle } from "./full-screen-toggle";
|
|
13
|
+
import { NotificationDropdown } from "./notification-dropdown";
|
|
14
|
+
import { PageTabs } from "./page-tabs";
|
|
15
|
+
import { UserDropdown } from "./user-dropdown";
|
|
16
|
+
import { ToggleMobileSidebar } from "./toggle-mobile-sidebar";
|
|
17
|
+
|
|
18
|
+
export function VerticalLayoutHeader({
|
|
19
|
+
dictionary,
|
|
20
|
+
}: {
|
|
21
|
+
dictionary: DictionaryType;
|
|
22
|
+
}) {
|
|
23
|
+
const params = useParams();
|
|
24
|
+
const locale = params.lang as LocaleType;
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<header className="sticky top-0 z-50 w-full bg-background/95 border-b border-sidebar-border backdrop-blur supports-[backdrop-filter]:bg-background/80">
|
|
28
|
+
<div className="container flex h-11 justify-between items-center gap-0">
|
|
29
|
+
{/* Left: sidebar toggles */}
|
|
30
|
+
<div className="flex items-center gap-2 flex-shrink-0">
|
|
31
|
+
<ToggleMobileSidebar />
|
|
32
|
+
<SidebarTrigger className="hidden lg:inline-flex" />
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
{/* Center: page tabs use available space */}
|
|
36
|
+
<div className="flex-1 min-w-0">
|
|
37
|
+
<PageTabs
|
|
38
|
+
dictionary={dictionary}
|
|
39
|
+
className="h-8 flex items-center"
|
|
40
|
+
variant="header"
|
|
41
|
+
/>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
{/* Right: user actions */}
|
|
45
|
+
<div className="flex items-center gap-2 flex-shrink-0">
|
|
46
|
+
<div className="hidden sm:flex items-center gap-2">
|
|
47
|
+
<NotificationDropdown dictionary={dictionary} />
|
|
48
|
+
<FullScreenToggle />
|
|
49
|
+
</div>
|
|
50
|
+
<Customizer
|
|
51
|
+
trigger={
|
|
52
|
+
<Button variant="ghost" size="icon" aria-label="Customize layout">
|
|
53
|
+
<Settings className="h-4 w-4" />
|
|
54
|
+
</Button>
|
|
55
|
+
}
|
|
56
|
+
/>
|
|
57
|
+
{/* <ModeDropdown dictionary={dictionary} /> */}
|
|
58
|
+
{/* <LanguageDropdown dictionary={dictionary} /> */}
|
|
59
|
+
{/* User dropdown */}
|
|
60
|
+
<UserDropdown dictionary={dictionary} locale={locale} />
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
</header>
|
|
64
|
+
);
|
|
65
|
+
}
|