@burdenoff/microfe-notification 2026.608.1 → 2026.624.2
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/dist/components/FeatureDisabledPage.js +1 -1
- package/dist/components/FeatureDisabledPage.js.map +1 -1
- package/dist/components/NotificationBell.js +2 -2
- package/dist/components/NotificationBell.js.map +1 -1
- package/dist/components/NotificationCard.js +4 -4
- package/dist/components/NotificationCard.js.map +1 -1
- package/dist/components/NotificationPanel.js +3 -3
- package/dist/components/NotificationPanel.js.map +1 -1
- package/dist/components/RecipientSelector.js +8 -8
- package/dist/components/RecipientSelector.js.map +1 -1
- package/dist/components/TemplatePreview.js +6 -6
- package/dist/components/TemplatePreview.js.map +1 -1
- package/dist/pages/CreateNotificationPage.js +1 -1
- package/dist/pages/CreateNotificationPage.js.map +1 -1
- package/dist/pages/NotificationCenterPage.js +3 -3
- package/dist/pages/NotificationCenterPage.js.map +1 -1
- package/dist/pages/NotificationHistoryAdminPage.js +5 -5
- package/dist/pages/NotificationHistoryAdminPage.js.map +1 -1
- package/dist/pages/NotificationHistoryPage.js +3 -3
- package/dist/pages/NotificationHistoryPage.js.map +1 -1
- package/dist/pages/NotificationPreferencesPage.js +3 -3
- package/dist/pages/NotificationPreferencesPage.js.map +1 -1
- package/dist/pages/NotificationTemplatesPage.js +4 -4
- package/dist/pages/NotificationTemplatesPage.js.map +1 -1
- package/dist/pages/NotificationTopicsPage.js +4 -4
- package/dist/pages/NotificationTopicsPage.js.map +1 -1
- package/dist/pages/TemplateEditorPage.js +8 -8
- package/dist/pages/TemplateEditorPage.js.map +1 -1
- package/dist/utils/index.js +2 -2
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -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-dom';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\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-300\">\n {/* Header */}\n <div className=\"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between\">\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\n onClick={() => navigate('new')}\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 hover:shadow-md\"\n >\n <Plus size={16} />\n {tr('notifTemplates.createTemplate', 'Create Template')}\n </button>\n )}\n </div>\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\"\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 <div className=\"flex flex-col gap-3 rounded-lg border border-default bg-surface p-4 sm:flex-row sm:items-center sm:justify-between\">\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 </div>\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 <div className=\"flex flex-col items-center justify-center h-48 gap-3\">\n <FileText size={32} className=\"text-tertiary\" />\n <p className=\"text-sm text-secondary\">\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 </p>\n </div>\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-surface border rounded-lg cursor-pointer transition-all duration-200 hover:bg-muted hover:shadow-md hover:-translate-y-0.5 ${selectedTemplateIds.has(template.id) ? 'border-accent-primary/50 ring-1 ring-accent-primary/20' : 'border-default'}`}\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-muted 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-muted rounded text-[10px]\">{template.slug}</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":";;;;;;;;;;;AAcA,IAAM,IAAgD;CACpD,eAAe;CACf,WAAW;CACX,QAAQ;CACR,OAAO;CACR,EAEK,IAAgD;CACpD,eAAe;CACf,WAAW;CACX,QAAQ;CACR,OAAO;CACR;AAED,SAAS,EAAW,GAA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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-dom';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\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 {/* Header */}\n <div className=\"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between\">\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\n onClick={() => navigate('new')}\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 hover:shadow-md\"\n >\n <Plus size={16} />\n {tr('notifTemplates.createTemplate', 'Create Template')}\n </button>\n )}\n </div>\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\"\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 <div className=\"flex flex-col gap-3 rounded-lg border border-default bg-surface p-4 sm:flex-row sm:items-center sm:justify-between\">\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 </div>\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 <div className=\"flex flex-col items-center justify-center h-48 gap-3\">\n <FileText size={32} className=\"text-tertiary\" />\n <p className=\"text-sm text-secondary\">\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 </p>\n </div>\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-surface border rounded-lg cursor-pointer transition-all duration-200 hover:bg-bg-sunken hover:shadow-md ${selectedTemplateIds.has(template.id) ? 'border-accent-primary/50 ring-1 ring-accent-primary/20' : 'border-default'}`}\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]\">{template.slug}</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":";;;;;;;;;;;AAcA,IAAM,IAAgD;CACpD,eAAe;CACf,WAAW;CACX,QAAQ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BAAC,OAAD;EAAK,WAAU;YACZ,EACC,mCACA,4DACD;EACG,CAAA"}
|
|
@@ -155,7 +155,7 @@ function m() {
|
|
|
155
155
|
isActive: !0
|
|
156
156
|
});
|
|
157
157
|
},
|
|
158
|
-
className: "rounded-md border border-default px-4 py-2 text-sm text-secondary hover:bg-
|
|
158
|
+
className: "rounded-md border border-default px-4 py-2 text-sm text-secondary hover:bg-bg-sunken",
|
|
159
159
|
children: m("notifications.cancelTopicEdit", "Cancel")
|
|
160
160
|
})]
|
|
161
161
|
})
|
|
@@ -195,11 +195,11 @@ function m() {
|
|
|
195
195
|
children: e.name
|
|
196
196
|
}),
|
|
197
197
|
/* @__PURE__ */ u("span", {
|
|
198
|
-
className: "rounded-full bg-
|
|
198
|
+
className: "rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary",
|
|
199
199
|
children: e.slug
|
|
200
200
|
}),
|
|
201
201
|
/* @__PURE__ */ u("span", {
|
|
202
|
-
className: "rounded-full bg-
|
|
202
|
+
className: "rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary",
|
|
203
203
|
children: e.type
|
|
204
204
|
})
|
|
205
205
|
]
|
|
@@ -230,7 +230,7 @@ function m() {
|
|
|
230
230
|
isActive: e.isActive
|
|
231
231
|
});
|
|
232
232
|
},
|
|
233
|
-
className: "rounded-md border border-default px-3 py-2 text-sm text-secondary hover:bg-
|
|
233
|
+
className: "rounded-md border border-default px-3 py-2 text-sm text-secondary hover:bg-bg-sunken",
|
|
234
234
|
children: m("notifications.edit", "Edit")
|
|
235
235
|
}), /* @__PURE__ */ d("button", {
|
|
236
236
|
type: "button",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationTopicsPage.js","names":[],"sources":["../../src/pages/NotificationTopicsPage.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { Plus, Save, Search, Trash2 } from 'lucide-react';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { useNotificationTopics } from '../hooks';\nimport { NOTIFICATION_PERMISSIONS } from '../constants/permissions';\nimport { useTr } from '../shared/hooks/useTr';\n\nconst topicTypeOptions = [\n { value: 'MARKETING', label: 'Marketing' },\n { value: 'TRANSACTIONAL', label: 'Transactional' },\n { value: 'SYSTEM', label: 'System' },\n { value: 'ALERT', label: 'Alert' },\n];\n\nfunction slugify(value: string) {\n return value\n .toLowerCase()\n .trim()\n .replace(/[^a-z0-9\\s-]/g, '')\n .replace(/\\s+/g, '-')\n .replace(/-+/g, '-');\n}\n\nexport function NotificationTopicsPage() {\n const tr = useTr();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const { topics, isLoading, createTopic, updateTopic, deleteTopic } = useNotificationTopics();\n const [search, setSearch] = useState('');\n const [editingId, setEditingId] = useState<string | null>(null);\n const [form, setForm] = useState({\n name: '',\n slug: '',\n description: '',\n type: 'MARKETING',\n isActive: true,\n });\n\n // Topics live under the `notification` resource type in the backend (see\n // `global-notification-svc/src/modules/notification/schema/mutations.gql`),\n // and create/update/delete all require `notification:create` per the\n // @rbac directive. SUPER_ADMIN bypass is inherited from PermissionProvider.\n const canManage = hasPermission(NOTIFICATION_PERMISSIONS.NOTIFICATION_CREATE);\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 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 (!canManage) {\n return (\n <div className=\"p-8 text-center text-text-secondary\">\n {tr(\n 'notifications.noPermissionTopics',\n \"You don't have permission to manage notification topics.\"\n )}\n </div>\n );\n }\n\n return (\n <div className=\"space-y-6 p-4 sm:p-6\">\n <div>\n <h1 className=\"text-2xl font-bold text-primary\">\n {tr('notifications.topicsTitle', 'Notification Topics')}\n </h1>\n <p className=\"mt-1 text-sm text-secondary\">\n {tr(\n 'notifications.topicsSubtitle',\n 'Create topics for campaigns so users can subscribe or unsubscribe with precision.'\n )}\n </p>\n </div>\n\n <div className=\"grid gap-6 xl:grid-cols-[380px,1fr]\">\n <form\n className=\"space-y-4 rounded-lg border border-default bg-surface p-4 shadow-sm\"\n onSubmit={async (event) => {\n event.preventDefault();\n\n if (!form.name.trim() || !form.slug.trim()) {\n return;\n }\n\n if (editingId) {\n await updateTopic(editingId, form);\n } else {\n await createTopic(form);\n }\n\n setEditingId(null);\n setForm({\n name: '',\n slug: '',\n description: '',\n type: 'MARKETING',\n isActive: true,\n });\n }}\n >\n <div className=\"flex items-center gap-2\">\n <Plus size={18} className=\"text-accent-primary\" />\n <h2 className=\"text-base font-semibold text-primary\">\n {editingId\n ? tr('notifications.editTopic', 'Edit Topic')\n : tr('notifications.createTopic', 'Create Topic')}\n </h2>\n </div>\n\n <label className=\"block space-y-1 text-sm text-secondary\">\n <span>{tr('notifications.topicName', 'Name')}</span>\n <input\n type=\"text\"\n value={form.name}\n onChange={(event) =>\n setForm((prev) => ({\n ...prev,\n name: event.target.value,\n slug: editingId ? prev.slug : slugify(event.target.value),\n }))\n }\n className=\"w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </label>\n\n <label className=\"block space-y-1 text-sm text-secondary\">\n <span>{tr('notifications.topicSlug', 'Slug')}</span>\n <input\n type=\"text\"\n value={form.slug}\n onChange={(event) =>\n setForm((prev) => ({ ...prev, slug: slugify(event.target.value) }))\n }\n className=\"w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </label>\n\n <label className=\"block space-y-1 text-sm text-secondary\">\n <span>{tr('notifications.topicType', 'Type')}</span>\n <select\n value={form.type}\n onChange={(event) => setForm((prev) => ({ ...prev, type: event.target.value }))}\n className=\"w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n >\n {topicTypeOptions.map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n </label>\n\n <label className=\"block space-y-1 text-sm text-secondary\">\n <span>{tr('notifications.topicDescription', 'Description')}</span>\n <textarea\n value={form.description}\n onChange={(event) =>\n setForm((prev) => ({ ...prev, description: event.target.value }))\n }\n rows={4}\n className=\"w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </label>\n\n <label className=\"flex items-center gap-2 text-sm text-secondary\">\n <input\n type=\"checkbox\"\n checked={form.isActive}\n onChange={(event) => setForm((prev) => ({ ...prev, isActive: event.target.checked }))}\n />\n <span>{tr('notifications.topicIsActive', 'Active topic')}</span>\n </label>\n\n <div className=\"flex items-center gap-3\">\n <button\n type=\"submit\"\n className=\"inline-flex items-center gap-2 rounded-md bg-accent-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90\"\n >\n <Save size={16} />\n {editingId\n ? tr('notifications.saveTopic', 'Save Topic')\n : tr('notifications.createTopicButton', 'Create Topic')}\n </button>\n\n {editingId && (\n <button\n type=\"button\"\n onClick={() => {\n setEditingId(null);\n setForm({\n name: '',\n slug: '',\n description: '',\n type: 'MARKETING',\n isActive: true,\n });\n }}\n className=\"rounded-md border border-default px-4 py-2 text-sm text-secondary hover:bg-muted\"\n >\n {tr('notifications.cancelTopicEdit', 'Cancel')}\n </button>\n )}\n </div>\n </form>\n\n <div className=\"space-y-4 rounded-lg border border-default bg-surface p-4 shadow-sm\">\n <div className=\"relative max-w-md\">\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 placeholder={tr('notifications.searchTopics', 'Search topics...')}\n className=\"w-full rounded-md border border-default bg-bg-canvas py-2 pl-9 pr-4 text-sm text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </div>\n\n <div className=\"space-y-3\">\n {isLoading ? (\n <div className=\"text-sm text-secondary\">\n {tr('notifications.loadingTopics', 'Loading topics...')}\n </div>\n ) : filteredTopics.length === 0 ? (\n <div className=\"text-sm text-secondary\">\n {tr('notifications.noTopicsFound', 'No topics found.')}\n </div>\n ) : (\n filteredTopics.map((topic) => (\n <div\n key={topic.id}\n className=\"flex flex-col gap-3 rounded-lg border border-default bg-bg-canvas p-4 sm:flex-row sm:items-start sm:justify-between\"\n >\n <div className=\"space-y-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h3 className=\"text-sm font-semibold text-primary\">{topic.name}</h3>\n <span className=\"rounded-full bg-muted px-2 py-0.5 text-xs text-secondary\">\n {topic.slug}\n </span>\n <span className=\"rounded-full bg-muted px-2 py-0.5 text-xs text-secondary\">\n {topic.type}\n </span>\n </div>\n {topic.description && (\n <p className=\"text-sm text-secondary\">{topic.description}</p>\n )}\n <p className=\"text-xs text-tertiary\">\n {tr('notifications.topicSubscribers', 'Subscribers')}: {topic.subscriberCount}\n </p>\n </div>\n\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => {\n setEditingId(topic.id);\n setForm({\n name: topic.name,\n slug: topic.slug,\n description: topic.description || '',\n type: topic.type,\n isActive: topic.isActive,\n });\n }}\n className=\"rounded-md border border-default px-3 py-2 text-sm text-secondary hover:bg-muted\"\n >\n {tr('notifications.edit', 'Edit')}\n </button>\n <button\n type=\"button\"\n onClick={() => deleteTopic(topic.id)}\n className=\"inline-flex items-center gap-2 rounded-md border border-status-error-border px-3 py-2 text-sm text-status-error-text hover:bg-status-error-bg-subtle\"\n >\n <Trash2 size={14} />\n {tr('notifications.delete', 'Delete')}\n </button>\n </div>\n </div>\n ))\n )}\n </div>\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAOA,IAAM,IAAmB;CACvB;EAAE,O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AAQ,MAAM,IAAM,CAAA,EACnB,EAAG,wBAAwB,SAAS,CAC9B;UACL;SACF;QA/CC,EAAM,GA+CP,CACN;KAEA,CAAA,CACF;MACF;KACF;MAvOJ,kBAAC,OAAD;EAAK,WAAU;YACZ,EACC,oCACA,2DACD;EACG,CAAA"}
|
|
1
|
+
{"version":3,"file":"NotificationTopicsPage.js","names":[],"sources":["../../src/pages/NotificationTopicsPage.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { Plus, Save, Search, Trash2 } from 'lucide-react';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { useNotificationTopics } from '../hooks';\nimport { NOTIFICATION_PERMISSIONS } from '../constants/permissions';\nimport { useTr } from '../shared/hooks/useTr';\n\nconst topicTypeOptions = [\n { value: 'MARKETING', label: 'Marketing' },\n { value: 'TRANSACTIONAL', label: 'Transactional' },\n { value: 'SYSTEM', label: 'System' },\n { value: 'ALERT', label: 'Alert' },\n];\n\nfunction slugify(value: string) {\n return value\n .toLowerCase()\n .trim()\n .replace(/[^a-z0-9\\s-]/g, '')\n .replace(/\\s+/g, '-')\n .replace(/-+/g, '-');\n}\n\nexport function NotificationTopicsPage() {\n const tr = useTr();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const { topics, isLoading, createTopic, updateTopic, deleteTopic } = useNotificationTopics();\n const [search, setSearch] = useState('');\n const [editingId, setEditingId] = useState<string | null>(null);\n const [form, setForm] = useState({\n name: '',\n slug: '',\n description: '',\n type: 'MARKETING',\n isActive: true,\n });\n\n // Topics live under the `notification` resource type in the backend (see\n // `global-notification-svc/src/modules/notification/schema/mutations.gql`),\n // and create/update/delete all require `notification:create` per the\n // @rbac directive. SUPER_ADMIN bypass is inherited from PermissionProvider.\n const canManage = hasPermission(NOTIFICATION_PERMISSIONS.NOTIFICATION_CREATE);\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 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 (!canManage) {\n return (\n <div className=\"p-8 text-center text-text-secondary\">\n {tr(\n 'notifications.noPermissionTopics',\n \"You don't have permission to manage notification topics.\"\n )}\n </div>\n );\n }\n\n return (\n <div className=\"space-y-6 p-4 sm:p-6\">\n <div>\n <h1 className=\"text-2xl font-bold text-primary\">\n {tr('notifications.topicsTitle', 'Notification Topics')}\n </h1>\n <p className=\"mt-1 text-sm text-secondary\">\n {tr(\n 'notifications.topicsSubtitle',\n 'Create topics for campaigns so users can subscribe or unsubscribe with precision.'\n )}\n </p>\n </div>\n\n <div className=\"grid gap-6 xl:grid-cols-[380px,1fr]\">\n <form\n className=\"space-y-4 rounded-lg border border-default bg-surface p-4 shadow-sm\"\n onSubmit={async (event) => {\n event.preventDefault();\n\n if (!form.name.trim() || !form.slug.trim()) {\n return;\n }\n\n if (editingId) {\n await updateTopic(editingId, form);\n } else {\n await createTopic(form);\n }\n\n setEditingId(null);\n setForm({\n name: '',\n slug: '',\n description: '',\n type: 'MARKETING',\n isActive: true,\n });\n }}\n >\n <div className=\"flex items-center gap-2\">\n <Plus size={18} className=\"text-accent-primary\" />\n <h2 className=\"text-base font-semibold text-primary\">\n {editingId\n ? tr('notifications.editTopic', 'Edit Topic')\n : tr('notifications.createTopic', 'Create Topic')}\n </h2>\n </div>\n\n <label className=\"block space-y-1 text-sm text-secondary\">\n <span>{tr('notifications.topicName', 'Name')}</span>\n <input\n type=\"text\"\n value={form.name}\n onChange={(event) =>\n setForm((prev) => ({\n ...prev,\n name: event.target.value,\n slug: editingId ? prev.slug : slugify(event.target.value),\n }))\n }\n className=\"w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </label>\n\n <label className=\"block space-y-1 text-sm text-secondary\">\n <span>{tr('notifications.topicSlug', 'Slug')}</span>\n <input\n type=\"text\"\n value={form.slug}\n onChange={(event) =>\n setForm((prev) => ({ ...prev, slug: slugify(event.target.value) }))\n }\n className=\"w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </label>\n\n <label className=\"block space-y-1 text-sm text-secondary\">\n <span>{tr('notifications.topicType', 'Type')}</span>\n <select\n value={form.type}\n onChange={(event) => setForm((prev) => ({ ...prev, type: event.target.value }))}\n className=\"w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n >\n {topicTypeOptions.map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n </label>\n\n <label className=\"block space-y-1 text-sm text-secondary\">\n <span>{tr('notifications.topicDescription', 'Description')}</span>\n <textarea\n value={form.description}\n onChange={(event) =>\n setForm((prev) => ({ ...prev, description: event.target.value }))\n }\n rows={4}\n className=\"w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </label>\n\n <label className=\"flex items-center gap-2 text-sm text-secondary\">\n <input\n type=\"checkbox\"\n checked={form.isActive}\n onChange={(event) => setForm((prev) => ({ ...prev, isActive: event.target.checked }))}\n />\n <span>{tr('notifications.topicIsActive', 'Active topic')}</span>\n </label>\n\n <div className=\"flex items-center gap-3\">\n <button\n type=\"submit\"\n className=\"inline-flex items-center gap-2 rounded-md bg-accent-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90\"\n >\n <Save size={16} />\n {editingId\n ? tr('notifications.saveTopic', 'Save Topic')\n : tr('notifications.createTopicButton', 'Create Topic')}\n </button>\n\n {editingId && (\n <button\n type=\"button\"\n onClick={() => {\n setEditingId(null);\n setForm({\n name: '',\n slug: '',\n description: '',\n type: 'MARKETING',\n isActive: true,\n });\n }}\n className=\"rounded-md border border-default px-4 py-2 text-sm text-secondary hover:bg-bg-sunken\"\n >\n {tr('notifications.cancelTopicEdit', 'Cancel')}\n </button>\n )}\n </div>\n </form>\n\n <div className=\"space-y-4 rounded-lg border border-default bg-surface p-4 shadow-sm\">\n <div className=\"relative max-w-md\">\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 placeholder={tr('notifications.searchTopics', 'Search topics...')}\n className=\"w-full rounded-md border border-default bg-bg-canvas py-2 pl-9 pr-4 text-sm text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </div>\n\n <div className=\"space-y-3\">\n {isLoading ? (\n <div className=\"text-sm text-secondary\">\n {tr('notifications.loadingTopics', 'Loading topics...')}\n </div>\n ) : filteredTopics.length === 0 ? (\n <div className=\"text-sm text-secondary\">\n {tr('notifications.noTopicsFound', 'No topics found.')}\n </div>\n ) : (\n filteredTopics.map((topic) => (\n <div\n key={topic.id}\n className=\"flex flex-col gap-3 rounded-lg border border-default bg-bg-canvas p-4 sm:flex-row sm:items-start sm:justify-between\"\n >\n <div className=\"space-y-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h3 className=\"text-sm font-semibold text-primary\">{topic.name}</h3>\n <span className=\"rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary\">\n {topic.slug}\n </span>\n <span className=\"rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary\">\n {topic.type}\n </span>\n </div>\n {topic.description && (\n <p className=\"text-sm text-secondary\">{topic.description}</p>\n )}\n <p className=\"text-xs text-tertiary\">\n {tr('notifications.topicSubscribers', 'Subscribers')}: {topic.subscriberCount}\n </p>\n </div>\n\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => {\n setEditingId(topic.id);\n setForm({\n name: topic.name,\n slug: topic.slug,\n description: topic.description || '',\n type: topic.type,\n isActive: topic.isActive,\n });\n }}\n className=\"rounded-md border border-default px-3 py-2 text-sm text-secondary hover:bg-bg-sunken\"\n >\n {tr('notifications.edit', 'Edit')}\n </button>\n <button\n type=\"button\"\n onClick={() => deleteTopic(topic.id)}\n className=\"inline-flex items-center gap-2 rounded-md border border-status-error-border px-3 py-2 text-sm text-status-error-text hover:bg-status-error-bg-subtle\"\n >\n <Trash2 size={14} />\n {tr('notifications.delete', 'Delete')}\n </button>\n </div>\n </div>\n ))\n )}\n </div>\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAOA,IAAM,IAAmB;CACvB;EAAE,OAAO;EAAa,OAAO;EAAa;CAC1C;EAAE,OAAO;EAAiB,OAAO;EAAiB;CAClD;EAAE,OAAO;EAAU,OAAO;EAAU;CACpC;EAAE,OAAO;EAAS,OAAO;EAAS;CACnC;AAED,SAAS,EAAQ,GAAe;AAC9B,QAAO,EACJ,aAAa,CACb,MAAM,CACN,QAAQ,iBAAiB,GAAG,CAC5B,QAAQ,QAAQ,IAAI,CACpB,QAAQ,OAAO,IAAI;;AAGxB,SAAgB,IAAyB;CACvC,IAAM,IAAK,GAAO,EACZ,EAAE,kBAAe,WAAW,MAAuB,GAAgB,EACnE,EAAE,WAAQ,cAAW,gBAAa,gBAAa,mBAAgB,GAAuB,EACtF,CAAC,GAAQ,KAAa,EAAS,GAAG,EAClC,CAAC,GAAW,KAAgB,EAAwB,KAAK,EACzD,CAAC,GAAM,KAAW,EAAS;EAC/B,MAAM;EACN,MAAM;EACN,aAAa;EACb,MAAM;EACN,UAAU;EACX,CAAC,EAMI,IAAY,EAAc,EAAyB,oBAAoB,EAEvE,IAAiB,QAAc;AACnC,MAAI,CAAC,EAAO,MAAM,CAChB,QAAO;EAGT,IAAM,IAAQ,EAAO,aAAa;AAClC,SAAO,EAAO,QACX,MACC,EAAM,KAAK,aAAa,CAAC,SAAS,EAAM,IACxC,EAAM,KAAK,aAAa,CAAC,SAAS,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AC;UAAG,EAAM;UAC5D;;QACA;UAEN,kBAAC,OAAD;OAAK,WAAU;iBAAf,CACE,kBAAC,UAAD;QACE,MAAK;QACL,eAAe;AAEb,SADA,EAAa,EAAM,GAAG,EACtB,EAAQ;UACN,MAAM,EAAM;UACZ,MAAM,EAAM;UACZ,aAAa,EAAM,eAAe;UAClC,MAAM,EAAM;UACZ,UAAU,EAAM;UACjB,CAAC;;QAEJ,WAAU;kBAET,EAAG,sBAAsB,OAAO;QAC1B,CAAA,EACT,kBAAC,UAAD;QACE,MAAK;QACL,eAAe,EAAY,EAAM,GAAG;QACpC,WAAU;kBAHZ,CAKE,kBAAC,GAAD,EAAQ,MAAM,IAAM,CAAA,EACnB,EAAG,wBAAwB,SAAS,CAC9B;UACL;SACF;QA/CC,EAAM,GA+CP,CACN;KAEA,CAAA,CACF;MACF;KACF;MAvOJ,kBAAC,OAAD;EAAK,WAAU;YACZ,EACC,oCACA,2DACD;EACG,CAAA"}
|
|
@@ -271,7 +271,7 @@ function v() {
|
|
|
271
271
|
});
|
|
272
272
|
let $ = Te || Ee;
|
|
273
273
|
return /* @__PURE__ */ h("div", {
|
|
274
|
-
className: "animate-in fade-in duration-
|
|
274
|
+
className: "animate-in fade-in duration-200 h-full flex flex-col",
|
|
275
275
|
children: [
|
|
276
276
|
/* @__PURE__ */ h("div", {
|
|
277
277
|
className: "flex items-center justify-between p-3 sm:px-6 sm:py-4 border-b border-default bg-surface/50 shrink-0",
|
|
@@ -279,7 +279,7 @@ function v() {
|
|
|
279
279
|
className: "flex items-center gap-3",
|
|
280
280
|
children: [/* @__PURE__ */ m("button", {
|
|
281
281
|
onClick: () => v("..", { relative: "path" }),
|
|
282
|
-
className: "p-2 hover:bg-
|
|
282
|
+
className: "p-2 hover:bg-bg-sunken rounded-lg transition-all duration-150",
|
|
283
283
|
children: /* @__PURE__ */ m(ae, {
|
|
284
284
|
size: 20,
|
|
285
285
|
className: "text-primary"
|
|
@@ -459,7 +459,7 @@ function v() {
|
|
|
459
459
|
className: "text-sm font-semibold text-primary uppercase tracking-wider",
|
|
460
460
|
children: y("notifTemplates.templateContent", "Template Content")
|
|
461
461
|
}), /* @__PURE__ */ h("div", {
|
|
462
|
-
className: "flex items-center bg-
|
|
462
|
+
className: "flex items-center bg-bg-sunken rounded-lg p-0.5",
|
|
463
463
|
children: [/* @__PURE__ */ h("button", {
|
|
464
464
|
type: "button",
|
|
465
465
|
onClick: () => W("text"),
|
|
@@ -534,7 +534,7 @@ function v() {
|
|
|
534
534
|
}), V.filter((e) => e.name.trim()).map((e, t) => /* @__PURE__ */ m("button", {
|
|
535
535
|
type: "button",
|
|
536
536
|
onClick: () => Ve(e.name),
|
|
537
|
-
className: "px-2 py-1 text-[11px] font-mono text-primary bg-
|
|
537
|
+
className: "px-2 py-1 text-[11px] font-mono text-primary bg-bg-sunken border border-default rounded hover:bg-bg-sunken/80 transition-colors",
|
|
538
538
|
children: `{{${e.name}}}`
|
|
539
539
|
}, t))]
|
|
540
540
|
})
|
|
@@ -578,13 +578,13 @@ function v() {
|
|
|
578
578
|
y("notifTemplates.noVariables", "No variables defined. Add variables to use dynamic content like"),
|
|
579
579
|
" ",
|
|
580
580
|
/* @__PURE__ */ m("code", {
|
|
581
|
-
className: "px-1.5 py-0.5 bg-
|
|
581
|
+
className: "px-1.5 py-0.5 bg-bg-sunken rounded text-[11px] font-mono",
|
|
582
582
|
children: "{{userName}}"
|
|
583
583
|
})
|
|
584
584
|
]
|
|
585
585
|
}),
|
|
586
586
|
V.map((e, t) => /* @__PURE__ */ h("div", {
|
|
587
|
-
className: "flex items-start gap-3 p-3 bg-
|
|
587
|
+
className: "flex items-start gap-3 p-3 bg-bg-sunken/50 rounded-lg border border-default/50",
|
|
588
588
|
children: [
|
|
589
589
|
/* @__PURE__ */ h("div", {
|
|
590
590
|
className: "flex-1",
|
|
@@ -657,7 +657,7 @@ function v() {
|
|
|
657
657
|
]
|
|
658
658
|
})
|
|
659
659
|
}), /* @__PURE__ */ h("div", {
|
|
660
|
-
className: "hidden lg:flex lg:flex-col lg:w-[440px] xl:w-[500px] bg-
|
|
660
|
+
className: "hidden lg:flex lg:flex-col lg:w-[440px] xl:w-[500px] bg-bg-sunken/30",
|
|
661
661
|
children: [/* @__PURE__ */ h("div", {
|
|
662
662
|
className: "flex items-center gap-2 px-4 py-3 border-b border-default bg-surface/50 shrink-0",
|
|
663
663
|
children: [
|
|
@@ -672,7 +672,7 @@ function v() {
|
|
|
672
672
|
/* @__PURE__ */ h("button", {
|
|
673
673
|
type: "button",
|
|
674
674
|
onClick: () => Ne((e) => !e),
|
|
675
|
-
className: `ml-auto flex items-center gap-1.5 px-2.5 py-1 text-[11px] font-medium rounded-md transition-all duration-150 ${Z ? "bg-accent-primary/10 text-accent-primary" : "bg-
|
|
675
|
+
className: `ml-auto flex items-center gap-1.5 px-2.5 py-1 text-[11px] font-medium rounded-md transition-all duration-150 ${Z ? "bg-accent-primary/10 text-accent-primary" : "bg-bg-sunken text-tertiary hover:text-primary"}`,
|
|
676
676
|
children: [m(Z ? u : d, { size: 12 }), Z ? y("notifTemplates.previewOn", "On") : y("notifTemplates.previewOffShort", "Off")]
|
|
677
677
|
})
|
|
678
678
|
]
|