@burdenoff/microfe-notification 2026.1125.1 → 2026.1129.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NotificationRoutes.d.ts +10 -0
- package/dist/NotificationRoutes.js +76 -71
- package/dist/NotificationRoutes.js.map +1 -1
- package/dist/components/NotificationPanel.js +0 -1
- package/dist/components/NotificationPanel.js.map +1 -1
- package/dist/generated/global-operations.d.ts +58 -3
- package/dist/generated/global-operations.js +31 -23
- package/dist/generated/global-operations.js.map +1 -1
- package/dist/generated/global-types.d.ts +10933 -581
- package/dist/graphql/global-client.js +34 -34
- package/dist/hooks/useNotificationAnalytics.d.ts +1 -1
- package/dist/hooks/useNotificationAnalytics.js.map +1 -1
- package/dist/hooks/useNotifications.d.ts +7 -0
- package/dist/hooks/useNotifications.js +1 -1
- package/dist/hooks/useNotifications.js.map +1 -1
- package/dist/index.js +9 -11
- package/dist/navigation-v2/NotificationArchivedV2.js +7 -8
- package/dist/navigation-v2/NotificationArchivedV2.js.map +1 -1
- package/dist/navigation-v2/NotificationInboxV2.js +8 -9
- package/dist/navigation-v2/NotificationInboxV2.js.map +1 -1
- package/dist/navigation-v2/NotificationSettingsV2.js +0 -1
- package/dist/navigation-v2/NotificationSettingsV2.js.map +1 -1
- package/dist/pages/NotificationCenterPage.js +5 -6
- package/dist/pages/NotificationCenterPage.js.map +1 -1
- package/dist/pages/NotificationHistoryAdminPage.js +9 -10
- package/dist/pages/NotificationHistoryAdminPage.js.map +1 -1
- package/dist/pages/NotificationHistoryPage.js +5 -6
- package/dist/pages/NotificationHistoryPage.js.map +1 -1
- package/dist/pages/NotificationPreferencesPage.js +0 -1
- package/dist/pages/NotificationPreferencesPage.js.map +1 -1
- package/dist/pages/NotificationTopicsPage.js +0 -1
- package/dist/pages/NotificationTopicsPage.js.map +1 -1
- package/dist/translations/en.d.ts +80 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/v2/ArchivedRedirect.d.ts +1 -0
- package/dist/v2/ArchivedRedirect.js +14 -0
- package/dist/v2/ArchivedRedirect.js.map +1 -0
- package/dist/v2/InboxPage.d.ts +1 -0
- package/dist/v2/InboxPage.js +191 -0
- package/dist/v2/InboxPage.js.map +1 -0
- package/dist/v2/InboxRows.d.ts +10 -0
- package/dist/v2/InboxRows.js +101 -0
- package/dist/v2/InboxRows.js.map +1 -0
- package/dist/v2/KindIcon.d.ts +4 -0
- package/dist/v2/KindIcon.js +33 -0
- package/dist/v2/KindIcon.js.map +1 -0
- package/dist/v2/NotificationDetailPanel.d.ts +7 -0
- package/dist/v2/NotificationDetailPanel.js +200 -0
- package/dist/v2/NotificationDetailPanel.js.map +1 -0
- package/dist/v2/PreferencesPage.d.ts +1 -0
- package/dist/v2/PreferencesPage.js +139 -0
- package/dist/v2/PreferencesPage.js.map +1 -0
- package/dist/v2/__tests__/routeShapes.d.ts +13 -0
- package/dist/v2/model/days.d.ts +9 -0
- package/dist/v2/model/days.js +25 -0
- package/dist/v2/model/days.js.map +1 -0
- package/dist/v2/model/events.d.ts +17 -0
- package/dist/v2/model/events.js +72 -0
- package/dist/v2/model/events.js.map +1 -0
- package/dist/v2/model/icons.d.ts +6 -0
- package/dist/v2/model/icons.js +19 -0
- package/dist/v2/model/icons.js.map +1 -0
- package/dist/v2/model/inbox.d.ts +15 -0
- package/dist/v2/model/inbox.js +22 -0
- package/dist/v2/model/inbox.js.map +1 -0
- package/dist/v2/model/thing.d.ts +16 -0
- package/dist/v2/model/thing.js +41 -0
- package/dist/v2/model/thing.js.map +1 -0
- package/dist/v2/model/tr.d.ts +2 -0
- package/dist/v2/useNotificationDetail.d.ts +19 -0
- package/dist/v2/useNotificationDetail.js +65 -0
- package/dist/v2/useNotificationDetail.js.map +1 -0
- package/package.json +5 -2
- package/dist/components/index.js +0 -4
- package/dist/hooks/index.js +0 -8
- package/dist/node_modules/@apollo/client/errors/CombinedGraphQLErrors.js +0 -23
- package/dist/node_modules/@apollo/client/errors/CombinedGraphQLErrors.js.map +0 -1
- package/dist/node_modules/@apollo/client/errors/utils.js +0 -15
- package/dist/node_modules/@apollo/client/errors/utils.js.map +0 -1
- package/dist/node_modules/@apollo/client/link/core/ApolloLink.js +0 -51
- package/dist/node_modules/@apollo/client/link/core/ApolloLink.js.map +0 -1
- package/dist/node_modules/@apollo/client/link/subscriptions/index.js +0 -40
- package/dist/node_modules/@apollo/client/link/subscriptions/index.js.map +0 -1
- package/dist/node_modules/@apollo/client/link/utils/createOperation.js +0 -33
- package/dist/node_modules/@apollo/client/link/utils/createOperation.js.map +0 -1
- package/dist/node_modules/@apollo/client/utilities/caching/sizes.js +0 -5
- package/dist/node_modules/@apollo/client/utilities/caching/sizes.js.map +0 -1
- package/dist/node_modules/@apollo/client/utilities/graphql/print.js +0 -15
- package/dist/node_modules/@apollo/client/utilities/graphql/print.js.map +0 -1
- package/dist/node_modules/@apollo/client/utilities/internal/caches.js +0 -18
- package/dist/node_modules/@apollo/client/utilities/internal/caches.js.map +0 -1
- package/dist/node_modules/@apollo/client/utilities/internal/checkDocument.js +0 -20
- package/dist/node_modules/@apollo/client/utilities/internal/checkDocument.js.map +0 -1
- package/dist/node_modules/@apollo/client/utilities/internal/getMainDefinition.js +0 -16
- package/dist/node_modules/@apollo/client/utilities/internal/getMainDefinition.js.map +0 -1
- package/dist/node_modules/@apollo/client/utilities/internal/getMemoryInternals.js +0 -8
- package/dist/node_modules/@apollo/client/utilities/internal/getMemoryInternals.js.map +0 -1
- package/dist/node_modules/@apollo/client/utilities/internal/getOperationDefinition.js +0 -8
- package/dist/node_modules/@apollo/client/utilities/internal/getOperationDefinition.js.map +0 -1
- package/dist/node_modules/@apollo/client/utilities/internal/getOperationName.js +0 -7
- package/dist/node_modules/@apollo/client/utilities/internal/getOperationName.js.map +0 -1
- package/dist/node_modules/@apollo/client/utilities/internal/globals/global.js +0 -8
- package/dist/node_modules/@apollo/client/utilities/internal/globals/global.js.map +0 -1
- package/dist/node_modules/@apollo/client/utilities/internal/globals/maybe.js +0 -9
- package/dist/node_modules/@apollo/client/utilities/internal/globals/maybe.js.map +0 -1
- package/dist/node_modules/@apollo/client/utilities/internal/isNonNullObject.js +0 -7
- package/dist/node_modules/@apollo/client/utilities/internal/isNonNullObject.js.map +0 -1
- package/dist/node_modules/@apollo/client/utilities/internal/makeUniqueId.js +0 -9
- package/dist/node_modules/@apollo/client/utilities/internal/makeUniqueId.js.map +0 -1
- package/dist/node_modules/@apollo/client/utilities/internal/memoize.js +0 -22
- package/dist/node_modules/@apollo/client/utilities/internal/memoize.js.map +0 -1
- package/dist/node_modules/@apollo/client/utilities/internal/stringifyForDisplay.js +0 -9
- package/dist/node_modules/@apollo/client/utilities/internal/stringifyForDisplay.js.map +0 -1
- package/dist/node_modules/@apollo/client/utilities/invariant/index.js +0 -56
- package/dist/node_modules/@apollo/client/utilities/invariant/index.js.map +0 -1
- package/dist/node_modules/@apollo/client/version.js +0 -5
- package/dist/node_modules/@apollo/client/version.js.map +0 -1
- package/dist/node_modules/@wry/caches/lib/weak.js +0 -66
- package/dist/node_modules/@wry/caches/lib/weak.js.map +0 -1
- package/dist/node_modules/@wry/trie/lib/index.js +0 -52
- package/dist/node_modules/@wry/trie/lib/index.js.map +0 -1
- package/dist/node_modules/graphql-ws/dist/client.js +0 -279
- package/dist/node_modules/graphql-ws/dist/client.js.map +0 -1
- package/dist/node_modules/graphql-ws/dist/common-CGW11Fyb.js +0 -61
- package/dist/node_modules/graphql-ws/dist/common-CGW11Fyb.js.map +0 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/NotificationFactories.js +0 -20
- package/dist/node_modules/rxjs/dist/esm5/internal/NotificationFactories.js.map +0 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/Observable.js +0 -77
- package/dist/node_modules/rxjs/dist/esm5/internal/Observable.js.map +0 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/Subscriber.js +0 -116
- package/dist/node_modules/rxjs/dist/esm5/internal/Subscriber.js.map +0 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/Subscription.js +0 -96
- package/dist/node_modules/rxjs/dist/esm5/internal/Subscription.js.map +0 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/config.js +0 -11
- package/dist/node_modules/rxjs/dist/esm5/internal/config.js.map +0 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/observable/empty.js +0 -8
- package/dist/node_modules/rxjs/dist/esm5/internal/observable/empty.js.map +0 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js +0 -15
- package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js.map +0 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/symbol/observable.js +0 -7
- package/dist/node_modules/rxjs/dist/esm5/internal/symbol/observable.js.map +0 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js +0 -12
- package/dist/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js.map +0 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js +0 -10
- package/dist/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js.map +0 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js +0 -10
- package/dist/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js.map +0 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/errorContext.js +0 -21
- package/dist/node_modules/rxjs/dist/esm5/internal/util/errorContext.js.map +0 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/identity.js +0 -7
- package/dist/node_modules/rxjs/dist/esm5/internal/util/identity.js.map +0 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isFunction.js +0 -7
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isFunction.js.map +0 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/noop.js +0 -5
- package/dist/node_modules/rxjs/dist/esm5/internal/util/noop.js.map +0 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/pipe.js +0 -12
- package/dist/node_modules/rxjs/dist/esm5/internal/util/pipe.js.map +0 -1
- package/dist/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js +0 -13
- package/dist/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js.map +0 -1
- package/dist/node_modules/tslib/tslib.es6.js +0 -51
- package/dist/node_modules/tslib/tslib.es6.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { ApolloClient as e, ApolloLink as t, HttpLink as n, InMemoryCache as r, Observable as i, from as a, split as o } from "@apollo/client";
|
|
2
|
+
import { setContext as s } from "@apollo/client/link/context";
|
|
3
|
+
import { onError as c } from "@apollo/client/link/error";
|
|
4
|
+
import { GraphQLWsLink as l } from "@apollo/client/link/subscriptions";
|
|
5
|
+
import { getMainDefinition as u } from "@apollo/client/utilities";
|
|
6
|
+
import { isAuthNetworkError as d, redirectToLogin as f } from "@burdenoff/fe-libs/shared/utils";
|
|
7
|
+
import { getStoredOrganizationId as p, getStoredWorkspaceId as m, getStoredWorkspaceToken as h, isWorkspaceTokenValidForContext as g } from "@burdenoff/fe-libs/shared/graphql";
|
|
8
|
+
import { createClient as _ } from "graphql-ws";
|
|
9
9
|
// src/graphql/global-client.ts
|
|
10
10
|
function v(e = []) {
|
|
11
11
|
return e.some((e) => {
|
|
@@ -14,17 +14,17 @@ function v(e = []) {
|
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
function y(e) {
|
|
17
|
-
let
|
|
18
|
-
return
|
|
17
|
+
let t = u(e);
|
|
18
|
+
return t.kind === "OperationDefinition" && t.operation === "mutation";
|
|
19
19
|
}
|
|
20
20
|
function b(e) {
|
|
21
21
|
let t = e.errors;
|
|
22
22
|
return Array.isArray(t) && t.length > 0;
|
|
23
23
|
}
|
|
24
24
|
function x(e) {
|
|
25
|
-
return new
|
|
25
|
+
return new t((t, n) => {
|
|
26
26
|
let r = y(t.query) && t.getContext().autoRefreshAfterMutation !== !1 && t.getContext().skipMutationAutoRefresh !== !0;
|
|
27
|
-
return new
|
|
27
|
+
return new i((i) => {
|
|
28
28
|
let a = n(t).subscribe({
|
|
29
29
|
next: (t) => {
|
|
30
30
|
i.next(t), r && !b(t) && e()?.refetchQueries({ include: "active" });
|
|
@@ -52,44 +52,44 @@ function D(e) {
|
|
|
52
52
|
}
|
|
53
53
|
var O = { preferWorkspaceAuth: !0 };
|
|
54
54
|
function k() {
|
|
55
|
-
let e =
|
|
55
|
+
let e = m();
|
|
56
56
|
if (!e) return null;
|
|
57
|
-
let t =
|
|
58
|
-
return
|
|
57
|
+
let t = h();
|
|
58
|
+
return g(t, {
|
|
59
59
|
workspaceId: e,
|
|
60
|
-
organizationId:
|
|
60
|
+
organizationId: p()
|
|
61
61
|
}) ? t : null;
|
|
62
62
|
}
|
|
63
|
-
function A(
|
|
64
|
-
let
|
|
65
|
-
if (S && C ===
|
|
66
|
-
C =
|
|
67
|
-
let
|
|
68
|
-
url: D(
|
|
69
|
-
connectionParams: () => ({ authorization:
|
|
63
|
+
function A(t, i) {
|
|
64
|
+
let p = E(t || "https://gw-global.local.burdenoff.com/global/graphql"), m = i ?? null;
|
|
65
|
+
if (S && C === p && w === m) return S;
|
|
66
|
+
C = p, w = m;
|
|
67
|
+
let h = new n({ uri: p }), g = typeof window < "u" ? new l(_({
|
|
68
|
+
url: D(p),
|
|
69
|
+
connectionParams: () => ({ authorization: i ? `Bearer ${i}` : "" }),
|
|
70
70
|
lazy: !0,
|
|
71
71
|
retryAttempts: 3
|
|
72
|
-
})) : null, y =
|
|
72
|
+
})) : null, y = s((e, t) => {
|
|
73
73
|
let n = t.preferWorkspaceAuth === !0 ? k() : null;
|
|
74
74
|
return { headers: {
|
|
75
75
|
...t.headers,
|
|
76
|
-
authorization:
|
|
76
|
+
authorization: i ? `Bearer ${i}` : "",
|
|
77
77
|
...n ? { "x-workspace-authorization": `Bearer ${n}` } : {}
|
|
78
78
|
} };
|
|
79
|
-
}), b =
|
|
80
|
-
e && (v("errors" in e && Array.isArray(e.errors) ? e.errors : []) || e instanceof Error &&
|
|
81
|
-
}), T =
|
|
82
|
-
let
|
|
83
|
-
return
|
|
84
|
-
},
|
|
85
|
-
return S = new
|
|
86
|
-
link:
|
|
79
|
+
}), b = c(({ error: e }) => {
|
|
80
|
+
e && (v("errors" in e && Array.isArray(e.errors) ? e.errors : []) || e instanceof Error && d(e)) && f();
|
|
81
|
+
}), T = g ? o(({ query: e }) => {
|
|
82
|
+
let t = u(e);
|
|
83
|
+
return t.kind === "OperationDefinition" && t.operation === "subscription";
|
|
84
|
+
}, g, h) : h, O = x(() => S);
|
|
85
|
+
return S = new e({
|
|
86
|
+
link: a([
|
|
87
87
|
b,
|
|
88
88
|
O,
|
|
89
89
|
y,
|
|
90
90
|
T
|
|
91
91
|
]),
|
|
92
|
-
cache: new
|
|
92
|
+
cache: new r({ typePolicies: {
|
|
93
93
|
Query: { fields: {
|
|
94
94
|
notifications: { merge(e, t) {
|
|
95
95
|
return t;
|
|
@@ -4,7 +4,7 @@ interface NotificationAnalyticsPayload {
|
|
|
4
4
|
source?: 'center' | 'panel' | 'history' | 'preferences' | 'admin_history' | 'composer' | 'template_editor';
|
|
5
5
|
action?: 'open' | 'set' | 'reset' | 'send' | 'create' | 'update' | 'cancel' | 'reschedule';
|
|
6
6
|
interaction?: 'card' | 'primary_action' | 'custom_action';
|
|
7
|
-
scope?: 'GLOBAL' | 'CHANNEL' | 'TYPE' | 'TOPIC';
|
|
7
|
+
scope?: 'GLOBAL' | 'CHANNEL' | 'TYPE' | 'TOPIC' | 'CATEGORY';
|
|
8
8
|
channel?: string;
|
|
9
9
|
type?: string;
|
|
10
10
|
priority?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNotificationAnalytics.js","names":["toNotificationOpenPayload","notification","useNotificationAnalytics","eventBus","useEventBus","emit","useCallback","name","payload","source","interaction","input"],"sources":["../../src/hooks/useNotificationAnalytics.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useEventBus } from '@burdenoff/fe-libs/shared/events';\nimport type { Notification, NotificationPreferenceScope } from '../types';\nimport type {\n NotificationChannelType,\n NotificationPriorityEnum,\n NotificationTypeEnum,\n} from './useSendNotification';\n\ntype NotificationAnalyticsName =\n | 'notification.item.opened'\n | 'notification.preference.updated'\n | 'notification.admin.sent'\n | 'notification.template.saved'\n | 'notification.schedule.updated';\n\ninterface NotificationAnalyticsPayload {\n source?:\n | 'center'\n | 'panel'\n | 'history'\n | 'preferences'\n | 'admin_history'\n | 'composer'\n | 'template_editor';\n action?: 'open' | 'set' | 'reset' | 'send' | 'create' | 'update' | 'cancel' | 'reschedule';\n interaction?: 'card' | 'primary_action' | 'custom_action';\n scope?: 'GLOBAL' | 'CHANNEL' | 'TYPE' | 'TOPIC';\n channel?: string;\n type?: string;\n priority?: string;\n mode?: 'compose' | 'template';\n recipientSource?: 'manual' | 'directory';\n recipientCount?: number;\n successCount?: number;\n failedCount?: number;\n scheduled?: boolean;\n includeInApp?: boolean;\n enabled?: boolean;\n hasActions?: boolean;\n hasMedia?: boolean;\n hasHtml?: boolean;\n variableCount?: number;\n}\n\ninterface NotificationAnalyticsEventBus {\n emit: (\n name: NotificationAnalyticsName,\n payload: NotificationAnalyticsPayload,\n options?: { component?: string }\n ) => void;\n}\n\ntype NotificationAnalyticsSource = NonNullable<NotificationAnalyticsPayload['source']>;\ntype NotificationAnalyticsAction = NonNullable<NotificationAnalyticsPayload['action']>;\ntype NotificationInteraction = NonNullable<NotificationAnalyticsPayload['interaction']>;\n\ninterface NotificationSentInput {\n mode: 'compose' | 'template';\n channel: NotificationChannelType;\n type?: NotificationTypeEnum | string;\n priority?: NotificationPriorityEnum | string;\n recipientSource: 'manual' | 'directory';\n recipientCount: number;\n successCount?: number;\n failedCount?: number;\n scheduled: boolean;\n includeInApp: boolean;\n hasActions: boolean;\n hasMedia: boolean;\n}\n\ninterface TemplateSavedInput {\n action: Extract<NotificationAnalyticsAction, 'create' | 'update'>;\n channel?: string;\n type?: string;\n variableCount: number;\n hasHtml?: boolean;\n}\n\ninterface PreferenceUpdatedInput {\n action: Extract<NotificationAnalyticsAction, 'set' | 'reset'>;\n scope: NotificationPreferenceScope;\n channel?: string;\n type?: string;\n enabled?: boolean;\n}\n\ninterface ScheduleUpdatedInput {\n action: Extract<NotificationAnalyticsAction, 'cancel' | 'reschedule'>;\n}\n\nfunction toNotificationOpenPayload(\n notification: Notification,\n source: NotificationAnalyticsSource,\n interaction: NotificationInteraction\n): NotificationAnalyticsPayload {\n return {\n source,\n action: 'open',\n interaction,\n channel: notification.channel,\n type: notification.type,\n priority: notification.priority,\n hasActions: Boolean(notification.actionUrl || notification.actions.length > 0),\n hasMedia: notification.media.length > 0,\n };\n}\n\nexport function useNotificationAnalytics() {\n const eventBus = useEventBus();\n\n const emit = useCallback(\n (name: NotificationAnalyticsName, payload: NotificationAnalyticsPayload) => {\n // The runtime event bus accepts string names; this local typed facade keeps\n // notification emissions constrained to the sparse Rybbit allowlist while\n // consuming app shells roll forward to the updated fe-libs event registry.\n const notificationEventBus = eventBus as unknown as NotificationAnalyticsEventBus;\n notificationEventBus.emit(name, payload, { component: 'microfe-notification' });\n },\n [eventBus]\n );\n\n const trackNotificationOpened = useCallback(\n (\n notification: Notification,\n source: NotificationAnalyticsSource,\n interaction: NotificationInteraction\n ) =>\n emit(\n 'notification.item.opened',\n toNotificationOpenPayload(notification, source, interaction)\n ),\n [emit]\n );\n\n const trackPreferenceUpdated = useCallback(\n (input: PreferenceUpdatedInput) =>\n emit('notification.preference.updated', {\n source: 'preferences',\n action: input.action,\n scope: input.scope,\n channel: input.channel,\n type: input.type,\n enabled: input.enabled,\n }),\n [emit]\n );\n\n const trackNotificationSent = useCallback(\n (input: NotificationSentInput) =>\n emit('notification.admin.sent', {\n source: 'composer',\n action: 'send',\n mode: input.mode,\n channel: input.channel,\n type: input.type,\n priority: input.priority,\n recipientSource: input.recipientSource,\n recipientCount: input.recipientCount,\n successCount: input.successCount,\n failedCount: input.failedCount,\n scheduled: input.scheduled,\n includeInApp: input.includeInApp,\n hasActions: input.hasActions,\n hasMedia: input.hasMedia,\n }),\n [emit]\n );\n\n const trackTemplateSaved = useCallback(\n (input: TemplateSavedInput) =>\n emit('notification.template.saved', {\n source: 'template_editor',\n action: input.action,\n channel: input.channel,\n type: input.type,\n variableCount: input.variableCount,\n hasHtml: input.hasHtml,\n }),\n [emit]\n );\n\n const trackScheduleUpdated = useCallback(\n (input: ScheduleUpdatedInput) =>\n emit('notification.schedule.updated', {\n source: 'admin_history',\n action: input.action,\n scheduled: input.action === 'reschedule',\n }),\n [emit]\n );\n\n return {\n trackNotificationOpened,\n trackPreferenceUpdated,\n trackNotificationSent,\n trackTemplateSaved,\n trackScheduleUpdated,\n };\n}\n"],"mappings":";;;AA4FA,SAASA,EACP,GACA,GACA,GAC8B;CAC9B,OAAO;EACL;EACA,QAAQ;EACR;EACA,SAASC,EAAa;EACtB,MAAMA,EAAa;EACnB,UAAUA,EAAa;EACvB,YAAY,GAAQA,EAAa,aAAaA,EAAa,QAAQ,SAAS;EAC5E,UAAUA,EAAa,MAAM,SAAS;CACxC;AACF;AAEA,SAAgBC,IAA2B;CACzC,IAAMC,IAAWC,EAAY,GAEvBC,IAAOC,GACV,GAAiC,MAA0C;EAK1E,EAAqB,KAAKC,GAAMC,GAAS,EAAE,WAAW,uBAAuB,CAAC;CAChF,GACA,CAACL,CAAQ,CACX;CAwEA,OAAO;EACL,yBAvE8BG,GAE5B,GACA,GACA,MAEAD,EACE,4BACAL,EAA0BC,GAAcQ,GAAQC,CAAW,CAC7D,GACF,CAACL,CAAI,CA6DL;EACA,wBA3D6BC,GAC5B,MACCD,EAAK,mCAAmC;GACtC,QAAQ;GACR,QAAQM,EAAM;GACd,OAAOA,EAAM;GACb,SAASA,EAAM;GACf,MAAMA,EAAM;GACZ,SAASA,EAAM;EACjB,CAAC,GACH,CAACN,CAAI,CAiDL;EACA,uBA/C4BC,GAC3B,MACCD,EAAK,2BAA2B;GAC9B,QAAQ;GACR,QAAQ;GACR,MAAMM,EAAM;GACZ,SAASA,EAAM;GACf,MAAMA,EAAM;GACZ,UAAUA,EAAM;GAChB,iBAAiBA,EAAM;GACvB,gBAAgBA,EAAM;GACtB,cAAcA,EAAM;GACpB,aAAaA,EAAM;GACnB,WAAWA,EAAM;GACjB,cAAcA,EAAM;GACpB,YAAYA,EAAM;GAClB,UAAUA,EAAM;EAClB,CAAC,GACH,CAACN,CAAI,CA6BL;EACA,oBA3ByBC,GACxB,MACCD,EAAK,+BAA+B;GAClC,QAAQ;GACR,QAAQM,EAAM;GACd,SAASA,EAAM;GACf,MAAMA,EAAM;GACZ,eAAeA,EAAM;GACrB,SAASA,EAAM;EACjB,CAAC,GACH,CAACN,CAAI,CAiBL;EACA,sBAf2BC,GAC1B,MACCD,EAAK,iCAAiC;GACpC,QAAQ;GACR,QAAQM,EAAM;GACd,WAAWA,EAAM,WAAW;EAC9B,CAAC,GACH,CAACN,CAAI,CAQL;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"useNotificationAnalytics.js","names":["toNotificationOpenPayload","notification","useNotificationAnalytics","eventBus","useEventBus","emit","useCallback","name","payload","source","interaction","input"],"sources":["../../src/hooks/useNotificationAnalytics.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useEventBus } from '@burdenoff/fe-libs/shared/events';\nimport type { Notification, NotificationPreferenceScope } from '../types';\nimport type {\n NotificationChannelType,\n NotificationPriorityEnum,\n NotificationTypeEnum,\n} from './useSendNotification';\n\ntype NotificationAnalyticsName =\n | 'notification.item.opened'\n | 'notification.preference.updated'\n | 'notification.admin.sent'\n | 'notification.template.saved'\n | 'notification.schedule.updated';\n\ninterface NotificationAnalyticsPayload {\n source?:\n | 'center'\n | 'panel'\n | 'history'\n | 'preferences'\n | 'admin_history'\n | 'composer'\n | 'template_editor';\n action?: 'open' | 'set' | 'reset' | 'send' | 'create' | 'update' | 'cancel' | 'reschedule';\n interaction?: 'card' | 'primary_action' | 'custom_action';\n scope?: 'GLOBAL' | 'CHANNEL' | 'TYPE' | 'TOPIC' | 'CATEGORY';\n channel?: string;\n type?: string;\n priority?: string;\n mode?: 'compose' | 'template';\n recipientSource?: 'manual' | 'directory';\n recipientCount?: number;\n successCount?: number;\n failedCount?: number;\n scheduled?: boolean;\n includeInApp?: boolean;\n enabled?: boolean;\n hasActions?: boolean;\n hasMedia?: boolean;\n hasHtml?: boolean;\n variableCount?: number;\n}\n\ninterface NotificationAnalyticsEventBus {\n emit: (\n name: NotificationAnalyticsName,\n payload: NotificationAnalyticsPayload,\n options?: { component?: string }\n ) => void;\n}\n\ntype NotificationAnalyticsSource = NonNullable<NotificationAnalyticsPayload['source']>;\ntype NotificationAnalyticsAction = NonNullable<NotificationAnalyticsPayload['action']>;\ntype NotificationInteraction = NonNullable<NotificationAnalyticsPayload['interaction']>;\n\ninterface NotificationSentInput {\n mode: 'compose' | 'template';\n channel: NotificationChannelType;\n type?: NotificationTypeEnum | string;\n priority?: NotificationPriorityEnum | string;\n recipientSource: 'manual' | 'directory';\n recipientCount: number;\n successCount?: number;\n failedCount?: number;\n scheduled: boolean;\n includeInApp: boolean;\n hasActions: boolean;\n hasMedia: boolean;\n}\n\ninterface TemplateSavedInput {\n action: Extract<NotificationAnalyticsAction, 'create' | 'update'>;\n channel?: string;\n type?: string;\n variableCount: number;\n hasHtml?: boolean;\n}\n\ninterface PreferenceUpdatedInput {\n action: Extract<NotificationAnalyticsAction, 'set' | 'reset'>;\n scope: NotificationPreferenceScope;\n channel?: string;\n type?: string;\n enabled?: boolean;\n}\n\ninterface ScheduleUpdatedInput {\n action: Extract<NotificationAnalyticsAction, 'cancel' | 'reschedule'>;\n}\n\nfunction toNotificationOpenPayload(\n notification: Notification,\n source: NotificationAnalyticsSource,\n interaction: NotificationInteraction\n): NotificationAnalyticsPayload {\n return {\n source,\n action: 'open',\n interaction,\n channel: notification.channel,\n type: notification.type,\n priority: notification.priority,\n hasActions: Boolean(notification.actionUrl || notification.actions.length > 0),\n hasMedia: notification.media.length > 0,\n };\n}\n\nexport function useNotificationAnalytics() {\n const eventBus = useEventBus();\n\n const emit = useCallback(\n (name: NotificationAnalyticsName, payload: NotificationAnalyticsPayload) => {\n // The runtime event bus accepts string names; this local typed facade keeps\n // notification emissions constrained to the sparse Rybbit allowlist while\n // consuming app shells roll forward to the updated fe-libs event registry.\n const notificationEventBus = eventBus as unknown as NotificationAnalyticsEventBus;\n notificationEventBus.emit(name, payload, { component: 'microfe-notification' });\n },\n [eventBus]\n );\n\n const trackNotificationOpened = useCallback(\n (\n notification: Notification,\n source: NotificationAnalyticsSource,\n interaction: NotificationInteraction\n ) =>\n emit(\n 'notification.item.opened',\n toNotificationOpenPayload(notification, source, interaction)\n ),\n [emit]\n );\n\n const trackPreferenceUpdated = useCallback(\n (input: PreferenceUpdatedInput) =>\n emit('notification.preference.updated', {\n source: 'preferences',\n action: input.action,\n scope: input.scope,\n channel: input.channel,\n type: input.type,\n enabled: input.enabled,\n }),\n [emit]\n );\n\n const trackNotificationSent = useCallback(\n (input: NotificationSentInput) =>\n emit('notification.admin.sent', {\n source: 'composer',\n action: 'send',\n mode: input.mode,\n channel: input.channel,\n type: input.type,\n priority: input.priority,\n recipientSource: input.recipientSource,\n recipientCount: input.recipientCount,\n successCount: input.successCount,\n failedCount: input.failedCount,\n scheduled: input.scheduled,\n includeInApp: input.includeInApp,\n hasActions: input.hasActions,\n hasMedia: input.hasMedia,\n }),\n [emit]\n );\n\n const trackTemplateSaved = useCallback(\n (input: TemplateSavedInput) =>\n emit('notification.template.saved', {\n source: 'template_editor',\n action: input.action,\n channel: input.channel,\n type: input.type,\n variableCount: input.variableCount,\n hasHtml: input.hasHtml,\n }),\n [emit]\n );\n\n const trackScheduleUpdated = useCallback(\n (input: ScheduleUpdatedInput) =>\n emit('notification.schedule.updated', {\n source: 'admin_history',\n action: input.action,\n scheduled: input.action === 'reschedule',\n }),\n [emit]\n );\n\n return {\n trackNotificationOpened,\n trackPreferenceUpdated,\n trackNotificationSent,\n trackTemplateSaved,\n trackScheduleUpdated,\n };\n}\n"],"mappings":";;;AA4FA,SAASA,EACP,GACA,GACA,GAC8B;CAC9B,OAAO;EACL;EACA,QAAQ;EACR;EACA,SAASC,EAAa;EACtB,MAAMA,EAAa;EACnB,UAAUA,EAAa;EACvB,YAAY,GAAQA,EAAa,aAAaA,EAAa,QAAQ,SAAS;EAC5E,UAAUA,EAAa,MAAM,SAAS;CACxC;AACF;AAEA,SAAgBC,IAA2B;CACzC,IAAMC,IAAWC,EAAY,GAEvBC,IAAOC,GACV,GAAiC,MAA0C;EAK1E,EAAqB,KAAKC,GAAMC,GAAS,EAAE,WAAW,uBAAuB,CAAC;CAChF,GACA,CAACL,CAAQ,CACX;CAwEA,OAAO;EACL,yBAvE8BG,GAE5B,GACA,GACA,MAEAD,EACE,4BACAL,EAA0BC,GAAcQ,GAAQC,CAAW,CAC7D,GACF,CAACL,CAAI,CA6DL;EACA,wBA3D6BC,GAC5B,MACCD,EAAK,mCAAmC;GACtC,QAAQ;GACR,QAAQM,EAAM;GACd,OAAOA,EAAM;GACb,SAASA,EAAM;GACf,MAAMA,EAAM;GACZ,SAASA,EAAM;EACjB,CAAC,GACH,CAACN,CAAI,CAiDL;EACA,uBA/C4BC,GAC3B,MACCD,EAAK,2BAA2B;GAC9B,QAAQ;GACR,QAAQ;GACR,MAAMM,EAAM;GACZ,SAASA,EAAM;GACf,MAAMA,EAAM;GACZ,UAAUA,EAAM;GAChB,iBAAiBA,EAAM;GACvB,gBAAgBA,EAAM;GACtB,cAAcA,EAAM;GACpB,aAAaA,EAAM;GACnB,WAAWA,EAAM;GACjB,cAAcA,EAAM;GACpB,YAAYA,EAAM;GAClB,UAAUA,EAAM;EAClB,CAAC,GACH,CAACN,CAAI,CA6BL;EACA,oBA3ByBC,GACxB,MACCD,EAAK,+BAA+B;GAClC,QAAQ;GACR,QAAQM,EAAM;GACd,SAASA,EAAM;GACf,MAAMA,EAAM;GACZ,eAAeA,EAAM;GACrB,SAASA,EAAM;EACjB,CAAC,GACH,CAACN,CAAI,CAiBL;EACA,sBAf2BC,GAC1B,MACCD,EAAK,iCAAiC;GACpC,QAAQ;GACR,QAAQM,EAAM;GACd,WAAWA,EAAM,WAAW;EAC9B,CAAC,GACH,CAACN,CAAI,CAQL;CACF;AACF"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { Notification, NotificationFilter } from '../types';
|
|
2
|
+
import { NotificationFieldsFragment } from '../generated/global-operations';
|
|
3
|
+
/**
|
|
4
|
+
* Backend Notification item type derived from the generated query
|
|
5
|
+
*/
|
|
6
|
+
type BackendNotification = NotificationFieldsFragment;
|
|
2
7
|
interface UseNotificationsOptions {
|
|
3
8
|
baseFilter?: Partial<NotificationFilter>;
|
|
4
9
|
unreadFilter?: Record<string, unknown>;
|
|
5
10
|
}
|
|
11
|
+
/** The GraphQL notification as the module's `Notification` (also used by the v2 detail panel). */
|
|
12
|
+
export declare function mapBackendToMfeNotification(n: BackendNotification): Notification;
|
|
6
13
|
/**
|
|
7
14
|
* Hook to manage notifications with real GraphQL backend integration.
|
|
8
15
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNotifications.js","names":["NotificationOps.GetNotificationsDocument","NotificationOps.GetMyUnreadNotificationCountDocument","NotificationOps.MarkNotificationAsReadDocument","NotificationOps.MarkAllMyNotificationsAsReadDocument","NotificationOps.ArchiveNotificationDocument","NotificationOps.ArchiveNotificationsDocument","NotificationOps.UnarchiveNotificationDocument","NotificationOps.RecordNotificationActionDocument","NotificationOps.NotificationReceivedDocument","NotificationOps.UnreadCountUpdatedDocument","mapBackendToMfeNotification","n","mapNotificationType","mapPriority","action","item","mapStatus","t","p","s","buildBackendFilter","backend","filter","mergeNotificationFilter","baseFilter","useNotifications","useNotification","setStoreUnreadCount","useNotificationStore","notifications","setNotifications","useState","selectedNotification","setSelectedNotification","isLoading","setIsLoading","error","setError","hasMore","setHasMore","total","setTotal","isLoadingMore","setIsLoadingMore","loadingMoreRef","useRef","listGenerationRef","pagedIdsRef","refreshSeqRef","replacingListRef","notificationsRef","effectiveFilter","useMemo","notificationFilter","options","debouncedFilter","setDebouncedFilter","timeout","getClient","useCallback","getGlobalNotificationClient","apiGatewayUrl","authToken","fetchNotifications","generation","setIsLoadingNotifications","result","USER_NOTIFICATION_CONTEXT","GetNotificationsDocument","mapped","notification","err","message","fetchUnreadCount","GetMyUnreadNotificationCountDocument","loadMore","pageWindow","nextNotificationWindow","more","appendNotificationPage","prev","refreshFirstPage","refresh","freshTotal","firstPageHasMore","firstPage","items","merged","mergeRefreshedFirstPage","handleMarkAsRead","MarkNotificationAsReadDocument","notificationId","unreadCount","handleMarkAllAsRead","MarkAllMyNotificationsAsReadDocument","handleArchive","ArchiveNotificationDocument","handleBulkArchive","ArchiveNotificationsDocument","idsSet","notificationIds","handleUnarchive","UnarchiveNotificationDocument","handleRecordAction","RecordNotificationActionDocument","useEffect","currentUser","client","notificationSubscription","NotificationReceivedDocument","eventBus","unreadSubscription","UnreadCountUpdatedDocument","nextCount","handleVisibilityChange","updateNotificationFilter","resetNotificationFilter"],"sources":["../../src/hooks/useNotifications.ts"],"sourcesContent":["import { useState, useCallback, useEffect, useMemo, useRef } from 'react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient, USER_NOTIFICATION_CONTEXT } from '../graphql/global-client';\nimport { useNotificationStore } from '../store/notificationStore';\nimport type { Notification, NotificationFilter } from '../types';\nimport {\n NOTIFICATION_PAGE_SIZE,\n appendNotificationPage,\n mergeRefreshedFirstPage,\n nextNotificationWindow,\n} from './notificationPaging';\nimport * as NotificationOps from '../generated/global-operations';\nimport type {\n GetNotificationsQuery,\n GetMyUnreadNotificationCountQuery,\n NotificationFieldsFragment,\n NotificationReceivedSubscription,\n UnreadCountUpdatedSubscription,\n} from '../generated/global-operations';\n\n// ---------------------------------------------------------------------------\n// GraphQL Operations — using generated Document nodes from global-operations\n// ---------------------------------------------------------------------------\n\n/**\n * Backend Notification item type derived from the generated query\n */\ntype BackendNotification = NotificationFieldsFragment;\n\ninterface UseNotificationsOptions {\n baseFilter?: Partial<NotificationFilter>;\n unreadFilter?: Record<string, unknown>;\n}\n\n// ---------------------------------------------------------------------------\n// Mapping helpers — backend → MFE types\n// ---------------------------------------------------------------------------\n\nfunction mapBackendToMfeNotification(n: BackendNotification): Notification {\n return {\n id: n.id,\n type: mapNotificationType(n.type),\n priority: mapPriority(n.priority),\n title: n.title,\n body: n.message,\n actionUrl: n.redirectUrl ?? undefined,\n actions: (n.actions || []).map((action) => ({\n id: action.id,\n label: action.label,\n url: action.url,\n style: action.style ?? undefined,\n actionType: action.actionType ?? undefined,\n metadata: action.metadata ?? undefined,\n })),\n appName: n.appName ?? undefined,\n archivedAt: n.archivedAt ?? undefined,\n channel: n.channel as Notification['channel'],\n clickedAt: n.clickedAt ?? undefined,\n deliveredAt: n.deliveredAt ?? undefined,\n deliveryStatus: n.deliveryStatus ?? undefined,\n htmlBody: n.htmlMessage ?? undefined,\n media: (n.media || []).map((item) => ({\n url: item.url,\n label: item.label ?? undefined,\n kind: item.kind ?? undefined,\n contentType: item.contentType ?? undefined,\n thumbnailUrl: item.thumbnailUrl ?? undefined,\n })),\n openedAt: n.openedAt ?? undefined,\n recipientEmail: n.recipientEmail ?? undefined,\n recipientPhone: n.recipientPhone ?? undefined,\n scheduledFor: n.scheduledFor ?? undefined,\n scheduledNotification: n.scheduledNotification\n ? {\n id: n.scheduledNotification.id,\n scheduledFor: n.scheduledNotification.scheduledFor,\n status: n.scheduledNotification.status,\n timezone: n.scheduledNotification.timezone ?? undefined,\n }\n : undefined,\n sentAt: n.sentAt ?? undefined,\n status: mapStatus(n.status),\n readAt: n.readAt ?? undefined,\n createdAt: n.createdAt,\n channels: [\n {\n id: n.id,\n channel: n.channel as Notification['channel'],\n status: mapStatus(n.status),\n sentAt: n.sentAt ?? undefined,\n deliveredAt: n.deliveredAt ?? undefined,\n failedAt: n.failedAt ?? undefined,\n errorCode: n.errorCode ?? undefined,\n errorMessage: n.errorMessage ?? undefined,\n },\n ],\n metadata: n.metadata ?? undefined,\n topic: n.topic\n ? {\n id: n.topic.id,\n name: n.topic.name,\n slug: n.topic.slug,\n type: mapNotificationType(n.topic.type),\n }\n : undefined,\n topicId: n.topicId ?? undefined,\n };\n}\n\nfunction mapNotificationType(t: string) {\n const map: Record<string, Notification['type']> = {\n SYSTEM: 'SYSTEM',\n TRANSACTIONAL: 'TRANSACTIONAL',\n MARKETING: 'MARKETING',\n ALERT: 'ALERT',\n };\n return map[t] || 'SYSTEM';\n}\n\nfunction mapPriority(p: string) {\n const map: Record<string, Notification['priority']> = {\n LOW: 'LOW',\n MEDIUM: 'NORMAL',\n HIGH: 'HIGH',\n URGENT: 'URGENT',\n };\n return map[p] || 'NORMAL';\n}\n\nfunction mapStatus(s: string) {\n const map: Record<string, Notification['status']> = {\n DRAFT: 'PENDING',\n PENDING: 'PENDING',\n SCHEDULED: 'PENDING',\n TRIGGERED: 'SENT',\n SENT: 'SENT',\n DELIVERED: 'DELIVERED',\n READ: 'DELIVERED',\n FAILED: 'FAILED',\n CANCELLED: 'ARCHIVED',\n EXPIRED: 'ARCHIVED',\n };\n return map[s] || 'PENDING';\n}\n\n// ---------------------------------------------------------------------------\n// Build the backend filter from the MFE NotificationFilter shape\n// ---------------------------------------------------------------------------\n\nfunction buildBackendFilter(filter: NotificationFilter) {\n const backend: Record<string, unknown> = {};\n\n // Type filter — map MFE type names to backend enum\n if (filter.type !== 'ALL') {\n const typeMap: Record<string, string> = {\n SYSTEM: 'SYSTEM',\n ACTIVITY: 'TRANSACTIONAL',\n BILLING: 'TRANSACTIONAL',\n SECURITY: 'ALERT',\n SOCIAL: 'MARKETING',\n REMINDER: 'SYSTEM',\n };\n backend.type = typeMap[filter.type] || filter.type;\n }\n\n // Priority filter\n if (filter.priority !== 'ALL') {\n const prioMap: Record<string, string> = {\n LOW: 'LOW',\n NORMAL: 'MEDIUM',\n HIGH: 'HIGH',\n URGENT: 'URGENT',\n };\n backend.priority = prioMap[filter.priority] || filter.priority;\n }\n\n // Read/unread filter — coerce null to undefined\n if (filter.isRead !== null && filter.isRead !== undefined) {\n backend.isRead = filter.isRead;\n }\n\n if (filter.topicId) {\n backend.topicId = filter.topicId;\n }\n\n if (filter.channel && filter.channel !== 'ALL') {\n backend.channel = filter.channel;\n }\n\n if (filter.archived !== null && filter.archived !== undefined) {\n backend.archived = filter.archived;\n }\n\n if (filter.search) {\n backend.search = filter.search;\n }\n\n // Date range\n if (filter.dateRange.start) {\n backend.startDate = filter.dateRange.start.toISOString();\n }\n if (filter.dateRange.end) {\n backend.endDate = filter.dateRange.end.toISOString();\n }\n\n return Object.keys(backend).length > 0 ? backend : undefined;\n}\n\nfunction mergeNotificationFilter(\n filter: NotificationFilter,\n baseFilter?: Partial<NotificationFilter>\n): NotificationFilter {\n if (!baseFilter) return filter;\n\n return {\n ...filter,\n ...baseFilter,\n dateRange: {\n ...filter.dateRange,\n ...(baseFilter.dateRange || {}),\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Hook\n// ---------------------------------------------------------------------------\n\n/**\n * Hook to manage notifications with real GraphQL backend integration.\n *\n * Uses the global Apollo client to query the notification service via the\n * public gateway (https://gw-global.local.burdenoff.com/global/graphql).\n *\n * @example\n * ```tsx\n * const { notifications, unreadCount, markAsRead } = useNotifications();\n * ```\n */\nexport function useNotifications(options: UseNotificationsOptions = {}) {\n const { authToken, apiGatewayUrl, currentUser, eventBus } = useNotification();\n const {\n notificationFilter,\n updateNotificationFilter,\n resetNotificationFilter,\n unreadCount,\n setUnreadCount: setStoreUnreadCount,\n setIsLoadingNotifications,\n } = useNotificationStore();\n\n const [notifications, setNotifications] = useState<Notification[]>([]);\n const [selectedNotification, setSelectedNotification] = useState<Notification | null>(null);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [hasMore, setHasMore] = useState(false);\n const [total, setTotal] = useState(0);\n const [isLoadingMore, setIsLoadingMore] = useState(false);\n // One \"load more\" at a time; the state drives the list's loading row.\n const loadingMoreRef = useRef(false);\n // Bumped whenever the list starts over (a new filter, a refetch), so a page\n // that was requested for the previous list is dropped instead of appended.\n const listGenerationRef = useRef(0);\n // Ids that came from the server's pages for the current list, as opposed to\n // the live feed; only these set where the next page starts.\n const pagedIdsRef = useRef<Set<string>>(new Set());\n // Each tab-refresh gets a number; only the latest one's answer is used.\n const refreshSeqRef = useRef(0);\n // A new first page (new filter, refetch) is on its way: the loaded list is\n // about to be replaced, so no page may be added after it meanwhile.\n const replacingListRef = useRef(false);\n // The loaded list as of the last render, for the tab-refresh merge below.\n const notificationsRef = useRef<Notification[]>([]);\n useEffect(() => {\n notificationsRef.current = notifications;\n }, [notifications]);\n const effectiveFilter = useMemo(\n () => mergeNotificationFilter(notificationFilter, options.baseFilter),\n [notificationFilter, options.baseFilter]\n );\n const [debouncedFilter, setDebouncedFilter] = useState(effectiveFilter);\n\n useEffect(() => {\n const timeout = window.setTimeout(() => setDebouncedFilter(effectiveFilter), 250);\n return () => window.clearTimeout(timeout);\n }, [effectiveFilter]);\n\n // Client accessor — coerce null/undefined authToken to undefined\n const getClient = useCallback(() => {\n return getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n }, [apiGatewayUrl, authToken]);\n\n // ---- Fetch notifications ------------------------------------------------\n\n const fetchNotifications = useCallback(async () => {\n listGenerationRef.current += 1;\n const generation = listGenerationRef.current;\n replacingListRef.current = true;\n setIsLoading(true);\n setIsLoadingNotifications(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: buildBackendFilter(debouncedFilter),\n limit: NOTIFICATION_PAGE_SIZE,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n\n if (result.data?.notifications && generation === listGenerationRef.current) {\n const mapped = result.data.notifications.items.map(mapBackendToMfeNotification);\n pagedIdsRef.current = new Set(mapped.map((notification) => notification.id));\n setNotifications(mapped);\n setTotal(result.data.notifications.total);\n setHasMore(result.data.notifications.hasMore);\n }\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to fetch notifications';\n console.error('[useNotifications] Failed to fetch notifications:', err);\n setError(message);\n // The list on screen was loaded for an earlier filter: do not page it.\n if (generation === listGenerationRef.current) setHasMore(false);\n } finally {\n if (generation === listGenerationRef.current) replacingListRef.current = false;\n setIsLoading(false);\n setIsLoadingNotifications(false);\n }\n }, [debouncedFilter, getClient, setIsLoadingNotifications]);\n\n // ---- Fetch unread count -------------------------------------------------\n\n const fetchUnreadCount = useCallback(async () => {\n try {\n const client = getClient();\n const result = await client.query<GetMyUnreadNotificationCountQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetMyUnreadNotificationCountDocument,\n variables: { filter: options.unreadFilter || { channel: 'IN_APP' } },\n fetchPolicy: 'network-only',\n });\n if (result.data) {\n setStoreUnreadCount(result.data.myUnreadNotificationCount);\n }\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to fetch unread count:', err);\n }\n }, [getClient, options.unreadFilter, setStoreUnreadCount]);\n\n // ---- Load more ----------------------------------------------------------\n\n const loadMore = useCallback(async () => {\n if (!hasMore || loadingMoreRef.current || replacingListRef.current) return;\n const pageWindow = nextNotificationWindow(notifications, pagedIdsRef.current, debouncedFilter);\n if (!pageWindow) return;\n loadingMoreRef.current = true;\n setIsLoadingMore(true);\n const generation = listGenerationRef.current;\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n // Everything at or before the oldest loaded notification (the\n // filter's own end date is never earlier than that).\n filter: buildBackendFilter({\n ...debouncedFilter,\n dateRange: { ...debouncedFilter.dateRange, end: pageWindow.before },\n }),\n limit: pageWindow.limit,\n offset: pageWindow.offset,\n },\n fetchPolicy: 'network-only',\n });\n\n // The list started over (new filter or refetch) while this page loaded.\n if (generation !== listGenerationRef.current) return;\n if (result.data?.notifications) {\n const more = result.data.notifications.items.map(mapBackendToMfeNotification);\n for (const notification of more) pagedIdsRef.current.add(notification.id);\n setNotifications((prev) => appendNotificationPage(prev, more));\n // `total` here counts only the window, so the list's total stays as\n // the first page reported it.\n setHasMore(result.data.notifications.hasMore);\n }\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to load more notifications';\n console.error('[useNotifications] Failed to load more:', err);\n setError(message);\n } finally {\n loadingMoreRef.current = false;\n setIsLoadingMore(false);\n }\n }, [debouncedFilter, getClient, hasMore, notifications]);\n\n // Coming back to the tab: fetch the first page again for anything new, and\n // keep the older pages already scrolled through.\n const refreshFirstPage = useCallback(async () => {\n const generation = listGenerationRef.current;\n refreshSeqRef.current += 1;\n const refresh = refreshSeqRef.current;\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: buildBackendFilter(debouncedFilter),\n limit: NOTIFICATION_PAGE_SIZE,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n // The list started over, or a later refresh superseded this one.\n if (\n generation !== listGenerationRef.current ||\n refresh !== refreshSeqRef.current ||\n !result.data?.notifications\n ) {\n return;\n }\n const { items, total: freshTotal, hasMore: firstPageHasMore } = result.data.notifications;\n const firstPage = items.map(mapBackendToMfeNotification);\n const merged = mergeRefreshedFirstPage(\n notificationsRef.current,\n firstPage,\n firstPageHasMore,\n pagedIdsRef.current\n );\n if (merged.continued) {\n // The older pages carry on after the fresh one: keep them, and\n // whether more exist is still what the last of them said.\n for (const notification of firstPage) pagedIdsRef.current.add(notification.id);\n setNotifications(merged.list);\n } else {\n // The list starts over from the fresh first page; a page still\n // loading belongs to the old list and is dropped when it arrives.\n listGenerationRef.current += 1;\n pagedIdsRef.current = new Set(firstPage.map((notification) => notification.id));\n setNotifications(merged.list);\n setHasMore(firstPageHasMore);\n }\n setTotal(freshTotal);\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to refresh notifications:', err);\n }\n }, [debouncedFilter, getClient]);\n\n // ---- Mutations ----------------------------------------------------------\n\n const handleMarkAsRead = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.MarkNotificationAsReadDocument,\n variables: { id: notificationId },\n });\n // Optimistic: update local state\n setNotifications((prev) =>\n prev.map((n) =>\n n.id === notificationId ? { ...n, readAt: new Date().toISOString() } : n\n )\n );\n setStoreUnreadCount(Math.max(0, unreadCount - 1));\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to mark as read:', err);\n setError('Failed to mark notification as read');\n }\n },\n [getClient, setStoreUnreadCount, unreadCount]\n );\n\n const handleMarkAllAsRead = useCallback(async () => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.MarkAllMyNotificationsAsReadDocument,\n });\n // Optimistic: update all local\n setNotifications((prev) =>\n prev.map((n) => ({ ...n, readAt: n.readAt || new Date().toISOString() }))\n );\n setStoreUnreadCount(0);\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to mark all as read:', err);\n setError('Failed to mark all notifications as read');\n }\n }, [getClient, setStoreUnreadCount]);\n\n const handleArchive = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.ArchiveNotificationDocument,\n variables: { id: notificationId },\n });\n setNotifications((prev) =>\n prev.map((n) =>\n n.id === notificationId ? { ...n, archivedAt: new Date().toISOString() } : n\n )\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to archive notification:', err);\n setError('Failed to archive notification');\n }\n },\n [getClient]\n );\n\n const handleBulkArchive = useCallback(\n async (notificationIds: string[]) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.ArchiveNotificationsDocument,\n variables: { notificationIds },\n });\n const idsSet = new Set(notificationIds);\n setNotifications((prev) =>\n prev.map((n) => (idsSet.has(n.id) ? { ...n, archivedAt: new Date().toISOString() } : n))\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to bulk archive:', err);\n setError('Failed to archive notifications');\n }\n },\n [getClient]\n );\n\n const handleUnarchive = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.UnarchiveNotificationDocument,\n variables: { id: notificationId },\n });\n\n setNotifications((prev) =>\n prev.map((n) => (n.id === notificationId ? { ...n, archivedAt: undefined } : n))\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to unarchive notification:', err);\n setError('Failed to restore notification');\n }\n },\n [getClient]\n );\n\n const handleRecordAction = useCallback(\n async (notificationId: string, actionId?: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.RecordNotificationActionDocument,\n variables: { input: { notificationId, actionId } },\n });\n\n setNotifications((prev) =>\n prev.map((n) =>\n n.id === notificationId\n ? {\n ...n,\n clickedAt: new Date().toISOString(),\n readAt: n.readAt || new Date().toISOString(),\n }\n : n\n )\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to record notification action:', err);\n setError('Failed to record notification action');\n }\n },\n [getClient]\n );\n\n // ---- Initial fetch on mount + when filter changes -----------------------\n\n useEffect(() => {\n fetchNotifications();\n }, [fetchNotifications]);\n\n useEffect(() => {\n fetchUnreadCount();\n }, [fetchUnreadCount]);\n\n // ---- Live notification subscriptions ------------------------------------\n\n useEffect(() => {\n if (!currentUser?.id) return undefined;\n\n const client = getClient();\n const notificationSubscription = client\n .subscribe<NotificationReceivedSubscription>({\n query: NotificationOps.NotificationReceivedDocument,\n variables: { userId: currentUser.id },\n })\n .subscribe({\n next: (result) => {\n const notification = result.data?.notificationReceived;\n if (!notification) return;\n const mapped = mapBackendToMfeNotification(notification);\n setNotifications((prev) => [mapped, ...prev.filter((item) => item.id !== mapped.id)]);\n eventBus?.emit('notification:received', { notification: mapped });\n },\n error: (err) => {\n console.error('[useNotifications] Notification subscription failed:', err);\n },\n });\n\n const unreadSubscription = client\n .subscribe<UnreadCountUpdatedSubscription>({\n query: NotificationOps.UnreadCountUpdatedDocument,\n variables: { userId: currentUser.id },\n })\n .subscribe({\n next: (result) => {\n const nextCount = result.data?.unreadCountUpdated;\n if (typeof nextCount === 'number') {\n setStoreUnreadCount(nextCount);\n eventBus?.emit('notification:unread-count-updated', { unreadCount: nextCount });\n }\n },\n error: (err) => {\n console.error('[useNotifications] Unread count subscription failed:', err);\n },\n });\n\n return () => {\n notificationSubscription.unsubscribe();\n unreadSubscription.unsubscribe();\n };\n }, [currentUser?.id, eventBus, getClient, setStoreUnreadCount]);\n\n useEffect(() => {\n const handleVisibilityChange = () => {\n if (document.visibilityState === 'visible') {\n void refreshFirstPage();\n fetchUnreadCount();\n }\n };\n\n document.addEventListener('visibilitychange', handleVisibilityChange);\n return () => document.removeEventListener('visibilitychange', handleVisibilityChange);\n }, [refreshFirstPage, fetchUnreadCount]);\n\n const visibleNotifications = useMemo(\n () =>\n notifications.filter((notification) => {\n if (notification.deliveryStatus === 'UNSUBSCRIBED') {\n return false;\n }\n\n if (notification.status === 'ARCHIVED' && !notification.archivedAt) {\n return false;\n }\n\n if (effectiveFilter.archived === true) {\n return Boolean(notification.archivedAt);\n }\n\n if (effectiveFilter.archived === false) {\n return !notification.archivedAt;\n }\n\n return true;\n }),\n [effectiveFilter.archived, notifications]\n );\n\n return {\n notifications: visibleNotifications,\n allNotifications: notifications,\n unreadCount,\n selectedNotification,\n notificationFilter: effectiveFilter,\n isLoading,\n /** A further page is loading (infinite scroll). */\n isLoadingMore,\n error,\n hasMore,\n total,\n markAsRead: handleMarkAsRead,\n markAllAsRead: handleMarkAllAsRead,\n archiveNotification: handleArchive,\n bulkArchive: handleBulkArchive,\n unarchiveNotification: handleUnarchive,\n recordAction: handleRecordAction,\n setSelectedNotification,\n updateFilter: updateNotificationFilter,\n resetFilter: resetNotificationFilter,\n refetch: fetchNotifications,\n loadMore,\n };\n}\n"],"mappings":";;;;;;;AAsCA,SAASU,EAA4B,GAAsC;CACzE,OAAO;EACL,IAAIC,EAAE;EACN,MAAMC,EAAoBD,EAAE,IAAI;EAChC,UAAUE,EAAYF,EAAE,QAAQ;EAChC,OAAOA,EAAE;EACT,MAAMA,EAAE;EACR,WAAWA,EAAE,eAAe,KAAA;EAC5B,UAAUA,EAAE,WAAW,CAAC,EAAA,CAAG,KAAK,OAAY;GAC1C,IAAIG,EAAO;GACX,OAAOA,EAAO;GACd,KAAKA,EAAO;GACZ,OAAOA,EAAO,SAAS,KAAA;GACvB,YAAYA,EAAO,cAAc,KAAA;GACjC,UAAUA,EAAO,YAAY,KAAA;EAC/B,EAAE;EACF,SAASH,EAAE,WAAW,KAAA;EACtB,YAAYA,EAAE,cAAc,KAAA;EAC5B,SAASA,EAAE;EACX,WAAWA,EAAE,aAAa,KAAA;EAC1B,aAAaA,EAAE,eAAe,KAAA;EAC9B,gBAAgBA,EAAE,kBAAkB,KAAA;EACpC,UAAUA,EAAE,eAAe,KAAA;EAC3B,QAAQA,EAAE,SAAS,CAAC,EAAA,CAAG,KAAK,OAAU;GACpC,KAAKI,EAAK;GACV,OAAOA,EAAK,SAAS,KAAA;GACrB,MAAMA,EAAK,QAAQ,KAAA;GACnB,aAAaA,EAAK,eAAe,KAAA;GACjC,cAAcA,EAAK,gBAAgB,KAAA;EACrC,EAAE;EACF,UAAUJ,EAAE,YAAY,KAAA;EACxB,gBAAgBA,EAAE,kBAAkB,KAAA;EACpC,gBAAgBA,EAAE,kBAAkB,KAAA;EACpC,cAAcA,EAAE,gBAAgB,KAAA;EAChC,uBAAuBA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AC3E;EACF,CAAC,GAEGwC,IAAqBJ,EACxB,UAA0C;GACzC,OAAOlG;GACP,WAAW,EAAE,QAAQiG,EAAY,GAAG;EACtC,CAAC,CAAC,CACD,UAAU;GACT,OAAO,MAAW;IAChB,IAAMO,IAAY/C,EAAO,MAAM;IAC/B,AAAI,OAAO+C,KAAc,aACvBtF,EAAoBsF,CAAS,GAC7BH,GAAU,KAAK,qCAAqC,EAAE,aAAaG,EAAU,CAAC;GAElF;GACA,QAAQ,MAAQ;IACd,QAAQ,MAAM,wDAAwD1C,CAAG;GAC3E;EACF,CAAC;EAEH,aAAa;GAEX,AADAqC,EAAyB,YAAY,GACrCG,EAAmB,YAAY;EACjC;CACF,GAAG;EAACL,GAAa;EAAII;EAAUpD;EAAW/B;CAAmB,CAAC,GAE9D8E,QAAgB;EACd,IAAMS,UAA+B;GACnC,AAAI,SAAS,oBAAoB,cAC/BjC,EAAsB,GACtBR,EAAiB;EAErB;EAGA,OADA,SAAS,iBAAiB,oBAAoByC,CAAsB,SACvD,SAAS,oBAAoB,oBAAoBA,CAAsB;CACtF,GAAG,CAACjC,GAAkBR,CAAgB,CAAC,GA0BhC;EACL,eAzB2BrB,QAEzBvB,EAAc,QAAQ,MAChByC,EAAa,mBAAmB,kBAIhCA,EAAa,WAAW,cAAc,CAACA,EAAa,aAC/C,KAGLnB,EAAgB,aAAa,KACxB,EAAQmB,EAAa,aAG1BnB,EAAgB,aAAa,MACxB,CAACmB,EAAa,UAIxB,GACH,CAACnB,EAAgB,UAAUtB,CAAa,CAIzB;EACf,kBAAkBA;EAClB;EACA;EACA,oBAAoBsB;EACpB;EAEA;EACA;EACA;EACA;EACA,YAAYsC;EACZ,eAAeI;EACf,qBAAqBE;EACrB,aAAaE;EACb,uBAAuBI;EACvB,cAAcE;EACd;EACA,cAAcY;EACd,aAAaC;EACb,SAASrD;EACT;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"useNotifications.js","names":["NotificationOps.GetNotificationsDocument","NotificationOps.GetMyUnreadNotificationCountDocument","NotificationOps.MarkNotificationAsReadDocument","NotificationOps.MarkAllMyNotificationsAsReadDocument","NotificationOps.ArchiveNotificationDocument","NotificationOps.ArchiveNotificationsDocument","NotificationOps.UnarchiveNotificationDocument","NotificationOps.RecordNotificationActionDocument","NotificationOps.NotificationReceivedDocument","NotificationOps.UnreadCountUpdatedDocument","mapBackendToMfeNotification","n","mapNotificationType","mapPriority","action","item","mapStatus","t","p","s","buildBackendFilter","backend","filter","mergeNotificationFilter","baseFilter","useNotifications","useNotification","setStoreUnreadCount","useNotificationStore","notifications","setNotifications","useState","selectedNotification","setSelectedNotification","isLoading","setIsLoading","error","setError","hasMore","setHasMore","total","setTotal","isLoadingMore","setIsLoadingMore","loadingMoreRef","useRef","listGenerationRef","pagedIdsRef","refreshSeqRef","replacingListRef","notificationsRef","effectiveFilter","useMemo","notificationFilter","options","debouncedFilter","setDebouncedFilter","timeout","getClient","useCallback","getGlobalNotificationClient","apiGatewayUrl","authToken","fetchNotifications","generation","setIsLoadingNotifications","result","USER_NOTIFICATION_CONTEXT","GetNotificationsDocument","mapped","notification","err","message","fetchUnreadCount","GetMyUnreadNotificationCountDocument","loadMore","pageWindow","nextNotificationWindow","more","appendNotificationPage","prev","refreshFirstPage","refresh","freshTotal","firstPageHasMore","firstPage","items","merged","mergeRefreshedFirstPage","handleMarkAsRead","MarkNotificationAsReadDocument","notificationId","unreadCount","handleMarkAllAsRead","MarkAllMyNotificationsAsReadDocument","handleArchive","ArchiveNotificationDocument","handleBulkArchive","ArchiveNotificationsDocument","idsSet","notificationIds","handleUnarchive","UnarchiveNotificationDocument","handleRecordAction","RecordNotificationActionDocument","useEffect","currentUser","client","notificationSubscription","NotificationReceivedDocument","eventBus","unreadSubscription","UnreadCountUpdatedDocument","nextCount","handleVisibilityChange","updateNotificationFilter","resetNotificationFilter"],"sources":["../../src/hooks/useNotifications.ts"],"sourcesContent":["import { useState, useCallback, useEffect, useMemo, useRef } from 'react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient, USER_NOTIFICATION_CONTEXT } from '../graphql/global-client';\nimport { useNotificationStore } from '../store/notificationStore';\nimport type { Notification, NotificationFilter } from '../types';\nimport {\n NOTIFICATION_PAGE_SIZE,\n appendNotificationPage,\n mergeRefreshedFirstPage,\n nextNotificationWindow,\n} from './notificationPaging';\nimport * as NotificationOps from '../generated/global-operations';\nimport type {\n GetNotificationsQuery,\n GetMyUnreadNotificationCountQuery,\n NotificationFieldsFragment,\n NotificationReceivedSubscription,\n UnreadCountUpdatedSubscription,\n} from '../generated/global-operations';\n\n// ---------------------------------------------------------------------------\n// GraphQL Operations — using generated Document nodes from global-operations\n// ---------------------------------------------------------------------------\n\n/**\n * Backend Notification item type derived from the generated query\n */\ntype BackendNotification = NotificationFieldsFragment;\n\ninterface UseNotificationsOptions {\n baseFilter?: Partial<NotificationFilter>;\n unreadFilter?: Record<string, unknown>;\n}\n\n// ---------------------------------------------------------------------------\n// Mapping helpers — backend → MFE types\n// ---------------------------------------------------------------------------\n\n/** The GraphQL notification as the module's `Notification` (also used by the v2 detail panel). */\nexport function mapBackendToMfeNotification(n: BackendNotification): Notification {\n return {\n id: n.id,\n type: mapNotificationType(n.type),\n priority: mapPriority(n.priority),\n title: n.title,\n body: n.message,\n actionUrl: n.redirectUrl ?? undefined,\n actions: (n.actions || []).map((action) => ({\n id: action.id,\n label: action.label,\n url: action.url,\n style: action.style ?? undefined,\n actionType: action.actionType ?? undefined,\n metadata: action.metadata ?? undefined,\n })),\n appName: n.appName ?? undefined,\n archivedAt: n.archivedAt ?? undefined,\n channel: n.channel as Notification['channel'],\n clickedAt: n.clickedAt ?? undefined,\n deliveredAt: n.deliveredAt ?? undefined,\n deliveryStatus: n.deliveryStatus ?? undefined,\n htmlBody: n.htmlMessage ?? undefined,\n media: (n.media || []).map((item) => ({\n url: item.url,\n label: item.label ?? undefined,\n kind: item.kind ?? undefined,\n contentType: item.contentType ?? undefined,\n thumbnailUrl: item.thumbnailUrl ?? undefined,\n })),\n openedAt: n.openedAt ?? undefined,\n recipientEmail: n.recipientEmail ?? undefined,\n recipientPhone: n.recipientPhone ?? undefined,\n scheduledFor: n.scheduledFor ?? undefined,\n scheduledNotification: n.scheduledNotification\n ? {\n id: n.scheduledNotification.id,\n scheduledFor: n.scheduledNotification.scheduledFor,\n status: n.scheduledNotification.status,\n timezone: n.scheduledNotification.timezone ?? undefined,\n }\n : undefined,\n sentAt: n.sentAt ?? undefined,\n status: mapStatus(n.status),\n readAt: n.readAt ?? undefined,\n createdAt: n.createdAt,\n channels: [\n {\n id: n.id,\n channel: n.channel as Notification['channel'],\n status: mapStatus(n.status),\n sentAt: n.sentAt ?? undefined,\n deliveredAt: n.deliveredAt ?? undefined,\n failedAt: n.failedAt ?? undefined,\n errorCode: n.errorCode ?? undefined,\n errorMessage: n.errorMessage ?? undefined,\n },\n ],\n metadata: n.metadata ?? undefined,\n topic: n.topic\n ? {\n id: n.topic.id,\n name: n.topic.name,\n slug: n.topic.slug,\n type: mapNotificationType(n.topic.type),\n }\n : undefined,\n topicId: n.topicId ?? undefined,\n };\n}\n\nfunction mapNotificationType(t: string) {\n const map: Record<string, Notification['type']> = {\n SYSTEM: 'SYSTEM',\n TRANSACTIONAL: 'TRANSACTIONAL',\n MARKETING: 'MARKETING',\n ALERT: 'ALERT',\n };\n return map[t] || 'SYSTEM';\n}\n\nfunction mapPriority(p: string) {\n const map: Record<string, Notification['priority']> = {\n LOW: 'LOW',\n MEDIUM: 'NORMAL',\n HIGH: 'HIGH',\n URGENT: 'URGENT',\n };\n return map[p] || 'NORMAL';\n}\n\nfunction mapStatus(s: string) {\n const map: Record<string, Notification['status']> = {\n DRAFT: 'PENDING',\n PENDING: 'PENDING',\n SCHEDULED: 'PENDING',\n TRIGGERED: 'SENT',\n SENT: 'SENT',\n DELIVERED: 'DELIVERED',\n READ: 'DELIVERED',\n FAILED: 'FAILED',\n CANCELLED: 'ARCHIVED',\n EXPIRED: 'ARCHIVED',\n };\n return map[s] || 'PENDING';\n}\n\n// ---------------------------------------------------------------------------\n// Build the backend filter from the MFE NotificationFilter shape\n// ---------------------------------------------------------------------------\n\nfunction buildBackendFilter(filter: NotificationFilter) {\n const backend: Record<string, unknown> = {};\n\n // Type filter — map MFE type names to backend enum\n if (filter.type !== 'ALL') {\n const typeMap: Record<string, string> = {\n SYSTEM: 'SYSTEM',\n ACTIVITY: 'TRANSACTIONAL',\n BILLING: 'TRANSACTIONAL',\n SECURITY: 'ALERT',\n SOCIAL: 'MARKETING',\n REMINDER: 'SYSTEM',\n };\n backend.type = typeMap[filter.type] || filter.type;\n }\n\n // Priority filter\n if (filter.priority !== 'ALL') {\n const prioMap: Record<string, string> = {\n LOW: 'LOW',\n NORMAL: 'MEDIUM',\n HIGH: 'HIGH',\n URGENT: 'URGENT',\n };\n backend.priority = prioMap[filter.priority] || filter.priority;\n }\n\n // Read/unread filter — coerce null to undefined\n if (filter.isRead !== null && filter.isRead !== undefined) {\n backend.isRead = filter.isRead;\n }\n\n if (filter.topicId) {\n backend.topicId = filter.topicId;\n }\n\n if (filter.channel && filter.channel !== 'ALL') {\n backend.channel = filter.channel;\n }\n\n if (filter.archived !== null && filter.archived !== undefined) {\n backend.archived = filter.archived;\n }\n\n if (filter.search) {\n backend.search = filter.search;\n }\n\n // Date range\n if (filter.dateRange.start) {\n backend.startDate = filter.dateRange.start.toISOString();\n }\n if (filter.dateRange.end) {\n backend.endDate = filter.dateRange.end.toISOString();\n }\n\n return Object.keys(backend).length > 0 ? backend : undefined;\n}\n\nfunction mergeNotificationFilter(\n filter: NotificationFilter,\n baseFilter?: Partial<NotificationFilter>\n): NotificationFilter {\n if (!baseFilter) return filter;\n\n return {\n ...filter,\n ...baseFilter,\n dateRange: {\n ...filter.dateRange,\n ...(baseFilter.dateRange || {}),\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Hook\n// ---------------------------------------------------------------------------\n\n/**\n * Hook to manage notifications with real GraphQL backend integration.\n *\n * Uses the global Apollo client to query the notification service via the\n * public gateway (https://gw-global.local.burdenoff.com/global/graphql).\n *\n * @example\n * ```tsx\n * const { notifications, unreadCount, markAsRead } = useNotifications();\n * ```\n */\nexport function useNotifications(options: UseNotificationsOptions = {}) {\n const { authToken, apiGatewayUrl, currentUser, eventBus } = useNotification();\n const {\n notificationFilter,\n updateNotificationFilter,\n resetNotificationFilter,\n unreadCount,\n setUnreadCount: setStoreUnreadCount,\n setIsLoadingNotifications,\n } = useNotificationStore();\n\n const [notifications, setNotifications] = useState<Notification[]>([]);\n const [selectedNotification, setSelectedNotification] = useState<Notification | null>(null);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [hasMore, setHasMore] = useState(false);\n const [total, setTotal] = useState(0);\n const [isLoadingMore, setIsLoadingMore] = useState(false);\n // One \"load more\" at a time; the state drives the list's loading row.\n const loadingMoreRef = useRef(false);\n // Bumped whenever the list starts over (a new filter, a refetch), so a page\n // that was requested for the previous list is dropped instead of appended.\n const listGenerationRef = useRef(0);\n // Ids that came from the server's pages for the current list, as opposed to\n // the live feed; only these set where the next page starts.\n const pagedIdsRef = useRef<Set<string>>(new Set());\n // Each tab-refresh gets a number; only the latest one's answer is used.\n const refreshSeqRef = useRef(0);\n // A new first page (new filter, refetch) is on its way: the loaded list is\n // about to be replaced, so no page may be added after it meanwhile.\n const replacingListRef = useRef(false);\n // The loaded list as of the last render, for the tab-refresh merge below.\n const notificationsRef = useRef<Notification[]>([]);\n useEffect(() => {\n notificationsRef.current = notifications;\n }, [notifications]);\n const effectiveFilter = useMemo(\n () => mergeNotificationFilter(notificationFilter, options.baseFilter),\n [notificationFilter, options.baseFilter]\n );\n const [debouncedFilter, setDebouncedFilter] = useState(effectiveFilter);\n\n useEffect(() => {\n const timeout = window.setTimeout(() => setDebouncedFilter(effectiveFilter), 250);\n return () => window.clearTimeout(timeout);\n }, [effectiveFilter]);\n\n // Client accessor — coerce null/undefined authToken to undefined\n const getClient = useCallback(() => {\n return getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n }, [apiGatewayUrl, authToken]);\n\n // ---- Fetch notifications ------------------------------------------------\n\n const fetchNotifications = useCallback(async () => {\n listGenerationRef.current += 1;\n const generation = listGenerationRef.current;\n replacingListRef.current = true;\n setIsLoading(true);\n setIsLoadingNotifications(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: buildBackendFilter(debouncedFilter),\n limit: NOTIFICATION_PAGE_SIZE,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n\n if (result.data?.notifications && generation === listGenerationRef.current) {\n const mapped = result.data.notifications.items.map(mapBackendToMfeNotification);\n pagedIdsRef.current = new Set(mapped.map((notification) => notification.id));\n setNotifications(mapped);\n setTotal(result.data.notifications.total);\n setHasMore(result.data.notifications.hasMore);\n }\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to fetch notifications';\n console.error('[useNotifications] Failed to fetch notifications:', err);\n setError(message);\n // The list on screen was loaded for an earlier filter: do not page it.\n if (generation === listGenerationRef.current) setHasMore(false);\n } finally {\n if (generation === listGenerationRef.current) replacingListRef.current = false;\n setIsLoading(false);\n setIsLoadingNotifications(false);\n }\n }, [debouncedFilter, getClient, setIsLoadingNotifications]);\n\n // ---- Fetch unread count -------------------------------------------------\n\n const fetchUnreadCount = useCallback(async () => {\n try {\n const client = getClient();\n const result = await client.query<GetMyUnreadNotificationCountQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetMyUnreadNotificationCountDocument,\n variables: { filter: options.unreadFilter || { channel: 'IN_APP' } },\n fetchPolicy: 'network-only',\n });\n if (result.data) {\n setStoreUnreadCount(result.data.myUnreadNotificationCount);\n }\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to fetch unread count:', err);\n }\n }, [getClient, options.unreadFilter, setStoreUnreadCount]);\n\n // ---- Load more ----------------------------------------------------------\n\n const loadMore = useCallback(async () => {\n if (!hasMore || loadingMoreRef.current || replacingListRef.current) return;\n const pageWindow = nextNotificationWindow(notifications, pagedIdsRef.current, debouncedFilter);\n if (!pageWindow) return;\n loadingMoreRef.current = true;\n setIsLoadingMore(true);\n const generation = listGenerationRef.current;\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n // Everything at or before the oldest loaded notification (the\n // filter's own end date is never earlier than that).\n filter: buildBackendFilter({\n ...debouncedFilter,\n dateRange: { ...debouncedFilter.dateRange, end: pageWindow.before },\n }),\n limit: pageWindow.limit,\n offset: pageWindow.offset,\n },\n fetchPolicy: 'network-only',\n });\n\n // The list started over (new filter or refetch) while this page loaded.\n if (generation !== listGenerationRef.current) return;\n if (result.data?.notifications) {\n const more = result.data.notifications.items.map(mapBackendToMfeNotification);\n for (const notification of more) pagedIdsRef.current.add(notification.id);\n setNotifications((prev) => appendNotificationPage(prev, more));\n // `total` here counts only the window, so the list's total stays as\n // the first page reported it.\n setHasMore(result.data.notifications.hasMore);\n }\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to load more notifications';\n console.error('[useNotifications] Failed to load more:', err);\n setError(message);\n } finally {\n loadingMoreRef.current = false;\n setIsLoadingMore(false);\n }\n }, [debouncedFilter, getClient, hasMore, notifications]);\n\n // Coming back to the tab: fetch the first page again for anything new, and\n // keep the older pages already scrolled through.\n const refreshFirstPage = useCallback(async () => {\n const generation = listGenerationRef.current;\n refreshSeqRef.current += 1;\n const refresh = refreshSeqRef.current;\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: buildBackendFilter(debouncedFilter),\n limit: NOTIFICATION_PAGE_SIZE,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n // The list started over, or a later refresh superseded this one.\n if (\n generation !== listGenerationRef.current ||\n refresh !== refreshSeqRef.current ||\n !result.data?.notifications\n ) {\n return;\n }\n const { items, total: freshTotal, hasMore: firstPageHasMore } = result.data.notifications;\n const firstPage = items.map(mapBackendToMfeNotification);\n const merged = mergeRefreshedFirstPage(\n notificationsRef.current,\n firstPage,\n firstPageHasMore,\n pagedIdsRef.current\n );\n if (merged.continued) {\n // The older pages carry on after the fresh one: keep them, and\n // whether more exist is still what the last of them said.\n for (const notification of firstPage) pagedIdsRef.current.add(notification.id);\n setNotifications(merged.list);\n } else {\n // The list starts over from the fresh first page; a page still\n // loading belongs to the old list and is dropped when it arrives.\n listGenerationRef.current += 1;\n pagedIdsRef.current = new Set(firstPage.map((notification) => notification.id));\n setNotifications(merged.list);\n setHasMore(firstPageHasMore);\n }\n setTotal(freshTotal);\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to refresh notifications:', err);\n }\n }, [debouncedFilter, getClient]);\n\n // ---- Mutations ----------------------------------------------------------\n\n const handleMarkAsRead = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.MarkNotificationAsReadDocument,\n variables: { id: notificationId },\n });\n // Optimistic: update local state\n setNotifications((prev) =>\n prev.map((n) =>\n n.id === notificationId ? { ...n, readAt: new Date().toISOString() } : n\n )\n );\n setStoreUnreadCount(Math.max(0, unreadCount - 1));\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to mark as read:', err);\n setError('Failed to mark notification as read');\n }\n },\n [getClient, setStoreUnreadCount, unreadCount]\n );\n\n const handleMarkAllAsRead = useCallback(async () => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.MarkAllMyNotificationsAsReadDocument,\n });\n // Optimistic: update all local\n setNotifications((prev) =>\n prev.map((n) => ({ ...n, readAt: n.readAt || new Date().toISOString() }))\n );\n setStoreUnreadCount(0);\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to mark all as read:', err);\n setError('Failed to mark all notifications as read');\n }\n }, [getClient, setStoreUnreadCount]);\n\n const handleArchive = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.ArchiveNotificationDocument,\n variables: { id: notificationId },\n });\n setNotifications((prev) =>\n prev.map((n) =>\n n.id === notificationId ? { ...n, archivedAt: new Date().toISOString() } : n\n )\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to archive notification:', err);\n setError('Failed to archive notification');\n }\n },\n [getClient]\n );\n\n const handleBulkArchive = useCallback(\n async (notificationIds: string[]) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.ArchiveNotificationsDocument,\n variables: { notificationIds },\n });\n const idsSet = new Set(notificationIds);\n setNotifications((prev) =>\n prev.map((n) => (idsSet.has(n.id) ? { ...n, archivedAt: new Date().toISOString() } : n))\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to bulk archive:', err);\n setError('Failed to archive notifications');\n }\n },\n [getClient]\n );\n\n const handleUnarchive = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.UnarchiveNotificationDocument,\n variables: { id: notificationId },\n });\n\n setNotifications((prev) =>\n prev.map((n) => (n.id === notificationId ? { ...n, archivedAt: undefined } : n))\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to unarchive notification:', err);\n setError('Failed to restore notification');\n }\n },\n [getClient]\n );\n\n const handleRecordAction = useCallback(\n async (notificationId: string, actionId?: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.RecordNotificationActionDocument,\n variables: { input: { notificationId, actionId } },\n });\n\n setNotifications((prev) =>\n prev.map((n) =>\n n.id === notificationId\n ? {\n ...n,\n clickedAt: new Date().toISOString(),\n readAt: n.readAt || new Date().toISOString(),\n }\n : n\n )\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to record notification action:', err);\n setError('Failed to record notification action');\n }\n },\n [getClient]\n );\n\n // ---- Initial fetch on mount + when filter changes -----------------------\n\n useEffect(() => {\n fetchNotifications();\n }, [fetchNotifications]);\n\n useEffect(() => {\n fetchUnreadCount();\n }, [fetchUnreadCount]);\n\n // ---- Live notification subscriptions ------------------------------------\n\n useEffect(() => {\n if (!currentUser?.id) return undefined;\n\n const client = getClient();\n const notificationSubscription = client\n .subscribe<NotificationReceivedSubscription>({\n query: NotificationOps.NotificationReceivedDocument,\n variables: { userId: currentUser.id },\n })\n .subscribe({\n next: (result) => {\n const notification = result.data?.notificationReceived;\n if (!notification) return;\n const mapped = mapBackendToMfeNotification(notification);\n setNotifications((prev) => [mapped, ...prev.filter((item) => item.id !== mapped.id)]);\n eventBus?.emit('notification:received', { notification: mapped });\n },\n error: (err) => {\n console.error('[useNotifications] Notification subscription failed:', err);\n },\n });\n\n const unreadSubscription = client\n .subscribe<UnreadCountUpdatedSubscription>({\n query: NotificationOps.UnreadCountUpdatedDocument,\n variables: { userId: currentUser.id },\n })\n .subscribe({\n next: (result) => {\n const nextCount = result.data?.unreadCountUpdated;\n if (typeof nextCount === 'number') {\n setStoreUnreadCount(nextCount);\n eventBus?.emit('notification:unread-count-updated', { unreadCount: nextCount });\n }\n },\n error: (err) => {\n console.error('[useNotifications] Unread count subscription failed:', err);\n },\n });\n\n return () => {\n notificationSubscription.unsubscribe();\n unreadSubscription.unsubscribe();\n };\n }, [currentUser?.id, eventBus, getClient, setStoreUnreadCount]);\n\n useEffect(() => {\n const handleVisibilityChange = () => {\n if (document.visibilityState === 'visible') {\n void refreshFirstPage();\n fetchUnreadCount();\n }\n };\n\n document.addEventListener('visibilitychange', handleVisibilityChange);\n return () => document.removeEventListener('visibilitychange', handleVisibilityChange);\n }, [refreshFirstPage, fetchUnreadCount]);\n\n const visibleNotifications = useMemo(\n () =>\n notifications.filter((notification) => {\n if (notification.deliveryStatus === 'UNSUBSCRIBED') {\n return false;\n }\n\n if (notification.status === 'ARCHIVED' && !notification.archivedAt) {\n return false;\n }\n\n if (effectiveFilter.archived === true) {\n return Boolean(notification.archivedAt);\n }\n\n if (effectiveFilter.archived === false) {\n return !notification.archivedAt;\n }\n\n return true;\n }),\n [effectiveFilter.archived, notifications]\n );\n\n return {\n notifications: visibleNotifications,\n allNotifications: notifications,\n unreadCount,\n selectedNotification,\n notificationFilter: effectiveFilter,\n isLoading,\n /** A further page is loading (infinite scroll). */\n isLoadingMore,\n error,\n hasMore,\n total,\n markAsRead: handleMarkAsRead,\n markAllAsRead: handleMarkAllAsRead,\n archiveNotification: handleArchive,\n bulkArchive: handleBulkArchive,\n unarchiveNotification: handleUnarchive,\n recordAction: handleRecordAction,\n setSelectedNotification,\n updateFilter: updateNotificationFilter,\n resetFilter: resetNotificationFilter,\n refetch: fetchNotifications,\n loadMore,\n };\n}\n"],"mappings":";;;;;;;AAuCA,SAAgBU,EAA4B,GAAsC;CAChF,OAAO;EACL,IAAIC,EAAE;EACN,MAAMC,EAAoBD,EAAE,IAAI;EAChC,UAAUE,EAAYF,EAAE,QAAQ;EAChC,OAAOA,EAAE;EACT,MAAMA,EAAE;EACR,WAAWA,EAAE,eAAe,KAAA;EAC5B,UAAUA,EAAE,WAAW,CAAC,EAAA,CAAG,KAAK,OAAY;GAC1C,IAAIG,EAAO;GACX,OAAOA,EAAO;GACd,KAAKA,EAAO;GACZ,OAAOA,EAAO,SAAS,KAAA;GACvB,YAAYA,EAAO,cAAc,KAAA;GACjC,UAAUA,EAAO,YAAY,KAAA;EAC/B,EAAE;EACF,SAASH,EAAE,WAAW,KAAA;EACtB,YAAYA,EAAE,cAAc,KAAA;EAC5B,SAASA,EAAE;EACX,WAAWA,EAAE,aAAa,KAAA;EAC1B,aAAaA,EAAE,eAAe,KAAA;EAC9B,gBAAgBA,EAAE,kBAAkB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LnB,EAAgB,aAAa,KACxB,EAAQmB,EAAa,aAG1BnB,EAAgB,aAAa,MACxB,CAACmB,EAAa,UAIxB,GACH,CAACnB,EAAgB,UAAUtB,CAAa,CAIzB;EACf,kBAAkBA;EAClB;EACA;EACA,oBAAoBsB;EACpB;EAEA;EACA;EACA;EACA;EACA,YAAYsC;EACZ,eAAeI;EACf,qBAAqBE;EACrB,aAAaE;EACb,uBAAuBI;EACvB,cAAcE;EACd;EACA,cAAcY;EACd,aAAaC;EACb,SAASrD;EACT;CACF;AACF"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import "./
|
|
9
|
-
import "./components/index.js";
|
|
10
|
-
import { NotificationBell as s } from "./components/NotificationBell.js";
|
|
1
|
+
import { NotificationRoot as e } from "./NotificationRoot.js";
|
|
2
|
+
import { UserNotificationRoot as t } from "./UserNotificationRoot.js";
|
|
3
|
+
import { AdminNotificationRoot as n } from "./AdminNotificationRoot.js";
|
|
4
|
+
import { useNotifications as r } from "./hooks/useNotifications.js";
|
|
5
|
+
import { useNotificationStore as i } from "./store/notificationStore.js";
|
|
6
|
+
import { useNotification as a } from "./providers/NotificationProvider.js";
|
|
7
|
+
import { NotificationBell as o } from "./components/NotificationBell.js";
|
|
8
|
+
import { NotificationCard as s } from "./components/NotificationCard.js";
|
|
11
9
|
import { NotificationPanel as c } from "./components/NotificationPanel.js";
|
|
12
10
|
import { filterNotifications as l, formatRelativeTime as u, getNotificationTypeIcon as d, getNotificationTypeLabel as f, getPriorityColor as p, getPriorityIcon as m, groupNotificationsByDate as h, sortNotificationsByDate as g, substituteTemplateVariables as _, truncateText as v, validateTemplateVariables as y } from "./utils/index.js";
|
|
13
|
-
export {
|
|
11
|
+
export { n as AdminNotificationRoot, o as NotificationBell, s as NotificationCard, c as NotificationPanel, e as NotificationRoot, t as UserNotificationRoot, l as filterNotifications, u as formatRelativeTime, d as getNotificationTypeIcon, f as getNotificationTypeLabel, p as getPriorityColor, m as getPriorityIcon, h as groupNotificationsByDate, g as sortNotificationsByDate, _ as substituteTemplateVariables, v as truncateText, a as useNotification, i as useNotificationStore, r as useNotifications, y as validateTemplateVariables };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { NotificationCard as e } from "../components/NotificationCard.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import "../hooks/index.js";
|
|
2
|
+
import { NotificationListFooter as t } from "../components/NotificationListFooter.js";
|
|
3
|
+
import { NOTIFICATION_PERMISSIONS as n } from "../constants/permissions.js";
|
|
4
|
+
import { useNotifications as r } from "../hooks/useNotifications.js";
|
|
5
|
+
import { useNotificationTopics as i } from "../hooks/useNotificationTopics.js";
|
|
7
6
|
import { useNotification as a } from "../providers/NotificationProvider.js";
|
|
8
7
|
import { useTr as o } from "../shared/hooks/useTr.js";
|
|
9
8
|
import { inArchivedView as s } from "./inboxFilters.js";
|
|
@@ -25,7 +24,7 @@ function M(e) {
|
|
|
25
24
|
return e ? e.toISOString().split("T")[0] : "";
|
|
26
25
|
}
|
|
27
26
|
function N() {
|
|
28
|
-
let N = o(), { hasPermission: P, isLoading: F } = g(), { currentUser: I } = a(), { topics: L } =
|
|
27
|
+
let N = o(), { hasPermission: P, isLoading: F } = g(), { currentUser: I } = a(), { topics: L } = i({ isActive: !0 }), { notifications: R, hasMore: z, isLoadingMore: B, loadMore: V, notificationFilter: H, updateFilter: U, archiveNotification: W, unarchiveNotification: G, recordAction: K } = r({ baseFilter: A }), [q, J] = h("archived"), [Y, X] = k("notifications.archived.moreFilters", !1), Z = m(() => R.filter((e) => s(e, q)), [R, q]), Q = !!(H.topicId || H.dateRange.start || H.dateRange.end), $ = !!H.search || Q;
|
|
29
28
|
if (F) return /* @__PURE__ */ y(ee, {
|
|
30
29
|
minHeight: "16rem",
|
|
31
30
|
today: /* @__PURE__ */ y("div", {
|
|
@@ -36,7 +35,7 @@ function N() {
|
|
|
36
35
|
})
|
|
37
36
|
})
|
|
38
37
|
});
|
|
39
|
-
if (!P(
|
|
38
|
+
if (!P(n.NOTIFICATION_LIST) && !I?.id) return /* @__PURE__ */ y("div", {
|
|
40
39
|
className: "p-8 text-center text-text-secondary",
|
|
41
40
|
children: N("notifications.noPermissionHistory", "You don't have permission to view notification history.")
|
|
42
41
|
});
|
|
@@ -175,7 +174,7 @@ function N() {
|
|
|
175
174
|
kind: H.search ? "no-results" : $ ? "filtered" : "first-use"
|
|
176
175
|
})
|
|
177
176
|
}),
|
|
178
|
-
/* @__PURE__ */ y(
|
|
177
|
+
/* @__PURE__ */ y(t, {
|
|
179
178
|
hasMore: z,
|
|
180
179
|
isLoadingMore: B,
|
|
181
180
|
onLoadMore: V,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationArchivedV2.js","names":["HISTORY_FILTER","ALL","toDateInput","value","NotificationArchivedV2","tr","useTr","permissionsLoading","usePermissions","useNotification","useNotificationTopics","useNotifications","view","setView","useState","moreFiltersOpen","setMoreFiltersOpen","useRememberedOpen","visible","useMemo","notifications","inArchivedView","notification","moreFiltersActive","notificationFilter","hasActiveFilters","SectionLoaderOr","CompactMarkOr","hasPermission","NOTIFICATION_PERMISSIONS","currentUser","chips","topicOptions","topics","topic","BackToNotifications","DropdownMenu","DropdownMenuTrigger","Button","MoreHorizontal","DropdownMenuContent","DropdownMenuItem","exportNotificationsAsCsv","Download","SearchField","updateFilter","ViewChips","MoreFiltersButton","NativeSelect","Input","NotificationCard","archiveNotification","recordAction","unarchiveNotification","IllustratedEmptyState","NotificationListFooter","loadMore"],"sources":["../../src/navigation-v2/NotificationArchivedV2.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { Download, MoreHorizontal } from 'lucide-react';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport {\n Button,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n IllustratedEmptyState,\n Input,\n NativeSelect,\n useRememberedOpen,\n} from '@burdenoff/fe-libs/ui';\nimport { NotificationCard } from '../components/NotificationCard';\nimport { NotificationListFooter } from '../components/NotificationListFooter';\nimport { NOTIFICATION_PERMISSIONS } from '../constants/permissions';\nimport { useNotifications, useNotificationTopics } from '../hooks';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { useTr } from '../shared/hooks/useTr';\nimport { inArchivedView, type ArchivedView } from './inboxFilters';\nimport { exportNotificationsAsCsv } from '../utils/notificationHistoryExport';\nimport { BackToNotifications } from './BackToNotifications';\nimport { MoreFiltersButton, SearchField, ViewChips } from './FilterControls';\nimport { CompactMarkOr, SectionLoaderOr } from '../components/loadingSystem';\n\nconst HISTORY_FILTER = { archived: null, channel: 'ALL' as const };\nconst ALL = 'ALL';\n\nfunction toDateInput(value: Date | null): string {\n return value ? value.toISOString().split('T')[0] : '';\n}\n\n/**\n * Archived, Navigation v2 (BOFF-11872; today's personal Notification\n * History). Same query as the classic page (every channel, archived or\n * not); the \"Archived\" chip, on by default, shows what you archived and\n * \"Everything\" shows the full history. Restore on each archived row, search\n * at level 1, topic and dates under \"More filters\", and \"Download as\n * spreadsheet\" in \"⋯\".\n */\nexport function NotificationArchivedV2() {\n const tr = useTr();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const { currentUser } = useNotification();\n const { topics } = useNotificationTopics({ isActive: true });\n const {\n notifications,\n hasMore,\n isLoadingMore,\n loadMore,\n notificationFilter,\n updateFilter,\n archiveNotification,\n unarchiveNotification,\n recordAction,\n } = useNotifications({ baseFilter: HISTORY_FILTER });\n const [view, setView] = useState<ArchivedView>('archived');\n const [moreFiltersOpen, setMoreFiltersOpen] = useRememberedOpen(\n 'notifications.archived.moreFilters',\n false\n );\n\n const visible = useMemo(\n () => notifications.filter((notification) => inArchivedView(notification, view)),\n [notifications, view]\n );\n\n const moreFiltersActive = Boolean(\n notificationFilter.topicId ||\n notificationFilter.dateRange.start ||\n notificationFilter.dateRange.end\n );\n const hasActiveFilters = Boolean(notificationFilter.search) || moreFiltersActive;\n\n if (permissionsLoading) {\n return (\n <SectionLoaderOr\n minHeight=\"16rem\"\n today={\n <div className=\"flex h-64 items-center justify-center\">\n <CompactMarkOr\n className=\"h-8 w-8\"\n today={\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n }\n />\n </div>\n }\n />\n );\n }\n\n if (!hasPermission(NOTIFICATION_PERMISSIONS.NOTIFICATION_LIST) && !currentUser?.id) {\n return (\n <div className=\"p-8 text-center text-text-secondary\">\n {tr(\n 'notifications.noPermissionHistory',\n \"You don't have permission to view notification history.\"\n )}\n </div>\n );\n }\n\n const chips: Array<{ id: ArchivedView; label: string }> = [\n { id: 'archived', label: tr('notifications.v2.archived', 'Archived') },\n { id: 'everything', label: tr('notifications.v2.everything', 'Everything') },\n ];\n const topicOptions = [\n { value: ALL, label: tr('notifications.allTopics', 'All Topics') },\n ...topics.map((topic) => ({ value: topic.id, label: topic.name })),\n ];\n\n return (\n <div className=\"mx-auto w-full max-w-5xl space-y-4 p-3 animate-in fade-in duration-200 sm:space-y-5 sm:p-6\">\n <BackToNotifications />\n <header\n data-tour=\"notification-history-header\"\n className=\"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between\"\n >\n <div>\n <h1 className=\"text-xl font-semibold text-text-primary sm:text-2xl\">\n {tr('notifications.v2.archivedTitle', 'Archived')}\n </h1>\n <p className=\"mt-1 text-sm text-text-secondary\">\n {tr(\n 'notifications.v2.archivedSubtitle',\n 'Notifications you archived. Restore one to put it back in your inbox.'\n )}\n </p>\n </div>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n aria-label={tr('notifications.v2.moreActions', 'More actions')}\n data-testid=\"notifications-archived-overflow\"\n >\n <MoreHorizontal size={18} aria-hidden=\"true\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n <DropdownMenuItem\n data-tour=\"notification-history-export\"\n disabled={notifications.length === 0}\n onSelect={() => exportNotificationsAsCsv(tr, notifications)}\n >\n <Download size={16} aria-hidden=\"true\" />\n {tr('notifications.v2.downloadSpreadsheet', 'Download as spreadsheet')}\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n </header>\n\n <section aria-label={tr('notifications.v2.filters', 'Filters')} className=\"space-y-3\">\n <div className=\"flex flex-col gap-3 sm:flex-row sm:items-center\">\n <SearchField\n label={tr('notifications.searchByTitleOrContent', 'Search by title or content...')}\n value={notificationFilter.search}\n onChange={(search) => updateFilter({ search })}\n />\n <div className=\"flex flex-wrap items-center gap-2\">\n <ViewChips\n chips={chips}\n value={view}\n onChange={setView}\n testIdPrefix=\"notifications-archived-view\"\n />\n <MoreFiltersButton\n open={moreFiltersOpen}\n active={moreFiltersActive}\n controls=\"notifications-archived-more-filters\"\n onToggle={() => setMoreFiltersOpen(!moreFiltersOpen)}\n />\n </div>\n </div>\n <div\n id=\"notifications-archived-more-filters\"\n hidden={!moreFiltersOpen}\n className=\"grid gap-3 rounded-lg border border-border-seam bg-bg-surface p-3 sm:grid-cols-3\"\n >\n <NativeSelect\n aria-label={tr('notifications.v2.topicFilter', 'Topic')}\n options={topicOptions}\n value={notificationFilter.topicId || ALL}\n onValueChange={(value) => updateFilter({ topicId: value === ALL ? undefined : value })}\n />\n <Input\n type=\"date\"\n aria-label={tr('notifications.startDate', 'Start date')}\n value={toDateInput(notificationFilter.dateRange.start)}\n onChange={(e) =>\n updateFilter({\n dateRange: {\n ...notificationFilter.dateRange,\n start: e.target.value ? new Date(e.target.value) : null,\n },\n })\n }\n />\n <Input\n type=\"date\"\n aria-label={tr('notifications.endDate', 'End date')}\n value={toDateInput(notificationFilter.dateRange.end)}\n onChange={(e) =>\n updateFilter({\n dateRange: {\n ...notificationFilter.dateRange,\n end: e.target.value ? new Date(e.target.value) : null,\n },\n })\n }\n />\n </div>\n </section>\n\n <div className=\"space-y-2\">\n {visible.length > 0 ? (\n visible.map((notification) => (\n <div key={notification.id} className=\"space-y-2\">\n <NotificationCard\n notification={notification}\n onArchive={notification.archivedAt ? undefined : archiveNotification}\n onAction={recordAction}\n showArchivedState\n analyticsSource=\"history\"\n navigationV2\n showTopic={moreFiltersOpen}\n />\n {notification.archivedAt && (\n <div className=\"flex justify-end\">\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={() => unarchiveNotification(notification.id)}\n >\n {tr('notifications.restore', 'Restore')}\n </Button>\n </div>\n )}\n </div>\n ))\n ) : (\n <IllustratedEmptyState\n illustration={hasActiveFilters ? 'empty-search' : 'empty-notifications'}\n title={\n hasActiveFilters\n ? tr('notifications.noNotificationsFound', 'No notifications found')\n : view === 'archived'\n ? tr('notifications.v2.archivedEmptyTitle', 'Nothing archived')\n : tr('notifications.historyEmptyTitle', 'No history yet')\n }\n description={\n hasActiveFilters\n ? tr('notifications.adjustSearchOrDateRange', 'Try adjusting your filters')\n : view === 'archived'\n ? tr(\n 'notifications.v2.archivedEmptyDescription',\n 'Archive a notification from your inbox and it moves here.'\n )\n : tr(\n 'notifications.historyEmptyDescription',\n 'Notifications you receive will be archived here so you can always find them again.'\n )\n }\n kind={\n notificationFilter.search ? 'no-results' : hasActiveFilters ? 'filtered' : 'first-use'\n }\n />\n )}\n </div>\n\n <NotificationListFooter\n hasMore={hasMore}\n isLoadingMore={isLoadingMore}\n onLoadMore={loadMore}\n shownCount={visible.length}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0BA,IAAMA,IAAiB;CAAE,UAAU;CAAM,SAAS;AAAe,GAC3DC,IAAM;AAEZ,SAASC,EAAY,GAA4B;CAC/C,OAAOC,IAAQA,EAAM,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK;AACrD;AAUA,SAAgBC,IAAyB;CACvC,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;OACR,MAAK;OACL,eAAee,EAAsB/B,EAAa,EAAE;OAEnD,UAAAjB,EAAG,yBAAyB,SAAS;MAChC,CAAA;KACL,CAAA,CAEJ;IAtBK,GAAAiB,EAAa,EAsBlB,CACN,IAED,kBAACgC,GAAD;KACE,cAAc7B,IAAmB,iBAAiB;KAClD,OACEA,IACIpB,EAAG,sCAAsC,wBAAwB,IACjEO,MAAS,aACPP,EAAG,uCAAuC,kBAAkB,IAC5DA,EAAG,mCAAmC,gBAAgB;KAE9D,aACEoB,IACIpB,EAAG,yCAAyC,4BAA4B,IACxEO,MAAS,aACPP,EACE,6CACA,2DACF,IACAA,EACE,yCACA,oFACF;KAER,MACEmB,EAAmB,SAAS,eAAeC,IAAmB,aAAa;IAE9E,CAAA;GAEA,CAAA;GAEL,kBAAC8B,GAAD;IACW;IACM;IACf,YAAYC;IACZ,YAAYtC,EAAQ;GACrB,CAAA;EACE;;AAET"}
|
|
1
|
+
{"version":3,"file":"NotificationArchivedV2.js","names":["HISTORY_FILTER","ALL","toDateInput","value","NotificationArchivedV2","tr","useTr","permissionsLoading","usePermissions","useNotification","useNotificationTopics","useNotifications","view","setView","useState","moreFiltersOpen","setMoreFiltersOpen","useRememberedOpen","visible","useMemo","notifications","inArchivedView","notification","moreFiltersActive","notificationFilter","hasActiveFilters","SectionLoaderOr","CompactMarkOr","hasPermission","NOTIFICATION_PERMISSIONS","currentUser","chips","topicOptions","topics","topic","BackToNotifications","DropdownMenu","DropdownMenuTrigger","Button","MoreHorizontal","DropdownMenuContent","DropdownMenuItem","exportNotificationsAsCsv","Download","SearchField","updateFilter","ViewChips","MoreFiltersButton","NativeSelect","Input","NotificationCard","archiveNotification","recordAction","unarchiveNotification","IllustratedEmptyState","NotificationListFooter","loadMore"],"sources":["../../src/navigation-v2/NotificationArchivedV2.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { Download, MoreHorizontal } from 'lucide-react';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport {\n Button,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n IllustratedEmptyState,\n Input,\n NativeSelect,\n useRememberedOpen,\n} from '@burdenoff/fe-libs/ui';\nimport { NotificationCard } from '../components/NotificationCard';\nimport { NotificationListFooter } from '../components/NotificationListFooter';\nimport { NOTIFICATION_PERMISSIONS } from '../constants/permissions';\nimport { useNotifications, useNotificationTopics } from '../hooks';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { useTr } from '../shared/hooks/useTr';\nimport { inArchivedView, type ArchivedView } from './inboxFilters';\nimport { exportNotificationsAsCsv } from '../utils/notificationHistoryExport';\nimport { BackToNotifications } from './BackToNotifications';\nimport { MoreFiltersButton, SearchField, ViewChips } from './FilterControls';\nimport { CompactMarkOr, SectionLoaderOr } from '../components/loadingSystem';\n\nconst HISTORY_FILTER = { archived: null, channel: 'ALL' as const };\nconst ALL = 'ALL';\n\nfunction toDateInput(value: Date | null): string {\n return value ? value.toISOString().split('T')[0] : '';\n}\n\n/**\n * Archived, Navigation v2 (BOFF-11872; today's personal Notification\n * History). Same query as the classic page (every channel, archived or\n * not); the \"Archived\" chip, on by default, shows what you archived and\n * \"Everything\" shows the full history. Restore on each archived row, search\n * at level 1, topic and dates under \"More filters\", and \"Download as\n * spreadsheet\" in \"⋯\".\n */\nexport function NotificationArchivedV2() {\n const tr = useTr();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const { currentUser } = useNotification();\n const { topics } = useNotificationTopics({ isActive: true });\n const {\n notifications,\n hasMore,\n isLoadingMore,\n loadMore,\n notificationFilter,\n updateFilter,\n archiveNotification,\n unarchiveNotification,\n recordAction,\n } = useNotifications({ baseFilter: HISTORY_FILTER });\n const [view, setView] = useState<ArchivedView>('archived');\n const [moreFiltersOpen, setMoreFiltersOpen] = useRememberedOpen(\n 'notifications.archived.moreFilters',\n false\n );\n\n const visible = useMemo(\n () => notifications.filter((notification) => inArchivedView(notification, view)),\n [notifications, view]\n );\n\n const moreFiltersActive = Boolean(\n notificationFilter.topicId ||\n notificationFilter.dateRange.start ||\n notificationFilter.dateRange.end\n );\n const hasActiveFilters = Boolean(notificationFilter.search) || moreFiltersActive;\n\n if (permissionsLoading) {\n return (\n <SectionLoaderOr\n minHeight=\"16rem\"\n today={\n <div className=\"flex h-64 items-center justify-center\">\n <CompactMarkOr\n className=\"h-8 w-8\"\n today={\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n }\n />\n </div>\n }\n />\n );\n }\n\n if (!hasPermission(NOTIFICATION_PERMISSIONS.NOTIFICATION_LIST) && !currentUser?.id) {\n return (\n <div className=\"p-8 text-center text-text-secondary\">\n {tr(\n 'notifications.noPermissionHistory',\n \"You don't have permission to view notification history.\"\n )}\n </div>\n );\n }\n\n const chips: Array<{ id: ArchivedView; label: string }> = [\n { id: 'archived', label: tr('notifications.v2.archived', 'Archived') },\n { id: 'everything', label: tr('notifications.v2.everything', 'Everything') },\n ];\n const topicOptions = [\n { value: ALL, label: tr('notifications.allTopics', 'All Topics') },\n ...topics.map((topic) => ({ value: topic.id, label: topic.name })),\n ];\n\n return (\n <div className=\"mx-auto w-full max-w-5xl space-y-4 p-3 animate-in fade-in duration-200 sm:space-y-5 sm:p-6\">\n <BackToNotifications />\n <header\n data-tour=\"notification-history-header\"\n className=\"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between\"\n >\n <div>\n <h1 className=\"text-xl font-semibold text-text-primary sm:text-2xl\">\n {tr('notifications.v2.archivedTitle', 'Archived')}\n </h1>\n <p className=\"mt-1 text-sm text-text-secondary\">\n {tr(\n 'notifications.v2.archivedSubtitle',\n 'Notifications you archived. Restore one to put it back in your inbox.'\n )}\n </p>\n </div>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n aria-label={tr('notifications.v2.moreActions', 'More actions')}\n data-testid=\"notifications-archived-overflow\"\n >\n <MoreHorizontal size={18} aria-hidden=\"true\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n <DropdownMenuItem\n data-tour=\"notification-history-export\"\n disabled={notifications.length === 0}\n onSelect={() => exportNotificationsAsCsv(tr, notifications)}\n >\n <Download size={16} aria-hidden=\"true\" />\n {tr('notifications.v2.downloadSpreadsheet', 'Download as spreadsheet')}\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n </header>\n\n <section aria-label={tr('notifications.v2.filters', 'Filters')} className=\"space-y-3\">\n <div className=\"flex flex-col gap-3 sm:flex-row sm:items-center\">\n <SearchField\n label={tr('notifications.searchByTitleOrContent', 'Search by title or content...')}\n value={notificationFilter.search}\n onChange={(search) => updateFilter({ search })}\n />\n <div className=\"flex flex-wrap items-center gap-2\">\n <ViewChips\n chips={chips}\n value={view}\n onChange={setView}\n testIdPrefix=\"notifications-archived-view\"\n />\n <MoreFiltersButton\n open={moreFiltersOpen}\n active={moreFiltersActive}\n controls=\"notifications-archived-more-filters\"\n onToggle={() => setMoreFiltersOpen(!moreFiltersOpen)}\n />\n </div>\n </div>\n <div\n id=\"notifications-archived-more-filters\"\n hidden={!moreFiltersOpen}\n className=\"grid gap-3 rounded-lg border border-border-seam bg-bg-surface p-3 sm:grid-cols-3\"\n >\n <NativeSelect\n aria-label={tr('notifications.v2.topicFilter', 'Topic')}\n options={topicOptions}\n value={notificationFilter.topicId || ALL}\n onValueChange={(value) => updateFilter({ topicId: value === ALL ? undefined : value })}\n />\n <Input\n type=\"date\"\n aria-label={tr('notifications.startDate', 'Start date')}\n value={toDateInput(notificationFilter.dateRange.start)}\n onChange={(e) =>\n updateFilter({\n dateRange: {\n ...notificationFilter.dateRange,\n start: e.target.value ? new Date(e.target.value) : null,\n },\n })\n }\n />\n <Input\n type=\"date\"\n aria-label={tr('notifications.endDate', 'End date')}\n value={toDateInput(notificationFilter.dateRange.end)}\n onChange={(e) =>\n updateFilter({\n dateRange: {\n ...notificationFilter.dateRange,\n end: e.target.value ? new Date(e.target.value) : null,\n },\n })\n }\n />\n </div>\n </section>\n\n <div className=\"space-y-2\">\n {visible.length > 0 ? (\n visible.map((notification) => (\n <div key={notification.id} className=\"space-y-2\">\n <NotificationCard\n notification={notification}\n onArchive={notification.archivedAt ? undefined : archiveNotification}\n onAction={recordAction}\n showArchivedState\n analyticsSource=\"history\"\n navigationV2\n showTopic={moreFiltersOpen}\n />\n {notification.archivedAt && (\n <div className=\"flex justify-end\">\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={() => unarchiveNotification(notification.id)}\n >\n {tr('notifications.restore', 'Restore')}\n </Button>\n </div>\n )}\n </div>\n ))\n ) : (\n <IllustratedEmptyState\n illustration={hasActiveFilters ? 'empty-search' : 'empty-notifications'}\n title={\n hasActiveFilters\n ? tr('notifications.noNotificationsFound', 'No notifications found')\n : view === 'archived'\n ? tr('notifications.v2.archivedEmptyTitle', 'Nothing archived')\n : tr('notifications.historyEmptyTitle', 'No history yet')\n }\n description={\n hasActiveFilters\n ? tr('notifications.adjustSearchOrDateRange', 'Try adjusting your filters')\n : view === 'archived'\n ? tr(\n 'notifications.v2.archivedEmptyDescription',\n 'Archive a notification from your inbox and it moves here.'\n )\n : tr(\n 'notifications.historyEmptyDescription',\n 'Notifications you receive will be archived here so you can always find them again.'\n )\n }\n kind={\n notificationFilter.search ? 'no-results' : hasActiveFilters ? 'filtered' : 'first-use'\n }\n />\n )}\n </div>\n\n <NotificationListFooter\n hasMore={hasMore}\n isLoadingMore={isLoadingMore}\n onLoadMore={loadMore}\n shownCount={visible.length}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,IAAMA,IAAiB;CAAE,UAAU;CAAM,SAAS;AAAe,GAC3DC,IAAM;AAEZ,SAASC,EAAY,GAA4B;CAC/C,OAAOC,IAAQA,EAAM,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK;AACrD;AAUA,SAAgBC,IAAyB;CACvC,IAAMC,I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AAK;OACL,eAAee,EAAsB/B,EAAa,EAAE;OAEnD,UAAAjB,EAAG,yBAAyB,SAAS;MAChC,CAAA;KACL,CAAA,CAEJ;IAtBK,GAAAiB,EAAa,EAsBlB,CACN,IAED,kBAACgC,GAAD;KACE,cAAc7B,IAAmB,iBAAiB;KAClD,OACEA,IACIpB,EAAG,sCAAsC,wBAAwB,IACjEO,MAAS,aACPP,EAAG,uCAAuC,kBAAkB,IAC5DA,EAAG,mCAAmC,gBAAgB;KAE9D,aACEoB,IACIpB,EAAG,yCAAyC,4BAA4B,IACxEO,MAAS,aACPP,EACE,6CACA,2DACF,IACAA,EACE,yCACA,oFACF;KAER,MACEmB,EAAmB,SAAS,eAAeC,IAAmB,aAAa;IAE9E,CAAA;GAEA,CAAA;GAEL,kBAAC8B,GAAD;IACW;IACM;IACf,YAAYC;IACZ,YAAYtC,EAAQ;GACrB,CAAA;EACE;;AAET"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { NotificationCard as e } from "../components/NotificationCard.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import "../hooks/index.js";
|
|
2
|
+
import { NotificationListFooter as t } from "../components/NotificationListFooter.js";
|
|
3
|
+
import { NOTIFICATION_PERMISSIONS as n } from "../constants/permissions.js";
|
|
4
|
+
import { useNotifications as r } from "../hooks/useNotifications.js";
|
|
5
|
+
import { useNotificationTopics as ee } from "../hooks/useNotificationTopics.js";
|
|
7
6
|
import { useNotification as i } from "../providers/NotificationProvider.js";
|
|
8
7
|
import { useTr as a } from "../shared/hooks/useTr.js";
|
|
9
8
|
import { needsAction as o } from "./inboxFilters.js";
|
|
@@ -25,10 +24,10 @@ var k = {
|
|
|
25
24
|
channel: "IN_APP"
|
|
26
25
|
}, A = { channel: "IN_APP" }, j = "ALL";
|
|
27
26
|
function M() {
|
|
28
|
-
let l = a(), y = p(), { hasPermission: b, isLoading: x } = v(), { currentUser: M } = i(), { notifications: P, hasMore: F, isLoadingMore: I, loadMore: L, unreadCount: R, notificationFilter: z, markAsRead: B, markAllAsRead: V, archiveNotification: H, recordAction: ne, updateFilter: U, resetFilter: W } =
|
|
27
|
+
let l = a(), y = p(), { hasPermission: b, isLoading: x } = v(), { currentUser: M } = i(), { notifications: P, hasMore: F, isLoadingMore: I, loadMore: L, unreadCount: R, notificationFilter: z, markAsRead: B, markAllAsRead: V, archiveNotification: H, recordAction: ne, updateFilter: U, resetFilter: W } = r({
|
|
29
28
|
baseFilter: k,
|
|
30
29
|
unreadFilter: A
|
|
31
|
-
}), { topics: G } =
|
|
30
|
+
}), { topics: G } = ee({ isActive: !0 }), [K, q] = _(!1), [J, Y] = O("notifications.inbox.moreFilters", !1), X = K ? "action" : z.isRead === !1 ? "unread" : z.isRead === null ? "all" : null, Z = g(() => {
|
|
32
31
|
let e = s(P, z);
|
|
33
32
|
return K ? e.filter(o) : e;
|
|
34
33
|
}, [
|
|
@@ -50,7 +49,7 @@ function M() {
|
|
|
50
49
|
})
|
|
51
50
|
})
|
|
52
51
|
});
|
|
53
|
-
if (!b(
|
|
52
|
+
if (!b(n.NOTIFICATION_LIST) && !M?.id) return /* @__PURE__ */ C("div", {
|
|
54
53
|
className: "p-8 text-center text-text-secondary",
|
|
55
54
|
children: l("notifications.noPermissionView", "You don't have permission to view notifications.")
|
|
56
55
|
});
|
|
@@ -245,7 +244,7 @@ function M() {
|
|
|
245
244
|
kind: z.search ? "no-results" : Q ? "filtered" : "all-done"
|
|
246
245
|
})
|
|
247
246
|
}),
|
|
248
|
-
/* @__PURE__ */ C(
|
|
247
|
+
/* @__PURE__ */ C(t, {
|
|
249
248
|
hasMore: F,
|
|
250
249
|
isLoadingMore: I,
|
|
251
250
|
onLoadMore: L,
|