@burdenoff/microfe-notification 2026.1029.2 → 2026.1109.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/dist/AdminNotificationRoot.d.ts +33 -0
  2. package/dist/AdminNotificationRoot.js +9 -6
  3. package/dist/AdminNotificationRoot.js.map +1 -1
  4. package/dist/AdminNotificationRoutes.d.ts +1 -0
  5. package/dist/AdminNotificationRoutes.js +22 -23
  6. package/dist/AdminNotificationRoutes.js.map +1 -1
  7. package/dist/NotificationRoot.d.ts +29 -0
  8. package/dist/NotificationRoot.js +9 -6
  9. package/dist/NotificationRoot.js.map +1 -1
  10. package/dist/NotificationRoutes.d.ts +18 -0
  11. package/dist/NotificationRoutes.js +1 -2
  12. package/dist/NotificationRoutes.js.map +1 -1
  13. package/dist/UserNotificationRoot.d.ts +32 -0
  14. package/dist/UserNotificationRoot.js +9 -6
  15. package/dist/UserNotificationRoot.js.map +1 -1
  16. package/dist/UserNotificationRoutes.d.ts +16 -0
  17. package/dist/UserNotificationRoutes.js +9 -10
  18. package/dist/UserNotificationRoutes.js.map +1 -1
  19. package/dist/components/FeatureDisabledPage.d.ts +6 -0
  20. package/dist/components/FeatureDisabledPage.js +1 -2
  21. package/dist/components/FeatureDisabledPage.js.map +1 -1
  22. package/dist/components/NotificationBell.d.ts +13 -0
  23. package/dist/components/NotificationBell.js +6 -7
  24. package/dist/components/NotificationBell.js.map +1 -1
  25. package/dist/components/NotificationCard.d.ts +18 -0
  26. package/dist/components/NotificationCard.js +10 -11
  27. package/dist/components/NotificationCard.js.map +1 -1
  28. package/dist/components/NotificationPanel.d.ts +10 -0
  29. package/dist/components/NotificationPanel.js +5 -6
  30. package/dist/components/NotificationPanel.js.map +1 -1
  31. package/dist/components/RecipientSelector.d.ts +32 -0
  32. package/dist/components/RecipientSelector.js +2 -3
  33. package/dist/components/RecipientSelector.js.map +1 -1
  34. package/dist/components/TemplatePreview.d.ts +21 -0
  35. package/dist/components/TemplatePreview.js +3 -4
  36. package/dist/components/TemplatePreview.js.map +1 -1
  37. package/dist/components/VariableInserter.d.ts +11 -0
  38. package/dist/components/index.d.ts +3 -0
  39. package/dist/components/index.js +4 -3
  40. package/dist/constants/permissions.d.ts +23 -0
  41. package/dist/constants/permissions.js +1 -2
  42. package/dist/constants/permissions.js.map +1 -1
  43. package/dist/dev/main.d.ts +0 -0
  44. package/dist/generated/global-operations.d.ts +2119 -0
  45. package/dist/generated/global-operations.js +80 -69
  46. package/dist/generated/global-operations.js.map +1 -1
  47. package/dist/generated/global-types.d.ts +23507 -0
  48. package/dist/generated/wspace-operations.d.ts +4 -0
  49. package/dist/generated/wspace-types.d.ts +57831 -0
  50. package/dist/graphql/global-client.d.ts +32 -0
  51. package/dist/graphql/global-client.js +23 -30
  52. package/dist/graphql/global-client.js.map +1 -1
  53. package/dist/hooks/index.d.ts +7 -0
  54. package/dist/hooks/index.js +7 -6
  55. package/dist/hooks/useNotificationAdmin.d.ts +46 -0
  56. package/dist/hooks/useNotificationAdmin.js +18 -17
  57. package/dist/hooks/useNotificationAdmin.js.map +1 -1
  58. package/dist/hooks/useNotificationAnalytics.d.ts +65 -0
  59. package/dist/hooks/useNotificationAnalytics.js +1 -2
  60. package/dist/hooks/useNotificationAnalytics.js.map +1 -1
  61. package/dist/hooks/useNotificationPreferences.d.ts +10 -0
  62. package/dist/hooks/useNotificationPreferences.js +7 -7
  63. package/dist/hooks/useNotificationPreferences.js.map +1 -1
  64. package/dist/hooks/useNotificationTemplates.d.ts +131 -0
  65. package/dist/hooks/useNotificationTemplates.js +1 -2
  66. package/dist/hooks/useNotificationTemplates.js.map +1 -1
  67. package/dist/hooks/useNotificationTopics.d.ts +35 -0
  68. package/dist/hooks/useNotificationTopics.js +22 -22
  69. package/dist/hooks/useNotificationTopics.js.map +1 -1
  70. package/dist/hooks/useNotifications.d.ts +39 -0
  71. package/dist/hooks/useNotifications.js +6 -4
  72. package/dist/hooks/useNotifications.js.map +1 -1
  73. package/dist/hooks/useSendNotification.d.ts +158 -0
  74. package/dist/hooks/useSendNotification.js +12 -10
  75. package/dist/hooks/useSendNotification.js.map +1 -1
  76. package/dist/hooks/useUserSearch.d.ts +26 -0
  77. package/dist/hooks/useUserSearch.js +8 -10
  78. package/dist/hooks/useUserSearch.js.map +1 -1
  79. package/dist/index.d.ts +36 -0
  80. package/dist/index.js +8 -8
  81. package/dist/node_modules/@apollo/client/errors/CombinedGraphQLErrors.js +1 -2
  82. package/dist/node_modules/@apollo/client/errors/CombinedGraphQLErrors.js.map +1 -1
  83. package/dist/node_modules/@apollo/client/errors/utils.js +1 -2
  84. package/dist/node_modules/@apollo/client/errors/utils.js.map +1 -1
  85. package/dist/node_modules/@apollo/client/link/core/ApolloLink.js +7 -8
  86. package/dist/node_modules/@apollo/client/link/core/ApolloLink.js.map +1 -1
  87. package/dist/node_modules/@apollo/client/link/subscriptions/index.js +9 -10
  88. package/dist/node_modules/@apollo/client/link/subscriptions/index.js.map +1 -1
  89. package/dist/node_modules/@apollo/client/link/utils/createOperation.js +5 -6
  90. package/dist/node_modules/@apollo/client/link/utils/createOperation.js.map +1 -1
  91. package/dist/node_modules/@apollo/client/utilities/caching/sizes.js +0 -1
  92. package/dist/node_modules/@apollo/client/utilities/caching/sizes.js.map +1 -1
  93. package/dist/node_modules/@apollo/client/utilities/graphql/print.js +4 -5
  94. package/dist/node_modules/@apollo/client/utilities/graphql/print.js.map +1 -1
  95. package/dist/node_modules/@apollo/client/utilities/internal/caches.js +1 -2
  96. package/dist/node_modules/@apollo/client/utilities/internal/caches.js.map +1 -1
  97. package/dist/node_modules/@apollo/client/utilities/internal/checkDocument.js +1 -2
  98. package/dist/node_modules/@apollo/client/utilities/internal/checkDocument.js.map +1 -1
  99. package/dist/node_modules/@apollo/client/utilities/internal/getMainDefinition.js +2 -3
  100. package/dist/node_modules/@apollo/client/utilities/internal/getMainDefinition.js.map +1 -1
  101. package/dist/node_modules/@apollo/client/utilities/internal/getMemoryInternals.js +1 -2
  102. package/dist/node_modules/@apollo/client/utilities/internal/getMemoryInternals.js.map +1 -1
  103. package/dist/node_modules/@apollo/client/utilities/internal/getOperationDefinition.js +1 -2
  104. package/dist/node_modules/@apollo/client/utilities/internal/getOperationDefinition.js.map +1 -1
  105. package/dist/node_modules/@apollo/client/utilities/internal/getOperationName.js +1 -2
  106. package/dist/node_modules/@apollo/client/utilities/internal/getOperationName.js.map +1 -1
  107. package/dist/node_modules/@apollo/client/utilities/internal/globals/global.js +1 -2
  108. package/dist/node_modules/@apollo/client/utilities/internal/globals/global.js.map +1 -1
  109. package/dist/node_modules/@apollo/client/utilities/internal/globals/maybe.js +1 -2
  110. package/dist/node_modules/@apollo/client/utilities/internal/globals/maybe.js.map +1 -1
  111. package/dist/node_modules/@apollo/client/utilities/internal/isNonNullObject.js +1 -2
  112. package/dist/node_modules/@apollo/client/utilities/internal/isNonNullObject.js.map +1 -1
  113. package/dist/node_modules/@apollo/client/utilities/internal/makeUniqueId.js +1 -2
  114. package/dist/node_modules/@apollo/client/utilities/internal/makeUniqueId.js.map +1 -1
  115. package/dist/node_modules/@apollo/client/utilities/internal/memoize.js +1 -2
  116. package/dist/node_modules/@apollo/client/utilities/internal/memoize.js.map +1 -1
  117. package/dist/node_modules/@apollo/client/utilities/internal/stringifyForDisplay.js +1 -2
  118. package/dist/node_modules/@apollo/client/utilities/internal/stringifyForDisplay.js.map +1 -1
  119. package/dist/node_modules/@apollo/client/utilities/invariant/index.js +2 -3
  120. package/dist/node_modules/@apollo/client/utilities/invariant/index.js.map +1 -1
  121. package/dist/node_modules/@apollo/client/version.js +2 -3
  122. package/dist/node_modules/@apollo/client/version.js.map +1 -1
  123. package/dist/node_modules/@wry/caches/lib/weak.js +1 -2
  124. package/dist/node_modules/@wry/caches/lib/weak.js.map +1 -1
  125. package/dist/node_modules/@wry/trie/lib/index.js +2 -3
  126. package/dist/node_modules/@wry/trie/lib/index.js.map +1 -1
  127. package/dist/node_modules/graphql-ws/dist/client.js +76 -69
  128. package/dist/node_modules/graphql-ws/dist/client.js.map +1 -1
  129. package/dist/node_modules/graphql-ws/dist/common-CGW11Fyb.js +2 -3
  130. package/dist/node_modules/graphql-ws/dist/common-CGW11Fyb.js.map +1 -1
  131. package/dist/node_modules/rxjs/dist/esm5/internal/NotificationFactories.js +2 -3
  132. package/dist/node_modules/rxjs/dist/esm5/internal/NotificationFactories.js.map +1 -1
  133. package/dist/node_modules/rxjs/dist/esm5/internal/Observable.js +41 -42
  134. package/dist/node_modules/rxjs/dist/esm5/internal/Observable.js.map +1 -1
  135. package/dist/node_modules/rxjs/dist/esm5/internal/Subscriber.js +14 -15
  136. package/dist/node_modules/rxjs/dist/esm5/internal/Subscriber.js.map +1 -1
  137. package/dist/node_modules/rxjs/dist/esm5/internal/Subscription.js +21 -18
  138. package/dist/node_modules/rxjs/dist/esm5/internal/Subscription.js.map +1 -1
  139. package/dist/node_modules/rxjs/dist/esm5/internal/config.js +1 -2
  140. package/dist/node_modules/rxjs/dist/esm5/internal/config.js.map +1 -1
  141. package/dist/node_modules/rxjs/dist/esm5/internal/observable/empty.js +1 -2
  142. package/dist/node_modules/rxjs/dist/esm5/internal/observable/empty.js.map +1 -1
  143. package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js +2 -3
  144. package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js.map +1 -1
  145. package/dist/node_modules/rxjs/dist/esm5/internal/symbol/observable.js +1 -2
  146. package/dist/node_modules/rxjs/dist/esm5/internal/symbol/observable.js.map +1 -1
  147. package/dist/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js +1 -2
  148. package/dist/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js.map +1 -1
  149. package/dist/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js +1 -2
  150. package/dist/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js.map +1 -1
  151. package/dist/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js +1 -2
  152. package/dist/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js.map +1 -1
  153. package/dist/node_modules/rxjs/dist/esm5/internal/util/errorContext.js +1 -2
  154. package/dist/node_modules/rxjs/dist/esm5/internal/util/errorContext.js.map +1 -1
  155. package/dist/node_modules/rxjs/dist/esm5/internal/util/identity.js +1 -2
  156. package/dist/node_modules/rxjs/dist/esm5/internal/util/identity.js.map +1 -1
  157. package/dist/node_modules/rxjs/dist/esm5/internal/util/isFunction.js +1 -2
  158. package/dist/node_modules/rxjs/dist/esm5/internal/util/isFunction.js.map +1 -1
  159. package/dist/node_modules/rxjs/dist/esm5/internal/util/noop.js +1 -2
  160. package/dist/node_modules/rxjs/dist/esm5/internal/util/noop.js.map +1 -1
  161. package/dist/node_modules/rxjs/dist/esm5/internal/util/pipe.js +1 -2
  162. package/dist/node_modules/rxjs/dist/esm5/internal/util/pipe.js.map +1 -1
  163. package/dist/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js +1 -2
  164. package/dist/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js.map +1 -1
  165. package/dist/node_modules/{rxjs/node_modules/tslib → tslib}/tslib.es6.js +1 -2
  166. package/dist/node_modules/tslib/tslib.es6.js.map +1 -0
  167. package/dist/pages/CreateNotificationPage.d.ts +5 -0
  168. package/dist/pages/CreateNotificationPage.js +18 -19
  169. package/dist/pages/CreateNotificationPage.js.map +1 -1
  170. package/dist/pages/NotificationCenterPage.d.ts +6 -0
  171. package/dist/pages/NotificationCenterPage.js +13 -14
  172. package/dist/pages/NotificationCenterPage.js.map +1 -1
  173. package/dist/pages/NotificationHistoryAdminPage.d.ts +2 -0
  174. package/dist/pages/NotificationHistoryAdminPage.js +7 -8
  175. package/dist/pages/NotificationHistoryAdminPage.js.map +1 -1
  176. package/dist/pages/NotificationHistoryPage.d.ts +2 -0
  177. package/dist/pages/NotificationHistoryPage.js +13 -14
  178. package/dist/pages/NotificationHistoryPage.js.map +1 -1
  179. package/dist/pages/NotificationLandingPage.d.ts +10 -0
  180. package/dist/pages/NotificationLandingPage.js +5 -6
  181. package/dist/pages/NotificationLandingPage.js.map +1 -1
  182. package/dist/pages/NotificationPreferencesPage.d.ts +1 -0
  183. package/dist/pages/NotificationPreferencesPage.js +14 -15
  184. package/dist/pages/NotificationPreferencesPage.js.map +1 -1
  185. package/dist/pages/NotificationTemplatesPage.d.ts +7 -0
  186. package/dist/pages/NotificationTemplatesPage.js +25 -23
  187. package/dist/pages/NotificationTemplatesPage.js.map +1 -1
  188. package/dist/pages/NotificationTopicsPage.d.ts +1 -0
  189. package/dist/pages/NotificationTopicsPage.js +6 -7
  190. package/dist/pages/NotificationTopicsPage.js.map +1 -1
  191. package/dist/pages/TemplateEditorPage.d.ts +12 -0
  192. package/dist/pages/TemplateEditorPage.js +294 -285
  193. package/dist/pages/TemplateEditorPage.js.map +1 -1
  194. package/dist/providers/NotificationProvider.d.ts +11 -0
  195. package/dist/providers/NotificationProvider.js +1 -2
  196. package/dist/providers/NotificationProvider.js.map +1 -1
  197. package/dist/shared/hooks/useTr.d.ts +13 -0
  198. package/dist/shared/hooks/useTr.js +1 -2
  199. package/dist/shared/hooks/useTr.js.map +1 -1
  200. package/dist/store/notificationStore.d.ts +30 -0
  201. package/dist/store/notificationStore.js +1 -2
  202. package/dist/store/notificationStore.js.map +1 -1
  203. package/dist/test/happydom.d.ts +1 -0
  204. package/dist/translations/en.d.ts +468 -0
  205. package/dist/types/index.d.ts +249 -0
  206. package/dist/utils/inAppNavigation.d.ts +37 -0
  207. package/dist/utils/inAppNavigation.js +2 -3
  208. package/dist/utils/inAppNavigation.js.map +1 -1
  209. package/dist/utils/index.d.ts +68 -0
  210. package/dist/utils/index.js +1 -2
  211. package/dist/utils/index.js.map +1 -1
  212. package/dist/utils/nativeBridge.d.ts +2 -0
  213. package/dist/utils/nativeBridge.js +1 -2
  214. package/dist/utils/notificationHistoryExport.d.ts +12 -0
  215. package/dist/utils/notificationHistoryExport.js +1 -2
  216. package/dist/utils/notificationHistoryExport.js.map +1 -1
  217. package/package.json +66 -48
  218. package/dist/node_modules/rxjs/node_modules/tslib/tslib.es6.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationLandingPage.js","names":[],"sources":["../../src/pages/NotificationLandingPage.tsx"],"sourcesContent":["import { Suspense, lazy, useEffect, useMemo } from 'react';\nimport { useSearchParams } from 'react-router';\nimport { Tabs, type TabItem } from '@burdenoff/fe-libs/chrome';\nimport { useFeatureFlagDetails } from '@burdenoff/fe-libs/shared/feature-flags';\n\nimport { NotificationCenterPage } from './NotificationCenterPage';\nimport { useTr } from '../shared/hooks/useTr';\n\n// Lazy-load admin tab bodies — each tab pulls its bundle only when activated,\n// matching the code-splitting done in AdminNotificationRoutes.\nconst NotificationHistoryAdminPage = lazy(() =>\n import('./NotificationHistoryAdminPage').then((m) => ({\n default: m.NotificationHistoryAdminPage,\n }))\n);\nconst NotificationTemplatesPage = lazy(() =>\n import('./NotificationTemplatesPage').then((m) => ({\n default: m.NotificationTemplatesPage,\n }))\n);\nconst CreateNotificationPage = lazy(() =>\n import('./CreateNotificationPage').then((m) => ({\n default: m.CreateNotificationPage,\n }))\n);\nconst NotificationTopicsPage = lazy(() =>\n import('./NotificationTopicsPage').then((m) => ({\n default: m.NotificationTopicsPage,\n }))\n);\n\nfunction TabBodyLoader() {\n return (\n <div className=\"flex h-64 items-center justify-center\">\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n </div>\n );\n}\n\n/**\n * Tabbed landing page for the Notification microfrontend.\n *\n * Admin-only tabs (Send, History, Templates, Topics) are gated by the\n * notification.* feature flags. Gating is applied here because this\n * page bypasses the route-level flag gates in AdminNotificationRoutes:\n * without this check an admin landing on /notifications could click\n * into any tab regardless of flag state.\n */\nexport function NotificationLandingPage() {\n const [params, setParams] = useSearchParams();\n const tr = useTr();\n\n // Explicit `false` fallback prevents the provider's default-allow from\n // leaking unseeded flags — same pattern as AdminNotificationRoot.tsx.\n const templatesDetails = useFeatureFlagDetails('notification.templates');\n const createDetails = useFeatureFlagDetails('notification.create');\n const historyDetails = useFeatureFlagDetails('notification.history');\n const templatesEnabled = templatesDetails ? Boolean(templatesDetails.value) : false;\n const createEnabled = createDetails ? Boolean(createDetails.value) : false;\n const historyEnabled = historyDetails ? Boolean(historyDetails.value) : false;\n\n const tabs: TabItem[] = useMemo(\n () => [\n { id: 'inbox', label: tr('notification.landing.tabs.inbox', 'Inbox') },\n ...(createEnabled\n ? [{ id: 'send', label: tr('notification.landing.tabs.send', 'Send') }]\n : []),\n ...(historyEnabled\n ? [{ id: 'history', label: tr('notification.landing.tabs.history', 'History') }]\n : []),\n ...(templatesEnabled\n ? [{ id: 'templates', label: tr('notification.landing.tabs.templates', 'Templates') }]\n : []),\n // Topics CRUD maps to `notification.create` per the backend @rbac (see\n // AdminNotificationRoutes.tsx: topics route is gated by createEnabled).\n ...(createEnabled\n ? [{ id: 'topics', label: tr('notification.landing.tabs.topics', 'Topics') }]\n : []),\n ],\n [tr, templatesEnabled, createEnabled, historyEnabled]\n );\n\n // Validate the `?tab=` query param against the filtered tab list — an\n // unknown value (stale URL, disabled flag) would otherwise leave the body\n // empty and the Tabs strip with no active item.\n const rawTab = params.get('tab');\n const activeId = rawTab && tabs.some((t) => t.id === rawTab) ? rawTab : tabs[0].id;\n\n // Rule 3 of COMPONENT_LEVEL_GATING.md: when a flag flips off while the\n // user is viewing that tab, clear the `tab` query param so subsequent\n // reloads don't resurrect the disabled view. Using the functional setter\n // form avoids depending on the `params` reference (which would re-fire\n // this effect on every update).\n useEffect(() => {\n if (rawTab && !tabs.some((t) => t.id === rawTab)) {\n setParams(\n (prev) => {\n const next = new URLSearchParams(prev);\n next.delete('tab');\n return next;\n },\n { replace: true }\n );\n }\n }, [rawTab, tabs, setParams]);\n\n // Functional setter avoids capturing a stale `params` reference in the\n // closure — prevents dropping a concurrent query param on rapid clicks.\n const handleTabChange = (id: string) => {\n setParams(\n (prev) => {\n const next = new URLSearchParams(prev);\n if (id === tabs[0].id) {\n next.delete('tab');\n } else {\n next.set('tab', id);\n }\n return next;\n },\n { replace: true }\n );\n };\n\n return (\n <div className=\"flex flex-col h-full\">\n <div className=\"border-b border-border-seam px-4 pt-3\">\n <Tabs\n items={tabs}\n activeTabId={activeId}\n onTabChange={handleTabChange}\n variant=\"underline\"\n />\n </div>\n <div className=\"flex-1 min-h-0 overflow-auto\">\n {/*\n History tab is flag-gated but not PermissionGate-wrapped at this layer\n — it mirrors AdminNotificationRoutes where the /history route is the\n same: the admin page itself requires NOTIFICATION_LIST permission and\n renders its own no-permission fallback when missing. Templates and\n Create tabs go through separate flag-gated routes with PermissionGate\n in AdminNotificationRoutes, so when navigated via tab here they\n bypass that gate — but the inner pages (TemplateEditor, CreateNotificationPage,\n NotificationTemplatesPage) each perform their own permission checks\n and hide write actions for read-only users.\n */}\n {activeId === 'inbox' && <NotificationCenterPage />}\n <Suspense fallback={<TabBodyLoader />}>\n {activeId === 'send' && createEnabled && <CreateNotificationPage />}\n {activeId === 'history' && historyEnabled && <NotificationHistoryAdminPage />}\n {activeId === 'templates' && templatesEnabled && <NotificationTemplatesPage />}\n {activeId === 'topics' && createEnabled && <NotificationTopicsPage />}\n </Suspense>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAUA,IAAM,IAA+B,QACnC,OAAO,qCAAkC,MAAM,OAAO,EACpD,SAAS,EAAE,8BACZ,EAAE,CACJ,EACK,IAA4B,QAChC,OAAO,kCAA+B,MAAM,OAAO,EACjD,SAAS,EAAE,2BACZ,EAAE,CACJ,EACK,IAAyB,QAC7B,OAAO,+BAA4B,MAAM,OAAO,EAC9C,SAAS,EAAE,wBACZ,EAAE,CACJ,EACK,IAAyB,QAC7B,OAAO,+BAA4B,MAAM,OAAO,EAC9C,SAAS,EAAE,wBACZ,EAAE,CACJ;AAED,SAAS,IAAgB;AACvB,QACE,kBAAC,OAAD;EAAK,WAAU;YACb,kBAAC,OAAD,EAA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;aACb,kBAAC,GAAD;IACE,OAAO;IACP,aAAa;IACb,cArBiB,MAAe;AACtC,QACG,MAAS;MACR,IAAM,IAAO,IAAI,gBAAgB,EAAK;AAMtC,aALI,MAAO,EAAK,GAAG,KACjB,EAAK,OAAO,MAAM,GAElB,EAAK,IAAI,OAAO,EAAG,EAEd;QAET,EAAE,SAAS,IAAM,CAClB;;IAUK,SAAQ;IACR,CAAA;GACE,CAAA,EACN,kBAAC,OAAD;GAAK,WAAU;aAAf,CAYG,MAAa,WAAW,kBAAC,GAAD,EAA0B,CAAA,EACnD,kBAAC,GAAD;IAAU,UAAU,kBAAC,GAAD,EAAiB,CAAA;cAArC;KACG,MAAa,UAAU,KAAiB,kBAAC,GAAD,EAA0B,CAAA;KAClE,MAAa,aAAa,KAAkB,kBAAC,GAAD,EAAgC,CAAA;KAC5E,MAAa,eAAe,KAAoB,kBAAC,GAAD,EAA6B,CAAA;KAC7E,MAAa,YAAY,KAAiB,kBAAC,GAAD,EAA0B,CAAA;KAC5D;MACP;KACF"}
1
+ {"version":3,"file":"NotificationLandingPage.js","names":["NotificationHistoryAdminPage","lazy","m","NotificationTemplatesPage","CreateNotificationPage","NotificationTopicsPage","TabBodyLoader","NotificationLandingPage","params","setParams","useSearchParams","tr","useTr","templatesDetails","useFeatureFlagDetails","createDetails","historyDetails","templatesEnabled","createEnabled","historyEnabled","tabs","useMemo","rawTab","activeId","t","useEffect","next","prev","Tabs","id","NotificationCenterPage","Suspense"],"sources":["../../src/pages/NotificationLandingPage.tsx"],"sourcesContent":["import { Suspense, lazy, useEffect, useMemo } from 'react';\nimport { useSearchParams } from 'react-router';\nimport { Tabs, type TabItem } from '@burdenoff/fe-libs/chrome';\nimport { useFeatureFlagDetails } from '@burdenoff/fe-libs/shared/feature-flags';\n\nimport { NotificationCenterPage } from './NotificationCenterPage';\nimport { useTr } from '../shared/hooks/useTr';\n\n// Lazy-load admin tab bodies — each tab pulls its bundle only when activated,\n// matching the code-splitting done in AdminNotificationRoutes.\nconst NotificationHistoryAdminPage = lazy(() =>\n import('./NotificationHistoryAdminPage').then((m) => ({\n default: m.NotificationHistoryAdminPage,\n }))\n);\nconst NotificationTemplatesPage = lazy(() =>\n import('./NotificationTemplatesPage').then((m) => ({\n default: m.NotificationTemplatesPage,\n }))\n);\nconst CreateNotificationPage = lazy(() =>\n import('./CreateNotificationPage').then((m) => ({\n default: m.CreateNotificationPage,\n }))\n);\nconst NotificationTopicsPage = lazy(() =>\n import('./NotificationTopicsPage').then((m) => ({\n default: m.NotificationTopicsPage,\n }))\n);\n\nfunction TabBodyLoader() {\n return (\n <div className=\"flex h-64 items-center justify-center\">\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n </div>\n );\n}\n\n/**\n * Tabbed landing page for the Notification microfrontend.\n *\n * Admin-only tabs (Send, History, Templates, Topics) are gated by the\n * notification.* feature flags. Gating is applied here because this\n * page bypasses the route-level flag gates in AdminNotificationRoutes:\n * without this check an admin landing on /notifications could click\n * into any tab regardless of flag state.\n */\nexport function NotificationLandingPage() {\n const [params, setParams] = useSearchParams();\n const tr = useTr();\n\n // Explicit `false` fallback prevents the provider's default-allow from\n // leaking unseeded flags — same pattern as AdminNotificationRoot.tsx.\n const templatesDetails = useFeatureFlagDetails('notification.templates');\n const createDetails = useFeatureFlagDetails('notification.create');\n const historyDetails = useFeatureFlagDetails('notification.history');\n const templatesEnabled = templatesDetails ? Boolean(templatesDetails.value) : false;\n const createEnabled = createDetails ? Boolean(createDetails.value) : false;\n const historyEnabled = historyDetails ? Boolean(historyDetails.value) : false;\n\n const tabs: TabItem[] = useMemo(\n () => [\n { id: 'inbox', label: tr('notification.landing.tabs.inbox', 'Inbox') },\n ...(createEnabled\n ? [{ id: 'send', label: tr('notification.landing.tabs.send', 'Send') }]\n : []),\n ...(historyEnabled\n ? [{ id: 'history', label: tr('notification.landing.tabs.history', 'History') }]\n : []),\n ...(templatesEnabled\n ? [{ id: 'templates', label: tr('notification.landing.tabs.templates', 'Templates') }]\n : []),\n // Topics CRUD maps to `notification.create` per the backend @rbac (see\n // AdminNotificationRoutes.tsx: topics route is gated by createEnabled).\n ...(createEnabled\n ? [{ id: 'topics', label: tr('notification.landing.tabs.topics', 'Topics') }]\n : []),\n ],\n [tr, templatesEnabled, createEnabled, historyEnabled]\n );\n\n // Validate the `?tab=` query param against the filtered tab list — an\n // unknown value (stale URL, disabled flag) would otherwise leave the body\n // empty and the Tabs strip with no active item.\n const rawTab = params.get('tab');\n const activeId = rawTab && tabs.some((t) => t.id === rawTab) ? rawTab : tabs[0].id;\n\n // Rule 3 of COMPONENT_LEVEL_GATING.md: when a flag flips off while the\n // user is viewing that tab, clear the `tab` query param so subsequent\n // reloads don't resurrect the disabled view. Using the functional setter\n // form avoids depending on the `params` reference (which would re-fire\n // this effect on every update).\n useEffect(() => {\n if (rawTab && !tabs.some((t) => t.id === rawTab)) {\n setParams(\n (prev) => {\n const next = new URLSearchParams(prev);\n next.delete('tab');\n return next;\n },\n { replace: true }\n );\n }\n }, [rawTab, tabs, setParams]);\n\n // Functional setter avoids capturing a stale `params` reference in the\n // closure — prevents dropping a concurrent query param on rapid clicks.\n const handleTabChange = (id: string) => {\n setParams(\n (prev) => {\n const next = new URLSearchParams(prev);\n if (id === tabs[0].id) {\n next.delete('tab');\n } else {\n next.set('tab', id);\n }\n return next;\n },\n { replace: true }\n );\n };\n\n return (\n <div className=\"flex flex-col h-full\">\n <div className=\"border-b border-border-seam px-4 pt-3\">\n <Tabs\n items={tabs}\n activeTabId={activeId}\n onTabChange={handleTabChange}\n variant=\"underline\"\n />\n </div>\n <div className=\"flex-1 min-h-0 overflow-auto\">\n {/*\n History tab is flag-gated but not PermissionGate-wrapped at this layer\n — it mirrors AdminNotificationRoutes where the /history route is the\n same: the admin page itself requires NOTIFICATION_LIST permission and\n renders its own no-permission fallback when missing. Templates and\n Create tabs go through separate flag-gated routes with PermissionGate\n in AdminNotificationRoutes, so when navigated via tab here they\n bypass that gate — but the inner pages (TemplateEditor, CreateNotificationPage,\n NotificationTemplatesPage) each perform their own permission checks\n and hide write actions for read-only users.\n */}\n {activeId === 'inbox' && <NotificationCenterPage />}\n <Suspense fallback={<TabBodyLoader />}>\n {activeId === 'send' && createEnabled && <CreateNotificationPage />}\n {activeId === 'history' && historyEnabled && <NotificationHistoryAdminPage />}\n {activeId === 'templates' && templatesEnabled && <NotificationTemplatesPage />}\n {activeId === 'topics' && createEnabled && <NotificationTopicsPage />}\n </Suspense>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAUA,IAAMA,IAA+BC,QACnC,OAAO,oCAAiC,CAAC,MAAM,OAAO,EACpD,SAASC,EAAE,6BACb,EAAE,CACJ,GACMC,IAA4BF,QAChC,OAAO,iCAA8B,CAAC,MAAM,OAAO,EACjD,SAASC,EAAE,0BACb,EAAE,CACJ,GACME,IAAyBH,QAC7B,OAAO,8BAA2B,CAAC,MAAM,OAAO,EAC9C,SAASC,EAAE,uBACb,EAAE,CACJ,GACMG,IAAyBJ,QAC7B,OAAO,8BAA2B,CAAC,MAAM,OAAO,EAC9C,SAASC,EAAE,uBACb,EAAE,CACJ;AAEA,SAASI,IAAgB;CACvB,OACE,kBAAC,OAAD;EAAK,WAAU;EACb,UAAA,kBAAC,OAAD,EAAK,WAAU,iFAAkF,CAAA;CAC9F,CAAA;AAET;AAWA,SAAgBC,IAA0B;CACxC,IAAM,CAACC,GAAQC,KAAaC,EAAgB,GACtCC,IAAKC,EAAM,GAIXC,IAAmBC,EAAsB,wBAAwB,GACjEC,IAAgBD,EAAsB,qBAAqB,GAC3DE,IAAiBF,EAAsB,sBAAsB,GAC7DG,IAAmBJ,IAAmB,EAAQA,EAAiB,QAAS,IACxEK,IAAgBH,IAAgB,EAAQA,EAAc,QAAS,IAC/DI,IAAiBH,IAAiB,EAAQA,EAAe,QAAS,IAElEI,IAAkBC,QAChB;EACJ;GAAE,IAAI;GAAS,OAAOV,EAAG,mCAAmC,OAAO;EAAE;EACrE,GAAIO,I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,WAAW,kBAACO,GAAD,CAAyB,CAAA,GAClD,kBAACC,GAAD;IAAU,UAAU,kBAACzB,GAAD,CAAgB,CAAA;IAApC,UAAA;KACGiB,MAAa,UAAUL,KAAiB,kBAACd,GAAD,CAAyB,CAAA;KACjEmB,MAAa,aAAaJ,KAAkB,kBAACnB,GAAD,CAA+B,CAAA;KAC3EuB,MAAa,eAAeN,KAAoB,kBAACd,GAAD,CAA4B,CAAA;KAC5EoB,MAAa,YAAYL,KAAiB,kBAACb,GAAD,CAAyB,CAAA;IAC5D;GACP,CAAA,CAAA;EACF,CAAA,CAAA;;AAET"}
@@ -0,0 +1 @@
1
+ export declare function NotificationPreferencesPage(): import('react').JSX.Element;
@@ -1,17 +1,17 @@
1
- import { useNotification as e } from "../providers/NotificationProvider.js";
2
- import { useNotificationAnalytics as t } from "../hooks/useNotificationAnalytics.js";
3
- import { useNotificationPreferences as n } from "../hooks/useNotificationPreferences.js";
4
- import { useNotificationTopics as r } from "../hooks/useNotificationTopics.js";
5
1
  import "../hooks/index.js";
6
- import { useTr as i } from "../shared/hooks/useTr.js";
7
- import { nativeImpact as a, nativeNotify as o } from "../utils/nativeBridge.js";
8
- import { NOTIFICATION_PERMISSIONS as s } from "../constants/permissions.js";
2
+ import { useNotificationAnalytics as e } from "../hooks/useNotificationAnalytics.js";
3
+ import { useNotificationPreferences as t } from "../hooks/useNotificationPreferences.js";
4
+ import { useNotificationTopics as n } from "../hooks/useNotificationTopics.js";
5
+ import { NOTIFICATION_PERMISSIONS as r } from "../constants/permissions.js";
6
+ import { useNotification as i } from "../providers/NotificationProvider.js";
7
+ import { useTr as a } from "../shared/hooks/useTr.js";
8
+ import { nativeImpact as o, nativeNotify as s } from "../utils/nativeBridge.js";
9
9
  import { useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
10
10
  import { usePermissions as f } from "@burdenoff/fe-libs/shared/providers/shell";
11
11
  import { BellRing as p, Search as m, ToggleLeft as h, ToggleRight as g } from "lucide-react";
12
12
  import { jsx as _, jsxs as v } from "react/jsx-runtime";
13
13
  import { EmphasisPanel as y, IllustratedEmptyState as b, OptionalFields as x, PagePurpose as S } from "@burdenoff/fe-libs/ui";
14
- //#region src/pages/NotificationPreferencesPage.tsx
14
+ // src/pages/NotificationPreferencesPage.tsx
15
15
  var C = [
16
16
  {
17
17
  value: "IN_APP",
@@ -69,10 +69,10 @@ function T(e) {
69
69
  return e.scope === "CHANNEL" ? `CHANNEL:${e.channel || ""}` : e.scope === "TYPE" ? `TYPE:${e.type || ""}` : e.scope === "TOPIC" ? `TOPIC:${e.topicId || ""}` : "GLOBAL";
70
70
  }
71
71
  function E() {
72
- let E = i(), { hasPermission: D, isLoading: O } = f(), { currentUser: k } = e(), { topics: A, isLoading: j, isForbidden: M } = r({
72
+ let E = a(), { hasPermission: D, isLoading: O } = f(), { currentUser: k } = i(), { topics: A, isLoading: j, isForbidden: M } = n({
73
73
  type: "MARKETING",
74
74
  isActive: !0
75
- }), { preferencesByKey: N, isLoading: P, setPreference: F, deletePreference: I } = n(), { trackPreferenceUpdated: L } = t(), [R, z] = d(""), [B, V] = d(null), [H, U] = d(null), W = u(null), G = j || P;
75
+ }), { preferencesByKey: N, isLoading: P, setPreference: F, deletePreference: I } = t(), { trackPreferenceUpdated: L } = e(), [R, z] = d(""), [B, V] = d(null), [H, U] = d(null), W = u(null), G = j || P;
76
76
  c(() => () => {
77
77
  W.current && clearTimeout(W.current);
78
78
  }, []);
@@ -86,7 +86,7 @@ function E() {
86
86
  return A.filter((t) => t.name.toLowerCase().includes(e) || t.slug.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e));
87
87
  }, [R, A]), J = async (e) => {
88
88
  let t = T(e), n = N.get(t), r = !(n?.enabled ?? !0);
89
- V(t), a("medium");
89
+ V(t), o("medium");
90
90
  try {
91
91
  await F({
92
92
  ...e,
@@ -102,13 +102,13 @@ function E() {
102
102
  key: t,
103
103
  type: "success",
104
104
  message: E("notifications.preferenceSaved", "Preference saved.")
105
- }), o("success");
105
+ }), s("success");
106
106
  } catch {
107
107
  K({
108
108
  key: t,
109
109
  type: "error",
110
110
  message: E("notifications.preferenceSaveFailed", "Could not save preference.")
111
- }), o("error");
111
+ }), s("error");
112
112
  } finally {
113
113
  V(null);
114
114
  }
@@ -200,7 +200,7 @@ function E() {
200
200
  return O ? /* @__PURE__ */ _("div", {
201
201
  className: "flex h-64 items-center justify-center",
202
202
  children: /* @__PURE__ */ _("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" })
203
- }) : !D(s.NOTIFICATION_LIST) && !k?.id ? /* @__PURE__ */ _("div", {
203
+ }) : !D(r.NOTIFICATION_LIST) && !k?.id ? /* @__PURE__ */ _("div", {
204
204
  className: "p-8 text-center text-text-secondary",
205
205
  children: E("notifications.noPermissionPreferences", "You don't have permission to manage notification preferences.")
206
206
  }) : /* @__PURE__ */ v("div", {
@@ -310,7 +310,6 @@ function E() {
310
310
  ]
311
311
  });
312
312
  }
313
- //#endregion
314
313
  export { E as NotificationPreferencesPage };
315
314
 
316
315
  //# sourceMappingURL=NotificationPreferencesPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationPreferencesPage.js","names":[],"sources":["../../src/pages/NotificationPreferencesPage.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react';\nimport { BellRing, Search, ToggleLeft, ToggleRight } from 'lucide-react';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport {\n EmphasisPanel,\n IllustratedEmptyState,\n OptionalFields,\n PagePurpose,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotificationPreferences, useNotificationTopics } from '../hooks';\nimport { useNotificationAnalytics } from '../hooks/useNotificationAnalytics';\nimport { NOTIFICATION_PERMISSIONS } from '../constants/permissions';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { useTr } from '../shared/hooks/useTr';\nimport type { NotificationChannel, NotificationPreferenceScope, NotificationType } from '../types';\nimport { nativeImpact, nativeNotify } from '../utils/nativeBridge';\n\nconst CHANNEL_OPTIONS: Array<{ value: NotificationChannel; labelKey: string; label: string }> = [\n { value: 'IN_APP', labelKey: 'notifications.channelInApp', label: 'In-app' },\n { value: 'EMAIL', labelKey: 'notifications.channelEmail', label: 'Email' },\n { value: 'PUSH', labelKey: 'notifications.channelPush', label: 'Push' },\n { value: 'SMS', labelKey: 'notifications.channelSms', label: 'SMS' },\n { value: 'WHATSAPP', labelKey: 'notifications.channelWhatsapp', label: 'WhatsApp' },\n { value: 'SLACK', labelKey: 'notifications.channelSlack', label: 'Slack' },\n];\n\nconst TYPE_OPTIONS: Array<{ value: NotificationType; labelKey: string; label: string }> = [\n { value: 'TRANSACTIONAL', labelKey: 'notifications.typeTransactional', label: 'Transactional' },\n { value: 'SYSTEM', labelKey: 'notifications.typeSystem', label: 'System' },\n { value: 'ALERT', labelKey: 'notifications.typeAlert', label: 'Alerts' },\n { value: 'MARKETING', labelKey: 'notifications.typeMarketing', label: 'Marketing' },\n];\n\nfunction preferenceKey(input: {\n scope: NotificationPreferenceScope;\n channel?: NotificationChannel;\n type?: NotificationType;\n topicId?: string;\n}) {\n if (input.scope === 'CHANNEL') return `CHANNEL:${input.channel || ''}`;\n if (input.scope === 'TYPE') return `TYPE:${input.type || ''}`;\n if (input.scope === 'TOPIC') return `TOPIC:${input.topicId || ''}`;\n return 'GLOBAL';\n}\n\nexport function NotificationPreferencesPage() {\n const tr = useTr();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const { currentUser } = useNotification();\n const {\n topics,\n isLoading: topicsLoading,\n isForbidden: topicsForbidden,\n } = useNotificationTopics({\n type: 'MARKETING',\n isActive: true,\n });\n const {\n preferencesByKey,\n isLoading: preferencesLoading,\n setPreference,\n deletePreference,\n } = useNotificationPreferences();\n const { trackPreferenceUpdated } = useNotificationAnalytics();\n const [search, setSearch] = useState('');\n const [savingKey, setSavingKey] = useState<string | null>(null);\n const [saveFeedback, setSaveFeedback] = useState<{\n key: string;\n type: 'success' | 'error';\n message: string;\n } | null>(null);\n const feedbackTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const isLoading = topicsLoading || preferencesLoading;\n\n useEffect(() => {\n return () => {\n if (feedbackTimerRef.current) {\n clearTimeout(feedbackTimerRef.current);\n }\n };\n }, []);\n\n const showSaveFeedback = (feedback: {\n key: string;\n type: 'success' | 'error';\n message: string;\n }) => {\n if (feedbackTimerRef.current) {\n clearTimeout(feedbackTimerRef.current);\n }\n\n setSaveFeedback(feedback);\n feedbackTimerRef.current = setTimeout(() => {\n setSaveFeedback((current) => (current?.key === feedback.key ? null : current));\n feedbackTimerRef.current = null;\n }, 2500);\n };\n\n const filteredTopics = useMemo(() => {\n if (!search.trim()) {\n return topics;\n }\n\n const query = search.toLowerCase();\n return topics.filter(\n (topic) =>\n topic.name.toLowerCase().includes(query) ||\n topic.slug.toLowerCase().includes(query) ||\n topic.description?.toLowerCase().includes(query)\n );\n }, [search, topics]);\n\n const togglePreference = async (input: {\n scope: NotificationPreferenceScope;\n channel?: NotificationChannel;\n type?: NotificationType;\n topicId?: string;\n }) => {\n const key = preferenceKey(input);\n const existing = preferencesByKey.get(key);\n const nextEnabled = !(existing?.enabled ?? true);\n setSavingKey(key);\n nativeImpact('medium');\n try {\n await setPreference({\n ...input,\n enabled: nextEnabled,\n frequency: existing?.frequency || 'IMMEDIATE',\n });\n trackPreferenceUpdated({\n action: 'set',\n scope: input.scope,\n channel: input.channel,\n type: input.type,\n enabled: nextEnabled,\n });\n showSaveFeedback({\n key,\n type: 'success',\n message: tr('notifications.preferenceSaved', 'Preference saved.'),\n });\n void nativeNotify('success');\n } catch {\n showSaveFeedback({\n key,\n type: 'error',\n message: tr('notifications.preferenceSaveFailed', 'Could not save preference.'),\n });\n void nativeNotify('error');\n } finally {\n setSavingKey(null);\n }\n };\n\n const resetPreference = async (key: string) => {\n const existing = preferencesByKey.get(key);\n if (!existing) return;\n setSavingKey(key);\n try {\n await deletePreference(existing.id);\n trackPreferenceUpdated({\n action: 'reset',\n scope: existing.scope,\n channel: existing.channel,\n type: existing.type,\n });\n showSaveFeedback({\n key,\n type: 'success',\n message: tr('notifications.preferenceReset', 'Preference reset.'),\n });\n } catch {\n showSaveFeedback({\n key,\n type: 'error',\n message: tr('notifications.preferenceResetFailed', 'Could not reset preference.'),\n });\n } finally {\n setSavingKey(null);\n }\n };\n\n const renderPreferenceRow = (input: {\n key: string;\n title: string;\n description: string;\n scope: NotificationPreferenceScope;\n channel?: NotificationChannel;\n type?: NotificationType;\n topicId?: string;\n }) => {\n const existing = preferencesByKey.get(input.key);\n const isEnabled = existing?.enabled ?? true;\n const isSaving = savingKey === input.key;\n const feedback = saveFeedback?.key === input.key ? saveFeedback : null;\n\n return (\n <div\n key={input.key}\n className=\"rounded-lg border border-border-seam bg-gloss-card p-4 transition-[box-shadow,border-color] duration-200 hover:shadow-[var(--shadow-pop)]\"\n >\n <div className=\"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between\">\n <div className=\"space-y-1\">\n <div className=\"flex items-center gap-2\">\n <BellRing size={16} className=\"text-accent-primary\" />\n <h2 className=\"text-sm font-semibold text-primary\">{input.title}</h2>\n {existing && (\n <span className=\"rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary\">\n {existing.frequency.replace('_', ' ').toLowerCase()}\n </span>\n )}\n </div>\n <p className=\"text-sm text-secondary\">{input.description}</p>\n </div>\n\n <div className=\"flex items-center gap-2\">\n {existing && (\n <button\n type=\"button\"\n disabled={isSaving}\n onClick={() => resetPreference(input.key)}\n className=\"rounded-md border border-default px-3 py-2 text-sm text-secondary hover:bg-bg-sunken disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {tr('notifications.reset', 'Reset')}\n </button>\n )}\n <button\n type=\"button\"\n aria-pressed={isEnabled}\n disabled={isSaving}\n onClick={() =>\n togglePreference({\n scope: input.scope,\n channel: input.channel,\n type: input.type,\n topicId: input.topicId,\n })\n }\n className={`inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium transition-colors ${\n isEnabled\n ? 'border-accent-primary bg-action-primary-bg text-text-inverse hover:opacity-90'\n : 'border-default bg-bg-sunken text-secondary hover:bg-bg-sunken/80'\n } disabled:cursor-not-allowed disabled:opacity-50`}\n >\n {isEnabled ? <ToggleRight size={18} /> : <ToggleLeft size={18} />}\n {isSaving\n ? tr('notifications.saving', 'Saving...')\n : isEnabled\n ? tr('notifications.enabled', 'Enabled')\n : tr('notifications.disabled', 'Disabled')}\n </button>\n </div>\n </div>\n <div className=\"mt-3 min-h-5\" aria-live=\"polite\">\n {feedback && (\n <p className={`text-xs ${feedback.type === 'success' ? 'text-success' : 'text-error'}`}>\n {feedback.message}\n </p>\n )}\n </div>\n </div>\n );\n };\n\n if (permissionsLoading) {\n return (\n <div className=\"flex h-64 items-center justify-center\">\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n </div>\n );\n }\n\n if (!hasPermission(NOTIFICATION_PERMISSIONS.NOTIFICATION_LIST) && !currentUser?.id) {\n return (\n <div className=\"p-8 text-center text-text-secondary\">\n {tr(\n 'notifications.noPermissionPreferences',\n \"You don't have permission to manage notification preferences.\"\n )}\n </div>\n );\n }\n\n return (\n <div data-tour=\"notification-preferences-page\" className=\"space-y-6 p-4 sm:p-6\">\n <div>\n <h1 className=\"text-2xl font-bold text-primary\">\n {tr('notifications.preferencesTitle', 'Notification Preferences')}\n </h1>\n <p className=\"mt-1 text-sm text-secondary\">\n {tr(\n 'notifications.preferencesSubtitle',\n 'Control global, channel, type, and topic-level notification delivery.'\n )}\n </p>\n </div>\n\n <PagePurpose icon={<BellRing size={16} />}>\n {tr(\n 'notifications.preferencesPurpose',\n 'Decide how and when we reach you. The Global switch is your master on/off, then you can fine-tune individual channels (email, push, SMS…), notification types and the marketing topics you have subscribed to. Settings cascade — turning a channel off silences it everywhere.'\n )}\n </PagePurpose>\n\n <EmphasisPanel data-tour=\"notification-preferences-global\" className=\"space-y-3 p-5 sm:p-6\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-tertiary\">\n {tr('notifications.globalPreferences', 'Global')}\n </h2>\n {renderPreferenceRow({\n key: 'GLOBAL',\n scope: 'GLOBAL',\n title: tr('notifications.allNotifications', 'All notifications'),\n description: tr(\n 'notifications.allNotificationsDescription',\n 'Master preference for notification delivery across all channels and types.'\n ),\n })}\n </EmphasisPanel>\n\n {/* Advanced: per-channel filter rules / quiet hours / custom templates — collapse the long-tail knobs */}\n <OptionalFields\n title={tr('notifications.advancedPreferences', 'Advanced settings')}\n description={tr(\n 'notifications.advancedPreferencesDescription',\n 'Per-channel filter rules, notification-type filters, and quiet-hour overrides.'\n )}\n >\n <section data-tour=\"notification-preferences-channels\" className=\"space-y-3\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-tertiary\">\n {tr('notifications.channelPreferences', 'Channels')}\n </h2>\n <div className=\"grid gap-3 lg:grid-cols-2\">\n {CHANNEL_OPTIONS.map((channel) =>\n renderPreferenceRow({\n key: `CHANNEL:${channel.value}`,\n scope: 'CHANNEL',\n channel: channel.value,\n title: tr(channel.labelKey, channel.label),\n description: tr(\n 'notifications.channelPreferenceDescription',\n 'Control delivery for this channel.'\n ),\n })\n )}\n </div>\n </section>\n\n <section data-tour=\"notification-preferences-types\" className=\"mt-6 space-y-3\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-tertiary\">\n {tr('notifications.typePreferences', 'Notification Types')}\n </h2>\n <div className=\"grid gap-3 lg:grid-cols-2\">\n {TYPE_OPTIONS.map((type) =>\n renderPreferenceRow({\n key: `TYPE:${type.value}`,\n scope: 'TYPE',\n type: type.value,\n title: tr(type.labelKey, type.label),\n description: tr(\n 'notifications.typePreferenceDescription',\n 'Control delivery for this notification type.'\n ),\n })\n )}\n </div>\n </section>\n </OptionalFields>\n\n <div className=\"relative max-w-xl\">\n <Search size={16} className=\"absolute left-3 top-1/2 -translate-y-1/2 text-tertiary\" />\n <input\n type=\"text\"\n value={search}\n onChange={(event) => setSearch(event.target.value)}\n aria-label={tr('notifications.searchTopics', 'Search topics...')}\n placeholder={tr('notifications.searchTopics', 'Search topics...')}\n className=\"w-full rounded-lg border border-default bg-surface py-2 pl-9 pr-4 text-sm text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </div>\n\n <section data-tour=\"notification-preferences-topics\" className=\"space-y-3\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-tertiary\">\n {tr('notifications.topicPreferences', 'Topics')}\n </h2>\n {isLoading ? (\n <div className=\"rounded-lg border border-default bg-surface p-6 text-sm text-secondary\">\n {tr('notifications.loadingPreferences', 'Loading preferences...')}\n </div>\n ) : topicsForbidden ? (\n <IllustratedEmptyState\n illustration=\"empty-generic\"\n title={tr(\n 'notifications.topicsNoAccessTitle',\n \"You don't have access to notification topics\"\n )}\n description={tr(\n 'notifications.topicsNoAccessDescription',\n \"Your role doesn't include permission to read notification topics. Ask a workspace admin if you need access.\"\n )}\n />\n ) : filteredTopics.length === 0 ? (\n <IllustratedEmptyState\n illustration={search.trim() ? 'empty-search' : 'empty-data'}\n title={\n search.trim()\n ? tr('notifications.noTopicsFound', 'No topics match your search')\n : tr('notifications.noTopicsAvailableTitle', 'No subscribable topics yet')\n }\n description={\n search.trim()\n ? tr('notifications.adjustSearchOrDateRange', 'Try adjusting your filters')\n : tr(\n 'notifications.noTopicsAvailableDescription',\n 'When marketing topics are published you can subscribe or unsubscribe from each one here.'\n )\n }\n />\n ) : (\n filteredTopics.map((topic) =>\n renderPreferenceRow({\n key: `TOPIC:${topic.id}`,\n scope: 'TOPIC',\n topicId: topic.id,\n title: topic.name,\n description: topic.description || topic.slug,\n })\n )\n )}\n </section>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAiBA,IAAM,IAA0F;CAC9F;EAAE,OAAO;EAAU,UAAU;EAA8B,OAAO;EAAU;CAC5E;EAAE,OAAO;EAAS,UAAU;EAA8B,OAAO;EAAS;CAC1E;EAAE,OAAO;EAAQ,UAAU;EAA6B,OAAO;E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C,6BAA6B,GACzE,EACE,8CACA,2FACD;KAEP,CAAA,GAEF,EAAe,KAAK,MAClB,EAAoB;KAClB,KAAK,SAAS,EAAM;KACpB,OAAO;KACP,SAAS,EAAM;KACf,OAAO,EAAM;KACb,aAAa,EAAM,eAAe,EAAM;KACzC,CAAC,CACH,CAEK;;GACN"}
1
+ {"version":3,"file":"NotificationPreferencesPage.js","names":["CHANNEL_OPTIONS","TYPE_OPTIONS","preferenceKey","input","NotificationPreferencesPage","tr","useTr","permissionsLoading","usePermissions","useNotification","topicsLoading","topicsForbidden","useNotificationTopics","preferencesLoading","useNotificationPreferences","useNotificationAnalytics","search","setSearch","useState","savingKey","setSavingKey","saveFeedback","setSaveFeedback","feedbackTimerRef","useRef","isLoading","showSaveFeedback","feedback","current","filteredTopics","useMemo","topics","query","topic","togglePreference","key","existing","preferencesByKey","nextEnabled","nativeImpact","setPreference","trackPreferenceUpdated","nativeNotify","resetPreference","deletePreference","renderPreferenceRow","isEnabled","isSaving","BellRing","jsx","ToggleRight","ToggleLeft","hasPermission","NOTIFICATION_PERMISSIONS","currentUser","PagePurpose","EmphasisPanel","OptionalFields","channel","type","Search","event","IllustratedEmptyState"],"sources":["../../src/pages/NotificationPreferencesPage.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react';\nimport { BellRing, Search, ToggleLeft, ToggleRight } from 'lucide-react';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport {\n EmphasisPanel,\n IllustratedEmptyState,\n OptionalFields,\n PagePurpose,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotificationPreferences, useNotificationTopics } from '../hooks';\nimport { useNotificationAnalytics } from '../hooks/useNotificationAnalytics';\nimport { NOTIFICATION_PERMISSIONS } from '../constants/permissions';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { useTr } from '../shared/hooks/useTr';\nimport type { NotificationChannel, NotificationPreferenceScope, NotificationType } from '../types';\nimport { nativeImpact, nativeNotify } from '../utils/nativeBridge';\n\nconst CHANNEL_OPTIONS: Array<{ value: NotificationChannel; labelKey: string; label: string }> = [\n { value: 'IN_APP', labelKey: 'notifications.channelInApp', label: 'In-app' },\n { value: 'EMAIL', labelKey: 'notifications.channelEmail', label: 'Email' },\n { value: 'PUSH', labelKey: 'notifications.channelPush', label: 'Push' },\n { value: 'SMS', labelKey: 'notifications.channelSms', label: 'SMS' },\n { value: 'WHATSAPP', labelKey: 'notifications.channelWhatsapp', label: 'WhatsApp' },\n { value: 'SLACK', labelKey: 'notifications.channelSlack', label: 'Slack' },\n];\n\nconst TYPE_OPTIONS: Array<{ value: NotificationType; labelKey: string; label: string }> = [\n { value: 'TRANSACTIONAL', labelKey: 'notifications.typeTransactional', label: 'Transactional' },\n { value: 'SYSTEM', labelKey: 'notifications.typeSystem', label: 'System' },\n { value: 'ALERT', labelKey: 'notifications.typeAlert', label: 'Alerts' },\n { value: 'MARKETING', labelKey: 'notifications.typeMarketing', label: 'Marketing' },\n];\n\nfunction preferenceKey(input: {\n scope: NotificationPreferenceScope;\n channel?: NotificationChannel;\n type?: NotificationType;\n topicId?: string;\n}) {\n if (input.scope === 'CHANNEL') return `CHANNEL:${input.channel || ''}`;\n if (input.scope === 'TYPE') return `TYPE:${input.type || ''}`;\n if (input.scope === 'TOPIC') return `TOPIC:${input.topicId || ''}`;\n return 'GLOBAL';\n}\n\nexport function NotificationPreferencesPage() {\n const tr = useTr();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const { currentUser } = useNotification();\n const {\n topics,\n isLoading: topicsLoading,\n isForbidden: topicsForbidden,\n } = useNotificationTopics({\n type: 'MARKETING',\n isActive: true,\n });\n const {\n preferencesByKey,\n isLoading: preferencesLoading,\n setPreference,\n deletePreference,\n } = useNotificationPreferences();\n const { trackPreferenceUpdated } = useNotificationAnalytics();\n const [search, setSearch] = useState('');\n const [savingKey, setSavingKey] = useState<string | null>(null);\n const [saveFeedback, setSaveFeedback] = useState<{\n key: string;\n type: 'success' | 'error';\n message: string;\n } | null>(null);\n const feedbackTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const isLoading = topicsLoading || preferencesLoading;\n\n useEffect(() => {\n return () => {\n if (feedbackTimerRef.current) {\n clearTimeout(feedbackTimerRef.current);\n }\n };\n }, []);\n\n const showSaveFeedback = (feedback: {\n key: string;\n type: 'success' | 'error';\n message: string;\n }) => {\n if (feedbackTimerRef.current) {\n clearTimeout(feedbackTimerRef.current);\n }\n\n setSaveFeedback(feedback);\n feedbackTimerRef.current = setTimeout(() => {\n setSaveFeedback((current) => (current?.key === feedback.key ? null : current));\n feedbackTimerRef.current = null;\n }, 2500);\n };\n\n const filteredTopics = useMemo(() => {\n if (!search.trim()) {\n return topics;\n }\n\n const query = search.toLowerCase();\n return topics.filter(\n (topic) =>\n topic.name.toLowerCase().includes(query) ||\n topic.slug.toLowerCase().includes(query) ||\n topic.description?.toLowerCase().includes(query)\n );\n }, [search, topics]);\n\n const togglePreference = async (input: {\n scope: NotificationPreferenceScope;\n channel?: NotificationChannel;\n type?: NotificationType;\n topicId?: string;\n }) => {\n const key = preferenceKey(input);\n const existing = preferencesByKey.get(key);\n const nextEnabled = !(existing?.enabled ?? true);\n setSavingKey(key);\n nativeImpact('medium');\n try {\n await setPreference({\n ...input,\n enabled: nextEnabled,\n frequency: existing?.frequency || 'IMMEDIATE',\n });\n trackPreferenceUpdated({\n action: 'set',\n scope: input.scope,\n channel: input.channel,\n type: input.type,\n enabled: nextEnabled,\n });\n showSaveFeedback({\n key,\n type: 'success',\n message: tr('notifications.preferenceSaved', 'Preference saved.'),\n });\n void nativeNotify('success');\n } catch {\n showSaveFeedback({\n key,\n type: 'error',\n message: tr('notifications.preferenceSaveFailed', 'Could not save preference.'),\n });\n void nativeNotify('error');\n } finally {\n setSavingKey(null);\n }\n };\n\n const resetPreference = async (key: string) => {\n const existing = preferencesByKey.get(key);\n if (!existing) return;\n setSavingKey(key);\n try {\n await deletePreference(existing.id);\n trackPreferenceUpdated({\n action: 'reset',\n scope: existing.scope,\n channel: existing.channel,\n type: existing.type,\n });\n showSaveFeedback({\n key,\n type: 'success',\n message: tr('notifications.preferenceReset', 'Preference reset.'),\n });\n } catch {\n showSaveFeedback({\n key,\n type: 'error',\n message: tr('notifications.preferenceResetFailed', 'Could not reset preference.'),\n });\n } finally {\n setSavingKey(null);\n }\n };\n\n const renderPreferenceRow = (input: {\n key: string;\n title: string;\n description: string;\n scope: NotificationPreferenceScope;\n channel?: NotificationChannel;\n type?: NotificationType;\n topicId?: string;\n }) => {\n const existing = preferencesByKey.get(input.key);\n const isEnabled = existing?.enabled ?? true;\n const isSaving = savingKey === input.key;\n const feedback = saveFeedback?.key === input.key ? saveFeedback : null;\n\n return (\n <div\n key={input.key}\n className=\"rounded-lg border border-border-seam bg-gloss-card p-4 transition-[box-shadow,border-color] duration-200 hover:shadow-[var(--shadow-pop)]\"\n >\n <div className=\"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between\">\n <div className=\"space-y-1\">\n <div className=\"flex items-center gap-2\">\n <BellRing size={16} className=\"text-accent-primary\" />\n <h2 className=\"text-sm font-semibold text-primary\">{input.title}</h2>\n {existing && (\n <span className=\"rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary\">\n {existing.frequency.replace('_', ' ').toLowerCase()}\n </span>\n )}\n </div>\n <p className=\"text-sm text-secondary\">{input.description}</p>\n </div>\n\n <div className=\"flex items-center gap-2\">\n {existing && (\n <button\n type=\"button\"\n disabled={isSaving}\n onClick={() => resetPreference(input.key)}\n className=\"rounded-md border border-default px-3 py-2 text-sm text-secondary hover:bg-bg-sunken disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {tr('notifications.reset', 'Reset')}\n </button>\n )}\n <button\n type=\"button\"\n aria-pressed={isEnabled}\n disabled={isSaving}\n onClick={() =>\n togglePreference({\n scope: input.scope,\n channel: input.channel,\n type: input.type,\n topicId: input.topicId,\n })\n }\n className={`inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium transition-colors ${\n isEnabled\n ? 'border-accent-primary bg-action-primary-bg text-text-inverse hover:opacity-90'\n : 'border-default bg-bg-sunken text-secondary hover:bg-bg-sunken/80'\n } disabled:cursor-not-allowed disabled:opacity-50`}\n >\n {isEnabled ? <ToggleRight size={18} /> : <ToggleLeft size={18} />}\n {isSaving\n ? tr('notifications.saving', 'Saving...')\n : isEnabled\n ? tr('notifications.enabled', 'Enabled')\n : tr('notifications.disabled', 'Disabled')}\n </button>\n </div>\n </div>\n <div className=\"mt-3 min-h-5\" aria-live=\"polite\">\n {feedback && (\n <p className={`text-xs ${feedback.type === 'success' ? 'text-success' : 'text-error'}`}>\n {feedback.message}\n </p>\n )}\n </div>\n </div>\n );\n };\n\n if (permissionsLoading) {\n return (\n <div className=\"flex h-64 items-center justify-center\">\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n </div>\n );\n }\n\n if (!hasPermission(NOTIFICATION_PERMISSIONS.NOTIFICATION_LIST) && !currentUser?.id) {\n return (\n <div className=\"p-8 text-center text-text-secondary\">\n {tr(\n 'notifications.noPermissionPreferences',\n \"You don't have permission to manage notification preferences.\"\n )}\n </div>\n );\n }\n\n return (\n <div data-tour=\"notification-preferences-page\" className=\"space-y-6 p-4 sm:p-6\">\n <div>\n <h1 className=\"text-2xl font-bold text-primary\">\n {tr('notifications.preferencesTitle', 'Notification Preferences')}\n </h1>\n <p className=\"mt-1 text-sm text-secondary\">\n {tr(\n 'notifications.preferencesSubtitle',\n 'Control global, channel, type, and topic-level notification delivery.'\n )}\n </p>\n </div>\n\n <PagePurpose icon={<BellRing size={16} />}>\n {tr(\n 'notifications.preferencesPurpose',\n 'Decide how and when we reach you. The Global switch is your master on/off, then you can fine-tune individual channels (email, push, SMS…), notification types and the marketing topics you have subscribed to. Settings cascade — turning a channel off silences it everywhere.'\n )}\n </PagePurpose>\n\n <EmphasisPanel data-tour=\"notification-preferences-global\" className=\"space-y-3 p-5 sm:p-6\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-tertiary\">\n {tr('notifications.globalPreferences', 'Global')}\n </h2>\n {renderPreferenceRow({\n key: 'GLOBAL',\n scope: 'GLOBAL',\n title: tr('notifications.allNotifications', 'All notifications'),\n description: tr(\n 'notifications.allNotificationsDescription',\n 'Master preference for notification delivery across all channels and types.'\n ),\n })}\n </EmphasisPanel>\n\n {/* Advanced: per-channel filter rules / quiet hours / custom templates — collapse the long-tail knobs */}\n <OptionalFields\n title={tr('notifications.advancedPreferences', 'Advanced settings')}\n description={tr(\n 'notifications.advancedPreferencesDescription',\n 'Per-channel filter rules, notification-type filters, and quiet-hour overrides.'\n )}\n >\n <section data-tour=\"notification-preferences-channels\" className=\"space-y-3\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-tertiary\">\n {tr('notifications.channelPreferences', 'Channels')}\n </h2>\n <div className=\"grid gap-3 lg:grid-cols-2\">\n {CHANNEL_OPTIONS.map((channel) =>\n renderPreferenceRow({\n key: `CHANNEL:${channel.value}`,\n scope: 'CHANNEL',\n channel: channel.value,\n title: tr(channel.labelKey, channel.label),\n description: tr(\n 'notifications.channelPreferenceDescription',\n 'Control delivery for this channel.'\n ),\n })\n )}\n </div>\n </section>\n\n <section data-tour=\"notification-preferences-types\" className=\"mt-6 space-y-3\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-tertiary\">\n {tr('notifications.typePreferences', 'Notification Types')}\n </h2>\n <div className=\"grid gap-3 lg:grid-cols-2\">\n {TYPE_OPTIONS.map((type) =>\n renderPreferenceRow({\n key: `TYPE:${type.value}`,\n scope: 'TYPE',\n type: type.value,\n title: tr(type.labelKey, type.label),\n description: tr(\n 'notifications.typePreferenceDescription',\n 'Control delivery for this notification type.'\n ),\n })\n )}\n </div>\n </section>\n </OptionalFields>\n\n <div className=\"relative max-w-xl\">\n <Search size={16} className=\"absolute left-3 top-1/2 -translate-y-1/2 text-tertiary\" />\n <input\n type=\"text\"\n value={search}\n onChange={(event) => setSearch(event.target.value)}\n aria-label={tr('notifications.searchTopics', 'Search topics...')}\n placeholder={tr('notifications.searchTopics', 'Search topics...')}\n className=\"w-full rounded-lg border border-default bg-surface py-2 pl-9 pr-4 text-sm text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </div>\n\n <section data-tour=\"notification-preferences-topics\" className=\"space-y-3\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-tertiary\">\n {tr('notifications.topicPreferences', 'Topics')}\n </h2>\n {isLoading ? (\n <div className=\"rounded-lg border border-default bg-surface p-6 text-sm text-secondary\">\n {tr('notifications.loadingPreferences', 'Loading preferences...')}\n </div>\n ) : topicsForbidden ? (\n <IllustratedEmptyState\n illustration=\"empty-generic\"\n title={tr(\n 'notifications.topicsNoAccessTitle',\n \"You don't have access to notification topics\"\n )}\n description={tr(\n 'notifications.topicsNoAccessDescription',\n \"Your role doesn't include permission to read notification topics. Ask a workspace admin if you need access.\"\n )}\n />\n ) : filteredTopics.length === 0 ? (\n <IllustratedEmptyState\n illustration={search.trim() ? 'empty-search' : 'empty-data'}\n title={\n search.trim()\n ? tr('notifications.noTopicsFound', 'No topics match your search')\n : tr('notifications.noTopicsAvailableTitle', 'No subscribable topics yet')\n }\n description={\n search.trim()\n ? tr('notifications.adjustSearchOrDateRange', 'Try adjusting your filters')\n : tr(\n 'notifications.noTopicsAvailableDescription',\n 'When marketing topics are published you can subscribe or unsubscribe from each one here.'\n )\n }\n />\n ) : (\n filteredTopics.map((topic) =>\n renderPreferenceRow({\n key: `TOPIC:${topic.id}`,\n scope: 'TOPIC',\n topicId: topic.id,\n title: topic.name,\n description: topic.description || topic.slug,\n })\n )\n )}\n </section>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAiBA,IAAMA,IAA0F;CAC9F;EAAE,OAAO;EAAU,UAAU;EAA8B,OAAO;CAAS;CAC3E;EAAE,OAAO;EAAS,UAAU;EAA8B,OAAO;CAAQ;CACzE;EAAE,OAAO;EAAQ,UAAU;EAA6B,OAAO;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AM,OAAO,KAAK;KACjD,cAAYxD,EAAG,8BAA8B,kBAAkB;KAC/D,aAAaA,EAAG,8BAA8B,kBAAkB;KAChE,WAAU;IACX,CAAA,CACE;;GAEL,kBAAC,WAAD;IAAS,aAAU;IAAkC,WAAU;IAA/D,UAAA,CACE,kBAAC,MAAD;KAAI,WAAU;KACX,UAAAA,EAAG,kCAAkC,QAAQ;IAC5C,CAAA,GACHoB,IACC,kBAAC,OAAD;KAAK,WAAU;KACZ,UAAApB,EAAG,oCAAoC,wBAAwB;IAC7D,CAAA,IACHM,IACF,kBAACmD,GAAD;KACE,cAAa;KACb,OAAOzD,EACL,qCACA,8CACF;KACA,aAAaA,EACX,2CACA,6GACF;IACD,CAAA,IACCwB,EAAe,WAAW,IAC5B,kBAACiC,GAAD;KACE,cAAc9C,EAAO,KAAK,IAAI,iBAAiB;KAC/C,OACEA,EAAO,KAAK,IACRX,EAAG,+BAA+B,6BAA6B,IAC/DA,EAAG,wCAAwC,4BAA4B;KAE7E,aACEW,EAAO,KAAK,IACRX,EAAG,yCAAyC,4BAA4B,IACxEA,EACE,8CACA,0FACF;IAEP,CAAA,IAEDwB,EAAe,KAAK,MAClBgB,EAAoB;KAClB,KAAK,SAASZ,EAAM;KACpB,OAAO;KACP,SAASA,EAAM;KACf,OAAOA,EAAM;KACb,aAAaA,EAAM,eAAeA,EAAM;IAC1C,CAAC,CACH,CAEK;;EACN;;AAET"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Notification Templates Page (Admin)
3
+ *
4
+ * Lists all notification templates from the real backend.
5
+ * Supports search, type filtering, delete, and navigation to editor.
6
+ */
7
+ export declare function NotificationTemplatesPage(): import('react').JSX.Element;
@@ -1,21 +1,21 @@
1
- import { useTr as e } from "../shared/hooks/useTr.js";
2
- import { nativeConfirm as t, nativeImpact as n, nativeNotify as r } from "../utils/nativeBridge.js";
3
- import { NOTIFICATION_PERMISSIONS as i } from "../constants/permissions.js";
4
- import { useNotificationTemplates as a } from "../hooks/useNotificationTemplates.js";
1
+ import { useNotificationTemplates as e } from "../hooks/useNotificationTemplates.js";
2
+ import { NOTIFICATION_PERMISSIONS as t } from "../constants/permissions.js";
3
+ import { useTr as n } from "../shared/hooks/useTr.js";
4
+ import { nativeConfirm as r, nativeImpact as i, nativeNotify as a } from "../utils/nativeBridge.js";
5
5
  import { useMemo as o, useState as s } from "react";
6
6
  import { usePermissions as c } from "@burdenoff/fe-libs/shared/providers/shell";
7
7
  import { AlertCircle as l, FileText as u, Loader2 as d, Plus as f, RefreshCw as p, Search as m, Trash2 as h } from "lucide-react";
8
8
  import { useNavigate as g } from "react-router";
9
9
  import { jsx as _, jsxs as v } from "react/jsx-runtime";
10
10
  import { Button as y, EmphasisPanel as b, GlassCard as x, IllustratedEmptyState as S, NextSteps as C, PagePurpose as w } from "@burdenoff/fe-libs/ui";
11
- import { useI18n as T } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
12
- //#region src/pages/NotificationTemplatesPage.tsx
13
- var ee = {
11
+ import { useI18n as ee } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
12
+ // src/pages/NotificationTemplatesPage.tsx
13
+ var te = {
14
14
  TRANSACTIONAL: "text-status-info-text bg-status-info-bg-subtle border-status-info-bg-subtle",
15
15
  MARKETING: "text-accent-purple bg-accent-purple-subtle border-accent-purple-subtle",
16
16
  SYSTEM: "text-status-warning-text bg-status-warning-bg-subtle border-status-warning-bg-subtle",
17
17
  ALERT: "text-status-error-text bg-status-error-bg-subtle border-status-error-bg-subtle"
18
- }, te = {
18
+ }, T = {
19
19
  TRANSACTIONAL: "Transactional",
20
20
  MARKETING: "Marketing",
21
21
  SYSTEM: "System",
@@ -29,32 +29,35 @@ function E(e, t) {
29
29
  });
30
30
  }
31
31
  function D() {
32
- let D = g(), O = e(), { locale: k } = T(), { hasPermission: A, isLoading: j } = c(), { templates: M, isLoading: N, isDeleting: P, error: F, total: I, hasMore: L, filter: R, refetch: z, loadMore: B, deleteTemplate: V, updateFilter: H } = a(), [U, W] = s(null), [G, K] = s(null), [q, J] = s(/* @__PURE__ */ new Set()), Y = o(() => M.filter((e) => q.has(e.id)), [q, M]), X = M.length > 0 && M.every((e) => q.has(e.id)), Z = M.some((e) => q.has(e.id)) && !X, Q = A(i.TEMPLATE_CREATE), $ = A(i.TEMPLATE_DELETE), ne = async (e, i) => {
33
- e.stopPropagation(), n("medium");
34
- let a = O("notifTemplates.confirmDelete", `Delete template "${i.name}"? This cannot be undone.`), o = await t({
32
+ let D = g(), O = n(), { locale: k } = ee(), { hasPermission: A, isLoading: j } = c(), { templates: M, isLoading: N, isDeleting: P, error: F, total: I, hasMore: L, filter: R, refetch: z, loadMore: B, deleteTemplate: V, updateFilter: H } = e(), [U, W] = s(null), [G, K] = s(null), [q, J] = s(/* @__PURE__ */ new Set()), Y = o(() => M.filter((e) => q.has(e.id)), [q, M]), X = M.length > 0 && M.every((e) => q.has(e.id)), Z = M.some((e) => q.has(e.id)) && !X, Q = A(t.TEMPLATE_CREATE), $ = A(t.TEMPLATE_DELETE), ne = async (e, t) => {
33
+ e.stopPropagation(), i("medium");
34
+ let n = O("notifTemplates.confirmDelete", `Delete template "${t.name}"? This cannot be undone.`), o = await r({
35
35
  title: O("notifTemplates.deleteTitle", "Delete template"),
36
- message: a,
36
+ message: n,
37
37
  okButtonTitle: O("notifTemplates.delete", "Delete")
38
38
  });
39
- if (o === null ? confirm(a) : o) {
40
- W(i.id), K(null);
39
+ if (o === null ? confirm(n) : o) {
40
+ W(t.id), K(null);
41
41
  try {
42
- await V(i.id), r("success");
42
+ await V(t.id), a("success");
43
43
  } catch (e) {
44
- r("error"), K(e instanceof Error ? e.message : O("notifTemplates.deleteFailed", "Failed to delete template"));
44
+ a("error"), K(e instanceof Error ? e.message : O("notifTemplates.deleteFailed", "Failed to delete template"));
45
45
  } finally {
46
46
  W(null);
47
47
  }
48
48
  }
49
49
  }, re = async () => {
50
50
  if (Y.length === 0) return;
51
- n("medium");
52
- let e = O("notifTemplates.confirmBulkDelete", `Delete ${Y.length} selected template${Y.length === 1 ? "" : "s"}? This cannot be undone.`), i = await t({
51
+ i("medium");
52
+ let e = O("notifTemplates.confirmBulkDelete", `Delete ${Y.length} selected template${Y.length === 1 ? "" : "s"}? This cannot be undone.`), t = await r({
53
53
  title: O("notifTemplates.bulkDeleteTitle", "Delete templates"),
54
54
  message: e,
55
55
  okButtonTitle: O("notifTemplates.delete", "Delete")
56
56
  });
57
- (i === null ? window.confirm(e) : i) && (K(null), r((await Promise.allSettled(Y.map((e) => V(e.id)))).some((e) => e.status === "rejected") ? "error" : "success"), J(/* @__PURE__ */ new Set()));
57
+ if (!(t === null ? window.confirm(e) : t)) return;
58
+ K(null);
59
+ let n = (await Promise.allSettled(Y.map((e) => V(e.id)))).some((e) => e.status === "rejected");
60
+ a(n ? "error" : "success"), J(/* @__PURE__ */ new Set());
58
61
  }, ie = (e, t) => {
59
62
  J((n) => {
60
63
  let r = new Set(n);
@@ -71,7 +74,7 @@ function D() {
71
74
  return j ? /* @__PURE__ */ _("div", {
72
75
  className: "flex h-64 items-center justify-center",
73
76
  children: /* @__PURE__ */ _("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" })
74
- }) : A(i.TEMPLATE_LIST) || Q || $ || A(i.TEMPLATE_UPDATE) ? N && M.length === 0 ? /* @__PURE__ */ v("div", {
77
+ }) : A(t.TEMPLATE_LIST) || Q || $ || A(t.TEMPLATE_UPDATE) ? N && M.length === 0 ? /* @__PURE__ */ v("div", {
75
78
  className: "flex flex-col items-center justify-center h-64 gap-3",
76
79
  children: [/* @__PURE__ */ _(d, {
77
80
  size: 28,
@@ -280,8 +283,8 @@ function D() {
280
283
  }), /* @__PURE__ */ v("div", {
281
284
  className: "flex items-center gap-2",
282
285
  children: [/* @__PURE__ */ _("span", {
283
- className: `px-2 py-0.5 text-[10px] font-semibold rounded-full border ${ee[e.type] || "text-tertiary bg-bg-sunken border-default"}`,
284
- children: O(`notifTemplates.type.${e.type}`, te[e.type] || e.type)
286
+ className: `px-2 py-0.5 text-[10px] font-semibold rounded-full border ${te[e.type] || "text-tertiary bg-bg-sunken border-default"}`,
287
+ children: O(`notifTemplates.type.${e.type}`, T[e.type] || e.type)
285
288
  }), $ && /* @__PURE__ */ _("button", {
286
289
  onClick: (t) => ne(t, e),
287
290
  disabled: P && U === e.id,
@@ -347,7 +350,6 @@ function D() {
347
350
  children: O("notifTemplates.noPermissionView", "You don't have permission to view notification templates.")
348
351
  });
349
352
  }
350
- //#endregion
351
353
  export { D as NotificationTemplatesPage };
352
354
 
353
355
  //# sourceMappingURL=NotificationTemplatesPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationTemplatesPage.js","names":[],"sources":["../../src/pages/NotificationTemplatesPage.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { FileText, Plus, Search, Trash2, Loader2, AlertCircle, RefreshCw } from 'lucide-react';\nimport { useNavigate } from 'react-router';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n Button,\n EmphasisPanel,\n GlassCard,\n IllustratedEmptyState,\n NextSteps,\n PagePurpose,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotificationTemplates } from '../hooks/useNotificationTemplates';\nimport type { BackendNotificationTemplate } from '../hooks/useNotificationTemplates';\nimport type { NotificationType } from '../types';\nimport { NOTIFICATION_PERMISSIONS } from '../constants/permissions';\nimport { useTr } from '../shared/hooks/useTr';\nimport { nativeConfirm, nativeImpact, nativeNotify } from '../utils/nativeBridge';\n\n// ── Helpers ────────────────────────────────────────────────────────────\n\nconst TYPE_COLORS: Record<NotificationType, string> = {\n TRANSACTIONAL: 'text-status-info-text bg-status-info-bg-subtle border-status-info-bg-subtle',\n MARKETING: 'text-accent-purple bg-accent-purple-subtle border-accent-purple-subtle',\n SYSTEM: 'text-status-warning-text bg-status-warning-bg-subtle border-status-warning-bg-subtle',\n ALERT: 'text-status-error-text bg-status-error-bg-subtle border-status-error-bg-subtle',\n};\n\nconst TYPE_LABELS: Record<NotificationType, string> = {\n TRANSACTIONAL: 'Transactional',\n MARKETING: 'Marketing',\n SYSTEM: 'System',\n ALERT: 'Alert',\n};\n\nfunction formatDate(iso: string, locale?: string) {\n return new Date(iso).toLocaleDateString(locale || 'en-US', {\n month: 'short',\n day: 'numeric',\n year: 'numeric',\n });\n}\n\n// ── Component ──────────────────────────────────────────────────────────\n\n/**\n * Notification Templates Page (Admin)\n *\n * Lists all notification templates from the real backend.\n * Supports search, type filtering, delete, and navigation to editor.\n */\nexport function NotificationTemplatesPage() {\n const navigate = useNavigate();\n const tr = useTr();\n const { locale } = useI18n();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const {\n templates,\n isLoading,\n isDeleting,\n error,\n total,\n hasMore,\n filter,\n refetch,\n loadMore,\n deleteTemplate,\n updateFilter,\n } = useNotificationTemplates();\n\n const [deletingId, setDeletingId] = useState<string | null>(null);\n const [deleteError, setDeleteError] = useState<string | null>(null);\n const [selectedTemplateIds, setSelectedTemplateIds] = useState<Set<string>>(new Set());\n\n const selectedTemplates = useMemo(\n () => templates.filter((template) => selectedTemplateIds.has(template.id)),\n [selectedTemplateIds, templates]\n );\n\n const allVisibleSelected =\n templates.length > 0 && templates.every((template) => selectedTemplateIds.has(template.id));\n const partiallySelected =\n templates.some((template) => selectedTemplateIds.has(template.id)) && !allVisibleSelected;\n\n const canCreateTemplate = hasPermission(NOTIFICATION_PERMISSIONS.TEMPLATE_CREATE);\n const canDeleteTemplate = hasPermission(NOTIFICATION_PERMISSIONS.TEMPLATE_DELETE);\n\n const handleDelete = async (e: React.MouseEvent, template: BackendNotificationTemplate) => {\n e.stopPropagation();\n nativeImpact('medium');\n const message = tr(\n 'notifTemplates.confirmDelete',\n `Delete template \"${template.name}\"? This cannot be undone.`\n );\n const nativeResult = await nativeConfirm({\n title: tr('notifTemplates.deleteTitle', 'Delete template'),\n message,\n okButtonTitle: tr('notifTemplates.delete', 'Delete'),\n });\n const confirmed = nativeResult === null ? confirm(message) : nativeResult;\n if (!confirmed) return;\n\n setDeletingId(template.id);\n setDeleteError(null);\n try {\n await deleteTemplate(template.id);\n void nativeNotify('success');\n } catch (err: unknown) {\n void nativeNotify('error');\n setDeleteError(\n err instanceof Error\n ? err.message\n : tr('notifTemplates.deleteFailed', 'Failed to delete template')\n );\n } finally {\n setDeletingId(null);\n }\n };\n\n const handleBulkDelete = async () => {\n if (selectedTemplates.length === 0) return;\n nativeImpact('medium');\n const message = tr(\n 'notifTemplates.confirmBulkDelete',\n `Delete ${selectedTemplates.length} selected template${selectedTemplates.length === 1 ? '' : 's'}? This cannot be undone.`\n );\n const nativeResult = await nativeConfirm({\n title: tr('notifTemplates.bulkDeleteTitle', 'Delete templates'),\n message,\n okButtonTitle: tr('notifTemplates.delete', 'Delete'),\n });\n const confirmed = nativeResult === null ? window.confirm(message) : nativeResult;\n if (!confirmed) return;\n\n setDeleteError(null);\n const results = await Promise.allSettled(\n selectedTemplates.map((template) => deleteTemplate(template.id))\n );\n const failed = results.some((r) => r.status === 'rejected');\n void nativeNotify(failed ? 'error' : 'success');\n setSelectedTemplateIds(new Set());\n };\n\n const toggleTemplateSelection = (templateId: string, checked: boolean) => {\n setSelectedTemplateIds((prev) => {\n const next = new Set(prev);\n if (checked) {\n next.add(templateId);\n } else {\n next.delete(templateId);\n }\n return next;\n });\n };\n\n const toggleAllTemplates = (checked: boolean) => {\n setSelectedTemplateIds((prev) => {\n const next = new Set(prev);\n templates.forEach((template) => {\n if (checked) {\n next.add(template.id);\n } else {\n next.delete(template.id);\n }\n });\n return next;\n });\n };\n\n // ── Permission guards ────────────────────────────────────────────────\n if (permissionsLoading) {\n return (\n <div className=\"flex h-64 items-center justify-center\">\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n </div>\n );\n }\n\n // TEMPLATE_LIST admits read-only admins; the page already hides/disables write actions for them.\n const canViewTemplates =\n hasPermission(NOTIFICATION_PERMISSIONS.TEMPLATE_LIST) ||\n canCreateTemplate ||\n canDeleteTemplate ||\n hasPermission(NOTIFICATION_PERMISSIONS.TEMPLATE_UPDATE);\n\n if (!canViewTemplates) {\n return (\n <div className=\"p-8 text-center text-text-secondary\">\n {tr(\n 'notifTemplates.noPermissionView',\n \"You don't have permission to view notification templates.\"\n )}\n </div>\n );\n }\n\n // ── Loading state ────────────────────────────────────────────────────\n if (isLoading && templates.length === 0) {\n return (\n <div className=\"flex flex-col items-center justify-center h-64 gap-3\">\n <Loader2 size={28} className=\"animate-spin text-accent-primary\" />\n <p className=\"text-sm text-secondary\">\n {tr('notifTemplates.loading', 'Loading templates...')}\n </p>\n </div>\n );\n }\n\n // ── Error state ──────────────────────────────────────────────────────\n if (error && templates.length === 0) {\n return (\n <div className=\"flex flex-col items-center justify-center h-64 gap-4\">\n <AlertCircle size={28} className=\"text-error\" />\n <p className=\"text-sm text-error\">{error}</p>\n <button\n onClick={refetch}\n className=\"flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-accent-primary hover:bg-accent-primary/90 rounded-lg transition-all duration-150\"\n >\n <RefreshCw size={14} />\n {tr('notifTemplates.retry', 'Retry')}\n </button>\n </div>\n );\n }\n\n return (\n <div className=\"space-y-4 sm:space-y-6 p-3 sm:p-6 animate-in fade-in duration-200\">\n <PagePurpose icon={<FileText size={16} />}>\n {tr(\n 'notifTemplates.purpose',\n 'Reusable, versioned message blueprints — subject lines, bodies and channel layouts with {{variables}} you fill in at send time. Build a template once (e.g. a welcome email or a payment receipt) and reuse it from the Send page so every notification stays on-brand and consistent.'\n )}\n </PagePurpose>\n\n {/* Header — single emphasis zone (count summary + the one create CTA). */}\n <EmphasisPanel className=\"flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:justify-between sm:p-6\">\n <div>\n <h1 className=\"text-xl sm:text-2xl font-bold text-primary\">\n {tr('notifTemplates.title', 'Notification Templates')}\n </h1>\n <p className=\"text-sm text-secondary mt-1\">\n {total} {tr('notifTemplates.templateCount', 'template')}\n {total !== 1 ? 's' : ''} {tr('notifTemplates.total', 'total')}\n </p>\n </div>\n\n {canCreateTemplate && (\n <Button onClick={() => navigate('new')} className=\"gap-2\">\n <Plus size={16} />\n {tr('notifTemplates.createTemplate', 'Create Template')}\n </Button>\n )}\n </EmphasisPanel>\n\n <NextSteps\n storageKey=\"notification-templates\"\n steps={[\n ...(canCreateTemplate\n ? [\n {\n id: 'create-template',\n label: tr('notifTemplates.nextCreateLabel', 'Create your first template'),\n description: tr(\n 'notifTemplates.nextCreateDesc',\n 'Build a reusable message blueprint with {{variables}} you fill in at send time.'\n ),\n onClick: () => navigate('new'),\n },\n ]\n : []),\n {\n id: 'filter-type',\n label: tr('notifTemplates.nextFilterLabel', 'Filter by type'),\n description: tr(\n 'notifTemplates.nextFilterDesc',\n 'Narrow to Transactional, Marketing, System or Alert templates to find one fast.'\n ),\n onClick: () => updateFilter({ type: 'TRANSACTIONAL' }),\n },\n {\n id: 'use-on-send',\n label: tr('notifTemplates.nextUseLabel', 'Send with a template'),\n description: tr(\n 'notifTemplates.nextUseDesc',\n 'Pick any saved template from the Send page so every notification stays on-brand.'\n ),\n href: '../send',\n },\n ]}\n />\n\n {/* Search + Type filter row */}\n <div className=\"flex flex-col gap-3 sm:flex-row sm:items-center\">\n {/* Search */}\n <div className=\"relative flex-1\">\n <Search size={16} className=\"absolute left-3 top-1/2 -translate-y-1/2 text-tertiary\" />\n <input\n type=\"text\"\n value={filter.search || ''}\n onChange={(e) => updateFilter({ search: e.target.value })}\n placeholder={tr('notifTemplates.searchPlaceholder', 'Search templates...')}\n className=\"w-full pl-9 pr-4 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150\"\n />\n </div>\n\n {/* Type filter */}\n <select\n value={filter.type || ''}\n onChange={(e) =>\n updateFilter({ type: (e.target.value || undefined) as NotificationType | undefined })\n }\n className=\"px-3 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150 scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"\">{tr('notifTemplates.allTypes', 'All Types')}</option>\n <option value=\"TRANSACTIONAL\">\n {tr('notifTemplates.typeTransactional', 'Transactional')}\n </option>\n <option value=\"MARKETING\">{tr('notifTemplates.typeMarketing', 'Marketing')}</option>\n <option value=\"SYSTEM\">{tr('notifTemplates.typeSystem', 'System')}</option>\n <option value=\"ALERT\">{tr('notifTemplates.typeAlert', 'Alert')}</option>\n </select>\n </div>\n\n {templates.length > 0 && (\n <GlassCard\n treatment=\"plain\"\n className=\"flex flex-col gap-3 border-border-seam p-4 sm:flex-row sm:items-center sm:justify-between\"\n >\n <label className=\"flex items-center gap-2 text-sm text-primary\">\n <input\n type=\"checkbox\"\n checked={allVisibleSelected}\n ref={(input) => {\n if (input) {\n input.indeterminate = partiallySelected && !allVisibleSelected;\n }\n }}\n onChange={(event) => toggleAllTemplates(event.target.checked)}\n aria-label={tr(\n 'notifTemplates.selectAllVisibleAria',\n 'Select all notification templates'\n )}\n className=\"h-4 w-4 rounded border-default text-accent-primary\"\n />\n <span>{tr('notifTemplates.selectAllVisible', 'Select all visible')}</span>\n </label>\n\n <div className=\"flex items-center gap-2\">\n <span className=\"text-sm text-secondary\">\n {selectedTemplateIds.size} {tr('notifTemplates.selected', 'selected')}\n </span>\n {selectedTemplateIds.size > 0 && (\n <button\n onClick={() => setSelectedTemplateIds(new Set())}\n className=\"text-sm text-secondary hover:text-primary\"\n >\n {tr('notifTemplates.clearSelection', 'Clear selection')}\n </button>\n )}\n {canDeleteTemplate && (\n <button\n onClick={handleBulkDelete}\n disabled={selectedTemplates.length === 0 || isDeleting}\n className=\"flex items-center gap-2 px-3 py-2 text-sm font-medium text-error border border-error/30 hover:bg-error/10 rounded-lg transition-all duration-150 disabled:opacity-50\"\n >\n <Trash2 size={14} />\n {tr('notifTemplates.deleteSelected', 'Delete Selected')}\n {selectedTemplates.length > 0 ? ` (${selectedTemplates.length})` : ''}\n </button>\n )}\n </div>\n </GlassCard>\n )}\n\n {/* Delete error banner */}\n {deleteError && (\n <div className=\"flex items-center gap-3 p-3 bg-error/10 border border-error/30 rounded-lg\">\n <AlertCircle size={16} className=\"text-error shrink-0\" />\n <p className=\"text-sm text-error\">{deleteError}</p>\n </div>\n )}\n\n {/* Empty state */}\n {templates.length === 0 && !isLoading && (\n <IllustratedEmptyState\n illustration={filter.search || filter.type ? 'empty-search' : 'empty-files'}\n title={\n filter.search || filter.type\n ? tr('notifTemplates.noMatchingTemplates', 'No templates match your filters')\n : tr('notifTemplates.noTemplatesYet', 'No templates yet. Create your first one!')\n }\n description={\n filter.search || filter.type\n ? tr('notifications.adjustSearchOrDateRange', 'Try adjusting your filters')\n : tr(\n 'notifTemplates.noTemplatesDescription',\n 'Reusable templates let you send consistent notifications fast.'\n )\n }\n action={\n !filter.search && !filter.type && canCreateTemplate ? (\n <Button onClick={() => navigate('new')} className=\"gap-2\">\n <Plus size={16} />\n {tr('notifTemplates.createTemplate', 'Create Template')}\n </Button>\n ) : undefined\n }\n />\n )}\n\n {/* Templates grid */}\n <div className=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {templates.map((template) => (\n <div\n key={template.id}\n onClick={() => navigate(template.slug)}\n className={`group relative p-4 bg-gloss-card border rounded-lg cursor-pointer transition-[box-shadow,border-color] duration-200 hover:shadow-[var(--shadow-pop)] hover:border-accent-primary/30 ${selectedTemplateIds.has(template.id) ? 'border-accent-primary/50 ring-1 ring-accent-primary/20' : 'border-border-seam'}`}\n >\n {/* Top row: icon + type badge + delete */}\n <div className=\"flex items-start justify-between mb-3\">\n <div className=\"flex items-center gap-2\">\n <input\n type=\"checkbox\"\n checked={selectedTemplateIds.has(template.id)}\n onChange={(event) => {\n event.stopPropagation();\n toggleTemplateSelection(template.id, event.target.checked);\n }}\n onClick={(event) => event.stopPropagation()}\n aria-label={tr(\n 'notifTemplates.selectTemplateAria',\n 'Select template {{name}}'\n ).replace('{{name}}', template.name)}\n className=\"h-4 w-4 rounded border-default text-accent-primary\"\n />\n <FileText size={20} className=\"text-accent-primary\" />\n </div>\n <div className=\"flex items-center gap-2\">\n <span\n className={`px-2 py-0.5 text-[10px] font-semibold rounded-full border ${\n TYPE_COLORS[template.type as NotificationType] ||\n 'text-tertiary bg-bg-sunken border-default'\n }`}\n >\n {tr(\n `notifTemplates.type.${template.type as NotificationType}`,\n TYPE_LABELS[template.type as NotificationType] || template.type\n )}\n </span>\n {canDeleteTemplate && (\n <button\n onClick={(e) => handleDelete(e, template)}\n disabled={isDeleting && deletingId === template.id}\n className=\"opacity-0 group-hover:opacity-100 p-1 text-tertiary hover:text-error rounded transition-all duration-150\"\n title={tr('notifTemplates.deleteTemplate', 'Delete template')}\n >\n {isDeleting && deletingId === template.id ? (\n <Loader2 size={14} className=\"animate-spin\" />\n ) : (\n <Trash2 size={14} />\n )}\n </button>\n )}\n </div>\n </div>\n\n {/* Name */}\n <h3 className=\"text-sm font-semibold text-primary mb-1 truncate\">{template.name}</h3>\n\n {/* Description */}\n {template.description && (\n <p className=\"text-xs text-secondary mb-2 line-clamp-2\">{template.description}</p>\n )}\n\n {/* Bottom row: slug + enabled badge + locale */}\n <div className=\"flex items-center gap-2 text-[11px] text-tertiary mt-auto pt-2 border-t border-default/50\">\n <code className=\"px-1.5 py-0.5 bg-bg-sunken rounded text-[10px]\">\n {template.slug}\n </code>\n <span>•</span>\n <span>{template.locale || 'en'}</span>\n <span>•</span>\n <span className={template.enabled ? 'text-success' : 'text-tertiary'}>\n {template.enabled\n ? tr('notifTemplates.enabled', 'Enabled')\n : tr('notifTemplates.disabled', 'Disabled')}\n </span>\n </div>\n\n {/* Updated date */}\n <p className=\"text-[10px] text-tertiary mt-1.5\">\n {tr('notifTemplates.updated', 'Updated')} {formatDate(template.updatedAt, locale)}\n </p>\n </div>\n ))}\n </div>\n\n {/* Load more */}\n {hasMore && (\n <div className=\"flex justify-center pt-2\">\n <button\n onClick={loadMore}\n disabled={isLoading}\n className=\"flex items-center gap-2 px-4 py-2 text-sm text-secondary hover:text-primary border border-default rounded-lg transition-all duration-150 hover:shadow-sm\"\n >\n {isLoading ? <Loader2 size={14} className=\"animate-spin\" /> : null}\n {tr('notifTemplates.loadMore', 'Load More')}\n </button>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAsBA,IAAM,KAAgD;CACpD,eAAe;CACf,WAAW;CACX,QAAQ;CACR,OAAO;CACR,EAEK,KAAgD;CACpD,eAAe;CACf,WAAW;CACX,QAAQ;CACR,OAAO;CACR;AAED,SAAS,EAAW,GAAa,GAAiB;AAChD,QAAO,IAAI,KAAK,EAAI,CAAC,mBAAmB,KAAU,SAAS;EACzD,OAAO;EACP,KAAK;EACL,MAAM;EACP,CAAC;;AAWJ,SAAgB,IAA4B;CAC1C,IAAM,IAAW,GAAa,EACxB,IAAK,GAAO,EACZ,EAAE,cAAW,GAAS,EACtB,EAAE,kBAAe,WAAW,MAAuB,GAAgB,EACnE,EACJ,cACA,cACA,eACA,UACA,UACA,YACA,WACA,YACA,aACA,mBACA,oBACE,GAA0B,EAExB,CAAC,GAAY,KAAiB,EAAwB,KAAK,EAC3D,CAAC,GAAa,KAAkB,EAAwB,KAAK,EAC7D,CAAC,GAAqB,KAA0B,kBAAsB,IAAI,KAAK,CAAC,EAEhF,IAAoB,QAClB,EAAU,QAAQ,MAAa,EAAoB,IAAI,EAAS,GAAG,CAAC,EAC1E,CAAC,GAAqB,EAAU,CACjC,EAEK,IACJ,EAAU,SAAS,KAAK,EAAU,OAAO,MAAa,EAAoB,IAAI,EAAS,GAAG,CAAC,EACvF,IACJ,EAAU,MAAM,MAAa,EAAoB,IAAI,EAAS,GAAG,CAAC,IAAI,CAAC,GAEnE,IAAoB,EAAc,EAAyB,gBAAgB,EAC3E,IAAoB,EAAc,EAAyB,gBAAgB,EAE3E,KAAe,OAAO,GAAqB,MAA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ificationTemplatesPage","navigate","useNavigate","tr","useTr","permissionsLoading","usePermissions","useNotificationTemplates","deletingId","setDeletingId","useState","deleteError","setDeleteError","selectedTemplateIds","setSelectedTemplateIds","selectedTemplates","useMemo","templates","template","allVisibleSelected","partiallySelected","canCreateTemplate","hasPermission","NOTIFICATION_PERMISSIONS","canDeleteTemplate","handleDelete","nativeImpact","message","nativeResult","nativeConfirm","deleteTemplate","nativeNotify","err","handleBulkDelete","failed","r","toggleTemplateSelection","next","prev","checked","templateId","toggleAllTemplates","isLoading","Loader2","error","AlertCircle","refetch","RefreshCw","PagePurpose","FileText","EmphasisPanel","total","Button","Plus","NextSteps","updateFilter","Search","filter","GlassCard","input","event","isDeleting","Trash2","IllustratedEmptyState","e","hasMore","loadMore"],"sources":["../../src/pages/NotificationTemplatesPage.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { FileText, Plus, Search, Trash2, Loader2, AlertCircle, RefreshCw } from 'lucide-react';\nimport { useNavigate } from 'react-router';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n Button,\n EmphasisPanel,\n GlassCard,\n IllustratedEmptyState,\n NextSteps,\n PagePurpose,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotificationTemplates } from '../hooks/useNotificationTemplates';\nimport type { BackendNotificationTemplate } from '../hooks/useNotificationTemplates';\nimport type { NotificationType } from '../types';\nimport { NOTIFICATION_PERMISSIONS } from '../constants/permissions';\nimport { useTr } from '../shared/hooks/useTr';\nimport { nativeConfirm, nativeImpact, nativeNotify } from '../utils/nativeBridge';\n\n// ── Helpers ────────────────────────────────────────────────────────────\n\nconst TYPE_COLORS: Record<NotificationType, string> = {\n TRANSACTIONAL: 'text-status-info-text bg-status-info-bg-subtle border-status-info-bg-subtle',\n MARKETING: 'text-accent-purple bg-accent-purple-subtle border-accent-purple-subtle',\n SYSTEM: 'text-status-warning-text bg-status-warning-bg-subtle border-status-warning-bg-subtle',\n ALERT: 'text-status-error-text bg-status-error-bg-subtle border-status-error-bg-subtle',\n};\n\nconst TYPE_LABELS: Record<NotificationType, string> = {\n TRANSACTIONAL: 'Transactional',\n MARKETING: 'Marketing',\n SYSTEM: 'System',\n ALERT: 'Alert',\n};\n\nfunction formatDate(iso: string, locale?: string) {\n return new Date(iso).toLocaleDateString(locale || 'en-US', {\n month: 'short',\n day: 'numeric',\n year: 'numeric',\n });\n}\n\n// ── Component ──────────────────────────────────────────────────────────\n\n/**\n * Notification Templates Page (Admin)\n *\n * Lists all notification templates from the real backend.\n * Supports search, type filtering, delete, and navigation to editor.\n */\nexport function NotificationTemplatesPage() {\n const navigate = useNavigate();\n const tr = useTr();\n const { locale } = useI18n();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const {\n templates,\n isLoading,\n isDeleting,\n error,\n total,\n hasMore,\n filter,\n refetch,\n loadMore,\n deleteTemplate,\n updateFilter,\n } = useNotificationTemplates();\n\n const [deletingId, setDeletingId] = useState<string | null>(null);\n const [deleteError, setDeleteError] = useState<string | null>(null);\n const [selectedTemplateIds, setSelectedTemplateIds] = useState<Set<string>>(new Set());\n\n const selectedTemplates = useMemo(\n () => templates.filter((template) => selectedTemplateIds.has(template.id)),\n [selectedTemplateIds, templates]\n );\n\n const allVisibleSelected =\n templates.length > 0 && templates.every((template) => selectedTemplateIds.has(template.id));\n const partiallySelected =\n templates.some((template) => selectedTemplateIds.has(template.id)) && !allVisibleSelected;\n\n const canCreateTemplate = hasPermission(NOTIFICATION_PERMISSIONS.TEMPLATE_CREATE);\n const canDeleteTemplate = hasPermission(NOTIFICATION_PERMISSIONS.TEMPLATE_DELETE);\n\n const handleDelete = async (e: React.MouseEvent, template: BackendNotificationTemplate) => {\n e.stopPropagation();\n nativeImpact('medium');\n const message = tr(\n 'notifTemplates.confirmDelete',\n `Delete template \"${template.name}\"? This cannot be undone.`\n );\n const nativeResult = await nativeConfirm({\n title: tr('notifTemplates.deleteTitle', 'Delete template'),\n message,\n okButtonTitle: tr('notifTemplates.delete', 'Delete'),\n });\n const confirmed = nativeResult === null ? confirm(message) : nativeResult;\n if (!confirmed) return;\n\n setDeletingId(template.id);\n setDeleteError(null);\n try {\n await deleteTemplate(template.id);\n void nativeNotify('success');\n } catch (err: unknown) {\n void nativeNotify('error');\n setDeleteError(\n err instanceof Error\n ? err.message\n : tr('notifTemplates.deleteFailed', 'Failed to delete template')\n );\n } finally {\n setDeletingId(null);\n }\n };\n\n const handleBulkDelete = async () => {\n if (selectedTemplates.length === 0) return;\n nativeImpact('medium');\n const message = tr(\n 'notifTemplates.confirmBulkDelete',\n `Delete ${selectedTemplates.length} selected template${selectedTemplates.length === 1 ? '' : 's'}? This cannot be undone.`\n );\n const nativeResult = await nativeConfirm({\n title: tr('notifTemplates.bulkDeleteTitle', 'Delete templates'),\n message,\n okButtonTitle: tr('notifTemplates.delete', 'Delete'),\n });\n const confirmed = nativeResult === null ? window.confirm(message) : nativeResult;\n if (!confirmed) return;\n\n setDeleteError(null);\n const results = await Promise.allSettled(\n selectedTemplates.map((template) => deleteTemplate(template.id))\n );\n const failed = results.some((r) => r.status === 'rejected');\n void nativeNotify(failed ? 'error' : 'success');\n setSelectedTemplateIds(new Set());\n };\n\n const toggleTemplateSelection = (templateId: string, checked: boolean) => {\n setSelectedTemplateIds((prev) => {\n const next = new Set(prev);\n if (checked) {\n next.add(templateId);\n } else {\n next.delete(templateId);\n }\n return next;\n });\n };\n\n const toggleAllTemplates = (checked: boolean) => {\n setSelectedTemplateIds((prev) => {\n const next = new Set(prev);\n templates.forEach((template) => {\n if (checked) {\n next.add(template.id);\n } else {\n next.delete(template.id);\n }\n });\n return next;\n });\n };\n\n // ── Permission guards ────────────────────────────────────────────────\n if (permissionsLoading) {\n return (\n <div className=\"flex h-64 items-center justify-center\">\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n </div>\n );\n }\n\n // TEMPLATE_LIST admits read-only admins; the page already hides/disables write actions for them.\n const canViewTemplates =\n hasPermission(NOTIFICATION_PERMISSIONS.TEMPLATE_LIST) ||\n canCreateTemplate ||\n canDeleteTemplate ||\n hasPermission(NOTIFICATION_PERMISSIONS.TEMPLATE_UPDATE);\n\n if (!canViewTemplates) {\n return (\n <div className=\"p-8 text-center text-text-secondary\">\n {tr(\n 'notifTemplates.noPermissionView',\n \"You don't have permission to view notification templates.\"\n )}\n </div>\n );\n }\n\n // ── Loading state ────────────────────────────────────────────────────\n if (isLoading && templates.length === 0) {\n return (\n <div className=\"flex flex-col items-center justify-center h-64 gap-3\">\n <Loader2 size={28} className=\"animate-spin text-accent-primary\" />\n <p className=\"text-sm text-secondary\">\n {tr('notifTemplates.loading', 'Loading templates...')}\n </p>\n </div>\n );\n }\n\n // ── Error state ──────────────────────────────────────────────────────\n if (error && templates.length === 0) {\n return (\n <div className=\"flex flex-col items-center justify-center h-64 gap-4\">\n <AlertCircle size={28} className=\"text-error\" />\n <p className=\"text-sm text-error\">{error}</p>\n <button\n onClick={refetch}\n className=\"flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-accent-primary hover:bg-accent-primary/90 rounded-lg transition-all duration-150\"\n >\n <RefreshCw size={14} />\n {tr('notifTemplates.retry', 'Retry')}\n </button>\n </div>\n );\n }\n\n return (\n <div className=\"space-y-4 sm:space-y-6 p-3 sm:p-6 animate-in fade-in duration-200\">\n <PagePurpose icon={<FileText size={16} />}>\n {tr(\n 'notifTemplates.purpose',\n 'Reusable, versioned message blueprints — subject lines, bodies and channel layouts with {{variables}} you fill in at send time. Build a template once (e.g. a welcome email or a payment receipt) and reuse it from the Send page so every notification stays on-brand and consistent.'\n )}\n </PagePurpose>\n\n {/* Header — single emphasis zone (count summary + the one create CTA). */}\n <EmphasisPanel className=\"flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:justify-between sm:p-6\">\n <div>\n <h1 className=\"text-xl sm:text-2xl font-bold text-primary\">\n {tr('notifTemplates.title', 'Notification Templates')}\n </h1>\n <p className=\"text-sm text-secondary mt-1\">\n {total} {tr('notifTemplates.templateCount', 'template')}\n {total !== 1 ? 's' : ''} {tr('notifTemplates.total', 'total')}\n </p>\n </div>\n\n {canCreateTemplate && (\n <Button onClick={() => navigate('new')} className=\"gap-2\">\n <Plus size={16} />\n {tr('notifTemplates.createTemplate', 'Create Template')}\n </Button>\n )}\n </EmphasisPanel>\n\n <NextSteps\n storageKey=\"notification-templates\"\n steps={[\n ...(canCreateTemplate\n ? [\n {\n id: 'create-template',\n label: tr('notifTemplates.nextCreateLabel', 'Create your first template'),\n description: tr(\n 'notifTemplates.nextCreateDesc',\n 'Build a reusable message blueprint with {{variables}} you fill in at send time.'\n ),\n onClick: () => navigate('new'),\n },\n ]\n : []),\n {\n id: 'filter-type',\n label: tr('notifTemplates.nextFilterLabel', 'Filter by type'),\n description: tr(\n 'notifTemplates.nextFilterDesc',\n 'Narrow to Transactional, Marketing, System or Alert templates to find one fast.'\n ),\n onClick: () => updateFilter({ type: 'TRANSACTIONAL' }),\n },\n {\n id: 'use-on-send',\n label: tr('notifTemplates.nextUseLabel', 'Send with a template'),\n description: tr(\n 'notifTemplates.nextUseDesc',\n 'Pick any saved template from the Send page so every notification stays on-brand.'\n ),\n href: '../send',\n },\n ]}\n />\n\n {/* Search + Type filter row */}\n <div className=\"flex flex-col gap-3 sm:flex-row sm:items-center\">\n {/* Search */}\n <div className=\"relative flex-1\">\n <Search size={16} className=\"absolute left-3 top-1/2 -translate-y-1/2 text-tertiary\" />\n <input\n type=\"text\"\n value={filter.search || ''}\n onChange={(e) => updateFilter({ search: e.target.value })}\n placeholder={tr('notifTemplates.searchPlaceholder', 'Search templates...')}\n className=\"w-full pl-9 pr-4 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150\"\n />\n </div>\n\n {/* Type filter */}\n <select\n value={filter.type || ''}\n onChange={(e) =>\n updateFilter({ type: (e.target.value || undefined) as NotificationType | undefined })\n }\n className=\"px-3 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150 scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"\">{tr('notifTemplates.allTypes', 'All Types')}</option>\n <option value=\"TRANSACTIONAL\">\n {tr('notifTemplates.typeTransactional', 'Transactional')}\n </option>\n <option value=\"MARKETING\">{tr('notifTemplates.typeMarketing', 'Marketing')}</option>\n <option value=\"SYSTEM\">{tr('notifTemplates.typeSystem', 'System')}</option>\n <option value=\"ALERT\">{tr('notifTemplates.typeAlert', 'Alert')}</option>\n </select>\n </div>\n\n {templates.length > 0 && (\n <GlassCard\n treatment=\"plain\"\n className=\"flex flex-col gap-3 border-border-seam p-4 sm:flex-row sm:items-center sm:justify-between\"\n >\n <label className=\"flex items-center gap-2 text-sm text-primary\">\n <input\n type=\"checkbox\"\n checked={allVisibleSelected}\n ref={(input) => {\n if (input) {\n input.indeterminate = partiallySelected && !allVisibleSelected;\n }\n }}\n onChange={(event) => toggleAllTemplates(event.target.checked)}\n aria-label={tr(\n 'notifTemplates.selectAllVisibleAria',\n 'Select all notification templates'\n )}\n className=\"h-4 w-4 rounded border-default text-accent-primary\"\n />\n <span>{tr('notifTemplates.selectAllVisible', 'Select all visible')}</span>\n </label>\n\n <div className=\"flex items-center gap-2\">\n <span className=\"text-sm text-secondary\">\n {selectedTemplateIds.size} {tr('notifTemplates.selected', 'selected')}\n </span>\n {selectedTemplateIds.size > 0 && (\n <button\n onClick={() => setSelectedTemplateIds(new Set())}\n className=\"text-sm text-secondary hover:text-primary\"\n >\n {tr('notifTemplates.clearSelection', 'Clear selection')}\n </button>\n )}\n {canDeleteTemplate && (\n <button\n onClick={handleBulkDelete}\n disabled={selectedTemplates.length === 0 || isDeleting}\n className=\"flex items-center gap-2 px-3 py-2 text-sm font-medium text-error border border-error/30 hover:bg-error/10 rounded-lg transition-all duration-150 disabled:opacity-50\"\n >\n <Trash2 size={14} />\n {tr('notifTemplates.deleteSelected', 'Delete Selected')}\n {selectedTemplates.length > 0 ? ` (${selectedTemplates.length})` : ''}\n </button>\n )}\n </div>\n </GlassCard>\n )}\n\n {/* Delete error banner */}\n {deleteError && (\n <div className=\"flex items-center gap-3 p-3 bg-error/10 border border-error/30 rounded-lg\">\n <AlertCircle size={16} className=\"text-error shrink-0\" />\n <p className=\"text-sm text-error\">{deleteError}</p>\n </div>\n )}\n\n {/* Empty state */}\n {templates.length === 0 && !isLoading && (\n <IllustratedEmptyState\n illustration={filter.search || filter.type ? 'empty-search' : 'empty-files'}\n title={\n filter.search || filter.type\n ? tr('notifTemplates.noMatchingTemplates', 'No templates match your filters')\n : tr('notifTemplates.noTemplatesYet', 'No templates yet. Create your first one!')\n }\n description={\n filter.search || filter.type\n ? tr('notifications.adjustSearchOrDateRange', 'Try adjusting your filters')\n : tr(\n 'notifTemplates.noTemplatesDescription',\n 'Reusable templates let you send consistent notifications fast.'\n )\n }\n action={\n !filter.search && !filter.type && canCreateTemplate ? (\n <Button onClick={() => navigate('new')} className=\"gap-2\">\n <Plus size={16} />\n {tr('notifTemplates.createTemplate', 'Create Template')}\n </Button>\n ) : undefined\n }\n />\n )}\n\n {/* Templates grid */}\n <div className=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {templates.map((template) => (\n <div\n key={template.id}\n onClick={() => navigate(template.slug)}\n className={`group relative p-4 bg-gloss-card border rounded-lg cursor-pointer transition-[box-shadow,border-color] duration-200 hover:shadow-[var(--shadow-pop)] hover:border-accent-primary/30 ${selectedTemplateIds.has(template.id) ? 'border-accent-primary/50 ring-1 ring-accent-primary/20' : 'border-border-seam'}`}\n >\n {/* Top row: icon + type badge + delete */}\n <div className=\"flex items-start justify-between mb-3\">\n <div className=\"flex items-center gap-2\">\n <input\n type=\"checkbox\"\n checked={selectedTemplateIds.has(template.id)}\n onChange={(event) => {\n event.stopPropagation();\n toggleTemplateSelection(template.id, event.target.checked);\n }}\n onClick={(event) => event.stopPropagation()}\n aria-label={tr(\n 'notifTemplates.selectTemplateAria',\n 'Select template {{name}}'\n ).replace('{{name}}', template.name)}\n className=\"h-4 w-4 rounded border-default text-accent-primary\"\n />\n <FileText size={20} className=\"text-accent-primary\" />\n </div>\n <div className=\"flex items-center gap-2\">\n <span\n className={`px-2 py-0.5 text-[10px] font-semibold rounded-full border ${\n TYPE_COLORS[template.type as NotificationType] ||\n 'text-tertiary bg-bg-sunken border-default'\n }`}\n >\n {tr(\n `notifTemplates.type.${template.type as NotificationType}`,\n TYPE_LABELS[template.type as NotificationType] || template.type\n )}\n </span>\n {canDeleteTemplate && (\n <button\n onClick={(e) => handleDelete(e, template)}\n disabled={isDeleting && deletingId === template.id}\n className=\"opacity-0 group-hover:opacity-100 p-1 text-tertiary hover:text-error rounded transition-all duration-150\"\n title={tr('notifTemplates.deleteTemplate', 'Delete template')}\n >\n {isDeleting && deletingId === template.id ? (\n <Loader2 size={14} className=\"animate-spin\" />\n ) : (\n <Trash2 size={14} />\n )}\n </button>\n )}\n </div>\n </div>\n\n {/* Name */}\n <h3 className=\"text-sm font-semibold text-primary mb-1 truncate\">{template.name}</h3>\n\n {/* Description */}\n {template.description && (\n <p className=\"text-xs text-secondary mb-2 line-clamp-2\">{template.description}</p>\n )}\n\n {/* Bottom row: slug + enabled badge + locale */}\n <div className=\"flex items-center gap-2 text-[11px] text-tertiary mt-auto pt-2 border-t border-default/50\">\n <code className=\"px-1.5 py-0.5 bg-bg-sunken rounded text-[10px]\">\n {template.slug}\n </code>\n <span>•</span>\n <span>{template.locale || 'en'}</span>\n <span>•</span>\n <span className={template.enabled ? 'text-success' : 'text-tertiary'}>\n {template.enabled\n ? tr('notifTemplates.enabled', 'Enabled')\n : tr('notifTemplates.disabled', 'Disabled')}\n </span>\n </div>\n\n {/* Updated date */}\n <p className=\"text-[10px] text-tertiary mt-1.5\">\n {tr('notifTemplates.updated', 'Updated')} {formatDate(template.updatedAt, locale)}\n </p>\n </div>\n ))}\n </div>\n\n {/* Load more */}\n {hasMore && (\n <div className=\"flex justify-center pt-2\">\n <button\n onClick={loadMore}\n disabled={isLoading}\n className=\"flex items-center gap-2 px-4 py-2 text-sm text-secondary hover:text-primary border border-default rounded-lg transition-all duration-150 hover:shadow-sm\"\n >\n {isLoading ? <Loader2 size={14} className=\"animate-spin\" /> : null}\n {tr('notifTemplates.loadMore', 'Load More')}\n </button>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAsBA,IAAME,KAAgD;CACpD,eAAe;CACf,WAAW;CACX,QAAQ;CACR,OAAO;AACT,GAEMC,IAAgD;CACpD,eAAe;CACf,WAAW;CACX,QAAQ;CACR,OAAO;AACT;AAEA,SAASC,EAAW,GAAa,GAAiB;CAChD,OAAO,IAAI,KAAKC,CAAG,CAAC,CAAC,mBAAmBC,KAAU,SAAS;EACzD,OAAO;EACP,KAAK;EACL,MAAM;CACR,CAAC;AACH;AAUA,SAAgBC,IAA4B;CAC1C,IAAMC,IAAWC,EAAY,GACvBC,IAAKC,EAAM,GACX,EAAE,cAAWX,GAAQ,GACrB,EAAE,kBAAe,WAAWY,MAAuBC,EAAe,GAClE,EACJ,cACA,cACA,eACA,UACA,UACA,YACA,WACA,YACA,aACA,mBACA,oBACEC,EAAyB,GAEvB,CAACC,GAAYC,KAAiBC,EAAwB,IAAI,GAC1D,CAACC,GAAaC,KAAkBF,EAAwB,IAAI,GAC5D,CAACG,GAAqBC,KAA0BJ,kBAAsB,IAAI,IAAI,CAAC,GAE/EK,IAAoBC,QAClBC,EAAU,QAAQ,MAAaJ,EAAoB,IAAIK,EAAS,EAAE,CAAC,GACzE,CAACL,GAAqBI,CAAS,CACjC,GAEME,IACJF,EAAU,SAAS,KAAKA,EAAU,OAAO,MAAaJ,EAAoB,IAAIK,EAAS,EAAE,CAAC,GACtFE,IACJH,EAAU,MAAM,MAAaJ,EAAoB,IAAIK,EAAS,EAAE,CAAC,KAAK,CAACC,GAEnEE,IAAoBC,EA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AA;QACE,kBAAC,QAAD;SAAM,WAAU;SACb,UAAAA,EAAS;QACN,CAAA;QACN,kBAAC,QAAD,EAAA,UAAM,IAAO,CAAA;QACb,kBAAC,QAAD,EAAA,UAAOA,EAAS,UAAU,KAAW,CAAA;QACrC,kBAAC,QAAD,EAAA,UAAM,IAAO,CAAA;QACb,kBAAC,QAAD;SAAM,WAAWA,EAAS,UAAU,iBAAiB;SAClD,UAAAA,EAAS,UACNf,EAAG,0BAA0B,SAAS,IACtCA,EAAG,2BAA2B,UAAU;QACxC,CAAA;OACH;;MAGL,kBAAC,KAAD;OAAG,WAAU;OAAb,UAAA;QACGA,EAAG,0BAA0B,SAAS;QAAE;QAAEN,EAAWqB,EAAS,WAAWnB,CAAM;OAC/E;;KACA;IA/EE,GAAAmB,EAAS,EA+EX,CACN;GACE,CAAA;GAGJ+C,KACC,kBAAC,OAAD;IAAK,WAAU;IACb,UAAA,kBAAC,UAAD;KACE,SAASC;KACT,UAAUxB;KACV,WAAU;KAHZ,UAAA,CAKGA,IAAY,kBAACC,GAAD;MAAS,MAAM;MAAI,WAAU;KAAgB,CAAA,IAAI,MAC7DxC,EAAG,2BAA2B,WAAW,CACpC;;GACL,CAAA;EAEJ;C,KAnUH,kBAAC,OAAD;EAAK,WAAU;EACZ,UAAAA,EACC,mCACA,2DACF;CACG,CAAA;AAgUX"}
@@ -0,0 +1 @@
1
+ export declare function NotificationTopicsPage(): import('react').JSX.Element;
@@ -1,13 +1,13 @@
1
1
  import { useNotificationTopics as e } from "../hooks/useNotificationTopics.js";
2
2
  import "../hooks/index.js";
3
- import { useTr as t } from "../shared/hooks/useTr.js";
4
- import { NOTIFICATION_PERMISSIONS as n } from "../constants/permissions.js";
3
+ import { NOTIFICATION_PERMISSIONS as t } from "../constants/permissions.js";
4
+ import { useTr as n } from "../shared/hooks/useTr.js";
5
5
  import { useMemo as r, useState as i } from "react";
6
6
  import { usePermissions as a } from "@burdenoff/fe-libs/shared/providers/shell";
7
7
  import { Plus as o, Save as s, Search as c, Trash2 as l } from "lucide-react";
8
8
  import { jsx as u, jsxs as d } from "react/jsx-runtime";
9
9
  import { EmphasisPanel as f, GlassCard as p, IllustratedEmptyState as m, NextSteps as h, PagePurpose as g } from "@burdenoff/fe-libs/ui";
10
- //#region src/pages/NotificationTopicsPage.tsx
10
+ // src/pages/NotificationTopicsPage.tsx
11
11
  var _ = [
12
12
  {
13
13
  value: "MARKETING",
@@ -34,13 +34,13 @@ function v(e) {
34
34
  return e.toLowerCase().trim().replace(/[^a-z0-9\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-");
35
35
  }
36
36
  function y() {
37
- let y = t(), { hasPermission: b, isLoading: x } = a(), { topics: S, isLoading: C, isForbidden: w, createTopic: T, updateTopic: E, deleteTopic: D } = e(), [O, k] = i(""), [A, j] = i(null), [M, N] = i({
37
+ let y = n(), { hasPermission: b, isLoading: x } = a(), { topics: S, isLoading: C, isForbidden: w, createTopic: T, updateTopic: E, deleteTopic: D } = e(), [O, k] = i(""), [A, j] = i(null), [M, N] = i({
38
38
  name: "",
39
39
  slug: "",
40
40
  description: "",
41
41
  type: "MARKETING",
42
42
  isActive: !0
43
- }), P = b(n.NOTIFICATION_CREATE), F = r(() => {
43
+ }), P = b(t.NOTIFICATION_CREATE), F = r(() => {
44
44
  if (!O.trim()) return S;
45
45
  let e = O.toLowerCase();
46
46
  return S.filter((t) => t.name.toLowerCase().includes(e) || t.slug.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e));
@@ -105,7 +105,7 @@ function y() {
105
105
  children: /* @__PURE__ */ d("form", {
106
106
  className: "space-y-4",
107
107
  onSubmit: async (e) => {
108
- e.preventDefault(), !(!M.name.trim() || !M.slug.trim()) && (A ? await E(A, M) : await T(M), j(null), N({
108
+ e.preventDefault(), M.name.trim() && M.slug.trim() && (A ? await E(A, M) : await T(M), j(null), N({
109
109
  name: "",
110
110
  slug: "",
111
111
  description: "",
@@ -307,7 +307,6 @@ function y() {
307
307
  children: y("notifications.noPermissionTopics", "You don't have permission to manage notification topics.")
308
308
  });
309
309
  }
310
- //#endregion
311
310
  export { y as NotificationTopicsPage };
312
311
 
313
312
  //# sourceMappingURL=NotificationTopicsPage.js.map