@burdenoff/microfe-notification 2026.424.101
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/README.md +376 -0
- package/dist/AdminNotificationRoot.d.ts +35 -0
- package/dist/AdminNotificationRoot.d.ts.map +1 -0
- package/dist/AdminNotificationRoot.js +81 -0
- package/dist/AdminNotificationRoot.js.map +1 -0
- package/dist/AdminNotificationRoutes.d.ts +2 -0
- package/dist/AdminNotificationRoutes.d.ts.map +1 -0
- package/dist/AdminNotificationRoutes.js +108 -0
- package/dist/AdminNotificationRoutes.js.map +1 -0
- package/dist/NotificationRoot.d.ts +31 -0
- package/dist/NotificationRoot.d.ts.map +1 -0
- package/dist/NotificationRoot.js +81 -0
- package/dist/NotificationRoot.js.map +1 -0
- package/dist/NotificationRoutes.d.ts +17 -0
- package/dist/NotificationRoutes.d.ts.map +1 -0
- package/dist/NotificationRoutes.js +67 -0
- package/dist/NotificationRoutes.js.map +1 -0
- package/dist/UserNotificationRoot.d.ts +34 -0
- package/dist/UserNotificationRoot.d.ts.map +1 -0
- package/dist/UserNotificationRoot.js +64 -0
- package/dist/UserNotificationRoot.js.map +1 -0
- package/dist/UserNotificationRoutes.d.ts +15 -0
- package/dist/UserNotificationRoutes.d.ts.map +1 -0
- package/dist/UserNotificationRoutes.js +52 -0
- package/dist/UserNotificationRoutes.js.map +1 -0
- package/dist/__tests__/setup.d.ts +2 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/components/NotificationBell.d.ts +14 -0
- package/dist/components/NotificationBell.d.ts.map +1 -0
- package/dist/components/NotificationBell.js +47 -0
- package/dist/components/NotificationBell.js.map +1 -0
- package/dist/components/NotificationCard.d.ts +19 -0
- package/dist/components/NotificationCard.d.ts.map +1 -0
- package/dist/components/NotificationCard.js +112 -0
- package/dist/components/NotificationCard.js.map +1 -0
- package/dist/components/NotificationPanel.d.ts +11 -0
- package/dist/components/NotificationPanel.d.ts.map +1 -0
- package/dist/components/NotificationPanel.js +100 -0
- package/dist/components/NotificationPanel.js.map +1 -0
- package/dist/components/RecipientSelector.d.ts +34 -0
- package/dist/components/RecipientSelector.d.ts.map +1 -0
- package/dist/components/RecipientSelector.js +212 -0
- package/dist/components/RecipientSelector.js.map +1 -0
- package/dist/components/TemplatePreview.d.ts +22 -0
- package/dist/components/TemplatePreview.d.ts.map +1 -0
- package/dist/components/TemplatePreview.js +425 -0
- package/dist/components/TemplatePreview.js.map +1 -0
- package/dist/components/VariableInserter.d.ts +12 -0
- package/dist/components/VariableInserter.d.ts.map +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +3 -0
- package/dist/constants/permissions.d.ts +24 -0
- package/dist/constants/permissions.d.ts.map +1 -0
- package/dist/constants/permissions.js +17 -0
- package/dist/constants/permissions.js.map +1 -0
- package/dist/dev/main.d.ts +2 -0
- package/dist/dev/main.d.ts.map +1 -0
- package/dist/generated/global-operations.d.ts +1408 -0
- package/dist/generated/global-operations.d.ts.map +1 -0
- package/dist/generated/global-operations.js +514 -0
- package/dist/generated/global-operations.js.map +1 -0
- package/dist/generated/global-types.d.ts +20773 -0
- package/dist/generated/global-types.d.ts.map +1 -0
- package/dist/generated/wspace-operations.d.ts +2 -0
- package/dist/generated/wspace-operations.d.ts.map +1 -0
- package/dist/generated/wspace-types.d.ts +53363 -0
- package/dist/generated/wspace-types.d.ts.map +1 -0
- package/dist/graphql/global-client.d.ts +19 -0
- package/dist/graphql/global-client.d.ts.map +1 -0
- package/dist/graphql/global-client.js +57 -0
- package/dist/graphql/global-client.js.map +1 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/useNotificationAdmin.d.ts +51 -0
- package/dist/hooks/useNotificationAdmin.d.ts.map +1 -0
- package/dist/hooks/useNotificationAdmin.js +203 -0
- package/dist/hooks/useNotificationAdmin.js.map +1 -0
- package/dist/hooks/useNotificationTemplates.d.ts +136 -0
- package/dist/hooks/useNotificationTemplates.d.ts.map +1 -0
- package/dist/hooks/useNotificationTemplates.js +168 -0
- package/dist/hooks/useNotificationTemplates.js.map +1 -0
- package/dist/hooks/useNotificationTopics.d.ts +36 -0
- package/dist/hooks/useNotificationTopics.d.ts.map +1 -0
- package/dist/hooks/useNotificationTopics.js +127 -0
- package/dist/hooks/useNotificationTopics.js.map +1 -0
- package/dist/hooks/useNotifications.d.ts +36 -0
- package/dist/hooks/useNotifications.d.ts.map +1 -0
- package/dist/hooks/useNotifications.js +289 -0
- package/dist/hooks/useNotifications.js.map +1 -0
- package/dist/hooks/useSendNotification.d.ts +159 -0
- package/dist/hooks/useSendNotification.d.ts.map +1 -0
- package/dist/hooks/useSendNotification.js +123 -0
- package/dist/hooks/useSendNotification.js.map +1 -0
- package/dist/hooks/useUserSearch.d.ts +27 -0
- package/dist/hooks/useUserSearch.d.ts.map +1 -0
- package/dist/hooks/useUserSearch.js +76 -0
- package/dist/hooks/useUserSearch.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/pages/CreateNotificationPage.d.ts +6 -0
- package/dist/pages/CreateNotificationPage.d.ts.map +1 -0
- package/dist/pages/CreateNotificationPage.js +1366 -0
- package/dist/pages/CreateNotificationPage.js.map +1 -0
- package/dist/pages/NotificationCenterPage.d.ts +7 -0
- package/dist/pages/NotificationCenterPage.d.ts.map +1 -0
- package/dist/pages/NotificationCenterPage.js +203 -0
- package/dist/pages/NotificationCenterPage.js.map +1 -0
- package/dist/pages/NotificationHistoryAdminPage.d.ts +3 -0
- package/dist/pages/NotificationHistoryAdminPage.d.ts.map +1 -0
- package/dist/pages/NotificationHistoryAdminPage.js +484 -0
- package/dist/pages/NotificationHistoryAdminPage.js.map +1 -0
- package/dist/pages/NotificationHistoryPage.d.ts +3 -0
- package/dist/pages/NotificationHistoryPage.d.ts.map +1 -0
- package/dist/pages/NotificationHistoryPage.js +136 -0
- package/dist/pages/NotificationHistoryPage.js.map +1 -0
- package/dist/pages/NotificationLandingPage.d.ts +11 -0
- package/dist/pages/NotificationLandingPage.d.ts.map +1 -0
- package/dist/pages/NotificationLandingPage.js +85 -0
- package/dist/pages/NotificationLandingPage.js.map +1 -0
- package/dist/pages/NotificationPreferencesPage.d.ts +2 -0
- package/dist/pages/NotificationPreferencesPage.d.ts.map +1 -0
- package/dist/pages/NotificationPreferencesPage.js +108 -0
- package/dist/pages/NotificationPreferencesPage.js.map +1 -0
- package/dist/pages/NotificationTemplatesPage.d.ts +8 -0
- package/dist/pages/NotificationTemplatesPage.d.ts.map +1 -0
- package/dist/pages/NotificationTemplatesPage.js +310 -0
- package/dist/pages/NotificationTemplatesPage.js.map +1 -0
- package/dist/pages/NotificationTopicsPage.d.ts +2 -0
- package/dist/pages/NotificationTopicsPage.d.ts.map +1 -0
- package/dist/pages/NotificationTopicsPage.js +254 -0
- package/dist/pages/NotificationTopicsPage.js.map +1 -0
- package/dist/pages/TemplateEditorPage.d.ts +13 -0
- package/dist/pages/TemplateEditorPage.d.ts.map +1 -0
- package/dist/pages/TemplateEditorPage.js +790 -0
- package/dist/pages/TemplateEditorPage.js.map +1 -0
- package/dist/providers/NotificationProvider.d.ts +19 -0
- package/dist/providers/NotificationProvider.d.ts.map +1 -0
- package/dist/providers/NotificationProvider.js +35 -0
- package/dist/providers/NotificationProvider.js.map +1 -0
- package/dist/shared/hooks/useTr.d.ts +14 -0
- package/dist/shared/hooks/useTr.d.ts.map +1 -0
- package/dist/shared/hooks/useTr.js +14 -0
- package/dist/shared/hooks/useTr.js.map +1 -0
- package/dist/store/notificationStore.d.ts +32 -0
- package/dist/store/notificationStore.d.ts.map +1 -0
- package/dist/store/notificationStore.js +124 -0
- package/dist/store/notificationStore.js.map +1 -0
- package/dist/types/index.d.ts +215 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/index.d.ts +68 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +122 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/notificationHistoryExport.d.ts +13 -0
- package/dist/utils/notificationHistoryExport.d.ts.map +1 -0
- package/dist/utils/notificationHistoryExport.js +29 -0
- package/dist/utils/notificationHistoryExport.js.map +1 -0
- package/package.json +115 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { useNotification as e } from "../providers/NotificationProvider.js";
|
|
2
|
+
import { getGlobalNotificationClient as t } from "../graphql/global-client.js";
|
|
3
|
+
import { useNotificationStore as n } from "../store/notificationStore.js";
|
|
4
|
+
import { ArchiveNotificationDocument as r, ArchiveNotificationsDocument as i, GetMyUnreadNotificationCountDocument as a, GetNotificationsDocument as o, MarkAllMyNotificationsAsReadDocument as s, MarkNotificationAsReadDocument as c, RecordNotificationActionDocument as l, UnarchiveNotificationDocument as u } from "../generated/global-operations.js";
|
|
5
|
+
import { useCallback as d, useEffect as f, useState as p } from "react";
|
|
6
|
+
//#region src/hooks/useNotifications.ts
|
|
7
|
+
function m(e) {
|
|
8
|
+
return {
|
|
9
|
+
id: e.id,
|
|
10
|
+
type: h(e.type),
|
|
11
|
+
priority: g(e.priority),
|
|
12
|
+
title: e.title,
|
|
13
|
+
body: e.message,
|
|
14
|
+
actionUrl: e.redirectUrl ?? void 0,
|
|
15
|
+
actions: (e.actions || []).map((e) => ({
|
|
16
|
+
id: e.id,
|
|
17
|
+
label: e.label,
|
|
18
|
+
url: e.url,
|
|
19
|
+
style: e.style ?? void 0,
|
|
20
|
+
actionType: e.actionType ?? void 0,
|
|
21
|
+
metadata: e.metadata ?? void 0
|
|
22
|
+
})),
|
|
23
|
+
appName: e.appName ?? void 0,
|
|
24
|
+
archivedAt: e.archivedAt ?? void 0,
|
|
25
|
+
channel: e.channel,
|
|
26
|
+
clickedAt: e.clickedAt ?? void 0,
|
|
27
|
+
deliveredAt: e.deliveredAt ?? void 0,
|
|
28
|
+
deliveryStatus: e.deliveryStatus ?? void 0,
|
|
29
|
+
htmlBody: e.htmlMessage ?? void 0,
|
|
30
|
+
media: (e.media || []).map((e) => ({
|
|
31
|
+
url: e.url,
|
|
32
|
+
label: e.label ?? void 0,
|
|
33
|
+
kind: e.kind ?? void 0,
|
|
34
|
+
contentType: e.contentType ?? void 0,
|
|
35
|
+
thumbnailUrl: e.thumbnailUrl ?? void 0
|
|
36
|
+
})),
|
|
37
|
+
openedAt: e.openedAt ?? void 0,
|
|
38
|
+
recipientEmail: e.recipientEmail ?? void 0,
|
|
39
|
+
recipientPhone: e.recipientPhone ?? void 0,
|
|
40
|
+
scheduledFor: e.scheduledFor ?? void 0,
|
|
41
|
+
scheduledNotification: e.scheduledNotification ? {
|
|
42
|
+
id: e.scheduledNotification.id,
|
|
43
|
+
scheduledFor: e.scheduledNotification.scheduledFor,
|
|
44
|
+
status: e.scheduledNotification.status,
|
|
45
|
+
timezone: e.scheduledNotification.timezone ?? void 0
|
|
46
|
+
} : void 0,
|
|
47
|
+
sentAt: e.sentAt ?? void 0,
|
|
48
|
+
status: _(e.status),
|
|
49
|
+
readAt: e.readAt ?? void 0,
|
|
50
|
+
createdAt: e.createdAt,
|
|
51
|
+
channels: [{
|
|
52
|
+
id: e.id,
|
|
53
|
+
channel: e.channel,
|
|
54
|
+
status: _(e.status),
|
|
55
|
+
sentAt: e.sentAt ?? void 0,
|
|
56
|
+
deliveredAt: e.deliveredAt ?? void 0,
|
|
57
|
+
failedAt: e.failedAt ?? void 0,
|
|
58
|
+
errorCode: e.errorCode ?? void 0,
|
|
59
|
+
errorMessage: e.errorMessage ?? void 0
|
|
60
|
+
}],
|
|
61
|
+
metadata: e.metadata ?? void 0,
|
|
62
|
+
topic: e.topic ? {
|
|
63
|
+
id: e.topic.id,
|
|
64
|
+
name: e.topic.name,
|
|
65
|
+
slug: e.topic.slug,
|
|
66
|
+
type: h(e.topic.type)
|
|
67
|
+
} : void 0,
|
|
68
|
+
topicId: e.topicId ?? void 0
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function h(e) {
|
|
72
|
+
return {
|
|
73
|
+
SYSTEM: "SYSTEM",
|
|
74
|
+
TRANSACTIONAL: "TRANSACTIONAL",
|
|
75
|
+
MARKETING: "MARKETING",
|
|
76
|
+
ALERT: "ALERT"
|
|
77
|
+
}[e] || "SYSTEM";
|
|
78
|
+
}
|
|
79
|
+
function g(e) {
|
|
80
|
+
return {
|
|
81
|
+
LOW: "LOW",
|
|
82
|
+
MEDIUM: "NORMAL",
|
|
83
|
+
HIGH: "HIGH",
|
|
84
|
+
URGENT: "URGENT"
|
|
85
|
+
}[e] || "NORMAL";
|
|
86
|
+
}
|
|
87
|
+
function _(e) {
|
|
88
|
+
return {
|
|
89
|
+
DRAFT: "PENDING",
|
|
90
|
+
PENDING: "PENDING",
|
|
91
|
+
SCHEDULED: "PENDING",
|
|
92
|
+
TRIGGERED: "SENT",
|
|
93
|
+
SENT: "SENT",
|
|
94
|
+
DELIVERED: "DELIVERED",
|
|
95
|
+
READ: "DELIVERED",
|
|
96
|
+
FAILED: "FAILED",
|
|
97
|
+
CANCELLED: "ARCHIVED",
|
|
98
|
+
EXPIRED: "ARCHIVED"
|
|
99
|
+
}[e] || "PENDING";
|
|
100
|
+
}
|
|
101
|
+
function v(e) {
|
|
102
|
+
let t = {};
|
|
103
|
+
return e.type !== "ALL" && (t.type = {
|
|
104
|
+
SYSTEM: "SYSTEM",
|
|
105
|
+
ACTIVITY: "TRANSACTIONAL",
|
|
106
|
+
BILLING: "TRANSACTIONAL",
|
|
107
|
+
SECURITY: "ALERT",
|
|
108
|
+
SOCIAL: "MARKETING",
|
|
109
|
+
REMINDER: "SYSTEM"
|
|
110
|
+
}[e.type] || e.type), e.priority !== "ALL" && (t.priority = {
|
|
111
|
+
LOW: "LOW",
|
|
112
|
+
NORMAL: "MEDIUM",
|
|
113
|
+
HIGH: "HIGH",
|
|
114
|
+
URGENT: "URGENT"
|
|
115
|
+
}[e.priority] || e.priority), e.isRead !== null && e.isRead !== void 0 && (t.isRead = e.isRead), e.topicId && (t.topicId = e.topicId), e.channel && e.channel !== "ALL" && (t.channel = e.channel), e.archived !== null && e.archived !== void 0 && (t.archived = e.archived), e.search && (t.search = e.search), e.dateRange.start && (t.startDate = e.dateRange.start.toISOString()), e.dateRange.end && (t.endDate = e.dateRange.end.toISOString()), Object.keys(t).length > 0 ? t : void 0;
|
|
116
|
+
}
|
|
117
|
+
function y() {
|
|
118
|
+
let { authToken: h, apiGatewayUrl: g } = e(), { notificationFilter: _, updateNotificationFilter: y, resetNotificationFilter: b, unreadCount: x, setUnreadCount: S, setIsLoadingNotifications: C } = n(), [w, T] = p([]), [E, D] = p(null), [O, k] = p(!1), [A, j] = p(null), [M, N] = p(!1), [P, F] = p(0), [I, L] = p(0), R = d(() => t(g ?? void 0, h ?? void 0), [g, h]), z = d(async () => {
|
|
119
|
+
k(!0), C(!0), j(null);
|
|
120
|
+
try {
|
|
121
|
+
let e = await R().query({
|
|
122
|
+
query: o,
|
|
123
|
+
variables: {
|
|
124
|
+
filter: v(_),
|
|
125
|
+
limit: 50,
|
|
126
|
+
offset: 0
|
|
127
|
+
},
|
|
128
|
+
fetchPolicy: "network-only"
|
|
129
|
+
});
|
|
130
|
+
e.data?.notifications && (T(e.data.notifications.items.map(m)), F(e.data.notifications.total), N(e.data.notifications.hasMore), L(50));
|
|
131
|
+
} catch (e) {
|
|
132
|
+
let t = e instanceof Error ? e.message : "Failed to fetch notifications";
|
|
133
|
+
console.error("[useNotifications] Failed to fetch notifications:", e), j(t);
|
|
134
|
+
} finally {
|
|
135
|
+
k(!1), C(!1);
|
|
136
|
+
}
|
|
137
|
+
}, [
|
|
138
|
+
R,
|
|
139
|
+
_,
|
|
140
|
+
C
|
|
141
|
+
]), B = d(async () => {
|
|
142
|
+
try {
|
|
143
|
+
let e = await R().query({
|
|
144
|
+
query: a,
|
|
145
|
+
variables: { filter: { channel: "IN_APP" } },
|
|
146
|
+
fetchPolicy: "network-only"
|
|
147
|
+
});
|
|
148
|
+
e.data && S(e.data.myUnreadNotificationCount);
|
|
149
|
+
} catch (e) {
|
|
150
|
+
console.error("[useNotifications] Failed to fetch unread count:", e);
|
|
151
|
+
}
|
|
152
|
+
}, [R, S]), V = d(async () => {
|
|
153
|
+
if (M) try {
|
|
154
|
+
let e = await R().query({
|
|
155
|
+
query: o,
|
|
156
|
+
variables: {
|
|
157
|
+
filter: v(_),
|
|
158
|
+
limit: 50,
|
|
159
|
+
offset: I
|
|
160
|
+
},
|
|
161
|
+
fetchPolicy: "network-only"
|
|
162
|
+
});
|
|
163
|
+
if (e.data?.notifications) {
|
|
164
|
+
let t = e.data.notifications.items.map(m);
|
|
165
|
+
T((e) => [...e, ...t]), N(e.data.notifications.hasMore), L((e) => e + 50);
|
|
166
|
+
}
|
|
167
|
+
} catch (e) {
|
|
168
|
+
let t = e instanceof Error ? e.message : "Failed to load more notifications";
|
|
169
|
+
console.error("[useNotifications] Failed to load more:", e), j(t);
|
|
170
|
+
}
|
|
171
|
+
}, [
|
|
172
|
+
R,
|
|
173
|
+
_,
|
|
174
|
+
M,
|
|
175
|
+
I
|
|
176
|
+
]), H = d(async (e) => {
|
|
177
|
+
try {
|
|
178
|
+
await R().mutate({
|
|
179
|
+
mutation: c,
|
|
180
|
+
variables: { id: e }
|
|
181
|
+
}), T((t) => t.map((t) => t.id === e ? {
|
|
182
|
+
...t,
|
|
183
|
+
readAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
184
|
+
} : t)), S(Math.max(0, x - 1));
|
|
185
|
+
} catch (e) {
|
|
186
|
+
console.error("[useNotifications] Failed to mark as read:", e), j("Failed to mark notification as read");
|
|
187
|
+
}
|
|
188
|
+
}, [
|
|
189
|
+
R,
|
|
190
|
+
S,
|
|
191
|
+
x
|
|
192
|
+
]), U = d(async () => {
|
|
193
|
+
try {
|
|
194
|
+
await R().mutate({ mutation: s }), T((e) => e.map((e) => ({
|
|
195
|
+
...e,
|
|
196
|
+
readAt: e.readAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
197
|
+
}))), S(0);
|
|
198
|
+
} catch (e) {
|
|
199
|
+
console.error("[useNotifications] Failed to mark all as read:", e), j("Failed to mark all notifications as read");
|
|
200
|
+
}
|
|
201
|
+
}, [R, S]), W = d(async (e) => {
|
|
202
|
+
try {
|
|
203
|
+
await R().mutate({
|
|
204
|
+
mutation: r,
|
|
205
|
+
variables: { id: e }
|
|
206
|
+
}), T((t) => t.map((t) => t.id === e ? {
|
|
207
|
+
...t,
|
|
208
|
+
archivedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
209
|
+
} : t));
|
|
210
|
+
} catch (e) {
|
|
211
|
+
console.error("[useNotifications] Failed to archive notification:", e), j("Failed to archive notification");
|
|
212
|
+
}
|
|
213
|
+
}, [R]), G = d(async (e) => {
|
|
214
|
+
try {
|
|
215
|
+
await R().mutate({
|
|
216
|
+
mutation: i,
|
|
217
|
+
variables: { notificationIds: e }
|
|
218
|
+
});
|
|
219
|
+
let t = new Set(e);
|
|
220
|
+
T((e) => e.map((e) => t.has(e.id) ? {
|
|
221
|
+
...e,
|
|
222
|
+
archivedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
223
|
+
} : e));
|
|
224
|
+
} catch (e) {
|
|
225
|
+
console.error("[useNotifications] Failed to bulk archive:", e), j("Failed to archive notifications");
|
|
226
|
+
}
|
|
227
|
+
}, [R]), K = d(async (e) => {
|
|
228
|
+
try {
|
|
229
|
+
await R().mutate({
|
|
230
|
+
mutation: u,
|
|
231
|
+
variables: { id: e }
|
|
232
|
+
}), T((t) => t.map((t) => t.id === e ? {
|
|
233
|
+
...t,
|
|
234
|
+
archivedAt: void 0
|
|
235
|
+
} : t));
|
|
236
|
+
} catch (e) {
|
|
237
|
+
console.error("[useNotifications] Failed to unarchive notification:", e), j("Failed to restore notification");
|
|
238
|
+
}
|
|
239
|
+
}, [R]), q = d(async (e, t) => {
|
|
240
|
+
try {
|
|
241
|
+
await R().mutate({
|
|
242
|
+
mutation: l,
|
|
243
|
+
variables: { input: {
|
|
244
|
+
notificationId: e,
|
|
245
|
+
actionId: t
|
|
246
|
+
} }
|
|
247
|
+
}), T((t) => t.map((t) => t.id === e ? {
|
|
248
|
+
...t,
|
|
249
|
+
clickedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
250
|
+
readAt: t.readAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
251
|
+
} : t));
|
|
252
|
+
} catch (e) {
|
|
253
|
+
console.error("[useNotifications] Failed to record notification action:", e), j("Failed to record notification action");
|
|
254
|
+
}
|
|
255
|
+
}, [R]);
|
|
256
|
+
return f(() => {
|
|
257
|
+
z(), B();
|
|
258
|
+
}, [z, B]), f(() => {
|
|
259
|
+
let e = setInterval(() => {
|
|
260
|
+
z(), B();
|
|
261
|
+
}, 5e3);
|
|
262
|
+
return () => clearInterval(e);
|
|
263
|
+
}, [z, B]), {
|
|
264
|
+
notifications: w.filter((e) => e.deliveryStatus === "UNSUBSCRIBED" || e.status === "ARCHIVED" && !e.archivedAt ? !1 : _.archived === !0 ? !!e.archivedAt : _.archived === !1 ? !e.archivedAt : !0),
|
|
265
|
+
allNotifications: w,
|
|
266
|
+
unreadCount: x,
|
|
267
|
+
selectedNotification: E,
|
|
268
|
+
notificationFilter: _,
|
|
269
|
+
isLoading: O,
|
|
270
|
+
error: A,
|
|
271
|
+
hasMore: M,
|
|
272
|
+
total: P,
|
|
273
|
+
markAsRead: H,
|
|
274
|
+
markAllAsRead: U,
|
|
275
|
+
archiveNotification: W,
|
|
276
|
+
bulkArchive: G,
|
|
277
|
+
unarchiveNotification: K,
|
|
278
|
+
recordAction: q,
|
|
279
|
+
setSelectedNotification: D,
|
|
280
|
+
updateFilter: y,
|
|
281
|
+
resetFilter: b,
|
|
282
|
+
refetch: z,
|
|
283
|
+
loadMore: V
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
//#endregion
|
|
287
|
+
export { y as useNotifications };
|
|
288
|
+
|
|
289
|
+
//# sourceMappingURL=useNotifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNotifications.js","names":[],"sources":["../../src/hooks/useNotifications.ts"],"sourcesContent":["import { useState, useCallback, useEffect } from 'react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient } from '../graphql/global-client';\nimport { useNotificationStore } from '../store/notificationStore';\nimport type { Notification, NotificationFilter } from '../types';\nimport * as NotificationOps from '../generated/global-operations';\nimport type {\n GetNotificationsQuery,\n GetMyUnreadNotificationCountQuery,\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 = GetNotificationsQuery['notifications']['items'][number];\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\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() {\n const { authToken, apiGatewayUrl } = 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 [offset, setOffset] = useState(0);\n\n const LIMIT = 50;\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 setIsLoading(true);\n setIsLoadingNotifications(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: buildBackendFilter(notificationFilter),\n limit: LIMIT,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n\n if (result.data?.notifications) {\n const mapped = result.data.notifications.items.map(mapBackendToMfeNotification);\n setNotifications(mapped);\n setTotal(result.data.notifications.total);\n setHasMore(result.data.notifications.hasMore);\n setOffset(LIMIT);\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 } finally {\n setIsLoading(false);\n setIsLoadingNotifications(false);\n }\n }, [getClient, notificationFilter, 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 query: NotificationOps.GetMyUnreadNotificationCountDocument,\n variables: { filter: { 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, setStoreUnreadCount]);\n\n // ---- Load more ----------------------------------------------------------\n\n const loadMore = useCallback(async () => {\n if (!hasMore) return;\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: buildBackendFilter(notificationFilter),\n limit: LIMIT,\n offset,\n },\n fetchPolicy: 'network-only',\n });\n\n if (result.data?.notifications) {\n const more = result.data.notifications.items.map(mapBackendToMfeNotification);\n setNotifications((prev) => [...prev, ...more]);\n setHasMore(result.data.notifications.hasMore);\n setOffset((prev) => prev + LIMIT);\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 }\n }, [getClient, notificationFilter, hasMore, offset]);\n\n // ---- Mutations ----------------------------------------------------------\n\n const handleMarkAsRead = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\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({ mutation: NotificationOps.MarkAllMyNotificationsAsReadDocument });\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 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 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 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 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 fetchUnreadCount();\n }, [fetchNotifications, fetchUnreadCount]);\n\n // ---- Notification + unread auto-polling (5s interval) -------------------\n\n useEffect(() => {\n const interval = setInterval(() => {\n fetchNotifications();\n fetchUnreadCount();\n }, 5_000);\n return () => clearInterval(interval);\n }, [fetchNotifications, fetchUnreadCount]);\n\n const visibleNotifications = 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 (notificationFilter.archived === true) {\n return Boolean(notification.archivedAt);\n }\n\n if (notificationFilter.archived === false) {\n return !notification.archivedAt;\n }\n\n return true;\n });\n\n return {\n notifications: visibleNotifications,\n allNotifications: notifications,\n unreadCount,\n selectedNotification,\n notificationFilter,\n isLoading,\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":";;;;;;AAwBA,SAAS,EAA4B,GAAsC;AACzE,QAAO;EACL,IAAI,EAAE;EACN,MAAM,EAAoB,EAAE,KAAK;EACjC,UAAU,EAAY,EAAE,SAAS;EACjC,OAAO,EAAE;EACT,MAAM,EAAE;EACR,WAAW,EAAE,eAAe,KAAA;EAC5B,UAAU,EAAE,WAAW,EAAE,EAAE,KAAK,OAAY;GAC1C,IAAI,EAAO;GACX,OAAO,EAAO;GACd,KAAK,EAAO;GACZ,OAAO,EAAO,SAAS,KAAA;GACvB,YAAY,EAAO,cAAc,KAAA;GACjC,UAAU,EAAO,YAAY,KAAA;GAC9B,EAAE;EACH,SAAS,EAAE,WAAW,KAAA;EACtB,YAAY,EAAE,cAAc,KAAA;EAC5B,SAAS,EAAE;EACX,WAAW,EAAE,aAAa,KAAA;EAC1B,aAAa,EAAE,eAAe,KAAA;EAC9B,gBAAgB,EAAE,kBAAkB,KAAA;EACpC,UAAU,EAAE,eAAe,KAAA;EAC3B,QAAQ,EAAE,SAAS,EAAE,EAAE,KAAK,OAAU;GACpC,KAAK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O,IACL;IACE,GAAG;IACH,4BAAW,IAAI,MAAM,EAAC,aAAa;IACnC,QAAQ,EAAE,2BAAU,IAAI,MAAM,EAAC,aAAa;IAC7C,GACD,EACL,CACF;WACM,GAAc;AAErB,GADA,QAAQ,MAAM,4DAA4D,EAAI,EAC9E,EAAS,uCAAuC;;IAGpD,CAAC,EAAU,CACZ;AAuCD,QAnCA,QAAgB;AAEd,EADA,GAAoB,EACpB,GAAkB;IACjB,CAAC,GAAoB,EAAiB,CAAC,EAI1C,QAAgB;EACd,IAAM,IAAW,kBAAkB;AAEjC,GADA,GAAoB,EACpB,GAAkB;KACjB,IAAM;AACT,eAAa,cAAc,EAAS;IACnC,CAAC,GAAoB,EAAiB,CAAC,EAsBnC;EACL,eArB2B,EAAc,QAAQ,MAC7C,EAAa,mBAAmB,kBAIhC,EAAa,WAAW,cAAc,CAAC,EAAa,aAC/C,KAGL,EAAmB,aAAa,KAC3B,EAAQ,EAAa,aAG1B,EAAmB,aAAa,KAC3B,CAAC,EAAa,aAGhB,GACP;EAIA,kBAAkB;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YAAY;EACZ,eAAe;EACf,qBAAqB;EACrB,aAAa;EACb,uBAAuB;EACvB,cAAc;EACd;EACA,cAAc;EACd,aAAa;EACb,SAAS;EACT;EACD"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
export type NotificationChannelType = 'DISCORD' | 'EMAIL' | 'PUSH' | 'SLACK' | 'SMS' | 'TEAMS' | 'TELEGRAM' | 'WEBHOOK' | 'WHATSAPP';
|
|
2
|
+
export type NotificationTypeEnum = 'ALERT' | 'MARKETING' | 'SYSTEM' | 'TRANSACTIONAL';
|
|
3
|
+
export type NotificationPriorityEnum = 'HIGH' | 'LOW' | 'MEDIUM' | 'URGENT';
|
|
4
|
+
export type NotificationStatusEnum = 'CANCELLED' | 'DELIVERED' | 'DRAFT' | 'EXPIRED' | 'FAILED' | 'PENDING' | 'READ' | 'SCHEDULED' | 'SENT' | 'TRIGGERED';
|
|
5
|
+
export type NotificationDeliveryStatusEnum = 'BOUNCED' | 'CLICKED' | 'COMPLAINED' | 'DELIVERED' | 'DELIVERING' | 'FAILED' | 'OPENED' | 'PENDING' | 'PROCESSING' | 'QUEUED' | 'RETRYING' | 'SENT' | 'UNSUBSCRIBED';
|
|
6
|
+
export type TriggerStatusEnum = 'CANCELLED' | 'FAILED' | 'PENDING' | 'TRIGGERED';
|
|
7
|
+
export interface RecipientInput {
|
|
8
|
+
email?: string;
|
|
9
|
+
locale?: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
phoneNumber?: string;
|
|
12
|
+
pushToken?: string;
|
|
13
|
+
slackUserId?: string;
|
|
14
|
+
teamsUserId?: string;
|
|
15
|
+
timezone?: string;
|
|
16
|
+
userId?: string;
|
|
17
|
+
webhookUrl?: string;
|
|
18
|
+
whatsappNumber?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface CreateNotificationInput {
|
|
21
|
+
actions?: Array<{
|
|
22
|
+
id?: string;
|
|
23
|
+
label: string;
|
|
24
|
+
url: string;
|
|
25
|
+
style?: string;
|
|
26
|
+
actionType?: string;
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
}>;
|
|
29
|
+
appName?: string;
|
|
30
|
+
body: string;
|
|
31
|
+
channel: NotificationChannelType;
|
|
32
|
+
data?: Record<string, unknown>;
|
|
33
|
+
expiresAt?: string;
|
|
34
|
+
htmlBody?: string;
|
|
35
|
+
media?: Array<{
|
|
36
|
+
url: string;
|
|
37
|
+
label?: string;
|
|
38
|
+
kind?: string;
|
|
39
|
+
contentType?: string;
|
|
40
|
+
thumbnailUrl?: string;
|
|
41
|
+
}>;
|
|
42
|
+
metadata?: Record<string, unknown>;
|
|
43
|
+
priority?: NotificationPriorityEnum;
|
|
44
|
+
recipient: RecipientInput;
|
|
45
|
+
redirectUrl?: string;
|
|
46
|
+
subject?: string;
|
|
47
|
+
trackClicks?: boolean;
|
|
48
|
+
trackOpens?: boolean;
|
|
49
|
+
topicId?: string;
|
|
50
|
+
type?: NotificationTypeEnum;
|
|
51
|
+
}
|
|
52
|
+
export interface TriggerNotificationInput {
|
|
53
|
+
notificationId?: string;
|
|
54
|
+
notification?: CreateNotificationInput;
|
|
55
|
+
channelId?: string;
|
|
56
|
+
platform?: NotificationChannelType;
|
|
57
|
+
includeInApp?: boolean;
|
|
58
|
+
userIds?: string[];
|
|
59
|
+
}
|
|
60
|
+
export interface TemplateNotificationResult {
|
|
61
|
+
totalRequested: number;
|
|
62
|
+
totalTriggered: number;
|
|
63
|
+
totalFailed: number;
|
|
64
|
+
notifications: TriggerNotificationResult[];
|
|
65
|
+
}
|
|
66
|
+
export interface TriggerWithTemplateInput {
|
|
67
|
+
actions?: Array<{
|
|
68
|
+
id?: string;
|
|
69
|
+
label: string;
|
|
70
|
+
url: string;
|
|
71
|
+
style?: string;
|
|
72
|
+
actionType?: string;
|
|
73
|
+
metadata?: Record<string, unknown>;
|
|
74
|
+
}>;
|
|
75
|
+
channelId?: string;
|
|
76
|
+
platform?: NotificationChannelType;
|
|
77
|
+
includeInApp?: boolean;
|
|
78
|
+
userIds?: string[];
|
|
79
|
+
expiresAt?: string;
|
|
80
|
+
redirectUrl?: string;
|
|
81
|
+
priority?: NotificationPriorityEnum;
|
|
82
|
+
/** Single recipient (use this OR recipients, not both) */
|
|
83
|
+
recipient?: RecipientInput;
|
|
84
|
+
/** Multiple recipients for bulk delivery (use this OR recipient, not both) */
|
|
85
|
+
recipients?: RecipientInput[];
|
|
86
|
+
templateSlug: string;
|
|
87
|
+
trackClicks?: boolean;
|
|
88
|
+
trackOpens?: boolean;
|
|
89
|
+
media?: Array<{
|
|
90
|
+
url: string;
|
|
91
|
+
label?: string;
|
|
92
|
+
kind?: string;
|
|
93
|
+
contentType?: string;
|
|
94
|
+
thumbnailUrl?: string;
|
|
95
|
+
}>;
|
|
96
|
+
topicId?: string;
|
|
97
|
+
variables: Record<string, unknown>;
|
|
98
|
+
scheduledFor?: string;
|
|
99
|
+
timezone?: string;
|
|
100
|
+
}
|
|
101
|
+
export interface TriggerBatchInput {
|
|
102
|
+
notificationIds?: string[];
|
|
103
|
+
notifications?: CreateNotificationInput[];
|
|
104
|
+
priority?: NotificationPriorityEnum;
|
|
105
|
+
delayBetweenBatches?: number;
|
|
106
|
+
batchSize?: number;
|
|
107
|
+
scheduledFor?: string;
|
|
108
|
+
timezone?: string;
|
|
109
|
+
}
|
|
110
|
+
export interface TriggerNotificationResult {
|
|
111
|
+
id: string;
|
|
112
|
+
status: NotificationStatusEnum;
|
|
113
|
+
deliveryStatus?: NotificationDeliveryStatusEnum;
|
|
114
|
+
triggerStatus: TriggerStatusEnum;
|
|
115
|
+
sentAt?: string;
|
|
116
|
+
title: string;
|
|
117
|
+
message: string;
|
|
118
|
+
}
|
|
119
|
+
export interface BatchNotificationResult {
|
|
120
|
+
batchId: string;
|
|
121
|
+
totalRequested: number;
|
|
122
|
+
totalTriggered: number;
|
|
123
|
+
totalFailed: number;
|
|
124
|
+
successCount: number;
|
|
125
|
+
failureCount: number;
|
|
126
|
+
results: Record<string, unknown>;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Hook to send notifications
|
|
130
|
+
* Provides methods for triggering single, batch, and template-based notifications
|
|
131
|
+
*/
|
|
132
|
+
export declare function useSendNotification(): {
|
|
133
|
+
isLoading: boolean;
|
|
134
|
+
isSending: boolean;
|
|
135
|
+
error: string | null;
|
|
136
|
+
lastResult: TemplateNotificationResult | TriggerNotificationResult | BatchNotificationResult | null;
|
|
137
|
+
sendNotification: (input: TriggerNotificationInput) => Promise<TriggerNotificationResult | null>;
|
|
138
|
+
sendWithTemplate: (input: TriggerWithTemplateInput) => Promise<TemplateNotificationResult | null>;
|
|
139
|
+
sendBatch: (input: TriggerBatchInput) => Promise<BatchNotificationResult | null>;
|
|
140
|
+
sendSimple: (params: {
|
|
141
|
+
recipient: RecipientInput;
|
|
142
|
+
channel: NotificationChannelType;
|
|
143
|
+
body: string;
|
|
144
|
+
subject?: string;
|
|
145
|
+
type?: NotificationTypeEnum;
|
|
146
|
+
priority?: NotificationPriorityEnum;
|
|
147
|
+
}) => Promise<TriggerNotificationResult | null>;
|
|
148
|
+
sendToMultiple: (params: {
|
|
149
|
+
recipients: RecipientInput[];
|
|
150
|
+
channel: NotificationChannelType;
|
|
151
|
+
body: string;
|
|
152
|
+
subject?: string;
|
|
153
|
+
type?: NotificationTypeEnum;
|
|
154
|
+
priority?: NotificationPriorityEnum;
|
|
155
|
+
}) => Promise<BatchNotificationResult | null>;
|
|
156
|
+
clearError: () => void;
|
|
157
|
+
clearResult: () => void;
|
|
158
|
+
};
|
|
159
|
+
//# sourceMappingURL=useSendNotification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSendNotification.d.ts","sourceRoot":"","sources":["../../src/hooks/useSendNotification.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,uBAAuB,GAC/B,SAAS,GACT,OAAO,GACP,MAAM,GACN,OAAO,GACP,KAAK,GACL,OAAO,GACP,UAAU,GACV,SAAS,GACT,UAAU,CAAC;AAEf,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,WAAW,GAAG,QAAQ,GAAG,eAAe,CAAC;AAEtF,MAAM,MAAM,wBAAwB,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE5E,MAAM,MAAM,sBAAsB,GAC9B,WAAW,GACX,WAAW,GACX,OAAO,GACP,SAAS,GACT,QAAQ,GACR,SAAS,GACT,MAAM,GACN,WAAW,GACX,MAAM,GACN,WAAW,CAAC;AAEhB,MAAM,MAAM,8BAA8B,GACtC,SAAS,GACT,SAAS,GACT,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,YAAY,GACZ,QAAQ,GACR,UAAU,GACV,MAAM,GACN,cAAc,CAAC;AAEnB,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAA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obalNotificationClient as t } from "../graphql/global-client.js";
|
|
3
|
+
import { TriggerBatchNotificationsDocument as n, TriggerNotificationDocument as r, TriggerNotificationWithTemplateDocument as i } from "../generated/global-operations.js";
|
|
4
|
+
import { useCallback as a, useState as o } from "react";
|
|
5
|
+
//#region src/hooks/useSendNotification.ts
|
|
6
|
+
function s() {
|
|
7
|
+
let { authToken: s, apiGatewayUrl: c } = e(), [l, u] = o(!1), [d, f] = o(!1), [p, m] = o(null), [h, g] = o(null), _ = a(() => t(c ?? void 0, s ?? void 0), [c, s]), v = a(async (e) => {
|
|
8
|
+
f(!0), m(null);
|
|
9
|
+
try {
|
|
10
|
+
let t = (await _().mutate({
|
|
11
|
+
mutation: r,
|
|
12
|
+
variables: { input: e }
|
|
13
|
+
})).data?.triggerNotification ?? null;
|
|
14
|
+
if (!t) return null;
|
|
15
|
+
let n = {
|
|
16
|
+
id: t.id,
|
|
17
|
+
status: t.status,
|
|
18
|
+
deliveryStatus: t.deliveryStatus ?? void 0,
|
|
19
|
+
triggerStatus: t.triggerStatus,
|
|
20
|
+
sentAt: t.sentAt ?? void 0,
|
|
21
|
+
title: t.title,
|
|
22
|
+
message: t.message
|
|
23
|
+
};
|
|
24
|
+
return g(n), n;
|
|
25
|
+
} catch (e) {
|
|
26
|
+
let t = e instanceof Error ? e.message : "Failed to send notification";
|
|
27
|
+
throw console.error("[useSendNotification] Failed to send notification:", e), m(t), e;
|
|
28
|
+
} finally {
|
|
29
|
+
f(!1);
|
|
30
|
+
}
|
|
31
|
+
}, [_]), y = a(async (e) => {
|
|
32
|
+
f(!0), m(null);
|
|
33
|
+
try {
|
|
34
|
+
let t = (await _().mutate({
|
|
35
|
+
mutation: i,
|
|
36
|
+
variables: { input: e }
|
|
37
|
+
})).data?.triggerNotificationWithTemplate ?? null;
|
|
38
|
+
if (!t) return null;
|
|
39
|
+
let n = {
|
|
40
|
+
totalRequested: t.totalRequested,
|
|
41
|
+
totalTriggered: t.totalTriggered,
|
|
42
|
+
totalFailed: t.totalFailed,
|
|
43
|
+
notifications: t.notifications.map((e) => ({
|
|
44
|
+
id: e.id,
|
|
45
|
+
status: e.status,
|
|
46
|
+
deliveryStatus: void 0,
|
|
47
|
+
triggerStatus: "TRIGGERED",
|
|
48
|
+
sentAt: e.sentAt ?? void 0,
|
|
49
|
+
title: e.title,
|
|
50
|
+
message: e.message
|
|
51
|
+
}))
|
|
52
|
+
};
|
|
53
|
+
return g(n), n;
|
|
54
|
+
} catch (e) {
|
|
55
|
+
let t = e instanceof Error ? e.message : "Failed to send notification with template";
|
|
56
|
+
throw console.error("[useSendNotification] Failed to send notification with template:", e), m(t), e;
|
|
57
|
+
} finally {
|
|
58
|
+
f(!1);
|
|
59
|
+
}
|
|
60
|
+
}, [_]), b = a(async (e) => {
|
|
61
|
+
f(!0), m(null);
|
|
62
|
+
try {
|
|
63
|
+
let t = (await _().mutate({
|
|
64
|
+
mutation: n,
|
|
65
|
+
variables: { input: e }
|
|
66
|
+
})).data?.triggerBatchNotifications ?? null;
|
|
67
|
+
if (!t) return null;
|
|
68
|
+
let r = {
|
|
69
|
+
batchId: t.batchId,
|
|
70
|
+
totalRequested: t.totalRequested,
|
|
71
|
+
totalTriggered: t.totalTriggered,
|
|
72
|
+
totalFailed: t.totalFailed,
|
|
73
|
+
successCount: t.totalTriggered,
|
|
74
|
+
failureCount: t.totalFailed,
|
|
75
|
+
results: t.results
|
|
76
|
+
};
|
|
77
|
+
return g(r), r;
|
|
78
|
+
} catch (e) {
|
|
79
|
+
let t = e instanceof Error ? e.message : "Failed to send batch notifications";
|
|
80
|
+
throw console.error("[useSendNotification] Failed to send batch notifications:", e), m(t), e;
|
|
81
|
+
} finally {
|
|
82
|
+
f(!1);
|
|
83
|
+
}
|
|
84
|
+
}, [_]);
|
|
85
|
+
return {
|
|
86
|
+
isLoading: l,
|
|
87
|
+
isSending: d,
|
|
88
|
+
error: p,
|
|
89
|
+
lastResult: h,
|
|
90
|
+
sendNotification: v,
|
|
91
|
+
sendWithTemplate: y,
|
|
92
|
+
sendBatch: b,
|
|
93
|
+
sendSimple: a(async (e) => v({
|
|
94
|
+
notification: {
|
|
95
|
+
body: e.body,
|
|
96
|
+
channel: e.channel,
|
|
97
|
+
recipient: e.recipient,
|
|
98
|
+
subject: e.subject,
|
|
99
|
+
type: e.type || "TRANSACTIONAL",
|
|
100
|
+
priority: e.priority || "MEDIUM"
|
|
101
|
+
},
|
|
102
|
+
platform: e.channel
|
|
103
|
+
}), [v]),
|
|
104
|
+
sendToMultiple: a(async (e) => b({ notifications: e.recipients.map((t) => ({
|
|
105
|
+
body: e.body,
|
|
106
|
+
channel: e.channel,
|
|
107
|
+
recipient: t,
|
|
108
|
+
subject: e.subject,
|
|
109
|
+
type: e.type || "MARKETING",
|
|
110
|
+
priority: e.priority || "MEDIUM"
|
|
111
|
+
})) }), [b]),
|
|
112
|
+
clearError: a(() => {
|
|
113
|
+
m(null);
|
|
114
|
+
}, []),
|
|
115
|
+
clearResult: a(() => {
|
|
116
|
+
g(null);
|
|
117
|
+
}, [])
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { s as useSendNotification };
|
|
122
|
+
|
|
123
|
+
//# sourceMappingURL=useSendNotification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSendNotification.js","names":[],"sources":["../../src/hooks/useSendNotification.ts"],"sourcesContent":["import { useState, useCallback } from 'react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient } from '../graphql/global-client';\nimport * as NotificationOps from '../generated/global-operations';\nimport type {\n TriggerNotificationMutation,\n TriggerNotificationWithTemplateMutation,\n TriggerBatchNotificationsMutation,\n} from '../generated/global-operations';\n\n// =============================================================================\n// Type Definitions (aligned with backend GraphQL schema)\n// =============================================================================\n\nexport type NotificationChannelType =\n | 'DISCORD'\n | 'EMAIL'\n | 'PUSH'\n | 'SLACK'\n | 'SMS'\n | 'TEAMS'\n | 'TELEGRAM'\n | 'WEBHOOK'\n | 'WHATSAPP';\n\nexport type NotificationTypeEnum = 'ALERT' | 'MARKETING' | 'SYSTEM' | 'TRANSACTIONAL';\n\nexport type NotificationPriorityEnum = 'HIGH' | 'LOW' | 'MEDIUM' | 'URGENT';\n\nexport type NotificationStatusEnum =\n | 'CANCELLED'\n | 'DELIVERED'\n | 'DRAFT'\n | 'EXPIRED'\n | 'FAILED'\n | 'PENDING'\n | 'READ'\n | 'SCHEDULED'\n | 'SENT'\n | 'TRIGGERED';\n\nexport type NotificationDeliveryStatusEnum =\n | 'BOUNCED'\n | 'CLICKED'\n | 'COMPLAINED'\n | 'DELIVERED'\n | 'DELIVERING'\n | 'FAILED'\n | 'OPENED'\n | 'PENDING'\n | 'PROCESSING'\n | 'QUEUED'\n | 'RETRYING'\n | 'SENT'\n | 'UNSUBSCRIBED';\n\nexport type TriggerStatusEnum = 'CANCELLED' | 'FAILED' | 'PENDING' | 'TRIGGERED';\n\nexport interface RecipientInput {\n email?: string;\n locale?: string;\n name?: string;\n phoneNumber?: string;\n pushToken?: string;\n slackUserId?: string;\n teamsUserId?: string;\n timezone?: string;\n userId?: string;\n webhookUrl?: string;\n whatsappNumber?: string;\n}\n\nexport interface CreateNotificationInput {\n actions?: Array<{\n id?: string;\n label: string;\n url: string;\n style?: string;\n actionType?: string;\n metadata?: Record<string, unknown>;\n }>;\n appName?: string;\n body: string;\n channel: NotificationChannelType;\n data?: Record<string, unknown>;\n expiresAt?: string;\n htmlBody?: string;\n media?: Array<{\n url: string;\n label?: string;\n kind?: string;\n contentType?: string;\n thumbnailUrl?: string;\n }>;\n metadata?: Record<string, unknown>;\n priority?: NotificationPriorityEnum;\n recipient: RecipientInput;\n redirectUrl?: string;\n subject?: string;\n trackClicks?: boolean;\n trackOpens?: boolean;\n topicId?: string;\n type?: NotificationTypeEnum;\n}\n\nexport interface TriggerNotificationInput {\n notificationId?: string;\n notification?: CreateNotificationInput;\n channelId?: string;\n platform?: NotificationChannelType;\n includeInApp?: boolean;\n userIds?: string[];\n}\n\nexport interface TemplateNotificationResult {\n totalRequested: number;\n totalTriggered: number;\n totalFailed: number;\n notifications: TriggerNotificationResult[];\n}\n\nexport interface TriggerWithTemplateInput {\n actions?: Array<{\n id?: string;\n label: string;\n url: string;\n style?: string;\n actionType?: string;\n metadata?: Record<string, unknown>;\n }>;\n channelId?: string;\n platform?: NotificationChannelType;\n includeInApp?: boolean;\n userIds?: string[];\n expiresAt?: string;\n redirectUrl?: string;\n priority?: NotificationPriorityEnum;\n /** Single recipient (use this OR recipients, not both) */\n recipient?: RecipientInput;\n /** Multiple recipients for bulk delivery (use this OR recipient, not both) */\n recipients?: RecipientInput[];\n templateSlug: string;\n trackClicks?: boolean;\n trackOpens?: boolean;\n media?: Array<{\n url: string;\n label?: string;\n kind?: string;\n contentType?: string;\n thumbnailUrl?: string;\n }>;\n topicId?: string;\n variables: Record<string, unknown>;\n scheduledFor?: string;\n timezone?: string;\n}\n\nexport interface TriggerBatchInput {\n notificationIds?: string[];\n notifications?: CreateNotificationInput[];\n priority?: NotificationPriorityEnum;\n delayBetweenBatches?: number;\n batchSize?: number;\n scheduledFor?: string;\n timezone?: string;\n}\n\nexport interface TriggerNotificationResult {\n id: string;\n status: NotificationStatusEnum;\n deliveryStatus?: NotificationDeliveryStatusEnum;\n triggerStatus: TriggerStatusEnum;\n sentAt?: string;\n title: string;\n message: string;\n}\n\nexport interface BatchNotificationResult {\n batchId: string;\n totalRequested: number;\n totalTriggered: number;\n totalFailed: number;\n successCount: number;\n failureCount: number;\n results: Record<string, unknown>;\n}\n\n// =============================================================================\n\n/**\n * Hook to send notifications\n * Provides methods for triggering single, batch, and template-based notifications\n */\nexport function useSendNotification() {\n const { authToken, apiGatewayUrl } = useNotification();\n const [isLoading, _setIsLoading] = useState(false);\n const [isSending, setIsSending] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [lastResult, setLastResult] = useState<\n TriggerNotificationResult | BatchNotificationResult | TemplateNotificationResult | null\n >(null);\n\n // Get global client — coerce null/undefined authToken to undefined\n const getClient = useCallback(() => {\n return getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n }, [apiGatewayUrl, authToken]);\n\n /**\n * Send a single notification.\n * @throws the underlying GraphQL/network error after setting the hook's `error` state, so callers can inspect it (e.g. detect gateway FORBIDDEN via `isPermissionError`).\n */\n const sendNotification = useCallback(\n async (input: TriggerNotificationInput): Promise<TriggerNotificationResult | null> => {\n setIsSending(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.mutate<TriggerNotificationMutation>({\n mutation: NotificationOps.TriggerNotificationDocument,\n variables: { input },\n });\n\n const raw = result.data?.triggerNotification ?? null;\n if (!raw) return null;\n const notification: TriggerNotificationResult = {\n id: raw.id,\n status: raw.status as unknown as NotificationStatusEnum,\n deliveryStatus: (raw.deliveryStatus ?? undefined) as\n | NotificationDeliveryStatusEnum\n | undefined,\n triggerStatus: raw.triggerStatus as unknown as TriggerStatusEnum,\n sentAt: raw.sentAt ?? undefined,\n title: raw.title,\n message: raw.message,\n };\n setLastResult(notification);\n return notification;\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to send notification';\n console.error('[useSendNotification] Failed to send notification:', err);\n setError(message);\n // Re-throw so the caller's catch block can inspect the raw error (e.g.,\n // detect gateway FORBIDDEN via isPermissionError) — matches the\n // useNotificationTemplates pattern.\n throw err;\n } finally {\n setIsSending(false);\n }\n },\n [getClient]\n );\n\n /**\n * Send notification using a template. Supports single recipient (recipient) or bulk delivery (recipients).\n * @throws the underlying error after setting `error` state — same contract as `sendNotification`.\n */\n const sendWithTemplate = useCallback(\n async (input: TriggerWithTemplateInput): Promise<TemplateNotificationResult | null> => {\n setIsSending(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.mutate<TriggerNotificationWithTemplateMutation>({\n mutation: NotificationOps.TriggerNotificationWithTemplateDocument,\n variables: { input },\n });\n\n const raw = result.data?.triggerNotificationWithTemplate ?? null;\n if (!raw) return null;\n const templateResult: TemplateNotificationResult = {\n totalRequested: raw.totalRequested,\n totalTriggered: raw.totalTriggered,\n totalFailed: raw.totalFailed,\n notifications: raw.notifications.map((n) => ({\n id: n.id,\n status: n.status as unknown as NotificationStatusEnum,\n deliveryStatus: undefined,\n triggerStatus: 'TRIGGERED' as TriggerStatusEnum,\n sentAt: n.sentAt ?? undefined,\n title: n.title,\n message: n.message,\n })),\n };\n setLastResult(templateResult);\n return templateResult;\n } catch (err: unknown) {\n const message =\n err instanceof Error ? err.message : 'Failed to send notification with template';\n console.error('[useSendNotification] Failed to send notification with template:', err);\n setError(message);\n throw err;\n } finally {\n setIsSending(false);\n }\n },\n [getClient]\n );\n\n /**\n * Send notifications to multiple recipients.\n * @throws the underlying error after setting `error` state — same contract as `sendNotification`.\n */\n const sendBatch = useCallback(\n async (input: TriggerBatchInput): Promise<BatchNotificationResult | null> => {\n setIsSending(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.mutate<TriggerBatchNotificationsMutation>({\n mutation: NotificationOps.TriggerBatchNotificationsDocument,\n variables: { input },\n });\n\n const raw = result.data?.triggerBatchNotifications ?? null;\n if (!raw) return null;\n const batchResult: BatchNotificationResult = {\n batchId: raw.batchId,\n totalRequested: raw.totalRequested,\n totalTriggered: raw.totalTriggered,\n totalFailed: raw.totalFailed,\n successCount: raw.totalTriggered,\n failureCount: raw.totalFailed,\n results: raw.results,\n };\n setLastResult(batchResult);\n return batchResult;\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to send batch notifications';\n console.error('[useSendNotification] Failed to send batch notifications:', err);\n setError(message);\n throw err;\n } finally {\n setIsSending(false);\n }\n },\n [getClient]\n );\n\n /**\n * Helper: Send a simple notification to one recipient\n * Simplified interface for common use case\n */\n const sendSimple = useCallback(\n async (params: {\n recipient: RecipientInput;\n channel: NotificationChannelType;\n body: string;\n subject?: string;\n type?: NotificationTypeEnum;\n priority?: NotificationPriorityEnum;\n }): Promise<TriggerNotificationResult | null> => {\n return sendNotification({\n notification: {\n body: params.body,\n channel: params.channel,\n recipient: params.recipient,\n subject: params.subject,\n type: params.type || 'TRANSACTIONAL',\n priority: params.priority || 'MEDIUM',\n },\n platform: params.channel,\n });\n },\n [sendNotification]\n );\n\n /**\n * Helper: Send to multiple recipients with same message\n */\n const sendToMultiple = useCallback(\n async (params: {\n recipients: RecipientInput[];\n channel: NotificationChannelType;\n body: string;\n subject?: string;\n type?: NotificationTypeEnum;\n priority?: NotificationPriorityEnum;\n }): Promise<BatchNotificationResult | null> => {\n const notifications: CreateNotificationInput[] = params.recipients.map((recipient) => ({\n body: params.body,\n channel: params.channel,\n recipient,\n subject: params.subject,\n type: params.type || 'MARKETING',\n priority: params.priority || 'MEDIUM',\n }));\n\n return sendBatch({ notifications });\n },\n [sendBatch]\n );\n\n /**\n * Clear error state\n */\n const clearError = useCallback(() => {\n setError(null);\n }, []);\n\n /**\n * Clear last result\n */\n const clearResult = useCallback(() => {\n setLastResult(null);\n }, []);\n\n return {\n // State\n isLoading,\n isSending,\n error,\n lastResult,\n\n // Core methods\n sendNotification,\n sendWithTemplate,\n sendBatch,\n\n // Helper methods\n sendSimple,\n sendToMultiple,\n\n // Utilities\n clearError,\n clearResult,\n };\n}\n"],"mappings":";;;;;AAiMA,SAAgB,IAAsB;CACpC,IAAM,EAAE,cAAW,qBAAkB,GAAiB,EAChD,CAAC,GAAW,KAAiB,EAAS,GAAM,EAC5C,CAAC,GAAW,KAAgB,EAAS,GAAM,EAC3C,CAAC,GAAO,KAAY,EAAwB,KAAK,EACjD,CAAC,GAAY,KAAiB,EAElC,KAAK,EAGD,IAAY,QACT,EAA4B,KAAiB,KAAA,GAAW,KAAa,KAAA,EAAU,EACrF,CAAC,GAAe,EAAU,CAAC,EAMxB,IAAmB,EACvB,OAAO,MAA+E;AAEpF,EADA,EAAa,GAAK,EAClB,EAAS,KAAK;AAEd,MAAI;GAOF,IAAM,KALS,MADA,GAAW,CACE,OAAoC;IAC9D,UAAU;IACV,WAAW,EAAE,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