@burdenoff/microfe-notification 2026.518.2 → 2026.521.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.
Files changed (60) hide show
  1. package/dist/AdminNotificationRoutes.d.ts.map +1 -1
  2. package/dist/AdminNotificationRoutes.js +50 -46
  3. package/dist/AdminNotificationRoutes.js.map +1 -1
  4. package/dist/UserNotificationRoutes.d.ts.map +1 -1
  5. package/dist/UserNotificationRoutes.js +28 -24
  6. package/dist/UserNotificationRoutes.js.map +1 -1
  7. package/dist/components/FeatureDisabledPage.d.ts +7 -0
  8. package/dist/components/FeatureDisabledPage.d.ts.map +1 -0
  9. package/dist/components/FeatureDisabledPage.js +32 -0
  10. package/dist/components/FeatureDisabledPage.js.map +1 -0
  11. package/dist/components/NotificationBell.d.ts.map +1 -1
  12. package/dist/components/NotificationBell.js +43 -22
  13. package/dist/components/NotificationBell.js.map +1 -1
  14. package/dist/components/NotificationCard.d.ts +2 -1
  15. package/dist/components/NotificationCard.d.ts.map +1 -1
  16. package/dist/components/NotificationCard.js +64 -63
  17. package/dist/components/NotificationCard.js.map +1 -1
  18. package/dist/components/NotificationPanel.d.ts.map +1 -1
  19. package/dist/components/NotificationPanel.js +2 -1
  20. package/dist/components/NotificationPanel.js.map +1 -1
  21. package/dist/graphql/global-client.js +1 -1
  22. package/dist/graphql/global-client.js.map +1 -1
  23. package/dist/hooks/index.d.ts +1 -0
  24. package/dist/hooks/index.d.ts.map +1 -1
  25. package/dist/hooks/index.js +1 -0
  26. package/dist/hooks/useNotificationAdmin.d.ts.map +1 -1
  27. package/dist/hooks/useNotificationAdmin.js +67 -64
  28. package/dist/hooks/useNotificationAdmin.js.map +1 -1
  29. package/dist/hooks/useNotificationAnalytics.d.ts +67 -0
  30. package/dist/hooks/useNotificationAnalytics.d.ts.map +1 -0
  31. package/dist/hooks/useNotificationAnalytics.js +64 -0
  32. package/dist/hooks/useNotificationAnalytics.js.map +1 -0
  33. package/dist/hooks/useNotificationPreferences.js +1 -1
  34. package/dist/hooks/useNotificationPreferences.js.map +1 -1
  35. package/dist/hooks/useNotificationTemplates.js +3 -3
  36. package/dist/hooks/useNotificationTemplates.js.map +1 -1
  37. package/dist/hooks/useNotificationTopics.js +1 -1
  38. package/dist/hooks/useNotificationTopics.js.map +1 -1
  39. package/dist/hooks/useNotifications.d.ts.map +1 -1
  40. package/dist/hooks/useNotifications.js +47 -40
  41. package/dist/hooks/useNotifications.js.map +1 -1
  42. package/dist/pages/CreateNotificationPage.d.ts.map +1 -1
  43. package/dist/pages/CreateNotificationPage.js +407 -391
  44. package/dist/pages/CreateNotificationPage.js.map +1 -1
  45. package/dist/pages/NotificationCenterPage.d.ts.map +1 -1
  46. package/dist/pages/NotificationCenterPage.js +80 -81
  47. package/dist/pages/NotificationCenterPage.js.map +1 -1
  48. package/dist/pages/NotificationHistoryAdminPage.d.ts.map +1 -1
  49. package/dist/pages/NotificationHistoryAdminPage.js +2 -1
  50. package/dist/pages/NotificationHistoryAdminPage.js.map +1 -1
  51. package/dist/pages/NotificationHistoryPage.d.ts.map +1 -1
  52. package/dist/pages/NotificationHistoryPage.js +2 -1
  53. package/dist/pages/NotificationHistoryPage.js.map +1 -1
  54. package/dist/pages/NotificationPreferencesPage.d.ts.map +1 -1
  55. package/dist/pages/NotificationPreferencesPage.js +140 -95
  56. package/dist/pages/NotificationPreferencesPage.js.map +1 -1
  57. package/dist/pages/TemplateEditorPage.d.ts.map +1 -1
  58. package/dist/pages/TemplateEditorPage.js +326 -313
  59. package/dist/pages/TemplateEditorPage.js.map +1 -1
  60. package/package.json +2 -2
@@ -1,117 +1,118 @@
1
- import { useTr as e } from "../shared/hooks/useTr.js";
2
- import { formatRelativeTime as t, getNotificationTypeIcon as n, getPriorityColor as r, getPriorityIcon as i, truncateText as a } from "../utils/index.js";
3
- import { nativeImpact as o, nativeOpenUrl as s } from "../utils/nativeBridge.js";
4
- import { ExternalLink as c, X as l } from "lucide-react";
5
- import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
1
+ import { useNotificationAnalytics as e } from "../hooks/useNotificationAnalytics.js";
2
+ import { useTr as t } from "../shared/hooks/useTr.js";
3
+ import { formatRelativeTime as n, getNotificationTypeIcon as r, getPriorityColor as i, getPriorityIcon as a, truncateText as o } from "../utils/index.js";
4
+ import { nativeImpact as s, nativeOpenUrl as c } from "../utils/nativeBridge.js";
5
+ import { ExternalLink as l, X as u } from "lucide-react";
6
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
6
7
  //#region src/components/NotificationCard.tsx
7
- function p({ notification: p, onMarkAsRead: m, onArchive: h, onAction: g, onClick: _, showArchivedState: v = !1, compact: y = !1 }) {
8
- let b = e(), x = !p.readAt, S = !!p.archivedAt, C = () => {
9
- _ && _(p), x && m && m(p.id);
10
- }, w = (e) => {
11
- e.stopPropagation(), h && h(p.id);
12
- }, T = (e) => {
13
- if (e.stopPropagation(), o("light"), p.actionUrl) {
14
- g?.(p.id);
15
- let e = p.actionUrl;
16
- e.startsWith("https://") ? s(e) : window.open(e, "_blank");
8
+ function m({ notification: m, onMarkAsRead: h, onArchive: g, onAction: _, onClick: v, showArchivedState: y = !1, compact: b = !1, analyticsSource: x = "center" }) {
9
+ let S = t(), { trackNotificationOpened: C } = e(), w = !m.readAt, T = !!m.archivedAt, E = () => {
10
+ C(m, x, "card"), v && v(m), w && h && h(m.id);
11
+ }, D = (e) => {
12
+ e.stopPropagation(), g && g(m.id);
13
+ }, O = (e) => {
14
+ if (e.stopPropagation(), s("light"), m.actionUrl) {
15
+ C(m, x, "primary_action"), _?.(m.id);
16
+ let e = m.actionUrl;
17
+ e.startsWith("https://") ? c(e) : window.open(e, "_blank");
17
18
  }
18
- }, E = (e, t, n) => {
19
- e.stopPropagation(), o("light"), g?.(p.id, t), n.startsWith("https://") ? s(n) : window.open(n, "_blank");
19
+ }, k = (e, t, n) => {
20
+ e.stopPropagation(), s("light"), C(m, x, "custom_action"), _?.(m.id, t), n.startsWith("https://") ? c(n) : window.open(n, "_blank");
20
21
  };
21
- return /* @__PURE__ */ f("div", {
22
+ return /* @__PURE__ */ p("div", {
22
23
  className: `
23
24
  relative flex flex-col gap-2 p-4 rounded-lg border cursor-pointer
24
25
  transition-all duration-200 ease-in-out
25
- ${x ? "bg-accent-subtle/5 border-accent-primary/20 shadow-sm ring-1 ring-accent-primary/10" : "bg-surface border-default opacity-75"}
26
- ${v && S ? "border-dashed opacity-60" : ""}
26
+ ${w ? "bg-accent-subtle/5 border-accent-primary/20 shadow-sm ring-1 ring-accent-primary/10" : "bg-surface border-default opacity-75"}
27
+ ${y && T ? "border-dashed opacity-60" : ""}
27
28
  hover:bg-muted hover:shadow-md hover:-translate-y-0.5 hover:opacity-100
28
29
  `,
29
- onClick: C,
30
+ onClick: E,
30
31
  children: [
31
- x && /* @__PURE__ */ d("div", { className: "absolute top-4 left-1.5 w-2.5 h-2.5 bg-accent-primary rounded-full shadow-sm shadow-accent-primary/50 animate-pulse" }),
32
- /* @__PURE__ */ f("div", {
32
+ w && /* @__PURE__ */ f("div", { className: "absolute top-4 left-1.5 w-2.5 h-2.5 bg-accent-primary rounded-full shadow-sm shadow-accent-primary/50 animate-pulse" }),
33
+ /* @__PURE__ */ p("div", {
33
34
  className: "flex items-start justify-between gap-2 ml-3",
34
- children: [/* @__PURE__ */ f("div", {
35
+ children: [/* @__PURE__ */ p("div", {
35
36
  className: "flex items-center gap-2 flex-1 min-w-0",
36
37
  children: [
37
- /* @__PURE__ */ d("span", {
38
+ /* @__PURE__ */ f("span", {
38
39
  className: "text-base",
39
40
  "aria-hidden": "true",
40
- children: n(p.type)
41
+ children: r(m.type)
41
42
  }),
42
- /* @__PURE__ */ d("h3", {
43
- className: `text-sm truncate ${x ? "font-bold text-primary" : "font-medium text-secondary"}`,
44
- children: y ? a(p.title, 60) : p.title
43
+ /* @__PURE__ */ f("h3", {
44
+ className: `text-sm truncate ${w ? "font-bold text-primary" : "font-medium text-secondary"}`,
45
+ children: b ? o(m.title, 60) : m.title
45
46
  }),
46
- /* @__PURE__ */ d("span", {
47
+ /* @__PURE__ */ f("span", {
47
48
  className: "text-xs",
48
- "aria-label": `Priority: ${p.priority}`,
49
- children: i(p.priority)
49
+ "aria-label": `Priority: ${m.priority}`,
50
+ children: a(m.priority)
50
51
  })
51
52
  ]
52
- }), h && /* @__PURE__ */ d("button", {
53
- onClick: w,
53
+ }), g && /* @__PURE__ */ f("button", {
54
+ onClick: D,
54
55
  className: "flex-shrink-0 p-1 hover:bg-muted rounded transition-colors duration-150",
55
- "aria-label": b("notifCommon.archiveNotification", "Archive notification"),
56
- children: /* @__PURE__ */ d(l, {
56
+ "aria-label": S("notifCommon.archiveNotification", "Archive notification"),
57
+ children: /* @__PURE__ */ f(u, {
57
58
  size: 16,
58
59
  className: "text-tertiary hover:text-secondary"
59
60
  })
60
61
  })]
61
62
  }),
62
- /* @__PURE__ */ f("div", {
63
+ /* @__PURE__ */ p("div", {
63
64
  className: "ml-3",
64
65
  children: [
65
- p.media[0]?.url && /* @__PURE__ */ d("img", {
66
- src: p.media[0].thumbnailUrl || p.media[0].url,
67
- alt: p.media[0].label || p.title,
66
+ m.media[0]?.url && /* @__PURE__ */ f("img", {
67
+ src: m.media[0].thumbnailUrl || m.media[0].url,
68
+ alt: m.media[0].label || m.title,
68
69
  className: "mb-3 h-40 w-full rounded-md object-cover border border-default"
69
70
  }),
70
- /* @__PURE__ */ d("p", {
71
- className: `text-sm text-secondary ${y ? "line-clamp-2" : ""}`,
72
- children: y ? a(p.body, 120) : p.body
71
+ /* @__PURE__ */ f("p", {
72
+ className: `text-sm text-secondary ${b ? "line-clamp-2" : ""}`,
73
+ children: b ? o(m.body, 120) : m.body
73
74
  }),
74
- p.topic && /* @__PURE__ */ d("div", {
75
+ m.topic && /* @__PURE__ */ f("div", {
75
76
  className: "mt-2 inline-flex items-center rounded-full bg-muted px-2 py-0.5 text-xs text-secondary",
76
- children: p.topic.name
77
+ children: m.topic.name
77
78
  })
78
79
  ]
79
80
  }),
80
- p.actions.length > 0 && !y && /* @__PURE__ */ d("div", {
81
+ m.actions.length > 0 && !b && /* @__PURE__ */ f("div", {
81
82
  className: "ml-3 flex flex-wrap gap-2",
82
- children: p.actions.map((e) => /* @__PURE__ */ d("button", {
83
- onClick: (t) => E(t, e.id, e.url),
83
+ children: m.actions.map((e) => /* @__PURE__ */ f("button", {
84
+ onClick: (t) => k(t, e.id, e.url),
84
85
  className: `rounded-md px-3 py-1.5 text-xs font-medium transition-colors ${e.style === "secondary" ? "bg-muted text-secondary hover:bg-muted/80" : e.style === "danger" ? "bg-status-error-bg-subtle text-status-error-text hover:opacity-80" : "bg-accent-primary text-white hover:opacity-90"}`,
85
86
  children: e.label
86
87
  }, e.id))
87
88
  }),
88
- /* @__PURE__ */ f("div", {
89
+ /* @__PURE__ */ p("div", {
89
90
  className: "flex items-center justify-between gap-2 ml-3",
90
- children: [/* @__PURE__ */ f("div", {
91
+ children: [/* @__PURE__ */ p("div", {
91
92
  className: "flex items-center gap-2 text-xs text-tertiary",
92
93
  children: [
93
- /* @__PURE__ */ d("span", {
94
- className: r(p.priority),
95
- children: p.priority
94
+ /* @__PURE__ */ f("span", {
95
+ className: i(m.priority),
96
+ children: m.priority
96
97
  }),
97
- v && S && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("span", { children: "•" }), /* @__PURE__ */ d("span", { children: b("notifCommon.archived", "Archived") })] }),
98
- /* @__PURE__ */ d("span", { children: "•" }),
99
- /* @__PURE__ */ d("time", {
100
- dateTime: p.createdAt,
101
- children: t(p.createdAt)
98
+ y && T && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("span", { children: "•" }), /* @__PURE__ */ f("span", { children: S("notifCommon.archived", "Archived") })] }),
99
+ /* @__PURE__ */ f("span", { children: "•" }),
100
+ /* @__PURE__ */ f("time", {
101
+ dateTime: m.createdAt,
102
+ children: n(m.createdAt)
102
103
  })
103
104
  ]
104
- }), p.actionUrl && /* @__PURE__ */ f("button", {
105
- onClick: T,
105
+ }), m.actionUrl && /* @__PURE__ */ p("button", {
106
+ onClick: O,
106
107
  className: "flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/80 transition-colors duration-150",
107
- "aria-label": b("notifCommon.openLink", "Open link"),
108
- children: [/* @__PURE__ */ d("span", { children: b("notifCommon.view", "View") }), /* @__PURE__ */ d(c, { size: 12 })]
108
+ "aria-label": S("notifCommon.openLink", "Open link"),
109
+ children: [/* @__PURE__ */ f("span", { children: S("notifCommon.view", "View") }), /* @__PURE__ */ f(l, { size: 12 })]
109
110
  })]
110
111
  })
111
112
  ]
112
113
  });
113
114
  }
114
115
  //#endregion
115
- export { p as NotificationCard };
116
+ export { m as NotificationCard };
116
117
 
117
118
  //# sourceMappingURL=NotificationCard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationCard.js","names":[],"sources":["../../src/components/NotificationCard.tsx"],"sourcesContent":["import { X, ExternalLink } from 'lucide-react';\nimport type { Notification } from '../types';\nimport { useTr } from '../shared/hooks/useTr';\nimport {\n formatRelativeTime,\n getPriorityColor,\n getPriorityIcon,\n getNotificationTypeIcon,\n truncateText,\n} from '../utils';\nimport { nativeImpact, nativeOpenUrl } from '../utils/nativeBridge';\n\ninterface NotificationCardProps {\n notification: Notification;\n onMarkAsRead?: (id: string) => void;\n onArchive?: (id: string) => void;\n onAction?: (notificationId: string, actionId?: string) => void;\n onClick?: (notification: Notification) => void;\n showArchivedState?: boolean;\n compact?: boolean;\n}\n\n/**\n * Notification card component\n *\n * Displays notification information with action buttons\n */\nexport function NotificationCard({\n notification,\n onMarkAsRead,\n onArchive,\n onAction,\n onClick,\n showArchivedState = false,\n compact = false,\n}: NotificationCardProps) {\n const tr = useTr();\n const isUnread = !notification.readAt;\n const isArchived = Boolean(notification.archivedAt);\n\n const handleClick = () => {\n if (onClick) {\n onClick(notification);\n }\n if (isUnread && onMarkAsRead) {\n onMarkAsRead(notification.id);\n }\n };\n\n const handleArchive = (e: React.MouseEvent) => {\n e.stopPropagation();\n if (onArchive) {\n onArchive(notification.id);\n }\n };\n\n const handleActionUrl = (e: React.MouseEvent) => {\n e.stopPropagation();\n nativeImpact('light');\n if (notification.actionUrl) {\n onAction?.(notification.id);\n const url = notification.actionUrl;\n if (url.startsWith('https://')) {\n void nativeOpenUrl(url);\n } else {\n window.open(url, '_blank');\n }\n }\n };\n\n const handleActionClick = (e: React.MouseEvent, actionId: string, actionUrl: string) => {\n e.stopPropagation();\n nativeImpact('light');\n onAction?.(notification.id, actionId);\n if (actionUrl.startsWith('https://')) {\n void nativeOpenUrl(actionUrl);\n } else {\n window.open(actionUrl, '_blank');\n }\n };\n\n return (\n <div\n className={`\n relative flex flex-col gap-2 p-4 rounded-lg border cursor-pointer\n transition-all duration-200 ease-in-out\n ${isUnread ? 'bg-accent-subtle/5 border-accent-primary/20 shadow-sm ring-1 ring-accent-primary/10' : 'bg-surface border-default opacity-75'}\n ${showArchivedState && isArchived ? 'border-dashed opacity-60' : ''}\n hover:bg-muted hover:shadow-md hover:-translate-y-0.5 hover:opacity-100\n `}\n onClick={handleClick}\n >\n {/* Unread indicator */}\n {isUnread && (\n <div className=\"absolute top-4 left-1.5 w-2.5 h-2.5 bg-accent-primary rounded-full shadow-sm shadow-accent-primary/50 animate-pulse\" />\n )}\n\n {/* Header */}\n <div className=\"flex items-start justify-between gap-2 ml-3\">\n <div className=\"flex items-center gap-2 flex-1 min-w-0\">\n <span className=\"text-base\" aria-hidden=\"true\">\n {getNotificationTypeIcon(notification.type)}\n </span>\n <h3\n className={`text-sm truncate ${isUnread ? 'font-bold text-primary' : 'font-medium text-secondary'}`}\n >\n {compact ? truncateText(notification.title, 60) : notification.title}\n </h3>\n <span className=\"text-xs\" aria-label={`Priority: ${notification.priority}`}>\n {getPriorityIcon(notification.priority)}\n </span>\n </div>\n\n {onArchive && (\n <button\n onClick={handleArchive}\n className=\"flex-shrink-0 p-1 hover:bg-muted rounded transition-colors duration-150\"\n aria-label={tr('notifCommon.archiveNotification', 'Archive notification')}\n >\n <X size={16} className=\"text-tertiary hover:text-secondary\" />\n </button>\n )}\n </div>\n\n {/* Body */}\n <div className=\"ml-3\">\n {notification.media[0]?.url && (\n <img\n src={notification.media[0].thumbnailUrl || notification.media[0].url}\n alt={notification.media[0].label || notification.title}\n className=\"mb-3 h-40 w-full rounded-md object-cover border border-default\"\n />\n )}\n <p className={`text-sm text-secondary ${compact ? 'line-clamp-2' : ''}`}>\n {compact ? truncateText(notification.body, 120) : notification.body}\n </p>\n {notification.topic && (\n <div className=\"mt-2 inline-flex items-center rounded-full bg-muted px-2 py-0.5 text-xs text-secondary\">\n {notification.topic.name}\n </div>\n )}\n </div>\n\n {notification.actions.length > 0 && !compact && (\n <div className=\"ml-3 flex flex-wrap gap-2\">\n {notification.actions.map((action) => (\n <button\n key={action.id}\n onClick={(e) => handleActionClick(e, action.id, action.url)}\n className={`rounded-md px-3 py-1.5 text-xs font-medium transition-colors ${\n action.style === 'secondary'\n ? 'bg-muted text-secondary hover:bg-muted/80'\n : action.style === 'danger'\n ? 'bg-status-error-bg-subtle text-status-error-text hover:opacity-80'\n : 'bg-accent-primary text-white hover:opacity-90'\n }`}\n >\n {action.label}\n </button>\n ))}\n </div>\n )}\n\n {/* Footer */}\n <div className=\"flex items-center justify-between gap-2 ml-3\">\n <div className=\"flex items-center gap-2 text-xs text-tertiary\">\n <span className={getPriorityColor(notification.priority)}>{notification.priority}</span>\n {showArchivedState && isArchived && (\n <>\n <span>•</span>\n <span>{tr('notifCommon.archived', 'Archived')}</span>\n </>\n )}\n <span>•</span>\n <time dateTime={notification.createdAt}>\n {formatRelativeTime(notification.createdAt)}\n </time>\n </div>\n\n {notification.actionUrl && (\n <button\n onClick={handleActionUrl}\n className=\"flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/80 transition-colors duration-150\"\n aria-label={tr('notifCommon.openLink', 'Open link')}\n >\n <span>{tr('notifCommon.view', 'View')}</span>\n <ExternalLink size={12} />\n </button>\n )}\n </div>\n </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EAAA,UAAM,KAAQ,CAAA;MACd,kBAAC,QAAD;OAAM,UAAU,EAAa;iBAC1B,EAAmB,EAAa,UAAU;OACtC,CAAA;MACH;QAEL,EAAa,aACZ,kBAAC,UAAD;KACE,SAAS;KACT,WAAU;KACV,cAAY,EAAG,wBAAwB,YAAY;eAHrD,CAKE,kBAAC,QAAD,EAAA,UAAO,EAAG,oBAAoB,OAAO,EAAQ,CAAA,EAC7C,kBAAC,GAAD,EAAc,MAAM,IAAM,CAAA,CACnB;OAEP;;GACF"}
1
+ {"version":3,"file":"NotificationCard.js","names":[],"sources":["../../src/components/NotificationCard.tsx"],"sourcesContent":["import { X, ExternalLink } from 'lucide-react';\nimport type { Notification } from '../types';\nimport { useNotificationAnalytics } from '../hooks/useNotificationAnalytics';\nimport { useTr } from '../shared/hooks/useTr';\nimport {\n formatRelativeTime,\n getPriorityColor,\n getPriorityIcon,\n getNotificationTypeIcon,\n truncateText,\n} from '../utils';\nimport { nativeImpact, nativeOpenUrl } from '../utils/nativeBridge';\n\ninterface NotificationCardProps {\n notification: Notification;\n onMarkAsRead?: (id: string) => void;\n onArchive?: (id: string) => void;\n onAction?: (notificationId: string, actionId?: string) => void;\n onClick?: (notification: Notification) => void;\n showArchivedState?: boolean;\n compact?: boolean;\n analyticsSource?: 'center' | 'panel' | 'history' | 'admin_history';\n}\n\n/**\n * Notification card component\n *\n * Displays notification information with action buttons\n */\nexport function NotificationCard({\n notification,\n onMarkAsRead,\n onArchive,\n onAction,\n onClick,\n showArchivedState = false,\n compact = false,\n analyticsSource = 'center',\n}: NotificationCardProps) {\n const tr = useTr();\n const { trackNotificationOpened } = useNotificationAnalytics();\n const isUnread = !notification.readAt;\n const isArchived = Boolean(notification.archivedAt);\n\n const handleClick = () => {\n trackNotificationOpened(notification, analyticsSource, 'card');\n if (onClick) {\n onClick(notification);\n }\n if (isUnread && onMarkAsRead) {\n onMarkAsRead(notification.id);\n }\n };\n\n const handleArchive = (e: React.MouseEvent) => {\n e.stopPropagation();\n if (onArchive) {\n onArchive(notification.id);\n }\n };\n\n const handleActionUrl = (e: React.MouseEvent) => {\n e.stopPropagation();\n nativeImpact('light');\n if (notification.actionUrl) {\n trackNotificationOpened(notification, analyticsSource, 'primary_action');\n onAction?.(notification.id);\n const url = notification.actionUrl;\n if (url.startsWith('https://')) {\n void nativeOpenUrl(url);\n } else {\n window.open(url, '_blank');\n }\n }\n };\n\n const handleActionClick = (e: React.MouseEvent, actionId: string, actionUrl: string) => {\n e.stopPropagation();\n nativeImpact('light');\n trackNotificationOpened(notification, analyticsSource, 'custom_action');\n onAction?.(notification.id, actionId);\n if (actionUrl.startsWith('https://')) {\n void nativeOpenUrl(actionUrl);\n } else {\n window.open(actionUrl, '_blank');\n }\n };\n\n return (\n <div\n className={`\n relative flex flex-col gap-2 p-4 rounded-lg border cursor-pointer\n transition-all duration-200 ease-in-out\n ${isUnread ? 'bg-accent-subtle/5 border-accent-primary/20 shadow-sm ring-1 ring-accent-primary/10' : 'bg-surface border-default opacity-75'}\n ${showArchivedState && isArchived ? 'border-dashed opacity-60' : ''}\n hover:bg-muted hover:shadow-md hover:-translate-y-0.5 hover:opacity-100\n `}\n onClick={handleClick}\n >\n {/* Unread indicator */}\n {isUnread && (\n <div className=\"absolute top-4 left-1.5 w-2.5 h-2.5 bg-accent-primary rounded-full shadow-sm shadow-accent-primary/50 animate-pulse\" />\n )}\n\n {/* Header */}\n <div className=\"flex items-start justify-between gap-2 ml-3\">\n <div className=\"flex items-center gap-2 flex-1 min-w-0\">\n <span className=\"text-base\" aria-hidden=\"true\">\n {getNotificationTypeIcon(notification.type)}\n </span>\n <h3\n className={`text-sm truncate ${isUnread ? 'font-bold text-primary' : 'font-medium text-secondary'}`}\n >\n {compact ? truncateText(notification.title, 60) : notification.title}\n </h3>\n <span className=\"text-xs\" aria-label={`Priority: ${notification.priority}`}>\n {getPriorityIcon(notification.priority)}\n </span>\n </div>\n\n {onArchive && (\n <button\n onClick={handleArchive}\n className=\"flex-shrink-0 p-1 hover:bg-muted rounded transition-colors duration-150\"\n aria-label={tr('notifCommon.archiveNotification', 'Archive notification')}\n >\n <X size={16} className=\"text-tertiary hover:text-secondary\" />\n </button>\n )}\n </div>\n\n {/* Body */}\n <div className=\"ml-3\">\n {notification.media[0]?.url && (\n <img\n src={notification.media[0].thumbnailUrl || notification.media[0].url}\n alt={notification.media[0].label || notification.title}\n className=\"mb-3 h-40 w-full rounded-md object-cover border border-default\"\n />\n )}\n <p className={`text-sm text-secondary ${compact ? 'line-clamp-2' : ''}`}>\n {compact ? truncateText(notification.body, 120) : notification.body}\n </p>\n {notification.topic && (\n <div className=\"mt-2 inline-flex items-center rounded-full bg-muted px-2 py-0.5 text-xs text-secondary\">\n {notification.topic.name}\n </div>\n )}\n </div>\n\n {notification.actions.length > 0 && !compact && (\n <div className=\"ml-3 flex flex-wrap gap-2\">\n {notification.actions.map((action) => (\n <button\n key={action.id}\n onClick={(e) => handleActionClick(e, action.id, action.url)}\n className={`rounded-md px-3 py-1.5 text-xs font-medium transition-colors ${\n action.style === 'secondary'\n ? 'bg-muted text-secondary hover:bg-muted/80'\n : action.style === 'danger'\n ? 'bg-status-error-bg-subtle text-status-error-text hover:opacity-80'\n : 'bg-accent-primary text-white hover:opacity-90'\n }`}\n >\n {action.label}\n </button>\n ))}\n </div>\n )}\n\n {/* Footer */}\n <div className=\"flex items-center justify-between gap-2 ml-3\">\n <div className=\"flex items-center gap-2 text-xs text-tertiary\">\n <span className={getPriorityColor(notification.priority)}>{notification.priority}</span>\n {showArchivedState && isArchived && (\n <>\n <span>•</span>\n <span>{tr('notifCommon.archived', 'Archived')}</span>\n </>\n )}\n <span>•</span>\n <time dateTime={notification.createdAt}>\n {formatRelativeTime(notification.createdAt)}\n </time>\n </div>\n\n {notification.actionUrl && (\n <button\n onClick={handleActionUrl}\n className=\"flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/80 transition-colors duration-150\"\n aria-label={tr('notifCommon.openLink', 'Open link')}\n >\n <span>{tr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,EAAa;OAAgB,CAAA;MACvF,KAAqB,KACpB,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,QAAD,EAAA,UAAM,KAAQ,CAAA,EACd,kBAAC,QAAD,EAAA,UAAO,EAAG,wBAAwB,WAAW,EAAQ,CAAA,CACpD,EAAA,CAAA;MAEL,kBAAC,QAAD,EAAA,UAAM,KAAQ,CAAA;MACd,kBAAC,QAAD;OAAM,UAAU,EAAa;iBAC1B,EAAmB,EAAa,UAAU;OACtC,CAAA;MACH;QAEL,EAAa,aACZ,kBAAC,UAAD;KACE,SAAS;KACT,WAAU;KACV,cAAY,EAAG,wBAAwB,YAAY;eAHrD,CAKE,kBAAC,QAAD,EAAA,UAAO,EAAG,oBAAoB,OAAO,EAAQ,CAAA,EAC7C,kBAAC,GAAD,EAAc,MAAM,IAAM,CAAA,CACnB;OAEP;;GACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationPanel.d.ts","sourceRoot":"","sources":["../../src/components/NotificationPanel.tsx"],"names":[],"mappings":"AAMA,UAAU,sBAAsB;IAC9B,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,SAAS,EAAE,EAAE,sBAAsB,kDAsGtE"}
1
+ {"version":3,"file":"NotificationPanel.d.ts","sourceRoot":"","sources":["../../src/components/NotificationPanel.tsx"],"names":[],"mappings":"AAMA,UAAU,sBAAsB;IAC9B,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,SAAS,EAAE,EAAE,sBAAsB,kDAuGtE"}
@@ -61,7 +61,8 @@ function l({ onViewAll: l }) {
61
61
  onMarkAsRead: h,
62
62
  onArchive: _,
63
63
  onAction: v,
64
- compact: !0
64
+ compact: !0,
65
+ analyticsSource: "panel"
65
66
  }, e.id))
66
67
  }) : /* @__PURE__ */ c("div", {
67
68
  className: "flex flex-col items-center justify-center p-8 text-center animate-in fade-in duration-300",
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationPanel.js","names":[],"sources":["../../src/components/NotificationPanel.tsx"],"sourcesContent":["import { X, Bell } from 'lucide-react';\nimport { useNotificationStore } from '../store/notificationStore';\nimport { useNotifications } from '../hooks';\nimport { NotificationCard } from './NotificationCard';\nimport { useTr } from '../shared/hooks/useTr';\n\ninterface NotificationPanelProps {\n onViewAll?: () => void;\n}\n\n/**\n * Notification dropdown panel\n *\n * Quick view of recent notifications that appears when clicking the bell icon\n */\nexport function NotificationPanel({ onViewAll }: NotificationPanelProps) {\n const tr = useTr();\n const { isPanelOpen, togglePanel } = useNotificationStore();\n const {\n notifications,\n unreadCount,\n markAsRead,\n markAllAsRead,\n archiveNotification,\n recordAction,\n } = useNotifications();\n\n if (!isPanelOpen) return null;\n\n // Show only the 5 most recent notifications\n const recentNotifications = notifications.slice(0, 5);\n\n return (\n <>\n {/* Backdrop */}\n <div className=\"fixed inset-0 z-40\" onClick={togglePanel} aria-hidden=\"true\" />\n\n {/* Panel */}\n <div className=\"absolute right-0 top-full mt-2 w-96 max-h-[600px] bg-surface border border-default rounded-lg shadow-lg z-50 overflow-hidden flex flex-col animate-in fade-in slide-in-from-top-2 duration-200\">\n {/* Header */}\n <div className=\"flex items-center justify-between p-4 border-b border-default\">\n <div className=\"flex items-center gap-2\">\n <Bell size={20} className=\"text-primary\" />\n <h2 className=\"text-base font-semibold text-primary\">\n {tr('notifCommon.notifications', 'Notifications')}\n </h2>\n {unreadCount > 0 && (\n <span className=\"px-2 py-0.5 text-xs font-semibold text-white bg-primary-500 rounded-full\">\n {unreadCount}\n </span>\n )}\n </div>\n\n <div className=\"flex items-center gap-2\">\n {unreadCount > 0 && (\n <button\n onClick={markAllAsRead}\n className=\"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors duration-150\"\n >\n {tr('notifCommon.markAllRead', 'Mark all read')}\n </button>\n )}\n <button\n onClick={togglePanel}\n className=\"p-1 hover:bg-muted rounded transition-colors duration-150\"\n aria-label={tr('notifCommon.closePanel', 'Close panel')}\n >\n <X size={16} className=\"text-tertiary\" />\n </button>\n </div>\n </div>\n\n {/* Notifications list */}\n <div className=\"flex-1 overflow-y-auto\">\n {recentNotifications.length > 0 ? (\n <div className=\"flex flex-col gap-2 p-2\">\n {recentNotifications.map((notification) => (\n <NotificationCard\n key={notification.id}\n notification={notification}\n onMarkAsRead={markAsRead}\n onArchive={archiveNotification}\n onAction={recordAction}\n compact\n />\n ))}\n </div>\n ) : (\n <div className=\"flex flex-col items-center justify-center p-8 text-center animate-in fade-in duration-300\">\n <Bell size={48} className=\"text-tertiary mb-4\" />\n <p className=\"text-sm text-secondary\">\n {tr('notifCommon.noNotifications', 'No notifications')}\n </p>\n <p className=\"text-xs text-tertiary mt-1\">\n {tr('notifCommon.allCaughtUp', \"You're all caught up!\")}\n </p>\n </div>\n )}\n </div>\n\n {/* Footer */}\n {recentNotifications.length > 0 && (\n <div className=\"p-3 border-t border-default\">\n <button\n onClick={() => {\n togglePanel();\n if (onViewAll) onViewAll();\n }}\n className=\"w-full py-2 text-sm text-accent-primary hover:text-accent-primary/80 font-medium transition-colors duration-150\"\n >\n {tr('notifCommon.viewAllNotifications', 'View All Notifications')}\n </button>\n </div>\n )}\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;;AAeA,SAAgB,EAAkB,EAAE,gBAAqC;CACvE,IAAM,IAAK,GAAO,EACZ,EAAE,gBAAa,mBAAgB,GAAsB,EACrD,EACJ,kBACA,gBACA,eACA,kBACA,wBACA,oBACE,GAAkB;AAEtB,KAAI,CAAC,EAAa,QAAO;CAGzB,IAAM,IAAsB,EAAc,MAAM,GAAG,EAAE;AAErD,QACE,kBAAA,GAAA,EAAA,UAAA,CAEE,kBAAC,OAAD;EAAK,WAAU;EAAqB,SAAS;EAAa,eAAY;EAAS,CAAA,EAG/E,kBAAC,OAAD;EAAK,WAAU;YAAf;GAEE,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE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otificationPanel.tsx"],"sourcesContent":["import { X, Bell } from 'lucide-react';\nimport { useNotificationStore } from '../store/notificationStore';\nimport { useNotifications } from '../hooks';\nimport { NotificationCard } from './NotificationCard';\nimport { useTr } from '../shared/hooks/useTr';\n\ninterface NotificationPanelProps {\n onViewAll?: () => void;\n}\n\n/**\n * Notification dropdown panel\n *\n * Quick view of recent notifications that appears when clicking the bell icon\n */\nexport function NotificationPanel({ onViewAll }: NotificationPanelProps) {\n const tr = useTr();\n const { isPanelOpen, togglePanel } = useNotificationStore();\n const {\n notifications,\n unreadCount,\n markAsRead,\n markAllAsRead,\n archiveNotification,\n recordAction,\n } = useNotifications();\n\n if (!isPanelOpen) return null;\n\n // Show only the 5 most recent notifications\n const recentNotifications = notifications.slice(0, 5);\n\n return (\n <>\n {/* Backdrop */}\n <div className=\"fixed inset-0 z-40\" onClick={togglePanel} aria-hidden=\"true\" />\n\n {/* Panel */}\n <div className=\"absolute right-0 top-full mt-2 w-96 max-h-[600px] bg-surface border border-default rounded-lg shadow-lg z-50 overflow-hidden flex flex-col animate-in fade-in slide-in-from-top-2 duration-200\">\n {/* Header */}\n <div className=\"flex items-center justify-between p-4 border-b border-default\">\n <div className=\"flex items-center gap-2\">\n <Bell size={20} className=\"text-primary\" />\n <h2 className=\"text-base font-semibold text-primary\">\n {tr('notifCommon.notifications', 'Notifications')}\n </h2>\n {unreadCount > 0 && (\n <span className=\"px-2 py-0.5 text-xs font-semibold text-white bg-primary-500 rounded-full\">\n {unreadCount}\n </span>\n )}\n </div>\n\n <div className=\"flex items-center gap-2\">\n {unreadCount > 0 && (\n <button\n onClick={markAllAsRead}\n className=\"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors duration-150\"\n >\n {tr('notifCommon.markAllRead', 'Mark all read')}\n </button>\n )}\n <button\n onClick={togglePanel}\n className=\"p-1 hover:bg-muted rounded transition-colors duration-150\"\n aria-label={tr('notifCommon.closePanel', 'Close panel')}\n >\n <X size={16} className=\"text-tertiary\" />\n </button>\n </div>\n </div>\n\n {/* Notifications list */}\n <div className=\"flex-1 overflow-y-auto\">\n {recentNotifications.length > 0 ? (\n <div className=\"flex flex-col gap-2 p-2\">\n {recentNotifications.map((notification) => (\n <NotificationCard\n key={notification.id}\n notification={notification}\n onMarkAsRead={markAsRead}\n onArchive={archiveNotification}\n onAction={recordAction}\n compact\n analyticsSource=\"panel\"\n />\n ))}\n </div>\n ) : (\n <div className=\"flex flex-col items-center justify-center p-8 text-center animate-in fade-in duration-300\">\n <Bell size={48} className=\"text-tertiary mb-4\" />\n <p className=\"text-sm text-secondary\">\n {tr('notifCommon.noNotifications', 'No notifications')}\n </p>\n <p className=\"text-xs text-tertiary mt-1\">\n {tr('notifCommon.allCaughtUp', \"You're all caught up!\")}\n </p>\n </div>\n )}\n </div>\n\n {/* Footer */}\n {recentNotifications.length > 0 && (\n <div className=\"p-3 border-t border-default\">\n <button\n onClick={() => {\n togglePanel();\n if (onViewAll) onViewAll();\n }}\n className=\"w-full py-2 text-sm text-accent-primary hover:text-accent-primary/80 font-medium transition-colors duration-150\"\n >\n {tr('notifCommon.viewAllNotifications', 'View All Notifications')}\n </button>\n </div>\n )}\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;;AAeA,SAAgB,EAAkB,EAAE,gBAAqC;CACvE,IAAM,IAAK,GAAO,EACZ,EAAE,gBAAa,mBAAgB,GAAsB,EACrD,EACJ,kBACA,gBACA,eACA,kBACA,wBACA,oBACE,GAAkB;AAEtB,KAAI,CAAC,EAAa,QAAO;CAGzB,IAAM,IAAsB,EAAc,MAAM,GAAG,EAAE;AAErD,QACE,kBAAA,GAAA,EAAA,UAAA,CAEE,kBAAC,OAAD;EAAK,WAAU;EAAqB,SAAS;EAAa,eAAY;EAAS,CAAA,EAG/E,kBAAC,OAAD;EAAK,WAAU;YAAf;GAEE,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,OAAD;KAAK,WAAU;eAAf;MACE,kBAAC,GAAD;OAAM,MAAM;OAAI,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fetchPolicy: "network-only" },
67
+ query: { fetchPolicy: "cache-first" },
68
68
  mutate: { fetchPolicy: "network-only" }
69
69
  }
70
70
  }), p;
@@ -1 +1 @@
1
- {"version":3,"file":"global-client.js","names":[],"sources":["../../src/graphql/global-client.ts"],"sourcesContent":["import { ApolloClient, InMemoryCache, HttpLink, from, split } from '@apollo/client';\nimport { setContext } from '@apollo/client/link/context';\nimport { onError } from '@apollo/client/link/error';\nimport { GraphQLWsLink } from '@apollo/client/link/subscriptions';\nimport { getMainDefinition } from '@apollo/client/utilities';\nimport { isAuthNetworkError, redirectToLogin } from '@burdenoff/fe-libs/shared/utils';\nimport { createClient } from 'graphql-ws';\n\nfunction hasSessionAuthErrors(\n errors: ReadonlyArray<{ message?: string; extensions?: Record<string, unknown> }> = []\n): boolean {\n return errors.some((error) => {\n const code = typeof error.extensions?.code === 'string' ? error.extensions.code : '';\n const errorCode =\n typeof error.extensions?.errorCode === 'string' ? error.extensions.errorCode : '';\n const message = (error.message ?? '').toLowerCase();\n\n return (\n code === 'UNAUTHENTICATED' ||\n errorCode === 'TOKEN_EXPIRED' ||\n message.includes('token_expired') ||\n message.includes('token expired') ||\n message.includes('session expired') ||\n message.includes('unauthorized') ||\n message.includes('unauthenticated') ||\n message.includes('authentication required') ||\n message.includes('workspace context missing')\n );\n });\n}\n\nlet globalClientInstance: InstanceType<typeof ApolloClient> | null = null;\nlet currentGlobalUrl: string | null = null;\nlet currentAuthToken: string | null = null;\n\n/**\n * Default Global Gateway URL\n * Notifications are a GLOBAL service and must use the global gateway\n */\nexport const DEFAULT_GLOBAL_GATEWAY_URL = 'https://gw-global.local.burdenoff.com/global/graphql';\n\nfunction toGraphqlUrl(url: string): string {\n const normalized = url.replace(/\\/$/, '');\n if (normalized.endsWith('/graphql')) return normalized;\n if (normalized.endsWith('/global')) return `${normalized}/graphql`;\n return `${normalized}/global/graphql`;\n}\n\nfunction toSubscriptionUrl(url: string): string {\n if (url.startsWith('https://')) return url.replace('https://', 'wss://');\n if (url.startsWith('http://')) return url.replace('http://', 'ws://');\n return url;\n}\n\n/**\n * Get or create the singleton Apollo client for global notification operations\n *\n * @param globalGatewayUrl - Global Gateway GraphQL URL (default: https://gw-global.local.burdenoff.com/global/graphql)\n * @param authToken - Optional JWT auth token\n */\nexport function getGlobalNotificationClient(\n globalGatewayUrl?: string,\n authToken?: string\n): InstanceType<typeof ApolloClient> {\n const url = toGraphqlUrl(globalGatewayUrl || DEFAULT_GLOBAL_GATEWAY_URL);\n const nextAuthToken = authToken ?? null;\n\n // Return existing instance if config hasn't changed\n if (globalClientInstance && currentGlobalUrl === url && currentAuthToken === nextAuthToken) {\n return globalClientInstance;\n }\n\n // Update current config\n currentGlobalUrl = url;\n currentAuthToken = nextAuthToken;\n\n const httpLink = new HttpLink({\n uri: url,\n });\n\n const wsLink =\n typeof window !== 'undefined'\n ? new GraphQLWsLink(\n createClient({\n url: toSubscriptionUrl(url),\n connectionParams: () => ({\n authorization: authToken ? `Bearer ${authToken}` : '',\n }),\n lazy: true,\n retryAttempts: 3,\n })\n )\n : null;\n\n const authLink = setContext((_, prevContext) => {\n return {\n headers: {\n ...(prevContext.headers as Record<string, string>),\n authorization: authToken ? `Bearer ${authToken}` : '',\n },\n };\n });\n\n const errorLink = onError(({ error }) => {\n if (!error) return;\n\n const graphQLErrors = 'errors' in error && Array.isArray(error.errors) ? error.errors : [];\n\n if (hasSessionAuthErrors(graphQLErrors)) {\n redirectToLogin();\n return;\n }\n\n if (error instanceof Error && isAuthNetworkError(error)) {\n redirectToLogin();\n }\n });\n\n const transportLink = wsLink\n ? split(\n ({ query }) => {\n const definition = getMainDefinition(query);\n return (\n definition.kind === 'OperationDefinition' && definition.operation === 'subscription'\n );\n },\n wsLink,\n httpLink\n )\n : httpLink;\n\n globalClientInstance = new ApolloClient({\n link: from([errorLink, authLink, transportLink]),\n cache: new InMemoryCache({\n typePolicies: {\n Query: {\n fields: {\n notifications: {\n merge(_existing: unknown, incoming: unknown) {\n return incoming;\n },\n },\n notificationTemplates: {\n merge(_existing: unknown, incoming: unknown) {\n return incoming;\n },\n },\n },\n },\n Notification: {\n keyFields: ['id'],\n },\n NotificationTemplate: {\n keyFields: ['id'],\n },\n },\n }),\n defaultOptions: {\n watchQuery: {\n fetchPolicy: 'cache-and-network',\n },\n query: {\n fetchPolicy: 'network-only',\n },\n mutate: {\n fetchPolicy: 'network-only',\n },\n },\n });\n\n return globalClientInstance;\n}\n\n/**\n * Reset the singleton client (useful for testing or re-initialization)\n */\nexport function resetGlobalNotificationClient(): void {\n if (globalClientInstance) {\n globalClientInstance.clearStore();\n globalClientInstance = null;\n currentGlobalUrl = null;\n currentAuthToken = null;\n }\n}\n"],"mappings":";;;;;;;;AAQA,SAAS,EACP,IAAoF,EAAE,EAC7E;AACT,QAAO,EAAO,MAAM,MAAU;EAC5B,IAAM,IAAO,OAAO,EAAM,YAAY,QAAS,WAAW,EAAM,WAAW,OAAO,IAC5E,IACJ,OAAO,EAAM,YAAY,aAAc,WAAW,EAAM,WAAW,YAAY,IAC3E,KAAW,EAAM,WAAW,IAAI,aAAa;AAEnD,SACE,MAAS,qBACT,MAAc,mBACd,EAAQ,SAAS,gBAAgB,IACjC,EAAQ,SAAS,gBAAgB,IACjC,EAAQ,SAAS,kBAAkB,IACnC,EAAQ,SAAS,eAAe,IAChC,EAAQ,SAAS,kBAAkB,IACnC,EAAQ,SAAS,0BAA0B,IAC3C,EAAQ,SAAS,4BAA4B;GAE/C;;AAGJ,IAAI,IAAiE,MACjE,IAAkC,MAClC,IAAkC;AAQtC,SAAS,EAAa,GAAqB;CACzC,IAAM,IAAa,EAAI,QAAQ,OAAO,GAAG;AAGzC,QAFI,EAAW,SAAS,WAAW,GAAS,IACxC,EAAW,SAAS,UAAU,GAAS,GAAG,EAAW,YAClD,GAAG,EAAW;;AAGvB,SAAS,EAAkB,GAAqB;AAG9C,QAFI,EAAI,WAAW,WAAW,GAAS,EAAI,QAAQ,YAAY,SAAS,GACpE,EAAI,WAAW,UAAU,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AgB;GACd,YAAY,EACV,aAAa,qBACd;GACD,OAAO,EACL,aAAa,gBACd;GACD,QAAQ,EACN,aAAa,gBACd;GACF;EACF,CAAC,EAEK"}
1
+ {"version":3,"file":"global-client.js","names":[],"sources":["../../src/graphql/global-client.ts"],"sourcesContent":["import { ApolloClient, InMemoryCache, HttpLink, from, split } from '@apollo/client';\nimport { setContext } from '@apollo/client/link/context';\nimport { onError } from '@apollo/client/link/error';\nimport { GraphQLWsLink } from '@apollo/client/link/subscriptions';\nimport { getMainDefinition } from '@apollo/client/utilities';\nimport { isAuthNetworkError, redirectToLogin } from '@burdenoff/fe-libs/shared/utils';\nimport { createClient } from 'graphql-ws';\n\nfunction hasSessionAuthErrors(\n errors: ReadonlyArray<{ message?: string; extensions?: Record<string, unknown> }> = []\n): boolean {\n return errors.some((error) => {\n const code = typeof error.extensions?.code === 'string' ? error.extensions.code : '';\n const errorCode =\n typeof error.extensions?.errorCode === 'string' ? error.extensions.errorCode : '';\n const message = (error.message ?? '').toLowerCase();\n\n return (\n code === 'UNAUTHENTICATED' ||\n errorCode === 'TOKEN_EXPIRED' ||\n message.includes('token_expired') ||\n message.includes('token expired') ||\n message.includes('session expired') ||\n message.includes('unauthorized') ||\n message.includes('unauthenticated') ||\n message.includes('authentication required') ||\n message.includes('workspace context missing')\n );\n });\n}\n\nlet globalClientInstance: InstanceType<typeof ApolloClient> | null = null;\nlet currentGlobalUrl: string | null = null;\nlet currentAuthToken: string | null = null;\n\n/**\n * Default Global Gateway URL\n * Notifications are a GLOBAL service and must use the global gateway\n */\nexport const DEFAULT_GLOBAL_GATEWAY_URL = 'https://gw-global.local.burdenoff.com/global/graphql';\n\nfunction toGraphqlUrl(url: string): string {\n const normalized = url.replace(/\\/$/, '');\n if (normalized.endsWith('/graphql')) return normalized;\n if (normalized.endsWith('/global')) return `${normalized}/graphql`;\n return `${normalized}/global/graphql`;\n}\n\nfunction toSubscriptionUrl(url: string): string {\n if (url.startsWith('https://')) return url.replace('https://', 'wss://');\n if (url.startsWith('http://')) return url.replace('http://', 'ws://');\n return url;\n}\n\n/**\n * Get or create the singleton Apollo client for global notification operations\n *\n * @param globalGatewayUrl - Global Gateway GraphQL URL (default: https://gw-global.local.burdenoff.com/global/graphql)\n * @param authToken - Optional JWT auth token\n */\nexport function getGlobalNotificationClient(\n globalGatewayUrl?: string,\n authToken?: string\n): InstanceType<typeof ApolloClient> {\n const url = toGraphqlUrl(globalGatewayUrl || DEFAULT_GLOBAL_GATEWAY_URL);\n const nextAuthToken = authToken ?? null;\n\n // Return existing instance if config hasn't changed\n if (globalClientInstance && currentGlobalUrl === url && currentAuthToken === nextAuthToken) {\n return globalClientInstance;\n }\n\n // Update current config\n currentGlobalUrl = url;\n currentAuthToken = nextAuthToken;\n\n const httpLink = new HttpLink({\n uri: url,\n });\n\n const wsLink =\n typeof window !== 'undefined'\n ? new GraphQLWsLink(\n createClient({\n url: toSubscriptionUrl(url),\n connectionParams: () => ({\n authorization: authToken ? `Bearer ${authToken}` : '',\n }),\n lazy: true,\n retryAttempts: 3,\n })\n )\n : null;\n\n const authLink = setContext((_, prevContext) => {\n return {\n headers: {\n ...(prevContext.headers as Record<string, string>),\n authorization: authToken ? `Bearer ${authToken}` : '',\n },\n };\n });\n\n const errorLink = onError(({ error }) => {\n if (!error) return;\n\n const graphQLErrors = 'errors' in error && Array.isArray(error.errors) ? error.errors : [];\n\n if (hasSessionAuthErrors(graphQLErrors)) {\n redirectToLogin();\n return;\n }\n\n if (error instanceof Error && isAuthNetworkError(error)) {\n redirectToLogin();\n }\n });\n\n const transportLink = wsLink\n ? split(\n ({ query }) => {\n const definition = getMainDefinition(query);\n return (\n definition.kind === 'OperationDefinition' && definition.operation === 'subscription'\n );\n },\n wsLink,\n httpLink\n )\n : httpLink;\n\n globalClientInstance = new ApolloClient({\n link: from([errorLink, authLink, transportLink]),\n cache: new InMemoryCache({\n typePolicies: {\n Query: {\n fields: {\n notifications: {\n merge(_existing: unknown, incoming: unknown) {\n return incoming;\n },\n },\n notificationTemplates: {\n merge(_existing: unknown, incoming: unknown) {\n return incoming;\n },\n },\n },\n },\n Notification: {\n keyFields: ['id'],\n },\n NotificationTemplate: {\n keyFields: ['id'],\n },\n },\n }),\n defaultOptions: {\n watchQuery: {\n fetchPolicy: 'cache-and-network',\n },\n query: {\n fetchPolicy: 'cache-first',\n },\n mutate: {\n fetchPolicy: 'network-only',\n },\n },\n });\n\n return globalClientInstance;\n}\n\n/**\n * Reset the singleton client (useful for testing or re-initialization)\n */\nexport function resetGlobalNotificationClient(): void {\n if (globalClientInstance) {\n globalClientInstance.clearStore();\n globalClientInstance = null;\n currentGlobalUrl = null;\n currentAuthToken = null;\n }\n}\n"],"mappings":";;;;;;;;AAQA,SAAS,EACP,IAAoF,EAAE,EAC7E;AACT,QAAO,EAAO,MAAM,MAAU;EAC5B,IAAM,IAAO,OAAO,EAAM,YAAY,QAAS,WAAW,EAAM,WAAW,OAAO,IAC5E,IACJ,OAAO,EAAM,YAAY,aAAc,WAAW,EAAM,WAAW,YAAY,IAC3E,KAAW,EAAM,WAAW,IAAI,aAAa;AAEnD,SACE,MAAS,qBACT,MAAc,mBACd,EAAQ,SAAS,gBAAgB,IACjC,EAAQ,SAAS,gBAAgB,IACjC,EAAQ,SAAS,kBAAkB,IACnC,EAAQ,SAAS,eAAe,IAChC,EAAQ,SAAS,kBAAkB,IACnC,EAAQ,SAAS,0BAA0B,IAC3C,EAAQ,SAAS,4BAA4B;GAE/C;;AAGJ,IAAI,IAAiE,MACjE,IAAkC,MAClC,IAAkC;AAQtC,SAAS,EAAa,GAAqB;CACzC,IAAM,IAAa,EAAI,QAAQ,OAAO,GAAG;AAGzC,QAFI,EAAW,SAAS,WAAW,GAAS,IACxC,EAAW,SAAS,UAAU,GAAS,GAAG,EAAW,YAClD,GAAG,EAAW;;AAGvB,SAAS,EAAkB,GAAqB;AAG9C,QAFI,EAAI,WAAW,WAAW,GAAS,EAAI,QAAQ,YAAY,SAAS,GACpE,EAAI,WAAW,U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,gBAAgB;GACd,YAAY,EACV,aAAa,qBACd;GACD,OAAO,EACL,aAAa,eACd;GACD,QAAQ,EACN,aAAa,gBACd;GACF;EACF,CAAC,EAEK"}
@@ -2,6 +2,7 @@ export { useNotifications } from './useNotifications';
2
2
  export { useNotificationAdmin } from './useNotificationAdmin';
3
3
  export { useNotificationPreferences } from './useNotificationPreferences';
4
4
  export { useNotificationTopics } from './useNotificationTopics';
5
+ export { useNotificationAnalytics } from './useNotificationAnalytics';
5
6
  export { useNotificationStore } from '../store/notificationStore';
6
7
  export { useNotification } from '../providers/NotificationProvider';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import "../providers/NotificationProvider.js";
2
2
  import "../store/notificationStore.js";
3
3
  import "./useNotifications.js";
4
+ import "./useNotificationAnalytics.js";
4
5
  import "./useNotificationAdmin.js";
5
6
  import "./useNotificationPreferences.js";
6
7
  import "./useNotificationTopics.js";
@@ -1 +1 @@
1
- {"version":3,"file":"useNotificationAdmin.d.ts","sourceRoot":"","sources":["../../src/hooks/useNotificationAdmin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AA8GvE,wBAAgB,oBAAoB;;;;;;;;;;;;;;sBA+Kq5a,CAAC;;;;;;;;mBAA6L,CAAC;;;;;;;;;;;;;;;;;;;uCA9G7lb,MAAM;0CA+BN,MAAM;4CAYN,MAAM;2DAYG,MAAM;sDAYN,MAAM,gBAAgB,MAAM,aAAa,MAAM;;EA0ClF"}
1
+ {"version":3,"file":"useNotificationAdmin.d.ts","sourceRoot":"","sources":["../../src/hooks/useNotificationAdmin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AA+GvE,wBAAgB,oBAAoB;;;;;;;;;;;;;;sBAkL2na,CAAC;;;;;;;;mBAA6L,CAAC;;;;;;;;;;;;;;;;;;;uCAhHn0a,MAAM;0CA+BN,MAAM;4CAYN,MAAM;2DAYG,MAAM;sDAaN,MAAM,gBAAgB,MAAM,aAAa,MAAM;;EA2ClF"}
@@ -1,9 +1,10 @@
1
1
  import { useNotification as e } from "../providers/NotificationProvider.js";
2
2
  import { getGlobalNotificationClient as t } from "../graphql/global-client.js";
3
3
  import { ArchiveNotificationDocument as n, CancelScheduledNotificationDocument as r, GetNotificationDocument as i, GetNotificationEventsDocument as a, GetNotificationsDocument as o, GetScheduledNotificationsDocument as s, RescheduleNotificationDocument as c, UnarchiveNotificationDocument as l } from "../generated/global-operations.js";
4
- import { useCallback as u, useEffect as d, useState as f } from "react";
4
+ import { useNotificationAnalytics as u } from "./useNotificationAnalytics.js";
5
+ import { useCallback as d, useEffect as f, useState as p } from "react";
5
6
  //#region src/hooks/useNotificationAdmin.ts
6
- var p = {
7
+ var m = {
7
8
  search: "",
8
9
  status: "all",
9
10
  channel: "all",
@@ -12,20 +13,20 @@ var p = {
12
13
  topicId: "",
13
14
  archived: "all"
14
15
  };
15
- function m(e) {
16
+ function h(e) {
16
17
  return e === "MEDIUM" ? "NORMAL" : e || "NORMAL";
17
18
  }
18
- function h(e) {
19
+ function g(e) {
19
20
  return e === "CANCELLED" ? "ARCHIVED" : e === "READ" ? "DELIVERED" : e || "PENDING";
20
21
  }
21
- function g(e) {
22
+ function _(e) {
22
23
  return {
23
24
  id: e.id,
24
25
  title: e.title,
25
26
  body: e.message,
26
27
  type: e.type,
27
- priority: m(e.priority),
28
- status: h(e.status),
28
+ priority: h(e.priority),
29
+ status: g(e.status),
29
30
  channel: e.channel,
30
31
  deliveryStatus: e.deliveryStatus ?? void 0,
31
32
  createdAt: e.createdAt,
@@ -58,7 +59,7 @@ function g(e) {
58
59
  channels: [{
59
60
  id: e.id,
60
61
  channel: e.channel,
61
- status: h(e.status),
62
+ status: g(e.status),
62
63
  sentAt: e.sentAt ?? void 0,
63
64
  deliveredAt: e.deliveredAt ?? void 0,
64
65
  failedAt: e.failedAt ?? void 0,
@@ -87,35 +88,35 @@ function g(e) {
87
88
  imageUrl: e.media?.[0]?.url ?? void 0
88
89
  };
89
90
  }
90
- function _() {
91
- let { authToken: m, apiGatewayUrl: h } = e(), [_, v] = f(p), [y, b] = f([]), [x, S] = f([]), [C, w] = f(null), [T, E] = f([]), [D, O] = f(!1), [k, A] = f(null), j = u(() => t(h ?? void 0, m ?? void 0), [h, m]), M = u(async () => {
92
- O(!0), A(null);
91
+ function v() {
92
+ let { authToken: h, apiGatewayUrl: g } = e(), { trackScheduleUpdated: v } = u(), [y, b] = p(m), [x, S] = p([]), [C, w] = p([]), [T, E] = p(null), [D, O] = p([]), [k, A] = p(!1), [j, M] = p(null), N = d(() => t(g ?? void 0, h ?? void 0), [g, h]), P = d(async () => {
93
+ A(!0), M(null);
93
94
  try {
94
- b(((await j().query({
95
+ S(((await N().query({
95
96
  query: o,
96
97
  variables: {
97
98
  filter: {
98
- ..._.search ? { search: _.search } : {},
99
- ..._.status === "all" ? {} : { status: _.status },
100
- ..._.channel === "all" ? {} : { channel: _.channel },
101
- ..._.deliveryStatus === "all" ? {} : { deliveryStatus: _.deliveryStatus },
102
- ..._.type === "all" ? {} : { type: _.type },
103
- ..._.topicId ? { topicId: _.topicId } : {},
104
- ..._.archived === "all" ? {} : { archived: _.archived === "archived" }
99
+ ...y.search ? { search: y.search } : {},
100
+ ...y.status === "all" ? {} : { status: y.status },
101
+ ...y.channel === "all" ? {} : { channel: y.channel },
102
+ ...y.deliveryStatus === "all" ? {} : { deliveryStatus: y.deliveryStatus },
103
+ ...y.type === "all" ? {} : { type: y.type },
104
+ ...y.topicId ? { topicId: y.topicId } : {},
105
+ ...y.archived === "all" ? {} : { archived: y.archived === "archived" }
105
106
  },
106
107
  limit: 100,
107
108
  offset: 0
108
109
  },
109
110
  fetchPolicy: "network-only"
110
- })).data?.notifications.items || []).map(g));
111
+ })).data?.notifications.items || []).map(_));
111
112
  } catch (e) {
112
- console.error("[useNotificationAdmin] Failed to fetch notifications:", e), A(e instanceof Error ? e.message : "Failed to fetch notifications");
113
+ console.error("[useNotificationAdmin] Failed to fetch notifications:", e), M(e instanceof Error ? e.message : "Failed to fetch notifications");
113
114
  } finally {
114
- O(!1);
115
+ A(!1);
115
116
  }
116
- }, [_, j]), N = u(async () => {
117
+ }, [y, N]), F = d(async () => {
117
118
  try {
118
- S((await j().query({
119
+ w((await N().query({
119
120
  query: s,
120
121
  variables: {
121
122
  limit: 100,
@@ -126,10 +127,10 @@ function _() {
126
127
  } catch (e) {
127
128
  console.error("[useNotificationAdmin] Failed to fetch scheduled notifications:", e);
128
129
  }
129
- }, [j]), P = u(async (e) => {
130
- A(null);
130
+ }, [N]), I = d(async (e) => {
131
+ M(null);
131
132
  try {
132
- let t = j(), [n, r] = await Promise.all([t.query({
133
+ let t = N(), [n, r] = await Promise.all([t.query({
133
134
  query: i,
134
135
  variables: { id: e },
135
136
  fetchPolicy: "network-only"
@@ -138,66 +139,68 @@ function _() {
138
139
  variables: { notificationId: e },
139
140
  fetchPolicy: "network-only"
140
141
  })]);
141
- n.data?.notification && w(g(n.data.notification)), E(r.data?.notificationEvents || []);
142
+ n.data?.notification && E(_(n.data.notification)), O(r.data?.notificationEvents || []);
142
143
  } catch (e) {
143
- console.error("[useNotificationAdmin] Failed to load notification detail:", e), A(e instanceof Error ? e.message : "Failed to load notification detail");
144
+ console.error("[useNotificationAdmin] Failed to load notification detail:", e), M(e instanceof Error ? e.message : "Failed to load notification detail");
144
145
  }
145
- }, [j]), F = u(async (e) => {
146
- await j().mutate({
146
+ }, [N]), L = d(async (e) => {
147
+ await N().mutate({
147
148
  mutation: n,
148
149
  variables: { id: e }
149
- }), await M();
150
- }, [M, j]), I = u(async (e) => {
151
- await j().mutate({
150
+ }), await P();
151
+ }, [P, N]), R = d(async (e) => {
152
+ await N().mutate({
152
153
  mutation: l,
153
154
  variables: { id: e }
154
- }), await M();
155
- }, [M, j]), L = u(async (e) => {
156
- await j().mutate({
155
+ }), await P();
156
+ }, [P, N]), z = d(async (e) => {
157
+ await N().mutate({
157
158
  mutation: r,
158
159
  variables: { id: e }
159
- }), await Promise.all([M(), N()]);
160
+ }), v({ action: "cancel" }), await Promise.all([P(), F()]);
160
161
  }, [
161
- M,
162
+ P,
163
+ F,
162
164
  N,
163
- j
164
- ]), R = u(async (e, t, n) => {
165
- await j().mutate({
165
+ v
166
+ ]), B = d(async (e, t, n) => {
167
+ await N().mutate({
166
168
  mutation: c,
167
169
  variables: { input: {
168
170
  scheduledNotificationId: e,
169
171
  scheduledFor: t,
170
172
  timezone: n
171
173
  } }
172
- }), await Promise.all([M(), N()]);
174
+ }), v({ action: "reschedule" }), await Promise.all([P(), F()]);
173
175
  }, [
174
- M,
176
+ P,
177
+ F,
175
178
  N,
176
- j
179
+ v
177
180
  ]);
178
- return d(() => {
179
- M(), N();
180
- }, [M, N]), {
181
- filters: _,
182
- setFilters: v,
183
- notifications: y,
184
- scheduledNotifications: x,
185
- selectedNotification: C,
186
- events: T,
187
- isLoading: D,
188
- error: k,
189
- refetch: M,
190
- loadNotification: P,
191
- archiveNotification: F,
192
- unarchiveNotification: I,
193
- cancelScheduledNotification: L,
194
- rescheduleNotification: R,
181
+ return f(() => {
182
+ P(), F();
183
+ }, [P, F]), {
184
+ filters: y,
185
+ setFilters: b,
186
+ notifications: x,
187
+ scheduledNotifications: C,
188
+ selectedNotification: T,
189
+ events: D,
190
+ isLoading: k,
191
+ error: j,
192
+ refetch: P,
193
+ loadNotification: I,
194
+ archiveNotification: L,
195
+ unarchiveNotification: R,
196
+ cancelScheduledNotification: z,
197
+ rescheduleNotification: B,
195
198
  clearSelection: () => {
196
- w(null), E([]);
199
+ E(null), O([]);
197
200
  }
198
201
  };
199
202
  }
200
203
  //#endregion
201
- export { _ as useNotificationAdmin };
204
+ export { v as useNotificationAdmin };
202
205
 
203
206
  //# sourceMappingURL=useNotificationAdmin.js.map