@burdenoff/microfe-notification 2026.424.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +376 -0
- package/dist/AdminNotificationRoot.d.ts +35 -0
- package/dist/AdminNotificationRoot.d.ts.map +1 -0
- package/dist/AdminNotificationRoot.js +81 -0
- package/dist/AdminNotificationRoot.js.map +1 -0
- package/dist/AdminNotificationRoutes.d.ts +2 -0
- package/dist/AdminNotificationRoutes.d.ts.map +1 -0
- package/dist/AdminNotificationRoutes.js +108 -0
- package/dist/AdminNotificationRoutes.js.map +1 -0
- package/dist/NotificationRoot.d.ts +31 -0
- package/dist/NotificationRoot.d.ts.map +1 -0
- package/dist/NotificationRoot.js +81 -0
- package/dist/NotificationRoot.js.map +1 -0
- package/dist/NotificationRoutes.d.ts +17 -0
- package/dist/NotificationRoutes.d.ts.map +1 -0
- package/dist/NotificationRoutes.js +67 -0
- package/dist/NotificationRoutes.js.map +1 -0
- package/dist/UserNotificationRoot.d.ts +34 -0
- package/dist/UserNotificationRoot.d.ts.map +1 -0
- package/dist/UserNotificationRoot.js +64 -0
- package/dist/UserNotificationRoot.js.map +1 -0
- package/dist/UserNotificationRoutes.d.ts +15 -0
- package/dist/UserNotificationRoutes.d.ts.map +1 -0
- package/dist/UserNotificationRoutes.js +52 -0
- package/dist/UserNotificationRoutes.js.map +1 -0
- package/dist/__tests__/setup.d.ts +2 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/components/NotificationBell.d.ts +14 -0
- package/dist/components/NotificationBell.d.ts.map +1 -0
- package/dist/components/NotificationBell.js +47 -0
- package/dist/components/NotificationBell.js.map +1 -0
- package/dist/components/NotificationCard.d.ts +19 -0
- package/dist/components/NotificationCard.d.ts.map +1 -0
- package/dist/components/NotificationCard.js +112 -0
- package/dist/components/NotificationCard.js.map +1 -0
- package/dist/components/NotificationPanel.d.ts +11 -0
- package/dist/components/NotificationPanel.d.ts.map +1 -0
- package/dist/components/NotificationPanel.js +100 -0
- package/dist/components/NotificationPanel.js.map +1 -0
- package/dist/components/RecipientSelector.d.ts +34 -0
- package/dist/components/RecipientSelector.d.ts.map +1 -0
- package/dist/components/RecipientSelector.js +212 -0
- package/dist/components/RecipientSelector.js.map +1 -0
- package/dist/components/TemplatePreview.d.ts +22 -0
- package/dist/components/TemplatePreview.d.ts.map +1 -0
- package/dist/components/TemplatePreview.js +425 -0
- package/dist/components/TemplatePreview.js.map +1 -0
- package/dist/components/VariableInserter.d.ts +12 -0
- package/dist/components/VariableInserter.d.ts.map +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +3 -0
- package/dist/constants/permissions.d.ts +24 -0
- package/dist/constants/permissions.d.ts.map +1 -0
- package/dist/constants/permissions.js +17 -0
- package/dist/constants/permissions.js.map +1 -0
- package/dist/dev/main.d.ts +2 -0
- package/dist/dev/main.d.ts.map +1 -0
- package/dist/generated/global-operations.d.ts +1408 -0
- package/dist/generated/global-operations.d.ts.map +1 -0
- package/dist/generated/global-operations.js +514 -0
- package/dist/generated/global-operations.js.map +1 -0
- package/dist/generated/global-types.d.ts +20773 -0
- package/dist/generated/global-types.d.ts.map +1 -0
- package/dist/generated/wspace-operations.d.ts +2 -0
- package/dist/generated/wspace-operations.d.ts.map +1 -0
- package/dist/generated/wspace-types.d.ts +53363 -0
- package/dist/generated/wspace-types.d.ts.map +1 -0
- package/dist/graphql/global-client.d.ts +19 -0
- package/dist/graphql/global-client.d.ts.map +1 -0
- package/dist/graphql/global-client.js +57 -0
- package/dist/graphql/global-client.js.map +1 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/useNotificationAdmin.d.ts +51 -0
- package/dist/hooks/useNotificationAdmin.d.ts.map +1 -0
- package/dist/hooks/useNotificationAdmin.js +203 -0
- package/dist/hooks/useNotificationAdmin.js.map +1 -0
- package/dist/hooks/useNotificationTemplates.d.ts +136 -0
- package/dist/hooks/useNotificationTemplates.d.ts.map +1 -0
- package/dist/hooks/useNotificationTemplates.js +168 -0
- package/dist/hooks/useNotificationTemplates.js.map +1 -0
- package/dist/hooks/useNotificationTopics.d.ts +36 -0
- package/dist/hooks/useNotificationTopics.d.ts.map +1 -0
- package/dist/hooks/useNotificationTopics.js +127 -0
- package/dist/hooks/useNotificationTopics.js.map +1 -0
- package/dist/hooks/useNotifications.d.ts +36 -0
- package/dist/hooks/useNotifications.d.ts.map +1 -0
- package/dist/hooks/useNotifications.js +289 -0
- package/dist/hooks/useNotifications.js.map +1 -0
- package/dist/hooks/useSendNotification.d.ts +159 -0
- package/dist/hooks/useSendNotification.d.ts.map +1 -0
- package/dist/hooks/useSendNotification.js +123 -0
- package/dist/hooks/useSendNotification.js.map +1 -0
- package/dist/hooks/useUserSearch.d.ts +27 -0
- package/dist/hooks/useUserSearch.d.ts.map +1 -0
- package/dist/hooks/useUserSearch.js +76 -0
- package/dist/hooks/useUserSearch.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/pages/CreateNotificationPage.d.ts +6 -0
- package/dist/pages/CreateNotificationPage.d.ts.map +1 -0
- package/dist/pages/CreateNotificationPage.js +1366 -0
- package/dist/pages/CreateNotificationPage.js.map +1 -0
- package/dist/pages/NotificationCenterPage.d.ts +7 -0
- package/dist/pages/NotificationCenterPage.d.ts.map +1 -0
- package/dist/pages/NotificationCenterPage.js +203 -0
- package/dist/pages/NotificationCenterPage.js.map +1 -0
- package/dist/pages/NotificationHistoryAdminPage.d.ts +3 -0
- package/dist/pages/NotificationHistoryAdminPage.d.ts.map +1 -0
- package/dist/pages/NotificationHistoryAdminPage.js +484 -0
- package/dist/pages/NotificationHistoryAdminPage.js.map +1 -0
- package/dist/pages/NotificationHistoryPage.d.ts +3 -0
- package/dist/pages/NotificationHistoryPage.d.ts.map +1 -0
- package/dist/pages/NotificationHistoryPage.js +136 -0
- package/dist/pages/NotificationHistoryPage.js.map +1 -0
- package/dist/pages/NotificationLandingPage.d.ts +11 -0
- package/dist/pages/NotificationLandingPage.d.ts.map +1 -0
- package/dist/pages/NotificationLandingPage.js +85 -0
- package/dist/pages/NotificationLandingPage.js.map +1 -0
- package/dist/pages/NotificationPreferencesPage.d.ts +2 -0
- package/dist/pages/NotificationPreferencesPage.d.ts.map +1 -0
- package/dist/pages/NotificationPreferencesPage.js +108 -0
- package/dist/pages/NotificationPreferencesPage.js.map +1 -0
- package/dist/pages/NotificationTemplatesPage.d.ts +8 -0
- package/dist/pages/NotificationTemplatesPage.d.ts.map +1 -0
- package/dist/pages/NotificationTemplatesPage.js +310 -0
- package/dist/pages/NotificationTemplatesPage.js.map +1 -0
- package/dist/pages/NotificationTopicsPage.d.ts +2 -0
- package/dist/pages/NotificationTopicsPage.d.ts.map +1 -0
- package/dist/pages/NotificationTopicsPage.js +254 -0
- package/dist/pages/NotificationTopicsPage.js.map +1 -0
- package/dist/pages/TemplateEditorPage.d.ts +13 -0
- package/dist/pages/TemplateEditorPage.d.ts.map +1 -0
- package/dist/pages/TemplateEditorPage.js +790 -0
- package/dist/pages/TemplateEditorPage.js.map +1 -0
- package/dist/providers/NotificationProvider.d.ts +19 -0
- package/dist/providers/NotificationProvider.d.ts.map +1 -0
- package/dist/providers/NotificationProvider.js +35 -0
- package/dist/providers/NotificationProvider.js.map +1 -0
- package/dist/shared/hooks/useTr.d.ts +14 -0
- package/dist/shared/hooks/useTr.d.ts.map +1 -0
- package/dist/shared/hooks/useTr.js +14 -0
- package/dist/shared/hooks/useTr.js.map +1 -0
- package/dist/store/notificationStore.d.ts +32 -0
- package/dist/store/notificationStore.d.ts.map +1 -0
- package/dist/store/notificationStore.js +124 -0
- package/dist/store/notificationStore.js.map +1 -0
- package/dist/types/index.d.ts +215 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/index.d.ts +68 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +122 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/notificationHistoryExport.d.ts +13 -0
- package/dist/utils/notificationHistoryExport.d.ts.map +1 -0
- package/dist/utils/notificationHistoryExport.js +29 -0
- package/dist/utils/notificationHistoryExport.js.map +1 -0
- package/package.json +115 -0
package/README.md
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
# Notification Microfrontend
|
|
2
|
+
|
|
3
|
+
A comprehensive notification management microfrontend for the Burdenoff platform. This is a **TENANT module** that provides multi-channel notification capabilities including in-app notifications, email, SMS, and push notifications.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Notification microfrontend enables users to:
|
|
8
|
+
|
|
9
|
+
- **View and manage** in-app notifications with real-time updates
|
|
10
|
+
- **Configure preferences** for notification channels and frequencies
|
|
11
|
+
- **Set quiet hours** and Do Not Disturb mode
|
|
12
|
+
- **Search and filter** notification history
|
|
13
|
+
- **Create and manage** notification templates (admin)
|
|
14
|
+
- **Build automation rules** for event-driven notifications (admin)
|
|
15
|
+
- **Monitor delivery** across all channels (admin)
|
|
16
|
+
|
|
17
|
+
## Architecture
|
|
18
|
+
|
|
19
|
+
This microfrontend follows the Burdenoff build-time composition architecture:
|
|
20
|
+
|
|
21
|
+
- **Layer 0**: Shared utilities and hooks (`@burdenoff/fe-libs/shared`)
|
|
22
|
+
- **Layer 1**: Primitive UI components (`@burdenoff/fe-libs`)
|
|
23
|
+
- **Layer 2**: This microfrontend (`@burdenoff/micro-fe/notification`)
|
|
24
|
+
- **Layer 3**: Host shells (workspaces-frontend, tenant-frontend, etc.)
|
|
25
|
+
|
|
26
|
+
## Directory Structure
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
notification/
|
|
30
|
+
├── index.ts # Public exports (ONLY NotificationRoot and types)
|
|
31
|
+
├── NotificationRoot.tsx # Entry point component
|
|
32
|
+
├── NotificationRoutes.tsx # Internal routing
|
|
33
|
+
├── types/
|
|
34
|
+
│ └── index.ts # TypeScript interfaces
|
|
35
|
+
├── store/
|
|
36
|
+
│ └── notificationStore.ts # Zustand state management
|
|
37
|
+
├── providers/
|
|
38
|
+
│ └── NotificationProvider.tsx # Context provider
|
|
39
|
+
├── pages/
|
|
40
|
+
│ ├── NotificationCenterPage.tsx # Main notification feed
|
|
41
|
+
│ ├── NotificationPreferencesPage.tsx # User preferences
|
|
42
|
+
│ ├── NotificationHistoryPage.tsx # Notification archive
|
|
43
|
+
│ ├── NotificationTemplatesPage.tsx # Template list (admin)
|
|
44
|
+
│ ├── TemplateEditorPage.tsx # Template editor (admin)
|
|
45
|
+
│ ├── NotificationRulesPage.tsx # Rules list (admin)
|
|
46
|
+
│ ├── RuleEditorPage.tsx # Rule editor (admin)
|
|
47
|
+
│ └── DeliveryMonitoringPage.tsx # Delivery dashboard (admin)
|
|
48
|
+
├── components/
|
|
49
|
+
│ ├── NotificationBell.tsx # Bell icon with badge
|
|
50
|
+
│ ├── NotificationPanel.tsx # Dropdown panel
|
|
51
|
+
│ ├── NotificationCard.tsx # Notification item
|
|
52
|
+
│ └── DoNotDisturbToggle.tsx # DND toggle
|
|
53
|
+
├── hooks/
|
|
54
|
+
│ ├── useNotifications.ts # Notifications hook
|
|
55
|
+
│ └── useNotificationPreferences.ts # Preferences hook
|
|
56
|
+
├── graphql/
|
|
57
|
+
│ └── operations/
|
|
58
|
+
│ ├── getNotifications.graphql
|
|
59
|
+
│ ├── markNotificationAsRead.graphql
|
|
60
|
+
│ ├── getNotificationPreferences.graphql
|
|
61
|
+
│ ├── updateNotificationPreferences.graphql
|
|
62
|
+
│ ├── getNotificationTemplates.graphql
|
|
63
|
+
│ ├── createNotificationTemplate.graphql
|
|
64
|
+
│ ├── getNotificationRules.graphql
|
|
65
|
+
│ ├── createNotificationRule.graphql
|
|
66
|
+
│ └── subscriptions/
|
|
67
|
+
│ ├── notificationReceived.graphql
|
|
68
|
+
│ └── notificationDeliveryStatusChanged.graphql
|
|
69
|
+
└── utils/
|
|
70
|
+
└── index.ts # Helper functions
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Installation
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# This microfrontend is part of the @burdenoff/micro-fe package
|
|
77
|
+
npm install @burdenoff/micro-fe
|
|
78
|
+
# or
|
|
79
|
+
bun install @burdenoff/micro-fe
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Usage
|
|
83
|
+
|
|
84
|
+
### Basic Integration
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
import { NotificationRoot, type NotificationRootProps } from '@burdenoff/micro-fe/notification';
|
|
88
|
+
|
|
89
|
+
function App() {
|
|
90
|
+
const props: NotificationRootProps = {
|
|
91
|
+
basePath: '/notifications',
|
|
92
|
+
navigate: (path) => router.push(path),
|
|
93
|
+
currentUser: { id: '1', email: 'user@example.com' },
|
|
94
|
+
workspaceId: 'ws-123',
|
|
95
|
+
apiGatewayUrl: 'http://localhost:4002/tenant/graphql', // TENANT API Gateway (port 4002)
|
|
96
|
+
authToken: 'your-auth-token',
|
|
97
|
+
registerNavItems: (items) => {
|
|
98
|
+
// Register navigation items with your shell
|
|
99
|
+
return () => {}; // Cleanup function
|
|
100
|
+
},
|
|
101
|
+
onNotificationClick: (notification) => {
|
|
102
|
+
console.log('Notification clicked:', notification);
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
return <NotificationRoot {...props} />;
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Standalone Notification Bell
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
import { NotificationBell } from '@burdenoff/micro-fe/notification';
|
|
114
|
+
|
|
115
|
+
function Header() {
|
|
116
|
+
return (
|
|
117
|
+
<header>
|
|
118
|
+
<NotificationBell onClick={() => navigate('/notifications/center')} />
|
|
119
|
+
</header>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Using Hooks Directly
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
import { useNotifications, useNotificationStore } from '@burdenoff/micro-fe/notification';
|
|
128
|
+
|
|
129
|
+
function CustomNotificationComponent() {
|
|
130
|
+
const { notifications, unreadCount, markAsRead } = useNotifications();
|
|
131
|
+
const { isPanelOpen, togglePanel } = useNotificationStore();
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<div>
|
|
135
|
+
<button onClick={togglePanel}>
|
|
136
|
+
Notifications ({unreadCount})
|
|
137
|
+
</button>
|
|
138
|
+
{isPanelOpen && (
|
|
139
|
+
<div>
|
|
140
|
+
{notifications.map(notification => (
|
|
141
|
+
<div key={notification.id} onClick={() => markAsRead(notification.id)}>
|
|
142
|
+
{notification.title}
|
|
143
|
+
</div>
|
|
144
|
+
))}
|
|
145
|
+
</div>
|
|
146
|
+
)}
|
|
147
|
+
</div>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Features
|
|
153
|
+
|
|
154
|
+
### User Features (All Users)
|
|
155
|
+
|
|
156
|
+
#### Notification Center
|
|
157
|
+
- Real-time notification feed with unread badges
|
|
158
|
+
- Mark as read/unread (individual or bulk)
|
|
159
|
+
- Archive notifications
|
|
160
|
+
- Filter by type, priority, status, date range
|
|
161
|
+
- Search by title or content
|
|
162
|
+
- Group by date (Today, Yesterday, This Week, Earlier)
|
|
163
|
+
- Deep linking to related resources
|
|
164
|
+
|
|
165
|
+
#### Notification Preferences
|
|
166
|
+
- Per-channel preferences (In-App, Email, SMS, Push)
|
|
167
|
+
- Per-notification-type preferences (System, Activity, Billing, Security, Social, Reminder)
|
|
168
|
+
- Frequency control (Immediate, Hourly, Daily, Weekly, Never)
|
|
169
|
+
- Quiet hours configuration
|
|
170
|
+
- Do Not Disturb mode
|
|
171
|
+
- Workspace-specific preferences
|
|
172
|
+
|
|
173
|
+
#### Notification History
|
|
174
|
+
- Searchable archive with advanced filters
|
|
175
|
+
- Export notifications (CSV, PDF)
|
|
176
|
+
- Restore archived notifications
|
|
177
|
+
|
|
178
|
+
### Admin Features (Workspace/Tenant Admins)
|
|
179
|
+
|
|
180
|
+
#### Template Management
|
|
181
|
+
- Create/edit/delete notification templates
|
|
182
|
+
- Multi-channel templates (Email HTML, SMS, Push, In-App)
|
|
183
|
+
- Variable substitution with autocomplete
|
|
184
|
+
- Template preview with sample data
|
|
185
|
+
- Multi-language support
|
|
186
|
+
- Version history
|
|
187
|
+
|
|
188
|
+
#### Automation Rules
|
|
189
|
+
- Event-driven notification rules
|
|
190
|
+
- Visual rule builder with conditions
|
|
191
|
+
- Template selector for automated notifications
|
|
192
|
+
- Rule testing/simulation
|
|
193
|
+
- Activation/deactivation controls
|
|
194
|
+
- Usage analytics
|
|
195
|
+
|
|
196
|
+
#### Delivery Monitoring
|
|
197
|
+
- Real-time delivery status tracking
|
|
198
|
+
- Channel health dashboard
|
|
199
|
+
- Delivery success/failure rates
|
|
200
|
+
- Error logs with retry management
|
|
201
|
+
- Rate limit monitoring
|
|
202
|
+
- Bounce and complaint handling
|
|
203
|
+
|
|
204
|
+
## GraphQL Integration
|
|
205
|
+
|
|
206
|
+
### Queries
|
|
207
|
+
|
|
208
|
+
All queries connect to the **TENANT API Gateway** at port 4002:
|
|
209
|
+
|
|
210
|
+
- `GetNotifications` - Fetch notifications with filters
|
|
211
|
+
- `GetNotificationPreferences` - Get user preferences
|
|
212
|
+
- `GetNotificationTemplates` - List templates (admin)
|
|
213
|
+
- `GetNotificationRules` - List automation rules (admin)
|
|
214
|
+
- `GetNotificationDeliveries` - Get delivery tracking (admin)
|
|
215
|
+
- `GetChannelHealth` - Get channel status (admin)
|
|
216
|
+
|
|
217
|
+
### Mutations
|
|
218
|
+
|
|
219
|
+
- `MarkNotificationAsRead` - Mark single notification as read
|
|
220
|
+
- `MarkAllNotificationsAsRead` - Mark all as read
|
|
221
|
+
- `ArchiveNotification` - Archive a notification
|
|
222
|
+
- `UpdateNotificationPreferences` - Update user preferences
|
|
223
|
+
- `CreateNotificationTemplate` - Create template (admin)
|
|
224
|
+
- `UpdateNotificationTemplate` - Update template (admin)
|
|
225
|
+
- `CreateNotificationRule` - Create automation rule (admin)
|
|
226
|
+
- `UpdateNotificationRule` - Update rule (admin)
|
|
227
|
+
|
|
228
|
+
### Subscriptions
|
|
229
|
+
|
|
230
|
+
- `NotificationReceived` - Real-time notification updates
|
|
231
|
+
- `NotificationDeliveryStatusChanged` - Delivery status updates
|
|
232
|
+
|
|
233
|
+
## State Management
|
|
234
|
+
|
|
235
|
+
This microfrontend uses **Zustand** for state management with the following stores:
|
|
236
|
+
|
|
237
|
+
### NotificationStore
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
{
|
|
241
|
+
notifications: Notification[];
|
|
242
|
+
unreadCount: number;
|
|
243
|
+
selectedNotification: Notification | null;
|
|
244
|
+
viewMode: 'center' | 'history' | 'preferences';
|
|
245
|
+
isPanelOpen: boolean;
|
|
246
|
+
notificationFilter: NotificationFilter;
|
|
247
|
+
preferences: NotificationPreference[];
|
|
248
|
+
isDoNotDisturb: boolean;
|
|
249
|
+
quietHours: QuietHours;
|
|
250
|
+
// ... actions
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Styling
|
|
255
|
+
|
|
256
|
+
This microfrontend uses **semantic tokens** from the design system. All colors are referenced using semantic token classes:
|
|
257
|
+
|
|
258
|
+
- `text-foreground` - Primary text
|
|
259
|
+
- `text-muted-foreground` - Secondary text
|
|
260
|
+
- `bg-surface` - Primary background
|
|
261
|
+
- `bg-surface-elevated` - Elevated surface
|
|
262
|
+
- `bg-surface-hover` - Hover state
|
|
263
|
+
- `border-border` - Default border
|
|
264
|
+
- `text-primary-500` - Primary color
|
|
265
|
+
- `text-error-500` - Error/urgent
|
|
266
|
+
- `text-warning-500` - Warning/high priority
|
|
267
|
+
- `text-success-500` - Success/delivered
|
|
268
|
+
- `text-info-500` - Info/normal priority
|
|
269
|
+
|
|
270
|
+
**No hardcoded colors** - all styling follows the design system.
|
|
271
|
+
|
|
272
|
+
## Accessibility
|
|
273
|
+
|
|
274
|
+
- **ARIA labels** on all interactive elements
|
|
275
|
+
- **Keyboard navigation** support (Tab, Enter, Escape)
|
|
276
|
+
- **Screen reader** announcements for new notifications
|
|
277
|
+
- **Focus management** for modal/panel states
|
|
278
|
+
- **Color contrast** meets WCAG 2.1 AA standards
|
|
279
|
+
- **Reduced motion** support (`prefers-reduced-motion`)
|
|
280
|
+
|
|
281
|
+
## Performance
|
|
282
|
+
|
|
283
|
+
- **Virtual scrolling** for long notification lists
|
|
284
|
+
- **Optimistic updates** for read/archive actions
|
|
285
|
+
- **Debounced search** to reduce query load
|
|
286
|
+
- **Lazy loading** of images and attachments
|
|
287
|
+
- **Cursor-based pagination** for efficient data fetching
|
|
288
|
+
- **Real-time subscription batching** to reduce re-renders
|
|
289
|
+
|
|
290
|
+
## RBAC Integration
|
|
291
|
+
|
|
292
|
+
All features respect the RBAC system. See the spec for detailed permission requirements:
|
|
293
|
+
|
|
294
|
+
- **User features**: `tenantmodule-notification:notification:view:own`
|
|
295
|
+
- **Template management**: `tenantmodule-notification:template:create`
|
|
296
|
+
- **Rule management**: `tenantmodule-notification:rule:create`
|
|
297
|
+
- **Delivery monitoring**: `tenantmodule-notification:analytics:view`
|
|
298
|
+
|
|
299
|
+
## Routes
|
|
300
|
+
|
|
301
|
+
When integrated at `/notifications`:
|
|
302
|
+
|
|
303
|
+
- `/notifications/center` - Notification center
|
|
304
|
+
- `/notifications/preferences` - User preferences
|
|
305
|
+
- `/notifications/history` - Notification history
|
|
306
|
+
- `/notifications/templates` - Template list (admin)
|
|
307
|
+
- `/notifications/templates/new` - Create template (admin)
|
|
308
|
+
- `/notifications/templates/:id` - Edit template (admin)
|
|
309
|
+
- `/notifications/rules` - Rules list (admin)
|
|
310
|
+
- `/notifications/rules/new` - Create rule (admin)
|
|
311
|
+
- `/notifications/rules/:id` - Edit rule (admin)
|
|
312
|
+
- `/notifications/delivery` - Delivery monitoring (admin)
|
|
313
|
+
|
|
314
|
+
## API Gateway Configuration
|
|
315
|
+
|
|
316
|
+
**CRITICAL**: This is a TENANT module and must connect to the **Tenant API Gateway** at port 4002:
|
|
317
|
+
|
|
318
|
+
```typescript
|
|
319
|
+
apiGatewayUrl: 'http://localhost:4002/tenant/graphql' // Development
|
|
320
|
+
apiGatewayUrl: 'https://api.burdenoff.com/tenant/graphql' // Production
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## Next Steps
|
|
324
|
+
|
|
325
|
+
### Phase 1 (Completed)
|
|
326
|
+
- ✅ Core notification center
|
|
327
|
+
- ✅ Basic preferences
|
|
328
|
+
- ✅ Notification bell component
|
|
329
|
+
- ✅ All 8 pages created
|
|
330
|
+
- ✅ GraphQL operations defined
|
|
331
|
+
- ✅ State management with Zustand
|
|
332
|
+
- ✅ Utility functions
|
|
333
|
+
|
|
334
|
+
### Phase 2 (TODO)
|
|
335
|
+
- [ ] Connect GraphQL queries/mutations to backend
|
|
336
|
+
- [ ] Implement real-time subscriptions
|
|
337
|
+
- [ ] Add GraphQL codegen integration
|
|
338
|
+
- [ ] Implement template variable picker component
|
|
339
|
+
- [ ] Add rule condition builder component
|
|
340
|
+
- [ ] Create preference matrix component
|
|
341
|
+
- [ ] Implement delivery status tracker
|
|
342
|
+
|
|
343
|
+
### Phase 3 (TODO)
|
|
344
|
+
- [ ] Add unit tests (Vitest)
|
|
345
|
+
- [ ] Add integration tests
|
|
346
|
+
- [ ] Add E2E tests (Playwright)
|
|
347
|
+
- [ ] Performance optimizations
|
|
348
|
+
- [ ] Accessibility audit
|
|
349
|
+
- [ ] i18n support
|
|
350
|
+
|
|
351
|
+
## Contributing
|
|
352
|
+
|
|
353
|
+
Follow the Burdenoff development standards:
|
|
354
|
+
|
|
355
|
+
1. **TypeScript strict mode** - No `any` types
|
|
356
|
+
2. **Semantic tokens** - No hardcoded colors
|
|
357
|
+
3. **GraphQL-first** - All data from GraphQL
|
|
358
|
+
4. **RBAC aware** - Check permissions
|
|
359
|
+
5. **Accessible** - WCAG 2.1 AA compliant
|
|
360
|
+
6. **Responsive** - Mobile-first design
|
|
361
|
+
7. **Run `bun run sanity`** before commits
|
|
362
|
+
|
|
363
|
+
## License
|
|
364
|
+
|
|
365
|
+
Proprietary - Copyright © 2025 Burdenoff Consultancy Services Pvt. Ltd. All rights reserved.
|
|
366
|
+
|
|
367
|
+
## Related Documentation
|
|
368
|
+
|
|
369
|
+
- [MICROFRONTEND-SPEC.md](/Users/vignesh/official/algoshred/products/tenant/tenant-specs/modules/notification/MICROFRONTEND-SPEC.md)
|
|
370
|
+
- [RBAC.md](/Users/vignesh/official/algoshred/products/tenant/tenant-specs/modules/notification/RBAC.md)
|
|
371
|
+
- [META.yml](/Users/vignesh/official/algoshred/products/tenant/tenant-specs/modules/notification/META.yml)
|
|
372
|
+
- [Microfrontend Architecture](/Users/vignesh/official/algoshred/products/workspaces/workspaces-specs/microfrontends/)
|
|
373
|
+
|
|
374
|
+
## Contact
|
|
375
|
+
|
|
376
|
+
For questions or issues, contact: vignesh@burdenoff.com
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { NotificationRootProps } from './types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Admin Root component for the Notification microfrontend.
|
|
5
|
+
*
|
|
6
|
+
* This is the full admin entry point intended for `admin-app`. It exposes all
|
|
7
|
+
* notification surfaces (Notification Center, History, Templates, Create &
|
|
8
|
+
* Send) and sets up the required provider stack. In-page actions remain gated
|
|
9
|
+
* by RBAC via `usePermissions` checks.
|
|
10
|
+
*
|
|
11
|
+
* For product shells that only need user-facing surfaces, use
|
|
12
|
+
* `UserNotificationRoot` instead.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* import { AdminNotificationRoot, type NotificationRootProps } from '@burdenoff/micro-fe/notification';
|
|
17
|
+
*
|
|
18
|
+
* function App() {
|
|
19
|
+
* const props: NotificationRootProps = {
|
|
20
|
+
* basePath: '/notifications',
|
|
21
|
+
* navigate: (path) => router.push(path),
|
|
22
|
+
* currentUser: { id: '1', email: 'user@example.com' },
|
|
23
|
+
* workspaceId: 'ws-123',
|
|
24
|
+
* apiGatewayUrl: 'https://api.example.com',
|
|
25
|
+
* authToken: 'token',
|
|
26
|
+
* registerNavItems: (items) => { return () => {}; },
|
|
27
|
+
* onNotificationClick: (notification) => console.log('Clicked:', notification),
|
|
28
|
+
* };
|
|
29
|
+
*
|
|
30
|
+
* return <AdminNotificationRoot {...props} />;
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function AdminNotificationRoot(props: NotificationRootProps): import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
//# sourceMappingURL=AdminNotificationRoot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdminNotificationRoot.d.ts","sourceRoot":"","sources":["../src/AdminNotificationRoot.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAuB,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAG1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,qBAAqB,2CAwHjE"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { NotificationProvider as e } from "./providers/NotificationProvider.js";
|
|
2
|
+
import { AdminNotificationRoutes as t } from "./AdminNotificationRoutes.js";
|
|
3
|
+
import { useEffect as n } from "react";
|
|
4
|
+
import { ErrorBoundary as r } from "@burdenoff/fe-libs/shared/components";
|
|
5
|
+
import { useFeatureFlagDetails as i } from "@burdenoff/fe-libs/shared/feature-flags";
|
|
6
|
+
import { Archive as a, Bell as o, FileText as s, Send as c, Tag as l } from "lucide-react";
|
|
7
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
8
|
+
//#region src/AdminNotificationRoot.tsx
|
|
9
|
+
function d(d) {
|
|
10
|
+
let { registerNavItems: f, registerFooterItems: p, basePath: m = "/" } = d, h = i("notification.templates"), g = i("notification.create"), _ = i("notification.history"), v = h ? !!h.value : !1, y = g ? !!g.value : !1, b = _ ? !!_.value : !1, x = (e, t) => (e.endsWith("/") ? e.slice(0, -1) : e) + (t.startsWith("/") ? t : `/${t}`);
|
|
11
|
+
return n(() => {
|
|
12
|
+
if (f) return f([
|
|
13
|
+
{
|
|
14
|
+
id: "admin-notification-center",
|
|
15
|
+
label: "Notification Center",
|
|
16
|
+
path: x(m, "center"),
|
|
17
|
+
icon: /* @__PURE__ */ u(o, { size: 20 }),
|
|
18
|
+
order: 10,
|
|
19
|
+
group: "notifications"
|
|
20
|
+
},
|
|
21
|
+
...b ? [{
|
|
22
|
+
id: "admin-notification-history",
|
|
23
|
+
label: "History",
|
|
24
|
+
path: x(m, "history"),
|
|
25
|
+
icon: /* @__PURE__ */ u(a, { size: 20 }),
|
|
26
|
+
order: 20,
|
|
27
|
+
group: "notifications"
|
|
28
|
+
}] : [],
|
|
29
|
+
...v ? [{
|
|
30
|
+
id: "admin-notification-templates",
|
|
31
|
+
label: "Templates",
|
|
32
|
+
path: x(m, "templates"),
|
|
33
|
+
icon: /* @__PURE__ */ u(s, { size: 20 }),
|
|
34
|
+
order: 30,
|
|
35
|
+
group: "notifications"
|
|
36
|
+
}] : [],
|
|
37
|
+
...y ? [{
|
|
38
|
+
id: "admin-notification-create",
|
|
39
|
+
label: "Send Notification",
|
|
40
|
+
path: x(m, "create"),
|
|
41
|
+
icon: /* @__PURE__ */ u(c, { size: 20 }),
|
|
42
|
+
order: 40,
|
|
43
|
+
group: "notifications"
|
|
44
|
+
}, {
|
|
45
|
+
id: "admin-notification-topics",
|
|
46
|
+
label: "Topics",
|
|
47
|
+
path: x(m, "topics"),
|
|
48
|
+
icon: /* @__PURE__ */ u(l, { size: 20 }),
|
|
49
|
+
order: 50,
|
|
50
|
+
group: "notifications"
|
|
51
|
+
}] : []
|
|
52
|
+
]);
|
|
53
|
+
}, [
|
|
54
|
+
f,
|
|
55
|
+
m,
|
|
56
|
+
b,
|
|
57
|
+
v,
|
|
58
|
+
y
|
|
59
|
+
]), n(() => {
|
|
60
|
+
if (p) return p([{
|
|
61
|
+
id: "admin-notification-status",
|
|
62
|
+
label: "Notifications Ready",
|
|
63
|
+
type: "status",
|
|
64
|
+
order: 10,
|
|
65
|
+
section: "left"
|
|
66
|
+
}]);
|
|
67
|
+
}, [p]), /* @__PURE__ */ u(r, {
|
|
68
|
+
fallback: /* @__PURE__ */ u("div", {
|
|
69
|
+
className: "p-6 text-center text-text-secondary",
|
|
70
|
+
children: "Something went wrong loading this module. Please refresh the page."
|
|
71
|
+
}),
|
|
72
|
+
children: /* @__PURE__ */ u(e, {
|
|
73
|
+
...d,
|
|
74
|
+
children: /* @__PURE__ */ u(t, {})
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
export { d as AdminNotificationRoot };
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=AdminNotificationRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdminNotificationRoot.js","names":[],"sources":["../src/AdminNotificationRoot.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { ErrorBoundary } from '@burdenoff/fe-libs/shared/components';\nimport { useFeatureFlagDetails } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { Bell, Archive, FileText, Send, Tag } from 'lucide-react';\nimport { NotificationProvider } from './providers/NotificationProvider';\nimport type { NavItem, FooterItem, NotificationRootProps } from './types';\nimport { AdminNotificationRoutes } from './AdminNotificationRoutes';\n\n/**\n * Admin Root component for the Notification microfrontend.\n *\n * This is the full admin entry point intended for `admin-app`. It exposes all\n * notification surfaces (Notification Center, History, Templates, Create &\n * Send) and sets up the required provider stack. In-page actions remain gated\n * by RBAC via `usePermissions` checks.\n *\n * For product shells that only need user-facing surfaces, use\n * `UserNotificationRoot` instead.\n *\n * @example\n * ```tsx\n * import { AdminNotificationRoot, type NotificationRootProps } from '@burdenoff/micro-fe/notification';\n *\n * function App() {\n * const props: NotificationRootProps = {\n * basePath: '/notifications',\n * navigate: (path) => router.push(path),\n * currentUser: { id: '1', email: 'user@example.com' },\n * workspaceId: 'ws-123',\n * apiGatewayUrl: 'https://api.example.com',\n * authToken: 'token',\n * registerNavItems: (items) => { return () => {}; },\n * onNotificationClick: (notification) => console.log('Clicked:', notification),\n * };\n *\n * return <AdminNotificationRoot {...props} />;\n * }\n * ```\n */\nexport function AdminNotificationRoot(props: NotificationRootProps) {\n const { registerNavItems, registerFooterItems, basePath = '/' } = props;\n\n // Component-level feature gates. `notification.*` flags are declared as\n // unreleased (defaultValue=false). We use `useFeatureFlagDetails` and\n // explicitly fall back to `false` when the flag is absent from the cache,\n // because the provider's global default-allow would otherwise return `true`\n // for unseeded flags — which would defeat the whole point of the unreleased\n // pattern.\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 // Helper to join paths correctly, avoiding double slashes\n const joinPath = (base: string, path: string): string => {\n const cleanBase = base.endsWith('/') ? base.slice(0, -1) : base;\n const cleanPath = path.startsWith('/') ? path : `/${path}`;\n return cleanBase + cleanPath;\n };\n\n // Register navigation items with the shell (admin - full surface)\n useEffect(() => {\n if (!registerNavItems) return;\n\n const navItems: NavItem[] = [\n {\n id: 'admin-notification-center',\n label: 'Notification Center',\n path: joinPath(basePath, 'center'),\n icon: <Bell size={20} />,\n order: 10,\n group: 'notifications',\n },\n ...(historyEnabled\n ? [\n {\n id: 'admin-notification-history',\n label: 'History',\n path: joinPath(basePath, 'history'),\n icon: <Archive size={20} />,\n order: 20,\n group: 'notifications',\n },\n ]\n : []),\n ...(templatesEnabled\n ? [\n {\n id: 'admin-notification-templates',\n label: 'Templates',\n path: joinPath(basePath, 'templates'),\n icon: <FileText size={20} />,\n order: 30,\n group: 'notifications',\n },\n ]\n : []),\n ...(createEnabled\n ? [\n {\n id: 'admin-notification-create',\n label: 'Send Notification',\n path: joinPath(basePath, 'create'),\n icon: <Send size={20} />,\n order: 40,\n group: 'notifications',\n },\n {\n id: 'admin-notification-topics',\n label: 'Topics',\n path: joinPath(basePath, 'topics'),\n icon: <Tag size={20} />,\n order: 50,\n group: 'notifications',\n },\n ]\n : []),\n ];\n\n // Register and get cleanup function\n const cleanup = registerNavItems(navItems);\n\n // Return cleanup function to unregister on unmount\n return cleanup;\n }, [registerNavItems, basePath, historyEnabled, templatesEnabled, createEnabled]);\n\n // Register footer items (status indicator in left section)\n useEffect(() => {\n if (!registerFooterItems) return;\n\n const footerItems: FooterItem[] = [\n {\n id: 'admin-notification-status',\n label: 'Notifications Ready',\n type: 'status',\n order: 10,\n section: 'left',\n },\n ];\n\n const cleanup = registerFooterItems(footerItems);\n return cleanup;\n }, [registerFooterItems]);\n\n return (\n <ErrorBoundary\n fallback={\n <div className=\"p-6 text-center text-text-secondary\">\n Something went wrong loading this module. Please refresh the page.\n </div>\n }\n >\n <NotificationProvider {...props}>\n <AdminNotificationRoutes />\n </NotificationProvider>\n </ErrorBoundary>\n );\n}\n"],"mappings":";;;;;;;;AAuCA,SAAgB,EAAsB,GAA8B;CAClE,IAAM,EAAE,qBAAkB,wBAAqB,cAAW,QAAQ,GAQ5D,IAAmB,EAAsB,yBAAyB,EAClE,IAAgB,EAAsB,sBAAsB,EAC5D,IAAiB,EAAsB,uBAAuB,EAC9D,IAAmB,IAAmB,EAAQ,EAAiB,QAAS,IACxE,IAAgB,IAAgB,EAAQ,EAAc,QAAS,IAC/D,IAAiB,IAAiB,EAAQ,EAAe,QAAS,IAGlE,KAAY,GAAc,OACZ,EAAK,SAAS,IAAI,GAAG,EAAK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GACN,CAAA;EACT,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdminNotificationRoutes.d.ts","sourceRoot":"","sources":["../src/AdminNotificationRoutes.tsx"],"names":[],"mappings":"AAqFA,wBAAgB,uBAAuB,4CA4FtC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { useNotification as e } from "./providers/NotificationProvider.js";
|
|
2
|
+
import { NOTIFICATION_PERMISSIONS as t } from "./constants/permissions.js";
|
|
3
|
+
import { NotificationCenterPage as n } from "./pages/NotificationCenterPage.js";
|
|
4
|
+
import { NotificationLandingPage as r } from "./pages/NotificationLandingPage.js";
|
|
5
|
+
import { Suspense as i, lazy as a, useEffect as o } from "react";
|
|
6
|
+
import { PermissionGate as s } from "@burdenoff/fe-libs/shared/components";
|
|
7
|
+
import { useFeatureFlagDetails as c } from "@burdenoff/fe-libs/shared/feature-flags";
|
|
8
|
+
import { Navigate as l, Route as u, Routes as d, useNavigate as f } from "react-router-dom";
|
|
9
|
+
import { useGlobalUi as p } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
10
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
11
|
+
//#region src/AdminNotificationRoutes.tsx
|
|
12
|
+
var g = a(() => import("./pages/NotificationHistoryAdminPage.js").then((e) => ({ default: e.NotificationHistoryAdminPage }))), _ = a(() => import("./pages/NotificationTemplatesPage.js").then((e) => ({ default: e.NotificationTemplatesPage }))), v = a(() => import("./pages/TemplateEditorPage.js").then((e) => ({ default: e.TemplateEditorPage }))), y = a(() => import("./pages/CreateNotificationPage.js").then((e) => ({ default: e.CreateNotificationPage }))), b = a(() => import("./pages/NotificationTopicsPage.js").then((e) => ({ default: e.NotificationTopicsPage })));
|
|
13
|
+
function x() {
|
|
14
|
+
return /* @__PURE__ */ m("div", {
|
|
15
|
+
className: "flex h-64 items-center justify-center",
|
|
16
|
+
children: /* @__PURE__ */ m("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" })
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function S() {
|
|
20
|
+
let { showToast: t } = p(), n = f(), { basePath: r } = e();
|
|
21
|
+
return o(() => {
|
|
22
|
+
t("You do not have permission to access that notification page.", "warning"), n(`${r}/center`, { replace: !0 });
|
|
23
|
+
}, []), null;
|
|
24
|
+
}
|
|
25
|
+
function C(e) {
|
|
26
|
+
let { children: t, ...n } = e;
|
|
27
|
+
return /* @__PURE__ */ m(s, {
|
|
28
|
+
permission: n.permission,
|
|
29
|
+
permissions: n.permissions,
|
|
30
|
+
requireAll: n.requireAll,
|
|
31
|
+
loading: /* @__PURE__ */ m(x, {}),
|
|
32
|
+
fallback: /* @__PURE__ */ m(S, {}),
|
|
33
|
+
children: t
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function w() {
|
|
37
|
+
let e = c("notification.templates"), a = c("notification.create"), o = c("notification.history"), s = e ? !!e.value : !1, f = a ? !!a.value : !1, p = o ? !!o.value : !1;
|
|
38
|
+
return /* @__PURE__ */ m(i, {
|
|
39
|
+
fallback: /* @__PURE__ */ m(x, {}),
|
|
40
|
+
children: /* @__PURE__ */ h(d, { children: [
|
|
41
|
+
/* @__PURE__ */ m(u, {
|
|
42
|
+
index: !0,
|
|
43
|
+
element: /* @__PURE__ */ m(r, {})
|
|
44
|
+
}),
|
|
45
|
+
/* @__PURE__ */ m(u, {
|
|
46
|
+
path: "center",
|
|
47
|
+
element: /* @__PURE__ */ m(n, {})
|
|
48
|
+
}),
|
|
49
|
+
p && /* @__PURE__ */ m(u, {
|
|
50
|
+
path: "history",
|
|
51
|
+
element: /* @__PURE__ */ m(g, {})
|
|
52
|
+
}),
|
|
53
|
+
s && /* @__PURE__ */ m(u, {
|
|
54
|
+
path: "templates",
|
|
55
|
+
element: /* @__PURE__ */ m(C, {
|
|
56
|
+
permissions: [
|
|
57
|
+
t.TEMPLATE_LIST,
|
|
58
|
+
t.TEMPLATE_CREATE,
|
|
59
|
+
t.TEMPLATE_UPDATE,
|
|
60
|
+
t.TEMPLATE_DELETE
|
|
61
|
+
],
|
|
62
|
+
children: /* @__PURE__ */ m(_, {})
|
|
63
|
+
})
|
|
64
|
+
}),
|
|
65
|
+
s && /* @__PURE__ */ m(u, {
|
|
66
|
+
path: "templates/new",
|
|
67
|
+
element: /* @__PURE__ */ m(C, {
|
|
68
|
+
permission: t.TEMPLATE_CREATE,
|
|
69
|
+
children: /* @__PURE__ */ m(v, {})
|
|
70
|
+
})
|
|
71
|
+
}),
|
|
72
|
+
s && /* @__PURE__ */ m(u, {
|
|
73
|
+
path: "templates/:templateId",
|
|
74
|
+
element: /* @__PURE__ */ m(C, {
|
|
75
|
+
permission: t.TEMPLATE_UPDATE,
|
|
76
|
+
children: /* @__PURE__ */ m(v, {})
|
|
77
|
+
})
|
|
78
|
+
}),
|
|
79
|
+
f && /* @__PURE__ */ m(u, {
|
|
80
|
+
path: "create",
|
|
81
|
+
element: /* @__PURE__ */ m(C, {
|
|
82
|
+
permissions: [t.NOTIFICATION_CREATE, t.NOTIFICATION_SEND],
|
|
83
|
+
requireAll: !0,
|
|
84
|
+
children: /* @__PURE__ */ m(y, {})
|
|
85
|
+
})
|
|
86
|
+
}),
|
|
87
|
+
f && /* @__PURE__ */ m(u, {
|
|
88
|
+
path: "topics",
|
|
89
|
+
element: /* @__PURE__ */ m(C, {
|
|
90
|
+
permission: t.NOTIFICATION_CREATE,
|
|
91
|
+
children: /* @__PURE__ */ m(b, {})
|
|
92
|
+
})
|
|
93
|
+
}),
|
|
94
|
+
/* @__PURE__ */ m(u, {
|
|
95
|
+
path: "*",
|
|
96
|
+
element: /* @__PURE__ */ m(l, {
|
|
97
|
+
to: "..",
|
|
98
|
+
replace: !0,
|
|
99
|
+
relative: "path"
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
] })
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { w as AdminNotificationRoutes };
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=AdminNotificationRoutes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdminNotificationRoutes.js","names":[],"sources":["../src/AdminNotificationRoutes.tsx"],"sourcesContent":["import { lazy, Suspense, useEffect, type ReactNode } from 'react';\nimport { Navigate, Route, Routes, useNavigate } from 'react-router-dom';\nimport { useFeatureFlagDetails } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { PermissionGate } from '@burdenoff/fe-libs/shared/components';\nimport { useGlobalUi } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { NOTIFICATION_PERMISSIONS, type NotificationPermission } from './constants/permissions';\nimport { useNotification } from './providers/NotificationProvider';\n\n// Eager load - Primary landing page\nimport { NotificationCenterPage } from './pages/NotificationCenterPage';\nimport { NotificationLandingPage } from './pages/NotificationLandingPage';\n\n// Lazy load - Secondary pages\nconst NotificationHistoryAdminPage = lazy(() =>\n import('./pages/NotificationHistoryAdminPage').then((m) => ({\n default: m.NotificationHistoryAdminPage,\n }))\n);\nconst NotificationTemplatesPage = lazy(() =>\n import('./pages/NotificationTemplatesPage').then((m) => ({\n default: m.NotificationTemplatesPage,\n }))\n);\nconst TemplateEditorPage = lazy(() =>\n import('./pages/TemplateEditorPage').then((m) => ({ default: m.TemplateEditorPage }))\n);\nconst CreateNotificationPage = lazy(() =>\n import('./pages/CreateNotificationPage').then((m) => ({ default: m.CreateNotificationPage }))\n);\nconst NotificationTopicsPage = lazy(() =>\n import('./pages/NotificationTopicsPage').then((m) => ({ default: m.NotificationTopicsPage }))\n);\n\n// Loading fallback component\nfunction PageLoader() {\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// Pair toast + programmatic navigation in one effect to avoid <Navigate> unmounting before the toast fires.\n// Uses absolute `${basePath}/center` because relative `../center` resolves wrong from nested paths like `/templates/new`.\nfunction AccessDeniedRedirect() {\n const { showToast } = useGlobalUi();\n const navigate = useNavigate();\n const { basePath } = useNotification();\n useEffect(() => {\n showToast('You do not have permission to access that notification page.', 'warning');\n navigate(`${basePath}/center`, { replace: true });\n // Run once per access-denied mount; re-running on hook identity changes would duplicate the toast.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return null;\n}\n\n// Discriminated union: callers must pass exactly one of `permission` / `permissions`.\ntype AdminRouteGateProps = {\n children: ReactNode;\n} & (\n | { permission: NotificationPermission; permissions?: never; requireAll?: never }\n | {\n permission?: never;\n permissions: NotificationPermission[];\n requireAll?: boolean;\n }\n);\n\nfunction AdminRouteGate(props: AdminRouteGateProps) {\n const { children, ...gateProps } = props;\n return (\n <PermissionGate\n permission={gateProps.permission}\n permissions={gateProps.permissions}\n requireAll={gateProps.requireAll}\n loading={<PageLoader />}\n fallback={<AccessDeniedRedirect />}\n >\n {children}\n </PermissionGate>\n );\n}\n\n// Admin-app router for the notification MFE. Admin routes are wrapped in PermissionGate.\nexport function AdminNotificationRoutes() {\n // Explicit `false` fallback prevents provider's default-allow from leaking unseeded flags.\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 return (\n <Suspense fallback={<PageLoader />}>\n <Routes>\n {/* Tabbed landing - default route */}\n <Route index element={<NotificationLandingPage />} />\n\n {/* User-facing routes (all users) */}\n <Route path=\"center\" element={<NotificationCenterPage />} />\n {historyEnabled && <Route path=\"history\" element={<NotificationHistoryAdminPage />} />}\n\n {/* Gate admits any actor with read or any write permission; page disables write actions for read-only. */}\n {templatesEnabled && (\n <Route\n path=\"templates\"\n element={\n <AdminRouteGate\n permissions={[\n NOTIFICATION_PERMISSIONS.TEMPLATE_LIST,\n NOTIFICATION_PERMISSIONS.TEMPLATE_CREATE,\n NOTIFICATION_PERMISSIONS.TEMPLATE_UPDATE,\n NOTIFICATION_PERMISSIONS.TEMPLATE_DELETE,\n ]}\n >\n <NotificationTemplatesPage />\n </AdminRouteGate>\n }\n />\n )}\n {templatesEnabled && (\n <Route\n path=\"templates/new\"\n element={\n <AdminRouteGate permission={NOTIFICATION_PERMISSIONS.TEMPLATE_CREATE}>\n <TemplateEditorPage />\n </AdminRouteGate>\n }\n />\n )}\n {templatesEnabled && (\n <Route\n path=\"templates/:templateId\"\n element={\n <AdminRouteGate permission={NOTIFICATION_PERMISSIONS.TEMPLATE_UPDATE}>\n <TemplateEditorPage />\n </AdminRouteGate>\n }\n />\n )}\n\n {/* Admin routes - Create/Send Notification (wrapped in PermissionGate) */}\n {createEnabled && (\n <Route\n path=\"create\"\n element={\n <AdminRouteGate\n permissions={[\n NOTIFICATION_PERMISSIONS.NOTIFICATION_CREATE,\n NOTIFICATION_PERMISSIONS.NOTIFICATION_SEND,\n ]}\n requireAll\n >\n <CreateNotificationPage />\n </AdminRouteGate>\n }\n />\n )}\n {/* Topics CRUD maps to `notification:create` per backend @rbac — tracked in BOFF-2386. */}\n {createEnabled && (\n <Route\n path=\"topics\"\n element={\n <AdminRouteGate permission={NOTIFICATION_PERMISSIONS.NOTIFICATION_CREATE}>\n <NotificationTopicsPage />\n </AdminRouteGate>\n }\n />\n )}\n\n {/* Catch-all route - redirect to index using path-relative navigation */}\n <Route path=\"*\" element={<Navigate to=\"..\" replace relative=\"path\" />} />\n </Routes>\n </Suspense>\n );\n}\n"],"mappings":";;;;;;;;;;;AAaA,IAAM,IAA+B,QACnC,OAAO,2CAAwC,MAAM,OAAO,EAC1D,SAAS,EAAE,8BACZ,EAAE,CACJ,EACK,IAA4B,QAChC,OAAO,wCAAqC,MAAM,OAAO,EACvD,SAAS,EAAE,2BACZ,EAAE,CACJ,EACK,IAAqB,QACzB,OAAO,iCAA8B,MAAM,OAAO,EAAE,SAAS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