@payez/next-mvp 3.5.0 → 3.6.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 (32) hide show
  1. package/dist/api-handlers/admin/index.d.ts +1 -0
  2. package/dist/api-handlers/admin/index.js +3 -1
  3. package/dist/api-handlers/admin/stats.d.ts +21 -0
  4. package/dist/api-handlers/admin/stats.js +240 -0
  5. package/dist/auth/utils/idp-client.js +1 -0
  6. package/dist/components/account/MobileNavDrawer.d.ts +32 -0
  7. package/dist/components/account/MobileNavDrawer.js +81 -0
  8. package/dist/components/account/UserAvatarMenu.js +5 -1
  9. package/dist/components/account/index.d.ts +2 -0
  10. package/dist/components/account/index.js +5 -2
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.js +2 -1
  13. package/dist/pages/admin-page-permissions/PagePermissionsAdminPage.d.ts +18 -0
  14. package/dist/pages/admin-page-permissions/PagePermissionsAdminPage.js +276 -0
  15. package/dist/pages/admin-page-permissions/index.d.ts +6 -0
  16. package/dist/pages/admin-page-permissions/index.js +13 -0
  17. package/dist/pages/admin-roles/RolesAdminPage.d.ts +12 -11
  18. package/dist/pages/admin-roles/RolesAdminPage.js +249 -66
  19. package/dist/routes/auth/session.d.ts +1 -30
  20. package/dist/routes/auth/session.js +3 -4
  21. package/package.json +6 -1
  22. package/src/api-handlers/admin/index.ts +5 -0
  23. package/src/api-handlers/admin/stats.ts +240 -0
  24. package/src/auth/utils/idp-client.ts +1 -0
  25. package/src/components/account/MobileNavDrawer.tsx +305 -0
  26. package/src/components/account/UserAvatarMenu.tsx +47 -17
  27. package/src/components/account/index.ts +5 -0
  28. package/src/index.ts +2 -2
  29. package/src/pages/admin-page-permissions/PagePermissionsAdminPage.tsx +527 -0
  30. package/src/pages/admin-page-permissions/index.ts +7 -0
  31. package/src/pages/admin-roles/RolesAdminPage.tsx +494 -318
  32. package/src/routes/auth/session.ts +3 -4
@@ -0,0 +1,527 @@
1
+ /**
2
+ * Page Permissions Admin Page (/admin/page-permissions)
3
+ *
4
+ * Design: Aurum (DESIGN_SPEC.md)
5
+ * Control which roles can access which pages
6
+ *
7
+ * Three sections:
8
+ * 1. Search & Filters — Find pages by route or category
9
+ * 2. Pages & Role Requirements — Table showing pages and their role assignments
10
+ * 3. Change History — Audit log of permission changes
11
+ *
12
+ * Design Principles:
13
+ * - No shadows, gradients, or animation
14
+ * - One accent color (blue #0066cc)
15
+ * - Inline interactions (no modals)
16
+ * - Scan-friendly tables and lists
17
+ */
18
+
19
+ 'use client';
20
+
21
+ import React, { useState } from 'react';
22
+
23
+ // Mock data
24
+ const MOCK_PAGES = [
25
+ {
26
+ id: 1,
27
+ route: '/dashboard',
28
+ displayName: 'Dashboard',
29
+ requires2fa: false,
30
+ roles: [],
31
+ category: 'user',
32
+ },
33
+ {
34
+ id: 2,
35
+ route: '/admin',
36
+ displayName: 'Admin Dashboard',
37
+ requires2fa: true,
38
+ roles: ['SiteAdmin', 'ClientAdmin'],
39
+ category: 'admin',
40
+ },
41
+ {
42
+ id: 3,
43
+ route: '/admin/users',
44
+ displayName: 'User Management',
45
+ requires2fa: true,
46
+ roles: ['SiteAdmin'],
47
+ category: 'admin',
48
+ },
49
+ {
50
+ id: 4,
51
+ route: '/account/security',
52
+ displayName: 'Security Settings',
53
+ requires2fa: true,
54
+ roles: [],
55
+ category: 'account',
56
+ },
57
+ {
58
+ id: 5,
59
+ route: '/interview-practice',
60
+ displayName: 'Interview Practice',
61
+ requires2fa: false,
62
+ roles: ['ClientAdmin'],
63
+ category: 'user',
64
+ },
65
+ ];
66
+
67
+ const MOCK_CHANGES = [
68
+ {
69
+ timestamp: '3/10/2026, 10:30 AM',
70
+ event: '/admin/users role requirement changed: Added ClientAdmin by Admin User',
71
+ },
72
+ {
73
+ timestamp: '3/10/2026, 10:15 AM',
74
+ event: '/dashboard updated: 2FA requirement removed by Admin User',
75
+ },
76
+ {
77
+ timestamp: '3/9/2026, 3:45 PM',
78
+ event: '/interview-practice role requirement changed: Added SiteAdmin by Admin User',
79
+ },
80
+ ];
81
+
82
+ interface PagePermission {
83
+ id: number;
84
+ route: string;
85
+ displayName: string;
86
+ requires2fa: boolean;
87
+ roles: string[];
88
+ category: string;
89
+ }
90
+
91
+ const CATEGORIES = ['All Pages', 'Admin Pages', 'Account Pages', 'User Pages'];
92
+
93
+ const categoryMap: { [key: string]: string } = {
94
+ 'All Pages': '',
95
+ 'Admin Pages': 'admin',
96
+ 'Account Pages': 'account',
97
+ 'User Pages': 'user',
98
+ };
99
+
100
+ export default function PagePermissionsAdminPage() {
101
+ const [pages, setPages] = useState<PagePermission[]>(MOCK_PAGES);
102
+ const [searchQuery, setSearchQuery] = useState('');
103
+ const [activeFilter, setActiveFilter] = useState('All Pages');
104
+ const [message, setMessage] = useState<string | null>(null);
105
+ const [editingPageId, setEditingPageId] = useState<number | null>(null);
106
+ const [tempRoles, setTempRoles] = useState<string[]>([]);
107
+
108
+ const filteredPages = pages.filter((page) => {
109
+ const matchesSearch =
110
+ page.route.toLowerCase().includes(searchQuery.toLowerCase()) ||
111
+ page.displayName.toLowerCase().includes(searchQuery.toLowerCase());
112
+
113
+ const categoryFilter = categoryMap[activeFilter];
114
+ const matchesCategory = !categoryFilter || page.category === categoryFilter;
115
+
116
+ return matchesSearch && matchesCategory;
117
+ });
118
+
119
+ const handleEditRoles = (pageId: number, currentRoles: string[]) => {
120
+ setEditingPageId(pageId);
121
+ setTempRoles([...currentRoles]);
122
+ };
123
+
124
+ const handleToggleRole = (role: string) => {
125
+ setTempRoles((prev) =>
126
+ prev.includes(role) ? prev.filter((r) => r !== role) : [...prev, role]
127
+ );
128
+ };
129
+
130
+ const handleSaveRoles = (pageId: number) => {
131
+ setPages((prev) =>
132
+ prev.map((p) => (p.id === pageId ? { ...p, roles: tempRoles } : p))
133
+ );
134
+ setMessage('Page updated');
135
+ setEditingPageId(null);
136
+ setTimeout(() => setMessage(null), 3000);
137
+ };
138
+
139
+ const handleRemoveRole = (pageId: number, role: string) => {
140
+ setPages((prev) =>
141
+ prev.map((p) =>
142
+ p.id === pageId ? { ...p, roles: p.roles.filter((r) => r !== role) } : p
143
+ )
144
+ );
145
+ setMessage('Role removed');
146
+ setTimeout(() => setMessage(null), 3000);
147
+ };
148
+
149
+ return (
150
+ <div style={{ background: '#f8f8f8', minHeight: '100vh', padding: '40px 20px' }}>
151
+ <div style={{ maxWidth: '1200px', margin: '0 auto' }}>
152
+ {/* Header */}
153
+ <div style={{ marginBottom: '40px' }}>
154
+ <h1
155
+ style={{
156
+ fontSize: '32px',
157
+ fontWeight: 400,
158
+ color: '#333',
159
+ marginBottom: '8px',
160
+ }}
161
+ >
162
+ Page Permissions
163
+ </h1>
164
+ <p style={{ fontSize: '16px', color: '#666', fontWeight: 400 }}>
165
+ Control which roles can access which pages
166
+ </p>
167
+ </div>
168
+
169
+ <div style={{ height: '1px', background: '#e0e0e0', margin: '24px 0' }} />
170
+
171
+ {/* Section 1: Search & Filters */}
172
+ <section style={{ marginBottom: '40px' }}>
173
+ <div style={{ marginBottom: '16px' }}>
174
+ <input
175
+ type="text"
176
+ placeholder="Search pages..."
177
+ value={searchQuery}
178
+ onChange={(e) => setSearchQuery(e.target.value)}
179
+ style={{
180
+ width: '100%',
181
+ padding: '10px 14px',
182
+ fontSize: '14px',
183
+ border: '1px solid #e0e0e0',
184
+ borderRadius: '4px',
185
+ background: 'white',
186
+ boxSizing: 'border-box',
187
+ }}
188
+ />
189
+ </div>
190
+
191
+ <div style={{ display: 'flex', gap: '8px', flexWrap: 'wrap' }}>
192
+ {CATEGORIES.map((cat) => (
193
+ <button
194
+ key={cat}
195
+ onClick={() => setActiveFilter(cat)}
196
+ style={{
197
+ padding: '8px 14px',
198
+ fontSize: '13px',
199
+ border: activeFilter === cat ? 'none' : '1px solid #e0e0e0',
200
+ borderRadius: '4px',
201
+ background: activeFilter === cat ? '#0066cc' : 'white',
202
+ color: activeFilter === cat ? 'white' : '#333',
203
+ cursor: 'pointer',
204
+ transition: 'all 0.2s',
205
+ }}
206
+ onMouseEnter={(e) => {
207
+ if (activeFilter !== cat) {
208
+ e.currentTarget.style.background = '#f5f5f5';
209
+ }
210
+ }}
211
+ onMouseLeave={(e) => {
212
+ if (activeFilter !== cat) {
213
+ e.currentTarget.style.background = 'white';
214
+ }
215
+ }}
216
+ >
217
+ {cat}
218
+ </button>
219
+ ))}
220
+ </div>
221
+ </section>
222
+
223
+ <div style={{ height: '1px', background: '#e0e0e0', margin: '24px 0' }} />
224
+
225
+ {/* Message */}
226
+ {message && (
227
+ <div
228
+ style={{
229
+ padding: '8px 12px',
230
+ background: '#e8f5e9',
231
+ color: '#2e7d32',
232
+ borderRadius: '4px',
233
+ marginBottom: '12px',
234
+ fontSize: '13px',
235
+ }}
236
+ >
237
+ ✓ {message}
238
+ </div>
239
+ )}
240
+
241
+ {/* Section 2: Pages & Role Requirements */}
242
+ <section style={{ marginBottom: '60px' }}>
243
+ <h2
244
+ style={{
245
+ fontSize: '18px',
246
+ fontWeight: 400,
247
+ color: '#666',
248
+ marginBottom: '24px',
249
+ textTransform: 'uppercase',
250
+ letterSpacing: '1px',
251
+ }}
252
+ >
253
+ Pages & Permissions
254
+ </h2>
255
+
256
+ <table
257
+ style={{
258
+ width: '100%',
259
+ borderCollapse: 'collapse',
260
+ background: 'white',
261
+ border: '1px solid #e0e0e0',
262
+ borderRadius: '4px',
263
+ overflow: 'hidden',
264
+ }}
265
+ >
266
+ <thead>
267
+ <tr style={{ background: '#f8f8f8', borderBottom: '1px solid #e0e0e0' }}>
268
+ <th
269
+ style={{
270
+ padding: '16px',
271
+ textAlign: 'left',
272
+ fontSize: '12px',
273
+ color: '#999',
274
+ textTransform: 'uppercase',
275
+ letterSpacing: '0.5px',
276
+ fontWeight: 'normal',
277
+ }}
278
+ >
279
+ Route
280
+ </th>
281
+ <th
282
+ style={{
283
+ padding: '16px',
284
+ textAlign: 'left',
285
+ fontSize: '12px',
286
+ color: '#999',
287
+ textTransform: 'uppercase',
288
+ letterSpacing: '0.5px',
289
+ fontWeight: 'normal',
290
+ }}
291
+ >
292
+ Display Name
293
+ </th>
294
+ <th
295
+ style={{
296
+ padding: '16px',
297
+ textAlign: 'center',
298
+ fontSize: '12px',
299
+ color: '#999',
300
+ textTransform: 'uppercase',
301
+ letterSpacing: '0.5px',
302
+ fontWeight: 'normal',
303
+ }}
304
+ >
305
+ 2FA
306
+ </th>
307
+ <th
308
+ style={{
309
+ padding: '16px',
310
+ textAlign: 'left',
311
+ fontSize: '12px',
312
+ color: '#999',
313
+ textTransform: 'uppercase',
314
+ letterSpacing: '0.5px',
315
+ fontWeight: 'normal',
316
+ }}
317
+ >
318
+ Roles
319
+ </th>
320
+ </tr>
321
+ </thead>
322
+ <tbody>
323
+ {filteredPages.map((page) => (
324
+ <tr
325
+ key={page.id}
326
+ style={{
327
+ borderBottom: '1px solid #e0e0e0',
328
+ height: '48px',
329
+ }}
330
+ onMouseEnter={(e) => (e.currentTarget.style.background = '#f5f5f5')}
331
+ onMouseLeave={(e) => (e.currentTarget.style.background = 'white')}
332
+ >
333
+ <td
334
+ style={{
335
+ padding: '16px',
336
+ fontSize: '12px',
337
+ fontFamily: 'Courier New, monospace',
338
+ color: '#333',
339
+ }}
340
+ title="Click to copy"
341
+ >
342
+ {page.route}
343
+ </td>
344
+ <td style={{ padding: '16px', fontSize: '14px', color: '#333' }}>
345
+ {page.displayName}
346
+ </td>
347
+ <td style={{ padding: '16px', textAlign: 'center', fontSize: '14px' }}>
348
+ {page.requires2fa ? '✓' : '✕'}
349
+ </td>
350
+ <td style={{ padding: '16px', fontSize: '13px' }}>
351
+ {editingPageId === page.id ? (
352
+ <div style={{ display: 'flex', gap: '12px', alignItems: 'center' }}>
353
+ <div style={{ display: 'flex', gap: '12px' }}>
354
+ {['SiteAdmin', 'ClientAdmin'].map((role) => (
355
+ <label
356
+ key={role}
357
+ style={{
358
+ display: 'flex',
359
+ alignItems: 'center',
360
+ gap: '6px',
361
+ cursor: 'pointer',
362
+ }}
363
+ >
364
+ <input
365
+ type="checkbox"
366
+ checked={tempRoles.includes(role)}
367
+ onChange={() => handleToggleRole(role)}
368
+ style={{ cursor: 'pointer' }}
369
+ />
370
+ <span style={{ fontSize: '12px', color: '#333' }}>{role}</span>
371
+ </label>
372
+ ))}
373
+ </div>
374
+ <div style={{ display: 'flex', gap: '6px' }}>
375
+ <button
376
+ onClick={() => handleSaveRoles(page.id)}
377
+ style={{
378
+ padding: '6px 10px',
379
+ background: '#0066cc',
380
+ color: 'white',
381
+ border: 'none',
382
+ borderRadius: '4px',
383
+ cursor: 'pointer',
384
+ fontSize: '11px',
385
+ }}
386
+ onMouseEnter={(e) => (e.currentTarget.style.background = '#0052a3')}
387
+ onMouseLeave={(e) => (e.currentTarget.style.background = '#0066cc')}
388
+ >
389
+ Save
390
+ </button>
391
+ <button
392
+ onClick={() => setEditingPageId(null)}
393
+ style={{
394
+ padding: '6px 10px',
395
+ background: 'white',
396
+ color: '#333',
397
+ border: '1px solid #e0e0e0',
398
+ borderRadius: '4px',
399
+ cursor: 'pointer',
400
+ fontSize: '11px',
401
+ }}
402
+ onMouseEnter={(e) => (e.currentTarget.style.background = '#f5f5f5')}
403
+ onMouseLeave={(e) => (e.currentTarget.style.background = 'white')}
404
+ >
405
+ Cancel
406
+ </button>
407
+ </div>
408
+ </div>
409
+ ) : (
410
+ <div style={{ display: 'flex', gap: '6px', alignItems: 'center' }}>
411
+ {page.roles.length > 0 ? (
412
+ <>
413
+ {page.roles.map((role) => (
414
+ <span
415
+ key={role}
416
+ style={{
417
+ background: '#e3f2fd',
418
+ color: '#0066cc',
419
+ padding: '4px 8px',
420
+ borderRadius: '3px',
421
+ fontSize: '12px',
422
+ display: 'inline-flex',
423
+ alignItems: 'center',
424
+ gap: '4px',
425
+ }}
426
+ >
427
+ {role}
428
+ <button
429
+ onClick={() => handleRemoveRole(page.id, role)}
430
+ style={{
431
+ background: 'none',
432
+ border: 'none',
433
+ color: '#0066cc',
434
+ cursor: 'pointer',
435
+ fontSize: '12px',
436
+ padding: '0',
437
+ lineHeight: '1',
438
+ }}
439
+ >
440
+
441
+ </button>
442
+ </span>
443
+ ))}
444
+ <button
445
+ onClick={() => handleEditRoles(page.id, page.roles)}
446
+ style={{
447
+ padding: '4px 8px',
448
+ background: 'white',
449
+ color: '#0066cc',
450
+ border: '1px solid #e0e0e0',
451
+ borderRadius: '3px',
452
+ cursor: 'pointer',
453
+ fontSize: '11px',
454
+ }}
455
+ onMouseEnter={(e) => (e.currentTarget.style.background = '#f5f5f5')}
456
+ onMouseLeave={(e) => (e.currentTarget.style.background = 'white')}
457
+ >
458
+ +
459
+ </button>
460
+ </>
461
+ ) : (
462
+ <button
463
+ onClick={() => handleEditRoles(page.id, [])}
464
+ style={{
465
+ padding: '4px 8px',
466
+ background: 'white',
467
+ color: '#0066cc',
468
+ border: '1px solid #e0e0e0',
469
+ borderRadius: '3px',
470
+ cursor: 'pointer',
471
+ fontSize: '11px',
472
+ }}
473
+ onMouseEnter={(e) => (e.currentTarget.style.background = '#f5f5f5')}
474
+ onMouseLeave={(e) => (e.currentTarget.style.background = 'white')}
475
+ >
476
+ + Add Role
477
+ </button>
478
+ )}
479
+ </div>
480
+ )}
481
+ </td>
482
+ </tr>
483
+ ))}
484
+ </tbody>
485
+ </table>
486
+ <div style={{ marginTop: '12px', fontSize: '12px', color: '#999' }}>
487
+ {filteredPages.length} of {pages.length} pages shown
488
+ </div>
489
+ </section>
490
+
491
+ <div style={{ height: '1px', background: '#e0e0e0', margin: '24px 0' }} />
492
+
493
+ {/* Section 3: Change History */}
494
+ <section>
495
+ <h2
496
+ style={{
497
+ fontSize: '18px',
498
+ fontWeight: 400,
499
+ color: '#666',
500
+ marginBottom: '24px',
501
+ textTransform: 'uppercase',
502
+ letterSpacing: '1px',
503
+ }}
504
+ >
505
+ Recent Changes
506
+ </h2>
507
+ <div style={{ background: 'white', border: '1px solid #e0e0e0', borderRadius: '4px' }}>
508
+ {MOCK_CHANGES.map((change, idx) => (
509
+ <div
510
+ key={idx}
511
+ style={{
512
+ padding: '16px',
513
+ borderBottom: idx < MOCK_CHANGES.length - 1 ? '1px solid #e0e0e0' : 'none',
514
+ }}
515
+ >
516
+ <div style={{ fontSize: '12px', color: '#999', marginBottom: '4px' }}>
517
+ {change.timestamp}
518
+ </div>
519
+ <div style={{ fontSize: '14px', color: '#333' }}>{change.event}</div>
520
+ </div>
521
+ ))}
522
+ </div>
523
+ </section>
524
+ </div>
525
+ </div>
526
+ );
527
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Page Permissions Admin exports
3
+ *
4
+ * - PagePermissionsAdminPage: Admin interface for managing page permissions (/admin/page-permissions)
5
+ */
6
+
7
+ export { default as PagePermissionsAdminPage } from './PagePermissionsAdminPage';