@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.
Files changed (161) hide show
  1. package/README.md +376 -0
  2. package/dist/AdminNotificationRoot.d.ts +35 -0
  3. package/dist/AdminNotificationRoot.d.ts.map +1 -0
  4. package/dist/AdminNotificationRoot.js +81 -0
  5. package/dist/AdminNotificationRoot.js.map +1 -0
  6. package/dist/AdminNotificationRoutes.d.ts +2 -0
  7. package/dist/AdminNotificationRoutes.d.ts.map +1 -0
  8. package/dist/AdminNotificationRoutes.js +108 -0
  9. package/dist/AdminNotificationRoutes.js.map +1 -0
  10. package/dist/NotificationRoot.d.ts +31 -0
  11. package/dist/NotificationRoot.d.ts.map +1 -0
  12. package/dist/NotificationRoot.js +81 -0
  13. package/dist/NotificationRoot.js.map +1 -0
  14. package/dist/NotificationRoutes.d.ts +17 -0
  15. package/dist/NotificationRoutes.d.ts.map +1 -0
  16. package/dist/NotificationRoutes.js +67 -0
  17. package/dist/NotificationRoutes.js.map +1 -0
  18. package/dist/UserNotificationRoot.d.ts +34 -0
  19. package/dist/UserNotificationRoot.d.ts.map +1 -0
  20. package/dist/UserNotificationRoot.js +64 -0
  21. package/dist/UserNotificationRoot.js.map +1 -0
  22. package/dist/UserNotificationRoutes.d.ts +15 -0
  23. package/dist/UserNotificationRoutes.d.ts.map +1 -0
  24. package/dist/UserNotificationRoutes.js +52 -0
  25. package/dist/UserNotificationRoutes.js.map +1 -0
  26. package/dist/__tests__/setup.d.ts +2 -0
  27. package/dist/__tests__/setup.d.ts.map +1 -0
  28. package/dist/components/NotificationBell.d.ts +14 -0
  29. package/dist/components/NotificationBell.d.ts.map +1 -0
  30. package/dist/components/NotificationBell.js +47 -0
  31. package/dist/components/NotificationBell.js.map +1 -0
  32. package/dist/components/NotificationCard.d.ts +19 -0
  33. package/dist/components/NotificationCard.d.ts.map +1 -0
  34. package/dist/components/NotificationCard.js +112 -0
  35. package/dist/components/NotificationCard.js.map +1 -0
  36. package/dist/components/NotificationPanel.d.ts +11 -0
  37. package/dist/components/NotificationPanel.d.ts.map +1 -0
  38. package/dist/components/NotificationPanel.js +100 -0
  39. package/dist/components/NotificationPanel.js.map +1 -0
  40. package/dist/components/RecipientSelector.d.ts +34 -0
  41. package/dist/components/RecipientSelector.d.ts.map +1 -0
  42. package/dist/components/RecipientSelector.js +212 -0
  43. package/dist/components/RecipientSelector.js.map +1 -0
  44. package/dist/components/TemplatePreview.d.ts +22 -0
  45. package/dist/components/TemplatePreview.d.ts.map +1 -0
  46. package/dist/components/TemplatePreview.js +425 -0
  47. package/dist/components/TemplatePreview.js.map +1 -0
  48. package/dist/components/VariableInserter.d.ts +12 -0
  49. package/dist/components/VariableInserter.d.ts.map +1 -0
  50. package/dist/components/index.d.ts +4 -0
  51. package/dist/components/index.d.ts.map +1 -0
  52. package/dist/components/index.js +3 -0
  53. package/dist/constants/permissions.d.ts +24 -0
  54. package/dist/constants/permissions.d.ts.map +1 -0
  55. package/dist/constants/permissions.js +17 -0
  56. package/dist/constants/permissions.js.map +1 -0
  57. package/dist/dev/main.d.ts +2 -0
  58. package/dist/dev/main.d.ts.map +1 -0
  59. package/dist/generated/global-operations.d.ts +1408 -0
  60. package/dist/generated/global-operations.d.ts.map +1 -0
  61. package/dist/generated/global-operations.js +514 -0
  62. package/dist/generated/global-operations.js.map +1 -0
  63. package/dist/generated/global-types.d.ts +20773 -0
  64. package/dist/generated/global-types.d.ts.map +1 -0
  65. package/dist/generated/wspace-operations.d.ts +2 -0
  66. package/dist/generated/wspace-operations.d.ts.map +1 -0
  67. package/dist/generated/wspace-types.d.ts +53363 -0
  68. package/dist/generated/wspace-types.d.ts.map +1 -0
  69. package/dist/graphql/global-client.d.ts +19 -0
  70. package/dist/graphql/global-client.d.ts.map +1 -0
  71. package/dist/graphql/global-client.js +57 -0
  72. package/dist/graphql/global-client.js.map +1 -0
  73. package/dist/hooks/index.d.ts +6 -0
  74. package/dist/hooks/index.d.ts.map +1 -0
  75. package/dist/hooks/index.js +5 -0
  76. package/dist/hooks/useNotificationAdmin.d.ts +51 -0
  77. package/dist/hooks/useNotificationAdmin.d.ts.map +1 -0
  78. package/dist/hooks/useNotificationAdmin.js +203 -0
  79. package/dist/hooks/useNotificationAdmin.js.map +1 -0
  80. package/dist/hooks/useNotificationTemplates.d.ts +136 -0
  81. package/dist/hooks/useNotificationTemplates.d.ts.map +1 -0
  82. package/dist/hooks/useNotificationTemplates.js +168 -0
  83. package/dist/hooks/useNotificationTemplates.js.map +1 -0
  84. package/dist/hooks/useNotificationTopics.d.ts +36 -0
  85. package/dist/hooks/useNotificationTopics.d.ts.map +1 -0
  86. package/dist/hooks/useNotificationTopics.js +127 -0
  87. package/dist/hooks/useNotificationTopics.js.map +1 -0
  88. package/dist/hooks/useNotifications.d.ts +36 -0
  89. package/dist/hooks/useNotifications.d.ts.map +1 -0
  90. package/dist/hooks/useNotifications.js +289 -0
  91. package/dist/hooks/useNotifications.js.map +1 -0
  92. package/dist/hooks/useSendNotification.d.ts +159 -0
  93. package/dist/hooks/useSendNotification.d.ts.map +1 -0
  94. package/dist/hooks/useSendNotification.js +123 -0
  95. package/dist/hooks/useSendNotification.js.map +1 -0
  96. package/dist/hooks/useUserSearch.d.ts +27 -0
  97. package/dist/hooks/useUserSearch.d.ts.map +1 -0
  98. package/dist/hooks/useUserSearch.js +76 -0
  99. package/dist/hooks/useUserSearch.js.map +1 -0
  100. package/dist/index.d.ts +37 -0
  101. package/dist/index.d.ts.map +1 -0
  102. package/dist/index.js +13 -0
  103. package/dist/pages/CreateNotificationPage.d.ts +6 -0
  104. package/dist/pages/CreateNotificationPage.d.ts.map +1 -0
  105. package/dist/pages/CreateNotificationPage.js +1366 -0
  106. package/dist/pages/CreateNotificationPage.js.map +1 -0
  107. package/dist/pages/NotificationCenterPage.d.ts +7 -0
  108. package/dist/pages/NotificationCenterPage.d.ts.map +1 -0
  109. package/dist/pages/NotificationCenterPage.js +203 -0
  110. package/dist/pages/NotificationCenterPage.js.map +1 -0
  111. package/dist/pages/NotificationHistoryAdminPage.d.ts +3 -0
  112. package/dist/pages/NotificationHistoryAdminPage.d.ts.map +1 -0
  113. package/dist/pages/NotificationHistoryAdminPage.js +484 -0
  114. package/dist/pages/NotificationHistoryAdminPage.js.map +1 -0
  115. package/dist/pages/NotificationHistoryPage.d.ts +3 -0
  116. package/dist/pages/NotificationHistoryPage.d.ts.map +1 -0
  117. package/dist/pages/NotificationHistoryPage.js +136 -0
  118. package/dist/pages/NotificationHistoryPage.js.map +1 -0
  119. package/dist/pages/NotificationLandingPage.d.ts +11 -0
  120. package/dist/pages/NotificationLandingPage.d.ts.map +1 -0
  121. package/dist/pages/NotificationLandingPage.js +85 -0
  122. package/dist/pages/NotificationLandingPage.js.map +1 -0
  123. package/dist/pages/NotificationPreferencesPage.d.ts +2 -0
  124. package/dist/pages/NotificationPreferencesPage.d.ts.map +1 -0
  125. package/dist/pages/NotificationPreferencesPage.js +108 -0
  126. package/dist/pages/NotificationPreferencesPage.js.map +1 -0
  127. package/dist/pages/NotificationTemplatesPage.d.ts +8 -0
  128. package/dist/pages/NotificationTemplatesPage.d.ts.map +1 -0
  129. package/dist/pages/NotificationTemplatesPage.js +310 -0
  130. package/dist/pages/NotificationTemplatesPage.js.map +1 -0
  131. package/dist/pages/NotificationTopicsPage.d.ts +2 -0
  132. package/dist/pages/NotificationTopicsPage.d.ts.map +1 -0
  133. package/dist/pages/NotificationTopicsPage.js +254 -0
  134. package/dist/pages/NotificationTopicsPage.js.map +1 -0
  135. package/dist/pages/TemplateEditorPage.d.ts +13 -0
  136. package/dist/pages/TemplateEditorPage.d.ts.map +1 -0
  137. package/dist/pages/TemplateEditorPage.js +790 -0
  138. package/dist/pages/TemplateEditorPage.js.map +1 -0
  139. package/dist/providers/NotificationProvider.d.ts +19 -0
  140. package/dist/providers/NotificationProvider.d.ts.map +1 -0
  141. package/dist/providers/NotificationProvider.js +35 -0
  142. package/dist/providers/NotificationProvider.js.map +1 -0
  143. package/dist/shared/hooks/useTr.d.ts +14 -0
  144. package/dist/shared/hooks/useTr.d.ts.map +1 -0
  145. package/dist/shared/hooks/useTr.js +14 -0
  146. package/dist/shared/hooks/useTr.js.map +1 -0
  147. package/dist/store/notificationStore.d.ts +32 -0
  148. package/dist/store/notificationStore.d.ts.map +1 -0
  149. package/dist/store/notificationStore.js +124 -0
  150. package/dist/store/notificationStore.js.map +1 -0
  151. package/dist/types/index.d.ts +215 -0
  152. package/dist/types/index.d.ts.map +1 -0
  153. package/dist/utils/index.d.ts +68 -0
  154. package/dist/utils/index.d.ts.map +1 -0
  155. package/dist/utils/index.js +122 -0
  156. package/dist/utils/index.js.map +1 -0
  157. package/dist/utils/notificationHistoryExport.d.ts +13 -0
  158. package/dist/utils/notificationHistoryExport.d.ts.map +1 -0
  159. package/dist/utils/notificationHistoryExport.js +29 -0
  160. package/dist/utils/notificationHistoryExport.js.map +1 -0
  161. package/package.json +115 -0
@@ -0,0 +1,168 @@
1
+ import { useNotification as e } from "../providers/NotificationProvider.js";
2
+ import { getGlobalNotificationClient as t } from "../graphql/global-client.js";
3
+ import { CreateNotificationTemplateDocument as n, DeleteNotificationTemplateDocument as r, GetNotificationTemplateDocument as i, GetNotificationTemplatesDocument as a, UpdateNotificationTemplateDocument as o } from "../generated/global-operations.js";
4
+ import { useCallback as s, useEffect as c, useState as l } from "react";
5
+ //#region src/hooks/useNotificationTemplates.ts
6
+ function u(i) {
7
+ let { authToken: u, apiGatewayUrl: d } = e(), [f, p] = l([]), [m, h] = l(!1), [g, _] = l(!1), [v, y] = l(!1), [b, x] = l(!1), [S, C] = l(null), [w, T] = l(!1), [E, D] = l(0), [O, k] = l(0), [A, j] = l(i || {}), M = s(() => t(d ?? void 0, u ?? void 0), [d, u]), N = s(() => {
8
+ let e = {};
9
+ return A.type && (e.type = A.type), A.locale && (e.locale = A.locale), A.enabled !== void 0 && (e.enabled = A.enabled), Object.keys(e).length > 0 ? e : void 0;
10
+ }, [A]), P = s(async () => {
11
+ h(!0), C(null);
12
+ try {
13
+ let e = await M().query({
14
+ query: a,
15
+ variables: {
16
+ filter: N(),
17
+ limit: 50,
18
+ offset: 0
19
+ },
20
+ fetchPolicy: "network-only"
21
+ });
22
+ e.data?.notificationTemplates && (p(e.data.notificationTemplates.items || []), D(e.data.notificationTemplates.total || 0), T(e.data.notificationTemplates.hasMore || !1), k(50));
23
+ } catch (e) {
24
+ let t = e instanceof Error ? e.message : "Failed to fetch templates";
25
+ console.error("[useNotificationTemplates] Failed to fetch templates:", e), C(t);
26
+ } finally {
27
+ h(!1);
28
+ }
29
+ }, [M, N]);
30
+ c(() => {
31
+ P();
32
+ }, [P]);
33
+ let F = A.search ? f.filter((e) => e.name.toLowerCase().includes(A.search.toLowerCase()) || e.slug.toLowerCase().includes(A.search.toLowerCase()) || e.description?.toLowerCase().includes(A.search.toLowerCase())) : f, I = s(async (e) => {
34
+ _(!0), C(null);
35
+ try {
36
+ let t = await M().mutate({
37
+ mutation: n,
38
+ variables: { input: e }
39
+ });
40
+ return await P(), t.data.createNotificationTemplate;
41
+ } catch (e) {
42
+ let t = e instanceof Error ? e.message : "Failed to create template";
43
+ throw console.error("Failed to create template:", e), C(t), e;
44
+ } finally {
45
+ _(!1);
46
+ }
47
+ }, [M, P]), L = s(async (e, t) => {
48
+ y(!0), C(null);
49
+ try {
50
+ let n = await M().mutate({
51
+ mutation: o,
52
+ variables: {
53
+ id: e,
54
+ input: t
55
+ }
56
+ });
57
+ return await P(), n.data.updateNotificationTemplate;
58
+ } catch (e) {
59
+ let t = e instanceof Error ? e.message : "Failed to update template";
60
+ throw console.error("Failed to update template:", e), C(t), e;
61
+ } finally {
62
+ y(!1);
63
+ }
64
+ }, [M, P]), R = s(async (e) => {
65
+ x(!0), C(null);
66
+ try {
67
+ return await M().mutate({
68
+ mutation: r,
69
+ variables: { id: e }
70
+ }), await P(), !0;
71
+ } catch (e) {
72
+ let t = e instanceof Error ? e.message : "Failed to delete template";
73
+ throw console.error("Failed to delete template:", e), C(t), e;
74
+ } finally {
75
+ x(!1);
76
+ }
77
+ }, [M, P]), z = s(async () => {
78
+ if (w) try {
79
+ let e = await M().query({
80
+ query: a,
81
+ variables: {
82
+ filter: N(),
83
+ limit: 50,
84
+ offset: O
85
+ },
86
+ fetchPolicy: "network-only"
87
+ });
88
+ if (e.data?.notificationTemplates) {
89
+ let t = e.data.notificationTemplates.items || [];
90
+ p((e) => [...e, ...t]), T(e.data.notificationTemplates.hasMore || !1), k((e) => e + 50);
91
+ }
92
+ } catch (e) {
93
+ let t = e instanceof Error ? e.message : "Failed to load more templates";
94
+ console.error("Failed to load more templates:", e), C(t);
95
+ }
96
+ }, [
97
+ M,
98
+ N,
99
+ w,
100
+ O
101
+ ]), B = s((e) => {
102
+ j((t) => ({
103
+ ...t,
104
+ ...e
105
+ }));
106
+ }, []), V = s(() => {
107
+ j({});
108
+ }, []);
109
+ return {
110
+ templates: F,
111
+ allTemplates: f,
112
+ isLoading: m,
113
+ isCreating: g,
114
+ isUpdating: v,
115
+ isDeleting: b,
116
+ isMutating: g || v || b,
117
+ error: S,
118
+ hasMore: w,
119
+ total: E,
120
+ filter: A,
121
+ refetch: P,
122
+ loadMore: z,
123
+ createTemplate: I,
124
+ updateTemplate: L,
125
+ deleteTemplate: R,
126
+ updateFilter: B,
127
+ resetFilter: V
128
+ };
129
+ }
130
+ function d(n, r) {
131
+ let { authToken: a, apiGatewayUrl: o } = e(), [u, d] = l(void 0), [f, p] = l(!1), [m, h] = l(null), g = s(() => t(o ?? void 0, a ?? void 0), [o, a]), _ = s(async () => {
132
+ if (n) {
133
+ p(!0), h(null);
134
+ try {
135
+ let e = await g().query({
136
+ query: i,
137
+ variables: {
138
+ slug: n,
139
+ locale: r
140
+ },
141
+ fetchPolicy: "network-only"
142
+ });
143
+ e.data?.notificationTemplate && d(e.data.notificationTemplate);
144
+ } catch (e) {
145
+ let t = e instanceof Error ? e.message : "Failed to fetch template";
146
+ console.error("[useNotificationTemplate] Failed to fetch template:", e), h(t);
147
+ } finally {
148
+ p(!1);
149
+ }
150
+ }
151
+ }, [
152
+ g,
153
+ n,
154
+ r
155
+ ]);
156
+ return c(() => {
157
+ _();
158
+ }, [_]), {
159
+ template: u,
160
+ isLoading: f,
161
+ error: m,
162
+ refetch: _
163
+ };
164
+ }
165
+ //#endregion
166
+ export { d as useNotificationTemplate, u as useNotificationTemplates };
167
+
168
+ //# sourceMappingURL=useNotificationTemplates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNotificationTemplates.js","names":[],"sources":["../../src/hooks/useNotificationTemplates.ts"],"sourcesContent":["import { useState, useCallback, useEffect } from 'react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient } from '../graphql/global-client';\nimport type { NotificationType } from '../types';\nimport * as NotificationOps from '../generated/global-operations';\nimport type {\n GetNotificationTemplatesQuery,\n GetNotificationTemplateQuery,\n CreateNotificationTemplateMutation,\n UpdateNotificationTemplateMutation,\n} from '../generated/global-operations';\n\n/**\n * Backend template type derived from the generated query\n */\nexport type BackendNotificationTemplate =\n GetNotificationTemplatesQuery['notificationTemplates']['items'][number];\n/**\n * Input type for creating a template (matches backend CreateTemplateInput)\n * Note: Templates are content-only - channel is specified at send time\n */\nexport interface CreateTemplateInput {\n slug: string;\n name: string;\n description?: string;\n type: NotificationType;\n channel?: string;\n locale?: string;\n subject?: string;\n bodyTemplate: string;\n htmlTemplate?: string;\n variables: Record<string, unknown>;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Input type for updating a template (matches backend UpdateTemplateInput)\n */\nexport interface UpdateTemplateInput {\n name?: string;\n description?: string;\n subject?: string;\n bodyTemplate?: string;\n htmlTemplate?: string;\n variables?: Record<string, unknown>;\n enabled?: boolean;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Filter options for templates (matches backend TemplateFilterInput)\n * Note: channel filter removed - templates are content-only\n */\nexport interface TemplateFilter {\n type?: NotificationType;\n locale?: string;\n enabled?: boolean;\n search?: string; // Local filter only\n}\n\n/**\n * Hook to manage notification templates\n * Uses the GLOBAL Apollo client for API calls\n */\nexport function useNotificationTemplates(initialFilter?: TemplateFilter) {\n const { authToken, apiGatewayUrl } = useNotification();\n const [templates, setTemplates] = useState<BackendNotificationTemplate[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [isCreating, setIsCreating] = useState(false);\n const [isUpdating, setIsUpdating] = useState(false);\n const [isDeleting, setIsDeleting] = 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 const [filter, setFilter] = useState<TemplateFilter>(initialFilter || {});\n\n const LIMIT = 50;\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 // Build backend filter (excludes local-only 'search')\n const buildBackendFilter = useCallback(() => {\n const backendFilter: Record<string, unknown> = {};\n if (filter.type) backendFilter.type = filter.type;\n if (filter.locale) backendFilter.locale = filter.locale;\n if (filter.enabled !== undefined) backendFilter.enabled = filter.enabled;\n return Object.keys(backendFilter).length > 0 ? backendFilter : undefined;\n }, [filter]);\n\n // Fetch templates\n const fetchTemplates = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationTemplatesQuery>({\n query: NotificationOps.GetNotificationTemplatesDocument,\n variables: {\n filter: buildBackendFilter(),\n limit: LIMIT,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n\n if (result.data?.notificationTemplates) {\n setTemplates(result.data.notificationTemplates.items || []);\n setTotal(result.data.notificationTemplates.total || 0);\n setHasMore(result.data.notificationTemplates.hasMore || false);\n setOffset(LIMIT);\n }\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to fetch templates';\n console.error('[useNotificationTemplates] Failed to fetch templates:', err);\n setError(message);\n } finally {\n setIsLoading(false);\n }\n }, [getClient, buildBackendFilter]);\n\n // Initial fetch\n useEffect(() => {\n fetchTemplates();\n }, [fetchTemplates]);\n\n // Filter by search locally\n const filteredTemplates = filter.search\n ? templates.filter(\n (t) =>\n t.name.toLowerCase().includes(filter.search!.toLowerCase()) ||\n t.slug.toLowerCase().includes(filter.search!.toLowerCase()) ||\n t.description?.toLowerCase().includes(filter.search!.toLowerCase())\n )\n : templates;\n\n // Create template\n const createTemplate = useCallback(\n async (input: CreateTemplateInput): Promise<BackendNotificationTemplate> => {\n setIsCreating(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.mutate<CreateNotificationTemplateMutation>({\n mutation: NotificationOps.CreateNotificationTemplateDocument,\n variables: { input },\n });\n await fetchTemplates();\n return result.data!.createNotificationTemplate;\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to create template';\n console.error('Failed to create template:', err);\n setError(message);\n throw err;\n } finally {\n setIsCreating(false);\n }\n },\n [getClient, fetchTemplates]\n );\n\n // Update template\n const updateTemplate = useCallback(\n async (id: string, input: UpdateTemplateInput): Promise<BackendNotificationTemplate> => {\n setIsUpdating(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.mutate<UpdateNotificationTemplateMutation>({\n mutation: NotificationOps.UpdateNotificationTemplateDocument,\n variables: { id, input },\n });\n await fetchTemplates();\n return result.data!.updateNotificationTemplate;\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to update template';\n console.error('Failed to update template:', err);\n setError(message);\n throw err;\n } finally {\n setIsUpdating(false);\n }\n },\n [getClient, fetchTemplates]\n );\n\n // Delete template\n const deleteTemplate = useCallback(\n async (id: string): Promise<boolean> => {\n setIsDeleting(true);\n setError(null);\n\n try {\n const client = getClient();\n await client.mutate({\n mutation: NotificationOps.DeleteNotificationTemplateDocument,\n variables: { id },\n });\n await fetchTemplates();\n return true;\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to delete template';\n console.error('Failed to delete template:', err);\n setError(message);\n throw err;\n } finally {\n setIsDeleting(false);\n }\n },\n [getClient, fetchTemplates]\n );\n\n // Load more templates\n const loadMore = useCallback(async () => {\n if (!hasMore) return;\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationTemplatesQuery>({\n query: NotificationOps.GetNotificationTemplatesDocument,\n variables: {\n filter: buildBackendFilter(),\n limit: LIMIT,\n offset: offset,\n },\n fetchPolicy: 'network-only',\n });\n\n if (result.data?.notificationTemplates) {\n const moreTemplates = result.data.notificationTemplates.items || [];\n setTemplates((prev) => [...prev, ...moreTemplates]);\n setHasMore(result.data.notificationTemplates.hasMore || false);\n setOffset((prev) => prev + LIMIT);\n }\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to load more templates';\n console.error('Failed to load more templates:', err);\n setError(message);\n }\n }, [getClient, buildBackendFilter, hasMore, offset]);\n\n // Update filter\n const updateFilter = useCallback((newFilter: Partial<TemplateFilter>) => {\n setFilter((prev) => ({ ...prev, ...newFilter }));\n }, []);\n\n // Reset filter\n const resetFilter = useCallback(() => {\n setFilter({});\n }, []);\n\n return {\n templates: filteredTemplates,\n allTemplates: templates,\n isLoading,\n isCreating,\n isUpdating,\n isDeleting,\n isMutating: isCreating || isUpdating || isDeleting,\n error,\n hasMore,\n total,\n filter,\n refetch: fetchTemplates,\n loadMore,\n createTemplate,\n updateTemplate,\n deleteTemplate,\n updateFilter,\n resetFilter,\n };\n}\n\n/**\n * Hook to fetch a single template by slug\n * Uses the GLOBAL Apollo client for API calls\n */\nexport function useNotificationTemplate(slug: string | undefined, locale?: string) {\n const { authToken, apiGatewayUrl } = useNotification();\n const [template, setTemplate] = useState<BackendNotificationTemplate | undefined>(undefined);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(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 // Fetch template\n const fetchTemplate = useCallback(async () => {\n if (!slug) return;\n\n setIsLoading(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationTemplateQuery>({\n query: NotificationOps.GetNotificationTemplateDocument,\n variables: { slug, locale },\n fetchPolicy: 'network-only',\n });\n\n if (result.data?.notificationTemplate) {\n setTemplate(result.data.notificationTemplate);\n }\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to fetch template';\n console.error('[useNotificationTemplate] Failed to fetch template:', err);\n setError(message);\n } finally {\n setIsLoading(false);\n }\n }, [getClient, slug, locale]);\n\n // Fetch on mount and when slug changes\n useEffect(() => {\n fetchTemplate();\n }, [fetchTemplate]);\n\n return {\n template,\n isLoading,\n error,\n refetch: fetchTemplate,\n };\n}\n"],"mappings":";;;;;AAgEA,SAAgB,EAAyB,GAAgC;CACvE,IAAM,EAAE,cAAW,qBAAkB,GAAiB,EAChD,CAAC,GAAW,KAAgB,EAAwC,EAAE,CAAC,EACvE,CAAC,GAAW,KAAgB,EAAS,GAAM,EAC3C,CAAC,GAAY,KAAiB,EAAS,GAAM,EAC7C,CAAC,GAAY,KAAiB,EAAS,GAAM,EAC7C,CAAC,GAAY,KAAiB,EAAS,GAAM,EAC7C,CAAC,GAAO,KAAY,EAAwB,KAAK,EACjD,CAAC,GAAS,KAAc,EAAS,GAAM,EACvC,CAAC,GAAO,KAAY,EAAS,EAAE,EAC/B,CAAC,GAAQ,KAAa,EAAS,EAAE,EACjC,CAAC,GAAQ,KAAa,EAAyB,KAAiB,EAAE,CAAC,EAKnE,IAAY,QACT,EAA4B,KAAiB,KAAA,GAAW,KAAa,KAAA,EAAU,EACrF,CAAC,GAAe,EAAU,CAAC,EAGxB,IAAqB,QAAkB;EAC3C,IAAM,IAAyC,EAAE;AAIjD,SAHI,EAAO,SAAM,EAAc,OAAO,EAAO,OACzC,EAAO,WAAQ,EAAc,SAAS,EAAO,SAC7C,EAAO,YAAY,KAAA,MAAW,EAAc,UA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,KAAe;IACd,CAAC,EAAc,CAAC,EAEZ;EACL;EACA;EACA;EACA,SAAS;EACV"}
@@ -0,0 +1,36 @@
1
+ import { NotificationTopic, NotificationTopicSubscription } from '../types';
2
+
3
+ export interface NotificationTopicFilter {
4
+ search?: string;
5
+ type?: string;
6
+ isActive?: boolean;
7
+ }
8
+ export interface CreateNotificationTopicInput {
9
+ name: string;
10
+ slug: string;
11
+ description?: string;
12
+ type: string;
13
+ isActive?: boolean;
14
+ metadata?: Record<string, unknown>;
15
+ }
16
+ export interface UpdateNotificationTopicInput {
17
+ name?: string;
18
+ slug?: string;
19
+ description?: string;
20
+ type?: string;
21
+ isActive?: boolean;
22
+ metadata?: Record<string, unknown>;
23
+ }
24
+ export declare function useNotificationTopics(initialFilter?: NotificationTopicFilter): {
25
+ topics: NotificationTopic[];
26
+ isLoading: boolean;
27
+ error: string | null;
28
+ filter: NotificationTopicFilter;
29
+ setFilter: import('react').Dispatch<import('react').SetStateAction<NotificationTopicFilter>>;
30
+ refetch: () => Promise<void>;
31
+ createTopic: (input: CreateNotificationTopicInput) => Promise<NotificationTopic | null>;
32
+ updateTopic: (id: string, input: UpdateNotificationTopicInput) => Promise<NotificationTopic | null>;
33
+ deleteTopic: (id: string) => Promise<boolean>;
34
+ setTopicSubscription: (topicId: string, subscribed: boolean) => Promise<NotificationTopicSubscription | null>;
35
+ };
36
+ //# sourceMappingURL=useNotificationTopics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNotificationTopics.d.ts","sourceRoot":"","sources":["../../src/hooks/useNotificationTopics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AASjF,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AA4BD,wBAAgB,qBAAqB,CAAC,aAAa,CAAC,EAAE,uBAAuB;;;;;;;yBA8C3D,4BAA4B,KAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;sBA0BnE,MAAM,SAAS,4BAA4B,KAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;sBA0B/E,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC;oCAapB,MAAM,cAAc,OAAO,KAAG,OAAO,CAAC,6BAA6B,GAAG,IAAI,CAAC;EAuC9F"}
@@ -0,0 +1,127 @@
1
+ import { useNotification as e } from "../providers/NotificationProvider.js";
2
+ import { getGlobalNotificationClient as t } from "../graphql/global-client.js";
3
+ import { CreateNotificationTopicDocument as n, DeleteNotificationTopicDocument as r, GetNotificationTopicsDocument as i, SetNotificationTopicSubscriptionDocument as a, UpdateNotificationTopicDocument as o } from "../generated/global-operations.js";
4
+ import { useCallback as s, useEffect as c, useState as l } from "react";
5
+ //#region src/hooks/useNotificationTopics.ts
6
+ function u(e) {
7
+ return {
8
+ id: e.id,
9
+ slug: e.slug,
10
+ name: e.name,
11
+ description: e.description ?? void 0,
12
+ type: e.type,
13
+ isActive: e.isActive,
14
+ metadata: e.metadata ?? void 0,
15
+ subscriberCount: e.subscriberCount ?? 0,
16
+ mySubscription: e.mySubscription ? {
17
+ id: e.mySubscription.id,
18
+ subscribed: e.mySubscription.subscribed,
19
+ unsubscribedAt: e.mySubscription.unsubscribedAt ?? void 0,
20
+ topicId: e.mySubscription.topicId,
21
+ userId: e.mySubscription.userId
22
+ } : void 0,
23
+ createdAt: e.createdAt,
24
+ updatedAt: e.updatedAt
25
+ };
26
+ }
27
+ function d(d) {
28
+ let { authToken: f, apiGatewayUrl: p } = e(), [m, h] = l([]), [g, _] = l(!1), [v, y] = l(null), [b, x] = l(d || {}), S = s(() => t(p ?? void 0, f ?? void 0), [p, f]), C = s(async () => {
29
+ _(!0), y(null);
30
+ try {
31
+ h(((await S().query({
32
+ query: i,
33
+ variables: {
34
+ filter: {
35
+ ...b.search ? { search: b.search } : {},
36
+ ...b.type ? { type: b.type } : {},
37
+ ...b.isActive === void 0 ? {} : { isActive: b.isActive }
38
+ },
39
+ limit: 100,
40
+ offset: 0
41
+ },
42
+ fetchPolicy: "network-only"
43
+ })).data?.notificationTopics.items || []).map(u));
44
+ } catch (e) {
45
+ console.error("[useNotificationTopics] Failed to fetch topics:", e), y(e instanceof Error ? e.message : "Failed to fetch topics"), h([]);
46
+ } finally {
47
+ _(!1);
48
+ }
49
+ }, [b, S]);
50
+ return c(() => {
51
+ C();
52
+ }, [C]), {
53
+ topics: m,
54
+ isLoading: g,
55
+ error: v,
56
+ filter: b,
57
+ setFilter: x,
58
+ refetch: C,
59
+ createTopic: s(async (e) => {
60
+ let t = await S().mutate({
61
+ mutation: n,
62
+ variables: { input: e }
63
+ });
64
+ await C();
65
+ let r = t.data?.createNotificationTopic;
66
+ return r ? {
67
+ id: r.id,
68
+ slug: r.slug,
69
+ name: r.name,
70
+ description: r.description ?? void 0,
71
+ type: r.type,
72
+ isActive: r.isActive,
73
+ subscriberCount: 0,
74
+ createdAt: r.createdAt,
75
+ updatedAt: r.updatedAt
76
+ } : null;
77
+ }, [C, S]),
78
+ updateTopic: s(async (e, t) => {
79
+ let n = await S().mutate({
80
+ mutation: o,
81
+ variables: {
82
+ id: e,
83
+ input: t
84
+ }
85
+ });
86
+ await C();
87
+ let r = n.data?.updateNotificationTopic;
88
+ return r ? {
89
+ id: r.id,
90
+ slug: r.slug,
91
+ name: r.name,
92
+ description: r.description ?? void 0,
93
+ type: r.type,
94
+ isActive: r.isActive,
95
+ subscriberCount: 0,
96
+ createdAt: r.createdAt,
97
+ updatedAt: r.updatedAt
98
+ } : null;
99
+ }, [C, S]),
100
+ deleteTopic: s(async (e) => (await S().mutate({
101
+ mutation: r,
102
+ variables: { id: e }
103
+ }), await C(), !0), [C, S]),
104
+ setTopicSubscription: s(async (e, t) => {
105
+ let n = await S().mutate({
106
+ mutation: a,
107
+ variables: { input: {
108
+ topicId: e,
109
+ subscribed: t
110
+ } }
111
+ });
112
+ await C();
113
+ let r = n.data?.setNotificationTopicSubscription;
114
+ return r ? {
115
+ id: r.id,
116
+ subscribed: r.subscribed,
117
+ unsubscribedAt: r.unsubscribedAt ?? void 0,
118
+ topicId: r.topicId,
119
+ userId: r.userId
120
+ } : null;
121
+ }, [C, S])
122
+ };
123
+ }
124
+ //#endregion
125
+ export { d as useNotificationTopics };
126
+
127
+ //# sourceMappingURL=useNotificationTopics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNotificationTopics.js","names":[],"sources":["../../src/hooks/useNotificationTopics.ts"],"sourcesContent":["import { useState, useEffect, useCallback } from 'react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient } from '../graphql/global-client';\nimport type { NotificationTopic, NotificationTopicSubscription } from '../types';\nimport * as NotificationOps from '../generated/global-operations';\nimport type {\n GetNotificationTopicsQuery,\n CreateNotificationTopicMutation,\n UpdateNotificationTopicMutation,\n SetNotificationTopicSubscriptionMutation,\n} from '../generated/global-operations';\n\nexport interface NotificationTopicFilter {\n search?: string;\n type?: string;\n isActive?: boolean;\n}\n\nexport interface CreateNotificationTopicInput {\n name: string;\n slug: string;\n description?: string;\n type: string;\n isActive?: boolean;\n metadata?: Record<string, unknown>;\n}\n\nexport interface UpdateNotificationTopicInput {\n name?: string;\n slug?: string;\n description?: string;\n type?: string;\n isActive?: boolean;\n metadata?: Record<string, unknown>;\n}\n\nfunction mapTopic(\n topic: GetNotificationTopicsQuery['notificationTopics']['items'][number]\n): NotificationTopic {\n return {\n id: topic.id,\n slug: topic.slug,\n name: topic.name,\n description: topic.description ?? undefined,\n type: topic.type as NotificationTopic['type'],\n isActive: topic.isActive,\n metadata: topic.metadata ?? undefined,\n subscriberCount: topic.subscriberCount ?? 0,\n mySubscription: topic.mySubscription\n ? {\n id: topic.mySubscription.id,\n subscribed: topic.mySubscription.subscribed,\n unsubscribedAt: topic.mySubscription.unsubscribedAt ?? undefined,\n topicId: topic.mySubscription.topicId,\n userId: topic.mySubscription.userId,\n }\n : undefined,\n createdAt: topic.createdAt,\n updatedAt: topic.updatedAt,\n };\n}\n\nexport function useNotificationTopics(initialFilter?: NotificationTopicFilter) {\n const { authToken, apiGatewayUrl } = useNotification();\n const [topics, setTopics] = useState<NotificationTopic[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [filter, setFilter] = useState<NotificationTopicFilter>(initialFilter || {});\n\n const getClient = useCallback(() => {\n return getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n }, [apiGatewayUrl, authToken]);\n\n const fetchTopics = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationTopicsQuery>({\n query: NotificationOps.GetNotificationTopicsDocument,\n variables: {\n filter: {\n ...(filter.search ? { search: filter.search } : {}),\n ...(filter.type ? { type: filter.type } : {}),\n ...(filter.isActive !== undefined ? { isActive: filter.isActive } : {}),\n },\n limit: 100,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n\n setTopics((result.data?.notificationTopics.items || []).map(mapTopic));\n } catch (err) {\n console.error('[useNotificationTopics] Failed to fetch topics:', err);\n setError(err instanceof Error ? err.message : 'Failed to fetch topics');\n setTopics([]);\n } finally {\n setIsLoading(false);\n }\n }, [filter, getClient]);\n\n useEffect(() => {\n fetchTopics();\n }, [fetchTopics]);\n\n const createTopic = useCallback(\n async (input: CreateNotificationTopicInput): Promise<NotificationTopic | null> => {\n const client = getClient();\n const result = await client.mutate<CreateNotificationTopicMutation>({\n mutation: NotificationOps.CreateNotificationTopicDocument,\n variables: { input },\n });\n await fetchTopics();\n const created = result.data?.createNotificationTopic;\n return created\n ? {\n id: created.id,\n slug: created.slug,\n name: created.name,\n description: created.description ?? undefined,\n type: created.type as NotificationTopic['type'],\n isActive: created.isActive,\n subscriberCount: 0,\n createdAt: created.createdAt,\n updatedAt: created.updatedAt,\n }\n : null;\n },\n [fetchTopics, getClient]\n );\n\n const updateTopic = useCallback(\n async (id: string, input: UpdateNotificationTopicInput): Promise<NotificationTopic | null> => {\n const client = getClient();\n const result = await client.mutate<UpdateNotificationTopicMutation>({\n mutation: NotificationOps.UpdateNotificationTopicDocument,\n variables: { id, input },\n });\n await fetchTopics();\n const updated = result.data?.updateNotificationTopic;\n return updated\n ? {\n id: updated.id,\n slug: updated.slug,\n name: updated.name,\n description: updated.description ?? undefined,\n type: updated.type as NotificationTopic['type'],\n isActive: updated.isActive,\n subscriberCount: 0,\n createdAt: updated.createdAt,\n updatedAt: updated.updatedAt,\n }\n : null;\n },\n [fetchTopics, getClient]\n );\n\n const deleteTopic = useCallback(\n async (id: string): Promise<boolean> => {\n const client = getClient();\n await client.mutate({\n mutation: NotificationOps.DeleteNotificationTopicDocument,\n variables: { id },\n });\n await fetchTopics();\n return true;\n },\n [fetchTopics, getClient]\n );\n\n const setTopicSubscription = useCallback(\n async (topicId: string, subscribed: boolean): Promise<NotificationTopicSubscription | null> => {\n const client = getClient();\n const result = await client.mutate<SetNotificationTopicSubscriptionMutation>({\n mutation: NotificationOps.SetNotificationTopicSubscriptionDocument,\n variables: {\n input: {\n topicId,\n subscribed,\n },\n },\n });\n await fetchTopics();\n\n const subscription = result.data?.setNotificationTopicSubscription;\n return subscription\n ? {\n id: subscription.id,\n subscribed: subscription.subscribed,\n unsubscribedAt: subscription.unsubscribedAt ?? undefined,\n topicId: subscription.topicId,\n userId: subscription.userId,\n }\n : null;\n },\n [fetchTopics, getClient]\n );\n\n return {\n topics,\n isLoading,\n error,\n filter,\n setFilter,\n refetch: fetchTopics,\n createTopic,\n updateTopic,\n deleteTopic,\n setTopicSubscription,\n };\n}\n"],"mappings":";;;;;AAoCA,SAAS,EACP,GACmB;AACnB,QAAO;EACL,IAAI,EAAM;EACV,MAAM,EAAM;EACZ,MAAM,EAAM;EACZ,aAAa,EAAM,eAAe,KAAA;EAClC,MAAM,EAAM;EACZ,UAAU,EAAM;EAChB,UAAU,EAAM,YAAY,KAAA;EAC5B,iBAAiB,EAAM,mBAAmB;EAC1C,gBAAgB,EAAM,iBAClB;GACE,IAAI,EAAM,eAAe;GACzB,YAAY,EAAM,eAAe;GACjC,gBAAgB,EAAM,eAAe,kBAAkB,KAAA;GACvD,SAAS,EAAM,eAAe;GAC9B,QAAQ,EAAM,eAAe;GAC9B,GACD,KAAA;EACJ,WAAW,EAAM;EACjB,WAAW,EAAM;EAClB;;AAGH,SAAgB,EAAsB,GAAyC;CAC7E,IAAM,EAAE,cAAW,qBAAkB,GAAiB,EAChD,CAAC,GAAQ,KAAa,EAA8B,EAAE,CAAC,EACvD,CAAC,GAAW,KAAgB,EAAS,GAAM,EAC3C,CAAC,GAAO,KAAY,EAAwB,KAAK,EACjD,CAAC,GAAQ,KAAa,EAAkC,KAAiB,EAAE,CAAC,EAE5E,IAAY,QACT,EAA4B,KAAiB,KAAA,GAAW,KAAa,KAAA,EAAU,EACrF,CAAC,GAAe,EAAU,CAAC,EAExB,IAAc,EAAY,YAAY;AAE1C,EADA,EAAa,GAAK,EAClB,EAAS,KAAK;AAEd,MAAI;AAgBF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,MAAM;AAC7B,UAAO,IACH;IACE,IAAI,EAAQ;IACZ,MAAM,EAAQ;IACd,MAAM,EAAQ;IACd,aAAa,EAAQ,eAAe,KAAA;IACpC,MAAM,EAAQ;IACd,UAAU,EAAQ;IAClB,iBAAiB;IACjB,WAAW,EAAQ;IACnB,WAAW,EAAQ;IACpB,GACD;KAEN,CAAC,GAAa,EAAU,CACzB;EAoDC,aAlDkB,EAClB,OAAO,OAEL,MADe,GAAW,CACb,OAAO;GAClB,UAAU;GACV,WAAW,EAAE,OAAI;GAClB,CAAC,EACF,MAAM,GAAa,EACZ,KAET,CAAC,GAAa,EAAU,CACzB;EAwCC,sBAtC2B,EAC3B,OAAO,GAAiB,MAAuE;GAE7F,IAAM,IAAS,MADA,GAAW,CACE,OAAiD;IAC3E,UAAU;IACV,WAAW,EACT,OAAO;KACL;KACA;KACD,EACF;IACF,CAAC;AACF,SAAM,GAAa;GAEnB,IAAM,IAAe,EAAO,MAAM;AAClC,UAAO,IACH;IACE,IAAI,EAAa;IACjB,YAAY,EAAa;IACzB,gBAAgB,EAAa,kBAAkB,KAAA;IAC/C,SAAS,EAAa;IACtB,QAAQ,EAAa;IACtB,GACD;KAEN,CAAC,GAAa,EAAU,CACzB;EAaA"}
@@ -0,0 +1,36 @@
1
+ import { Notification, NotificationFilter } from '../types';
2
+
3
+ /**
4
+ * Hook to manage notifications with real GraphQL backend integration.
5
+ *
6
+ * Uses the global Apollo client to query the notification service via the
7
+ * public gateway (https://gw-global.local.burdenoff.com/global/graphql).
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * const { notifications, unreadCount, markAsRead } = useNotifications();
12
+ * ```
13
+ */
14
+ export declare function useNotifications(): {
15
+ notifications: Notification[];
16
+ allNotifications: Notification[];
17
+ unreadCount: number;
18
+ selectedNotification: Notification | null;
19
+ notificationFilter: NotificationFilter;
20
+ isLoading: boolean;
21
+ error: string | null;
22
+ hasMore: boolean;
23
+ total: number;
24
+ markAsRead: (notificationId: string) => Promise<void>;
25
+ markAllAsRead: () => Promise<void>;
26
+ archiveNotification: (notificationId: string) => Promise<void>;
27
+ bulkArchive: (notificationIds: string[]) => Promise<void>;
28
+ unarchiveNotification: (notificationId: string) => Promise<void>;
29
+ recordAction: (notificationId: string, actionId?: string) => Promise<void>;
30
+ setSelectedNotification: import('react').Dispatch<import('react').SetStateAction<Notification | null>>;
31
+ updateFilter: (filter: Partial<NotificationFilter>) => void;
32
+ resetFilter: () => void;
33
+ refetch: () => Promise<void>;
34
+ loadMore: () => Promise<void>;
35
+ };
36
+ //# sourceMappingURL=useNotifications.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNotifications.d.ts","sourceRoot":"","sources":["../../src/hooks/useNotifications.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAkMjE;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB;;;;;;;;;;iCAiHL,MAAM;;0CAsCN,MAAM;mCAqBL,MAAM,EAAE;4CAoBT,MAAM;mCAoBN,MAAM,aAAa,MAAM;;;;;;EAsFnD"}