@omersx/bemms 0.0.0-stage → 0.1.0
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/LICENSE +22 -0
- package/README.md +203 -2
- package/drizzle.config.ts +11 -0
- package/next.config.ts +51 -0
- package/package.json +99 -3
- package/postcss.config.mjs +7 -0
- package/public/hospital_demo_devices.csv +32 -0
- package/public/icons/icon-192.png +0 -0
- package/public/icons/icon-512.png +0 -0
- package/public/icons/icon-maskable-512.png +0 -0
- package/public/manifest.webmanifest +31 -0
- package/public/sw.js +177 -0
- package/src/app/(auth)/layout.tsx +20 -0
- package/src/app/(auth)/login/page.tsx +135 -0
- package/src/app/(dashboard)/admin/audit-logs/page.tsx +178 -0
- package/src/app/(dashboard)/admin/data/page.tsx +37 -0
- package/src/app/(dashboard)/admin/departments/[deptId]/edit/page.tsx +206 -0
- package/src/app/(dashboard)/admin/departments/[deptId]/page.tsx +71 -0
- package/src/app/(dashboard)/admin/departments/new/page.tsx +6 -0
- package/src/app/(dashboard)/admin/departments/page.tsx +6 -0
- package/src/app/(dashboard)/admin/general/page.tsx +374 -0
- package/src/app/(dashboard)/admin/hospitals/[hospitalId]/edit/page.tsx +304 -0
- package/src/app/(dashboard)/admin/hospitals/[hospitalId]/page.tsx +94 -0
- package/src/app/(dashboard)/admin/hospitals/new/page.tsx +302 -0
- package/src/app/(dashboard)/admin/hospitals/page.tsx +6 -0
- package/src/app/(dashboard)/admin/layout.tsx +49 -0
- package/src/app/(dashboard)/admin/organizations/[orgId]/edit/page.tsx +172 -0
- package/src/app/(dashboard)/admin/organizations/[orgId]/page.tsx +82 -0
- package/src/app/(dashboard)/admin/organizations/new/page.tsx +150 -0
- package/src/app/(dashboard)/admin/organizations/page.tsx +6 -0
- package/src/app/(dashboard)/admin/page.tsx +258 -0
- package/src/app/(dashboard)/admin/roles/page.tsx +153 -0
- package/src/app/(dashboard)/admin/settings/page.tsx +69 -0
- package/src/app/(dashboard)/admin/users/[userId]/edit/page.tsx +153 -0
- package/src/app/(dashboard)/admin/users/[userId]/page.tsx +317 -0
- package/src/app/(dashboard)/admin/users/invite/page.tsx +3 -0
- package/src/app/(dashboard)/admin/users/new/page.tsx +5 -0
- package/src/app/(dashboard)/admin/users/page.tsx +23 -0
- package/src/app/(dashboard)/dashboard/page.tsx +462 -0
- package/src/app/(dashboard)/departments/[deptId]/page.tsx +39 -0
- package/src/app/(dashboard)/departments/new/page.tsx +330 -0
- package/src/app/(dashboard)/departments/page.tsx +52 -0
- package/src/app/(dashboard)/devices/[id]/edit/page.tsx +131 -0
- package/src/app/(dashboard)/devices/[id]/page.tsx +408 -0
- package/src/app/(dashboard)/devices/[id]/qr/page.tsx +54 -0
- package/src/app/(dashboard)/devices/new/page.tsx +382 -0
- package/src/app/(dashboard)/devices/page.tsx +80 -0
- package/src/app/(dashboard)/engineering-team/page.tsx +41 -0
- package/src/app/(dashboard)/layout.tsx +43 -0
- package/src/app/(dashboard)/maintenance/checklists/page.tsx +57 -0
- package/src/app/(dashboard)/maintenance/page.tsx +231 -0
- package/src/app/(dashboard)/maintenance/plans/page.tsx +142 -0
- package/src/app/(dashboard)/maintenance/tasks/[id]/page.tsx +997 -0
- package/src/app/(dashboard)/maintenance/tasks/page.tsx +119 -0
- package/src/app/(dashboard)/more/page.tsx +310 -0
- package/src/app/(dashboard)/my-department/page.tsx +151 -0
- package/src/app/(dashboard)/notifications/notification-list.tsx +103 -0
- package/src/app/(dashboard)/notifications/page.tsx +59 -0
- package/src/app/(dashboard)/profile/page.tsx +27 -0
- package/src/app/(dashboard)/reports/costs/page.tsx +127 -0
- package/src/app/(dashboard)/reports/history/page.tsx +105 -0
- package/src/app/(dashboard)/reports/inventory/page.tsx +116 -0
- package/src/app/(dashboard)/reports/maintenance/page.tsx +136 -0
- package/src/app/(dashboard)/reports/page.tsx +120 -0
- package/src/app/(dashboard)/reports/tickets/page.tsx +139 -0
- package/src/app/(dashboard)/reports/workload/page.tsx +135 -0
- package/src/app/(dashboard)/rounds/[id]/page.tsx +197 -0
- package/src/app/(dashboard)/rounds/history/page.tsx +82 -0
- package/src/app/(dashboard)/rounds/page.tsx +107 -0
- package/src/app/(dashboard)/scan/[code]/page.tsx +154 -0
- package/src/app/(dashboard)/scan/page.tsx +73 -0
- package/src/app/(dashboard)/team/page.tsx +42 -0
- package/src/app/(dashboard)/tickets/[id]/page.tsx +465 -0
- package/src/app/(dashboard)/tickets/create/page.tsx +722 -0
- package/src/app/(dashboard)/tickets/page.tsx +55 -0
- package/src/app/(dashboard)/tickets/triage/page.tsx +161 -0
- package/src/app/api/admin/data/export/route.ts +316 -0
- package/src/app/api/auth/[...nextauth]/route.ts +3 -0
- package/src/app/api/health/route.ts +46 -0
- package/src/app/api/notifications/sse/route.ts +91 -0
- package/src/app/api/notifications/subscribe/route.ts +54 -0
- package/src/app/api/notifications/vapid-key/route.ts +7 -0
- package/src/app/api/reports/export/route.ts +102 -0
- package/src/app/api/tickets/[id]/attachments/route.ts +129 -0
- package/src/app/api/tickets/[id]/live-sync/route.ts +52 -0
- package/src/app/error.tsx +54 -0
- package/src/app/globals.css +89 -0
- package/src/app/layout.tsx +59 -0
- package/src/app/not-found.tsx +32 -0
- package/src/app/page.tsx +5 -0
- package/src/components/admin/add-department-user-dialog.tsx +759 -0
- package/src/components/admin/add-engineer-dialog.tsx +773 -0
- package/src/components/admin/add-user-type-dialog.tsx +89 -0
- package/src/components/admin/audit-log-export.tsx +113 -0
- package/src/components/admin/audit-log-filters.tsx +255 -0
- package/src/components/admin/audit-log-table.tsx +383 -0
- package/src/components/admin/data-management/danger-zone.tsx +301 -0
- package/src/components/admin/data-management/data-management-tabs.tsx +61 -0
- package/src/components/admin/data-management/export-center.tsx +301 -0
- package/src/components/admin/data-management/import-wizard.tsx +558 -0
- package/src/components/admin/settings-forms/features-form.tsx +115 -0
- package/src/components/admin/settings-forms/health-panel.tsx +182 -0
- package/src/components/admin/settings-forms/localization-form.tsx +203 -0
- package/src/components/admin/settings-forms/retention-form.tsx +164 -0
- package/src/components/admin/settings-forms/security-form.tsx +186 -0
- package/src/components/admin/system-settings-tabs.tsx +88 -0
- package/src/components/admin/user-role-dialog.tsx +293 -0
- package/src/components/admin/user-status-dialog.tsx +166 -0
- package/src/components/admin/users-page-client.tsx +514 -0
- package/src/components/dashboard/action-buttons.tsx +93 -0
- package/src/components/dashboard/admin-alerts.tsx +86 -0
- package/src/components/dashboard/availability-alerts.tsx +65 -0
- package/src/components/dashboard/maintenance-due-list.tsx +87 -0
- package/src/components/dashboard/round-widget.tsx +110 -0
- package/src/components/dashboard/stat-card.tsx +38 -0
- package/src/components/dashboard/ticket-list-compact.tsx +86 -0
- package/src/components/departments/department-cards-view.tsx +244 -0
- package/src/components/departments/department-detail-view.tsx +467 -0
- package/src/components/departments/department-visuals.tsx +190 -0
- package/src/components/departments/my-department-view.tsx +333 -0
- package/src/components/devices/change-status-dialog.tsx +146 -0
- package/src/components/devices/device-action-buttons.tsx +125 -0
- package/src/components/devices/device-availability-banner.tsx +59 -0
- package/src/components/devices/device-badges.tsx +55 -0
- package/src/components/devices/device-documents-tab.tsx +93 -0
- package/src/components/devices/device-maintenance-tab.tsx +113 -0
- package/src/components/devices/device-mini-qr.tsx +109 -0
- package/src/components/devices/device-qr-card.tsx +187 -0
- package/src/components/devices/device-signatures-tab.tsx +607 -0
- package/src/components/devices/device-tickets-tab.tsx +139 -0
- package/src/components/devices/device-timelines.tsx +124 -0
- package/src/components/devices/qr-camera-scanner.tsx +167 -0
- package/src/components/devices/qr-code-display.tsx +139 -0
- package/src/components/devices/quick-add-category-dialog.tsx +135 -0
- package/src/components/devices/quick-add-manufacturer-dialog.tsx +212 -0
- package/src/components/devices/transfer-device-dialog.tsx +190 -0
- package/src/components/layout/header.tsx +80 -0
- package/src/components/layout/mobile-nav.tsx +91 -0
- package/src/components/layout/more-item-badge.tsx +15 -0
- package/src/components/layout/nav-badge.tsx +72 -0
- package/src/components/layout/sidebar.tsx +297 -0
- package/src/components/maintenance/maintenance-badges.tsx +579 -0
- package/src/components/maintenance/maintenance-nav.tsx +107 -0
- package/src/components/maintenance/parts-costs-manager.tsx +909 -0
- package/src/components/maintenance/signature-card.tsx +413 -0
- package/src/components/maintenance/task-action-bar.tsx +955 -0
- package/src/components/notifications/notification-bell.tsx +367 -0
- package/src/components/notifications/notification-item.tsx +93 -0
- package/src/components/notifications/notification-preferences.tsx +182 -0
- package/src/components/profile/user-profile-view.tsx +626 -0
- package/src/components/providers/nav-counts-provider.tsx +235 -0
- package/src/components/providers/session-provider.tsx +7 -0
- package/src/components/providers/theme-provider.tsx +124 -0
- package/src/components/pwa/install-prompt.tsx +82 -0
- package/src/components/pwa/sw-register.tsx +43 -0
- package/src/components/reports/export-button.tsx +62 -0
- package/src/components/reports/filter-chips.tsx +47 -0
- package/src/components/reports/summary-cards.tsx +40 -0
- package/src/components/reports/transparency-header.tsx +54 -0
- package/src/components/rounds/department-visit-sheet.tsx +199 -0
- package/src/components/rounds/mention-textarea.tsx +187 -0
- package/src/components/rounds/round-calendar.tsx +233 -0
- package/src/components/rounds/round-department-list.tsx +281 -0
- package/src/components/rounds/round-history-client.tsx +218 -0
- package/src/components/rounds/start-round-card.tsx +184 -0
- package/src/components/shared/confirm-dialog.tsx +67 -0
- package/src/components/shared/data-table.tsx +104 -0
- package/src/components/shared/page-header.tsx +20 -0
- package/src/components/shared/sign-out-button.tsx +52 -0
- package/src/components/shared/status-badge.tsx +42 -0
- package/src/components/shared/table-search.tsx +55 -0
- package/src/components/signatures/sign-action-dialog.tsx +253 -0
- package/src/components/signatures/signature-history.tsx +121 -0
- package/src/components/signatures/signature-status-panel.tsx +164 -0
- package/src/components/team/department-coverage.tsx +141 -0
- package/src/components/team/edit-engineer-dialog.tsx +242 -0
- package/src/components/team/engineer-card.tsx +180 -0
- package/src/components/team/engineer-details-dialog.tsx +432 -0
- package/src/components/team/schedule-calendar.tsx +204 -0
- package/src/components/team/staff-engineer-team-view.tsx +368 -0
- package/src/components/team/team-header-stats.tsx +88 -0
- package/src/components/team/team-page-client.tsx +216 -0
- package/src/components/theme/theme-selector-card.tsx +63 -0
- package/src/components/theme/theme-toggle.tsx +65 -0
- package/src/components/tickets/staff-status-label.tsx +58 -0
- package/src/components/tickets/staff-ticket-card.tsx +109 -0
- package/src/components/tickets/staff-ticket-progress-tracker.tsx +405 -0
- package/src/components/tickets/staff-tickets-view.tsx +182 -0
- package/src/components/tickets/ticket-action-buttons.tsx +873 -0
- package/src/components/tickets/ticket-auto-refresh.tsx +197 -0
- package/src/components/tickets/ticket-badges.tsx +43 -0
- package/src/components/tickets/ticket-card.tsx +197 -0
- package/src/components/tickets/ticket-cards-view.tsx +395 -0
- package/src/components/tickets/ticket-comment-section.tsx +684 -0
- package/src/components/tickets/ticket-dispatch-status.tsx +184 -0
- package/src/components/tickets/ticket-list-auto-refresh.tsx +55 -0
- package/src/components/tickets/ticket-reporter-profile.tsx +235 -0
- package/src/components/tickets/ticket-signatures-panel.tsx +32 -0
- package/src/components/tickets/ticket-timeline.tsx +131 -0
- package/src/components/tickets/ticket-triage-panel.tsx +124 -0
- package/src/components/tickets/tickets-nav.tsx +107 -0
- package/src/components/ui/avatar.tsx +43 -0
- package/src/components/ui/badge.tsx +34 -0
- package/src/components/ui/button.tsx +58 -0
- package/src/components/ui/card.tsx +77 -0
- package/src/components/ui/checkbox.tsx +31 -0
- package/src/components/ui/dialog.tsx +123 -0
- package/src/components/ui/dropdown-menu.tsx +126 -0
- package/src/components/ui/form.tsx +179 -0
- package/src/components/ui/input.tsx +24 -0
- package/src/components/ui/label.tsx +27 -0
- package/src/components/ui/popover.tsx +34 -0
- package/src/components/ui/progress.tsx +36 -0
- package/src/components/ui/scroll-area.tsx +47 -0
- package/src/components/ui/select.tsx +160 -0
- package/src/components/ui/separator.tsx +25 -0
- package/src/components/ui/sheet.tsx +131 -0
- package/src/components/ui/switch.tsx +30 -0
- package/src/components/ui/table.tsx +121 -0
- package/src/components/ui/tabs.tsx +62 -0
- package/src/components/ui/textarea.tsx +23 -0
- package/src/components/ui/tooltip.tsx +27 -0
- package/src/lib/actions/__tests__/devices.test.ts +176 -0
- package/src/lib/actions/__tests__/signatures.test.ts +303 -0
- package/src/lib/actions/__tests__/tickets.test.ts +243 -0
- package/src/lib/actions/audit-logs.ts +298 -0
- package/src/lib/actions/checklists.ts +429 -0
- package/src/lib/actions/dashboard.ts +358 -0
- package/src/lib/actions/data-management.ts +723 -0
- package/src/lib/actions/departments.ts +369 -0
- package/src/lib/actions/device-categories.ts +117 -0
- package/src/lib/actions/devices.ts +748 -0
- package/src/lib/actions/engineer-rounds.ts +973 -0
- package/src/lib/actions/engineers.ts +285 -0
- package/src/lib/actions/hospitals.ts +148 -0
- package/src/lib/actions/locations.ts +115 -0
- package/src/lib/actions/maintenance-plans.ts +316 -0
- package/src/lib/actions/maintenance-tasks.ts +415 -0
- package/src/lib/actions/manufacturers.ts +132 -0
- package/src/lib/actions/nav-counts.ts +144 -0
- package/src/lib/actions/notifications.ts +136 -0
- package/src/lib/actions/organizations.ts +99 -0
- package/src/lib/actions/qr.ts +147 -0
- package/src/lib/actions/report-history.ts +77 -0
- package/src/lib/actions/reports.ts +192 -0
- package/src/lib/actions/roles.ts +32 -0
- package/src/lib/actions/signature-auth.ts +377 -0
- package/src/lib/actions/signatures.ts +532 -0
- package/src/lib/actions/system-settings.ts +274 -0
- package/src/lib/actions/tickets.ts +1445 -0
- package/src/lib/actions/users.ts +740 -0
- package/src/lib/audit/index.ts +103 -0
- package/src/lib/auth/__tests__/rbac.test.ts +33 -0
- package/src/lib/auth/index.ts +338 -0
- package/src/lib/auth/password.ts +10 -0
- package/src/lib/auth/rbac.ts +103 -0
- package/src/lib/auth/types.ts +57 -0
- package/src/lib/constants/departments.ts +16 -0
- package/src/lib/constants/manufacturers.ts +32 -0
- package/src/lib/db/index.ts +23 -0
- package/src/lib/db/schema/audit-logs.ts +42 -0
- package/src/lib/db/schema/departments.ts +39 -0
- package/src/lib/db/schema/device-categories.ts +38 -0
- package/src/lib/db/schema/devices.ts +195 -0
- package/src/lib/db/schema/engineer-profiles.ts +63 -0
- package/src/lib/db/schema/engineer-rounds.ts +115 -0
- package/src/lib/db/schema/enums.ts +148 -0
- package/src/lib/db/schema/hospitals.ts +34 -0
- package/src/lib/db/schema/index.ts +24 -0
- package/src/lib/db/schema/locations.ts +46 -0
- package/src/lib/db/schema/maintenance-plans.ts +99 -0
- package/src/lib/db/schema/maintenance-records.ts +161 -0
- package/src/lib/db/schema/maintenance-tasks.ts +196 -0
- package/src/lib/db/schema/manufacturers.ts +60 -0
- package/src/lib/db/schema/notifications.ts +48 -0
- package/src/lib/db/schema/organizations.ts +24 -0
- package/src/lib/db/schema/report-history.ts +28 -0
- package/src/lib/db/schema/roles.ts +59 -0
- package/src/lib/db/schema/sessions.ts +46 -0
- package/src/lib/db/schema/signature-events.ts +48 -0
- package/src/lib/db/schema/signature-policies.ts +60 -0
- package/src/lib/db/schema/signatures.ts +87 -0
- package/src/lib/db/schema/tickets.ts +169 -0
- package/src/lib/db/schema/user-assignments.ts +85 -0
- package/src/lib/db/schema/users.ts +39 -0
- package/src/lib/db/seed.ts +131 -0
- package/src/lib/logger/__tests__/logger.test.ts +154 -0
- package/src/lib/logger/formatters.ts +159 -0
- package/src/lib/logger/index.ts +184 -0
- package/src/lib/logger/types.ts +48 -0
- package/src/lib/notifications/create.ts +71 -0
- package/src/lib/notifications/dispatcher.ts +490 -0
- package/src/lib/notifications/index.ts +7 -0
- package/src/lib/notifications/push-sender.ts +128 -0
- package/src/lib/notifications/push.ts +64 -0
- package/src/lib/notifications/triggers.ts +166 -0
- package/src/lib/utils/__tests__/crypto.test.ts +30 -0
- package/src/lib/utils/__tests__/export.test.ts +55 -0
- package/src/lib/utils/__tests__/nav-badge.test.ts +147 -0
- package/src/lib/utils/__tests__/staff-status.test.ts +50 -0
- package/src/lib/utils/attestations.ts +19 -0
- package/src/lib/utils/crypto.ts +18 -0
- package/src/lib/utils/csv-parser.ts +181 -0
- package/src/lib/utils/export.ts +45 -0
- package/src/lib/utils/nav-badge.ts +225 -0
- package/src/lib/utils/sound.ts +152 -0
- package/src/lib/utils/staff-status.ts +115 -0
- package/src/lib/utils.ts +6 -0
- package/src/lib/validators/__tests__/auth.test.ts +127 -0
- package/src/lib/validators/__tests__/data-management.test.ts +182 -0
- package/src/lib/validators/__tests__/devices-profile.test.ts +129 -0
- package/src/lib/validators/__tests__/devices.test.ts +98 -0
- package/src/lib/validators/__tests__/engineer-rounds.test.ts +170 -0
- package/src/lib/validators/__tests__/maintenance.test.ts +178 -0
- package/src/lib/validators/__tests__/signatures.test.ts +154 -0
- package/src/lib/validators/__tests__/system-settings.test.ts +119 -0
- package/src/lib/validators/__tests__/tickets.test.ts +176 -0
- package/src/lib/validators/__tests__/users.test.ts +92 -0
- package/src/lib/validators/auth.ts +32 -0
- package/src/lib/validators/data-management.ts +67 -0
- package/src/lib/validators/departments.ts +14 -0
- package/src/lib/validators/devices.ts +94 -0
- package/src/lib/validators/engineer-rounds.ts +70 -0
- package/src/lib/validators/hospitals.ts +17 -0
- package/src/lib/validators/locations.ts +15 -0
- package/src/lib/validators/maintenance.ts +211 -0
- package/src/lib/validators/organizations.ts +11 -0
- package/src/lib/validators/reports.ts +31 -0
- package/src/lib/validators/signatures.ts +49 -0
- package/src/lib/validators/system-settings.ts +55 -0
- package/src/lib/validators/tickets.ts +125 -0
- package/src/lib/validators/users.ts +43 -0
- package/src/middleware.ts +45 -0
- package/tailwind.config.ts +76 -0
- package/tsconfig.json +28 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { useRouter } from "next/navigation";
|
|
5
|
+
import {
|
|
6
|
+
Dialog,
|
|
7
|
+
DialogContent,
|
|
8
|
+
DialogHeader,
|
|
9
|
+
DialogTitle,
|
|
10
|
+
DialogTrigger,
|
|
11
|
+
DialogFooter,
|
|
12
|
+
} from "@/components/ui/dialog";
|
|
13
|
+
import { Button } from "@/components/ui/button";
|
|
14
|
+
import { Input } from "@/components/ui/input";
|
|
15
|
+
import { Label } from "@/components/ui/label";
|
|
16
|
+
import { Plus, Loader2 } from "lucide-react";
|
|
17
|
+
import { createDeviceCategory } from "@/lib/actions/device-categories";
|
|
18
|
+
|
|
19
|
+
interface QuickAddCategoryDialogProps {
|
|
20
|
+
onSuccess?: (newCategory: any) => void;
|
|
21
|
+
triggerVariant?: "outline" | "ghost" | "default" | "secondary";
|
|
22
|
+
triggerSize?: "sm" | "default" | "icon";
|
|
23
|
+
triggerLabel?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function QuickAddCategoryDialog({
|
|
27
|
+
onSuccess,
|
|
28
|
+
triggerVariant = "outline",
|
|
29
|
+
triggerSize = "sm",
|
|
30
|
+
triggerLabel = "New Type",
|
|
31
|
+
}: QuickAddCategoryDialogProps) {
|
|
32
|
+
const router = useRouter();
|
|
33
|
+
const [open, setOpen] = useState(false);
|
|
34
|
+
const [loading, setLoading] = useState(false);
|
|
35
|
+
const [error, setError] = useState("");
|
|
36
|
+
const [name, setName] = useState("");
|
|
37
|
+
|
|
38
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
if (!name.trim()) {
|
|
41
|
+
setError("Please enter a device type name");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setLoading(true);
|
|
46
|
+
setError("");
|
|
47
|
+
|
|
48
|
+
// Auto-generate code from name
|
|
49
|
+
const code = name.trim().toUpperCase().replace(/[^A-Z0-9]/g, "_").slice(0, 15);
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const result = await createDeviceCategory({
|
|
53
|
+
name: name.trim(),
|
|
54
|
+
code,
|
|
55
|
+
criticalityLevel: "medium",
|
|
56
|
+
defaultPmIntervalDays: 180,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (result.success) {
|
|
60
|
+
if (onSuccess) onSuccess((result as any).data);
|
|
61
|
+
router.refresh();
|
|
62
|
+
setOpen(false);
|
|
63
|
+
setName("");
|
|
64
|
+
} else {
|
|
65
|
+
setError((result as any)?.error || "Failed to create device type");
|
|
66
|
+
}
|
|
67
|
+
} catch (err: any) {
|
|
68
|
+
setError(err?.message || "An unexpected error occurred");
|
|
69
|
+
} finally {
|
|
70
|
+
setLoading(false);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<Dialog open={open} onOpenChange={setOpen}>
|
|
76
|
+
<DialogTrigger asChild>
|
|
77
|
+
<Button
|
|
78
|
+
type="button"
|
|
79
|
+
variant={triggerVariant}
|
|
80
|
+
size={triggerSize}
|
|
81
|
+
className="h-8 gap-1 text-xs shrink-0"
|
|
82
|
+
>
|
|
83
|
+
<Plus className="w-3.5 h-3.5" />
|
|
84
|
+
{triggerLabel}
|
|
85
|
+
</Button>
|
|
86
|
+
</DialogTrigger>
|
|
87
|
+
<DialogContent className="sm:max-w-[400px]">
|
|
88
|
+
<form onSubmit={handleSubmit} className="space-y-4">
|
|
89
|
+
<DialogHeader>
|
|
90
|
+
<DialogTitle>Add Device Type</DialogTitle>
|
|
91
|
+
</DialogHeader>
|
|
92
|
+
|
|
93
|
+
{error && (
|
|
94
|
+
<div className="bg-destructive/10 text-destructive text-xs p-2.5 rounded-md border border-destructive/20">
|
|
95
|
+
{error}
|
|
96
|
+
</div>
|
|
97
|
+
)}
|
|
98
|
+
|
|
99
|
+
<div>
|
|
100
|
+
<Label htmlFor="cat-name">Device Type Name *</Label>
|
|
101
|
+
<Input
|
|
102
|
+
id="cat-name"
|
|
103
|
+
value={name}
|
|
104
|
+
onChange={(e) => setName(e.target.value)}
|
|
105
|
+
placeholder="e.g. Blood Gas Analyzer, Autoclave..."
|
|
106
|
+
className="mt-1"
|
|
107
|
+
autoFocus
|
|
108
|
+
required
|
|
109
|
+
/>
|
|
110
|
+
<p className="text-xs text-muted-foreground mt-1.5">
|
|
111
|
+
Enter the general type of equipment (e.g. "Infusion Pump", "Sterilizer")
|
|
112
|
+
</p>
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<DialogFooter className="gap-2 sm:gap-0 pt-2">
|
|
116
|
+
<Button
|
|
117
|
+
type="button"
|
|
118
|
+
variant="outline"
|
|
119
|
+
size="sm"
|
|
120
|
+
onClick={() => setOpen(false)}
|
|
121
|
+
disabled={loading}
|
|
122
|
+
>
|
|
123
|
+
Cancel
|
|
124
|
+
</Button>
|
|
125
|
+
<Button type="submit" size="sm" disabled={loading}>
|
|
126
|
+
{loading && <Loader2 className="w-3.5 h-3.5 mr-1.5 animate-spin" />}
|
|
127
|
+
Add Type
|
|
128
|
+
</Button>
|
|
129
|
+
</DialogFooter>
|
|
130
|
+
</form>
|
|
131
|
+
</DialogContent>
|
|
132
|
+
</Dialog>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { useRouter } from "next/navigation";
|
|
5
|
+
import {
|
|
6
|
+
Dialog,
|
|
7
|
+
DialogContent,
|
|
8
|
+
DialogHeader,
|
|
9
|
+
DialogTitle,
|
|
10
|
+
DialogTrigger,
|
|
11
|
+
DialogFooter,
|
|
12
|
+
} from "@/components/ui/dialog";
|
|
13
|
+
import { Button } from "@/components/ui/button";
|
|
14
|
+
import { Input } from "@/components/ui/input";
|
|
15
|
+
import { Label } from "@/components/ui/label";
|
|
16
|
+
import { Plus, Loader2 } from "lucide-react";
|
|
17
|
+
import { createManufacturer } from "@/lib/actions/manufacturers";
|
|
18
|
+
|
|
19
|
+
interface QuickAddManufacturerDialogProps {
|
|
20
|
+
onSuccess?: (newManufacturer: any) => void;
|
|
21
|
+
triggerVariant?: "outline" | "ghost" | "default" | "secondary";
|
|
22
|
+
triggerSize?: "sm" | "default" | "icon";
|
|
23
|
+
triggerLabel?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function QuickAddManufacturerDialog({
|
|
27
|
+
onSuccess,
|
|
28
|
+
triggerVariant = "outline",
|
|
29
|
+
triggerSize = "sm",
|
|
30
|
+
triggerLabel = "New Manufacturer",
|
|
31
|
+
}: QuickAddManufacturerDialogProps) {
|
|
32
|
+
const router = useRouter();
|
|
33
|
+
const [open, setOpen] = useState(false);
|
|
34
|
+
const [loading, setLoading] = useState(false);
|
|
35
|
+
const [error, setError] = useState("");
|
|
36
|
+
|
|
37
|
+
const [name, setName] = useState("");
|
|
38
|
+
const [code, setCode] = useState("");
|
|
39
|
+
const [country, setCountry] = useState("");
|
|
40
|
+
const [supportPhone, setSupportPhone] = useState("");
|
|
41
|
+
const [supportEmail, setSupportEmail] = useState("");
|
|
42
|
+
const [website, setWebsite] = useState("");
|
|
43
|
+
|
|
44
|
+
const handleNameChange = (val: string) => {
|
|
45
|
+
setName(val);
|
|
46
|
+
if (!code || code === name.toUpperCase().replace(/[^A-Z0-9]/g, "_").slice(0, 15)) {
|
|
47
|
+
setCode(val.toUpperCase().replace(/[^A-Z0-9]/g, "_").slice(0, 15));
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
if (!name.trim()) {
|
|
54
|
+
setError("Manufacturer name is required");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
setLoading(true);
|
|
59
|
+
setError("");
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
const result = await createManufacturer({
|
|
63
|
+
name: name.trim(),
|
|
64
|
+
code: code.trim() || undefined,
|
|
65
|
+
country: country.trim() || undefined,
|
|
66
|
+
supportPhone: supportPhone.trim() || undefined,
|
|
67
|
+
supportEmail: supportEmail.trim() || undefined,
|
|
68
|
+
website: website.trim() || undefined,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (result.success) {
|
|
72
|
+
if (onSuccess) onSuccess((result as any).data);
|
|
73
|
+
router.refresh();
|
|
74
|
+
setOpen(false);
|
|
75
|
+
// Reset form
|
|
76
|
+
setName("");
|
|
77
|
+
setCode("");
|
|
78
|
+
setCountry("");
|
|
79
|
+
setSupportPhone("");
|
|
80
|
+
setSupportEmail("");
|
|
81
|
+
setWebsite("");
|
|
82
|
+
} else {
|
|
83
|
+
setError((result as any)?.error || "Failed to create manufacturer");
|
|
84
|
+
}
|
|
85
|
+
} catch (err: any) {
|
|
86
|
+
setError(err?.message || "An unexpected error occurred");
|
|
87
|
+
} finally {
|
|
88
|
+
setLoading(false);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<Dialog open={open} onOpenChange={setOpen}>
|
|
94
|
+
<DialogTrigger asChild>
|
|
95
|
+
<Button
|
|
96
|
+
type="button"
|
|
97
|
+
variant={triggerVariant}
|
|
98
|
+
size={triggerSize}
|
|
99
|
+
className="h-8 gap-1 text-xs shrink-0"
|
|
100
|
+
>
|
|
101
|
+
<Plus className="w-3.5 h-3.5" />
|
|
102
|
+
{triggerLabel}
|
|
103
|
+
</Button>
|
|
104
|
+
</DialogTrigger>
|
|
105
|
+
<DialogContent className="sm:max-w-[480px]">
|
|
106
|
+
<form onSubmit={handleSubmit} className="space-y-4">
|
|
107
|
+
<DialogHeader>
|
|
108
|
+
<DialogTitle>Add Device Manufacturer</DialogTitle>
|
|
109
|
+
</DialogHeader>
|
|
110
|
+
|
|
111
|
+
{error && (
|
|
112
|
+
<div className="bg-destructive/10 text-destructive text-xs p-2.5 rounded-md border border-destructive/20">
|
|
113
|
+
{error}
|
|
114
|
+
</div>
|
|
115
|
+
)}
|
|
116
|
+
|
|
117
|
+
<div className="grid gap-3">
|
|
118
|
+
<div>
|
|
119
|
+
<Label htmlFor="mfr-name" className="text-xs">Manufacturer Name *</Label>
|
|
120
|
+
<Input
|
|
121
|
+
id="mfr-name"
|
|
122
|
+
value={name}
|
|
123
|
+
onChange={(e) => handleNameChange(e.target.value)}
|
|
124
|
+
placeholder="e.g. Philips Healthcare"
|
|
125
|
+
className="mt-1"
|
|
126
|
+
required
|
|
127
|
+
/>
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<div className="grid grid-cols-2 gap-3">
|
|
131
|
+
<div>
|
|
132
|
+
<Label htmlFor="mfr-code" className="text-xs">Short Code</Label>
|
|
133
|
+
<Input
|
|
134
|
+
id="mfr-code"
|
|
135
|
+
value={code}
|
|
136
|
+
onChange={(e) => setCode(e.target.value)}
|
|
137
|
+
placeholder="e.g. PHILIPS"
|
|
138
|
+
className="mt-1 font-mono text-xs uppercase"
|
|
139
|
+
/>
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
<div>
|
|
143
|
+
<Label htmlFor="mfr-country" className="text-xs">Country of Origin</Label>
|
|
144
|
+
<Input
|
|
145
|
+
id="mfr-country"
|
|
146
|
+
value={country}
|
|
147
|
+
onChange={(e) => setCountry(e.target.value)}
|
|
148
|
+
placeholder="e.g. Netherlands"
|
|
149
|
+
className="mt-1 text-xs"
|
|
150
|
+
/>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
|
|
154
|
+
<div className="grid grid-cols-2 gap-3">
|
|
155
|
+
<div>
|
|
156
|
+
<Label htmlFor="mfr-phone" className="text-xs">Support Phone</Label>
|
|
157
|
+
<Input
|
|
158
|
+
id="mfr-phone"
|
|
159
|
+
value={supportPhone}
|
|
160
|
+
onChange={(e) => setSupportPhone(e.target.value)}
|
|
161
|
+
placeholder="+1-800-..."
|
|
162
|
+
className="mt-1 text-xs"
|
|
163
|
+
/>
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
<div>
|
|
167
|
+
<Label htmlFor="mfr-email" className="text-xs">Support Email</Label>
|
|
168
|
+
<Input
|
|
169
|
+
id="mfr-email"
|
|
170
|
+
type="email"
|
|
171
|
+
value={supportEmail}
|
|
172
|
+
onChange={(e) => setSupportEmail(e.target.value)}
|
|
173
|
+
placeholder="support@..."
|
|
174
|
+
className="mt-1 text-xs"
|
|
175
|
+
/>
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
<div>
|
|
180
|
+
<Label htmlFor="mfr-web" className="text-xs">Official Website</Label>
|
|
181
|
+
<Input
|
|
182
|
+
id="mfr-web"
|
|
183
|
+
type="url"
|
|
184
|
+
value={website}
|
|
185
|
+
onChange={(e) => setWebsite(e.target.value)}
|
|
186
|
+
placeholder="https://..."
|
|
187
|
+
className="mt-1 text-xs"
|
|
188
|
+
/>
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<DialogFooter className="gap-2 sm:gap-0 pt-2">
|
|
193
|
+
<Button
|
|
194
|
+
type="button"
|
|
195
|
+
variant="outline"
|
|
196
|
+
size="sm"
|
|
197
|
+
onClick={() => setOpen(false)}
|
|
198
|
+
disabled={loading}
|
|
199
|
+
>
|
|
200
|
+
Cancel
|
|
201
|
+
</Button>
|
|
202
|
+
<Button type="submit" size="sm" disabled={loading}>
|
|
203
|
+
{loading && <Loader2 className="w-3.5 h-3.5 mr-1.5 animate-spin" />}
|
|
204
|
+
Save Manufacturer
|
|
205
|
+
</Button>
|
|
206
|
+
</DialogFooter>
|
|
207
|
+
</form>
|
|
208
|
+
</DialogContent>
|
|
209
|
+
</Dialog>
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect } from "react"
|
|
4
|
+
import { useRouter } from "next/navigation"
|
|
5
|
+
import { toast } from "sonner"
|
|
6
|
+
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog"
|
|
7
|
+
import { Button } from "@/components/ui/button"
|
|
8
|
+
import { Input } from "@/components/ui/input"
|
|
9
|
+
import { Label } from "@/components/ui/label"
|
|
10
|
+
import { Textarea } from "@/components/ui/textarea"
|
|
11
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
|
|
12
|
+
import { getHospitals } from "@/lib/actions/hospitals"
|
|
13
|
+
import { getDepartments } from "@/lib/actions/departments"
|
|
14
|
+
import { transferDeviceLocation } from "@/lib/actions/devices"
|
|
15
|
+
|
|
16
|
+
interface TransferDeviceDialogProps {
|
|
17
|
+
open: boolean;
|
|
18
|
+
onOpenChange: (open: boolean) => void;
|
|
19
|
+
deviceId: string;
|
|
20
|
+
deviceName: string;
|
|
21
|
+
currentHospital: string;
|
|
22
|
+
currentDepartment: string;
|
|
23
|
+
currentLocation?: string;
|
|
24
|
+
onSuccess: () => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function TransferDeviceDialog({
|
|
28
|
+
open,
|
|
29
|
+
onOpenChange,
|
|
30
|
+
deviceId,
|
|
31
|
+
deviceName,
|
|
32
|
+
currentHospital,
|
|
33
|
+
currentDepartment,
|
|
34
|
+
currentLocation,
|
|
35
|
+
onSuccess
|
|
36
|
+
}: TransferDeviceDialogProps) {
|
|
37
|
+
const router = useRouter()
|
|
38
|
+
const [loading, setLoading] = useState(false)
|
|
39
|
+
const [hospitals, setHospitals] = useState<any[]>([])
|
|
40
|
+
const [departments, setDepartments] = useState<any[]>([])
|
|
41
|
+
|
|
42
|
+
const [hospitalId, setHospitalId] = useState("")
|
|
43
|
+
const [departmentId, setDepartmentId] = useState("")
|
|
44
|
+
const [locationDescription, setLocationDescription] = useState("")
|
|
45
|
+
const [reason, setReason] = useState("")
|
|
46
|
+
const [notes, setNotes] = useState("")
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (open) {
|
|
50
|
+
getHospitals().then(res => {
|
|
51
|
+
if (res?.success && Array.isArray(res.data)) {
|
|
52
|
+
setHospitals(res.data)
|
|
53
|
+
}
|
|
54
|
+
}).catch(console.error)
|
|
55
|
+
}
|
|
56
|
+
}, [open])
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (hospitalId) {
|
|
60
|
+
getDepartments(hospitalId).then(res => {
|
|
61
|
+
if (res?.success && Array.isArray(res.data)) {
|
|
62
|
+
setDepartments(res.data)
|
|
63
|
+
}
|
|
64
|
+
}).catch(console.error)
|
|
65
|
+
setDepartmentId("")
|
|
66
|
+
}
|
|
67
|
+
}, [hospitalId])
|
|
68
|
+
|
|
69
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
70
|
+
e.preventDefault()
|
|
71
|
+
if (!hospitalId || !departmentId || !reason) {
|
|
72
|
+
toast.error("Please fill in all required fields")
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
setLoading(true)
|
|
77
|
+
try {
|
|
78
|
+
await transferDeviceLocation(deviceId, {
|
|
79
|
+
destinationHospitalId: hospitalId,
|
|
80
|
+
destinationDepartmentId: departmentId,
|
|
81
|
+
exactLocationDescription: locationDescription,
|
|
82
|
+
transferReason: reason as any,
|
|
83
|
+
notes
|
|
84
|
+
})
|
|
85
|
+
toast.success("Device transferred successfully")
|
|
86
|
+
onSuccess()
|
|
87
|
+
onOpenChange(false)
|
|
88
|
+
router.refresh()
|
|
89
|
+
} catch (error) {
|
|
90
|
+
console.error(error)
|
|
91
|
+
toast.error("Failed to transfer device")
|
|
92
|
+
} finally {
|
|
93
|
+
setLoading(false)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
99
|
+
<DialogContent className="sm:max-w-[500px]">
|
|
100
|
+
<form onSubmit={handleSubmit}>
|
|
101
|
+
<DialogHeader>
|
|
102
|
+
<DialogTitle>Transfer Device Location</DialogTitle>
|
|
103
|
+
</DialogHeader>
|
|
104
|
+
<div className="grid gap-4 py-4">
|
|
105
|
+
<div className="text-sm bg-muted p-3 rounded-md">
|
|
106
|
+
<p><strong>Device:</strong> {deviceName}</p>
|
|
107
|
+
<p><strong>Current:</strong> {currentHospital} - {currentDepartment} {currentLocation ? `(${currentLocation})` : ""}</p>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<div className="grid gap-2">
|
|
111
|
+
<Label htmlFor="hospital">Destination Hospital *</Label>
|
|
112
|
+
<Select value={hospitalId} onValueChange={setHospitalId} required>
|
|
113
|
+
<SelectTrigger>
|
|
114
|
+
<SelectValue placeholder="Select hospital" />
|
|
115
|
+
</SelectTrigger>
|
|
116
|
+
<SelectContent>
|
|
117
|
+
{hospitals.map(h => (
|
|
118
|
+
<SelectItem key={h.id} value={h.id}>{h.name}</SelectItem>
|
|
119
|
+
))}
|
|
120
|
+
</SelectContent>
|
|
121
|
+
</Select>
|
|
122
|
+
</div>
|
|
123
|
+
|
|
124
|
+
<div className="grid gap-2">
|
|
125
|
+
<Label htmlFor="department">Destination Department *</Label>
|
|
126
|
+
<Select value={departmentId} onValueChange={setDepartmentId} disabled={!hospitalId} required>
|
|
127
|
+
<SelectTrigger>
|
|
128
|
+
<SelectValue placeholder="Select department" />
|
|
129
|
+
</SelectTrigger>
|
|
130
|
+
<SelectContent>
|
|
131
|
+
{departments.map(d => (
|
|
132
|
+
<SelectItem key={d.id} value={d.id}>{d.name}</SelectItem>
|
|
133
|
+
))}
|
|
134
|
+
</SelectContent>
|
|
135
|
+
</Select>
|
|
136
|
+
</div>
|
|
137
|
+
|
|
138
|
+
<div className="grid gap-2">
|
|
139
|
+
<Label htmlFor="location">Location Description</Label>
|
|
140
|
+
<Input
|
|
141
|
+
id="location"
|
|
142
|
+
placeholder="e.g. Room 101, Bed 3"
|
|
143
|
+
value={locationDescription}
|
|
144
|
+
onChange={(e) => setLocationDescription(e.target.value)}
|
|
145
|
+
/>
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
<div className="grid gap-2">
|
|
149
|
+
<Label htmlFor="reason">Transfer Reason *</Label>
|
|
150
|
+
<Select value={reason} onValueChange={setReason} required>
|
|
151
|
+
<SelectTrigger>
|
|
152
|
+
<SelectValue placeholder="Select reason" />
|
|
153
|
+
</SelectTrigger>
|
|
154
|
+
<SelectContent>
|
|
155
|
+
<SelectItem value="relocation">Relocation</SelectItem>
|
|
156
|
+
<SelectItem value="temporary_loan">Temporary Loan</SelectItem>
|
|
157
|
+
<SelectItem value="department_change">Department Change</SelectItem>
|
|
158
|
+
<SelectItem value="correction">Correction</SelectItem>
|
|
159
|
+
<SelectItem value="replacement">Replacement</SelectItem>
|
|
160
|
+
<SelectItem value="workshop">Workshop</SelectItem>
|
|
161
|
+
<SelectItem value="storage">Storage</SelectItem>
|
|
162
|
+
<SelectItem value="other">Other</SelectItem>
|
|
163
|
+
</SelectContent>
|
|
164
|
+
</Select>
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
<div className="grid gap-2">
|
|
168
|
+
<Label htmlFor="notes">Notes (Optional)</Label>
|
|
169
|
+
<Textarea
|
|
170
|
+
id="notes"
|
|
171
|
+
placeholder="Additional details about the transfer"
|
|
172
|
+
value={notes}
|
|
173
|
+
onChange={(e) => setNotes(e.target.value)}
|
|
174
|
+
/>
|
|
175
|
+
</div>
|
|
176
|
+
</div>
|
|
177
|
+
<DialogFooter>
|
|
178
|
+
<Button type="button" variant="outline" onClick={() => onOpenChange(false)}>
|
|
179
|
+
Cancel
|
|
180
|
+
</Button>
|
|
181
|
+
<Button type="submit" disabled={loading}>
|
|
182
|
+
{loading ? "Transferring..." : "Transfer Device"}
|
|
183
|
+
</Button>
|
|
184
|
+
</DialogFooter>
|
|
185
|
+
</form>
|
|
186
|
+
</DialogContent>
|
|
187
|
+
</Dialog>
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { Search, Activity, LogOut, User, Settings } from 'lucide-react'
|
|
4
|
+
import { signOut } from 'next-auth/react'
|
|
5
|
+
import { Input } from '@/components/ui/input'
|
|
6
|
+
import { Button } from '@/components/ui/button'
|
|
7
|
+
import { Avatar, AvatarFallback } from '@/components/ui/avatar'
|
|
8
|
+
import {
|
|
9
|
+
DropdownMenu, DropdownMenuContent, DropdownMenuItem,
|
|
10
|
+
DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger
|
|
11
|
+
} from '@/components/ui/dropdown-menu'
|
|
12
|
+
import { NotificationBell } from '@/components/notifications/notification-bell'
|
|
13
|
+
import { ThemeToggle } from '@/components/theme/theme-toggle'
|
|
14
|
+
|
|
15
|
+
import Link from 'next/link'
|
|
16
|
+
|
|
17
|
+
export function Header({ user }: { user: { name: string; role: string; email: string } }) {
|
|
18
|
+
return (
|
|
19
|
+
<header className="sticky top-0 z-40 flex h-16 items-center gap-4 border-b border-border bg-card/80 backdrop-blur-sm px-4 md:px-6">
|
|
20
|
+
<div className="flex items-center md:hidden gap-2 text-primary mr-auto">
|
|
21
|
+
<Activity className="h-6 w-6" />
|
|
22
|
+
<span className="font-bold tracking-tight text-foreground">BEMMS</span>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<div className="hidden md:flex items-center flex-1 max-w-md">
|
|
26
|
+
<div className="relative w-full">
|
|
27
|
+
<Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />
|
|
28
|
+
<Input
|
|
29
|
+
type="search"
|
|
30
|
+
placeholder="Search devices, tickets..."
|
|
31
|
+
className="w-full bg-muted/50 pl-9 md:w-[300px] lg:w-[400px]"
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<div className="flex items-center gap-2 ml-auto md:ml-0">
|
|
37
|
+
<ThemeToggle />
|
|
38
|
+
<NotificationBell />
|
|
39
|
+
|
|
40
|
+
<DropdownMenu>
|
|
41
|
+
<DropdownMenuTrigger asChild>
|
|
42
|
+
<Button variant="ghost" className="relative h-9 w-9 rounded-full">
|
|
43
|
+
<Avatar className="h-9 w-9">
|
|
44
|
+
<AvatarFallback className="bg-primary/10 text-primary">
|
|
45
|
+
{user.name.substring(0, 2).toUpperCase()}
|
|
46
|
+
</AvatarFallback>
|
|
47
|
+
</Avatar>
|
|
48
|
+
</Button>
|
|
49
|
+
</DropdownMenuTrigger>
|
|
50
|
+
<DropdownMenuContent className="w-56" align="end" forceMount>
|
|
51
|
+
<DropdownMenuLabel className="font-normal">
|
|
52
|
+
<div className="flex flex-col space-y-1">
|
|
53
|
+
<p className="text-sm font-medium leading-none">{user.name}</p>
|
|
54
|
+
<p className="text-xs leading-none text-muted-foreground">{user.email}</p>
|
|
55
|
+
</div>
|
|
56
|
+
</DropdownMenuLabel>
|
|
57
|
+
<DropdownMenuSeparator />
|
|
58
|
+
<DropdownMenuItem asChild>
|
|
59
|
+
<Link href="/profile" className="flex items-center w-full cursor-pointer">
|
|
60
|
+
<User className="mr-2 h-4 w-4" />
|
|
61
|
+
<span>My Profile</span>
|
|
62
|
+
</Link>
|
|
63
|
+
</DropdownMenuItem>
|
|
64
|
+
<DropdownMenuItem asChild>
|
|
65
|
+
<Link href="/more" className="flex items-center w-full cursor-pointer">
|
|
66
|
+
<Settings className="mr-2 h-4 w-4" />
|
|
67
|
+
<span>Menu & Settings</span>
|
|
68
|
+
</Link>
|
|
69
|
+
</DropdownMenuItem>
|
|
70
|
+
<DropdownMenuSeparator />
|
|
71
|
+
<DropdownMenuItem onClick={() => signOut({ callbackUrl: '/login' })} className="cursor-pointer">
|
|
72
|
+
<LogOut className="mr-2 h-4 w-4" />
|
|
73
|
+
<span>Log out</span>
|
|
74
|
+
</DropdownMenuItem>
|
|
75
|
+
</DropdownMenuContent>
|
|
76
|
+
</DropdownMenu>
|
|
77
|
+
</div>
|
|
78
|
+
</header>
|
|
79
|
+
)
|
|
80
|
+
}
|