@burdenoff/microfe-newsletter 2026.830.2 → 2026.1013.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/newsletter/AdminNewsletterRoot.js +1 -1
- package/dist/newsletter/AdminNewsletterRoot.js.map +1 -1
- package/dist/newsletter/pages/ABTestingPage.js +2 -2
- package/dist/newsletter/pages/ABTestingPage.js.map +1 -1
- package/dist/newsletter/pages/AnalyticsDashboardPage.js +1 -1
- package/dist/newsletter/pages/AnalyticsDashboardPage.js.map +1 -1
- package/dist/newsletter/pages/CampaignsListPage.js +1 -1
- package/dist/newsletter/pages/CampaignsListPage.js.map +1 -1
- package/dist/newsletter/pages/CompliancePage.js +4 -4
- package/dist/newsletter/pages/CompliancePage.js.map +1 -1
- package/dist/newsletter/pages/SubscribersListPage.js +1 -1
- package/dist/newsletter/pages/SubscribersListPage.js.map +1 -1
- package/dist/newsletter/pages/TemplateEditorPage.js +1 -1
- package/dist/newsletter/pages/TemplateEditorPage.js.map +1 -1
- package/dist/newsletter/pages/TemplateLibraryPage.js +1 -1
- package/dist/newsletter/pages/TemplateLibraryPage.js.map +1 -1
- package/dist/newsletter/pages/WaitlistListPage.js +1 -1
- package/dist/newsletter/pages/WaitlistListPage.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubscribersListPage.js","names":[],"sources":["../../../src/newsletter/pages/SubscribersListPage.tsx"],"sourcesContent":["import { useState, useRef } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { useNavigate } from 'react-router';\nimport {\n Plus,\n Search,\n Filter,\n Upload,\n Download,\n Users,\n Loader2,\n AlertCircle,\n CheckCircle,\n Trash2,\n Mail,\n MailX,\n RefreshCw,\n X,\n} from 'lucide-react';\nimport { useNewsletter } from '../providers/NewsletterProvider';\nimport { useNewsletterStore } from '../store/newsletterStore';\nimport {\n useSubscribers,\n useSubscriberMutations,\n useExportSubscribers,\n usePlatformProducts,\n type Subscriber,\n type SubscribeInput,\n type ImportSubscriberInput,\n} from '../hooks/useNewsletterOperations';\n\nimport {\n GradientText,\n AuroraBackground,\n CTAOverflowMenu,\n IllustratedEmptyState,\n EmphasisPanel,\n Button,\n PagePurpose,\n} from '@burdenoff/fe-libs/ui';\nimport { AccessDenied } from '@burdenoff/fe-libs/shared/components';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { NEWSLETTER_PERMISSIONS } from '../constants/permissions';\nimport { useTr } from '../shared/hooks/useTr';\nimport { nativeConfirm, nativeNotify } from '../../utils/nativeBridge';\n\nfunction getProductName(\n pid: string | null | undefined,\n emptyLabel: string,\n products: Array<{ id: string; name: string }>\n): string {\n if (!pid) return emptyLabel;\n return products.find((product) => product.id === pid)?.name ?? pid.slice(0, 8);\n}\n\n/**\n * SubscribersListPage - Manage newsletter subscribers\n *\n * **Features**:\n * - List all subscribers with status (active, unsubscribed, bounced, complained)\n * - Search subscribers by email, name\n * - Filter by status, tags, segments\n * - Add subscribers manually (individual or bulk CSV import)\n * - Export subscribers to CSV/Excel\n * - Bulk actions (tag, untag, delete, export)\n * - View subscriber engagement metrics\n * - Create and manage segments\n *\n * **RBAC**: Requires `tenantmodule-newsletter:subscribers:read` scope\n */\nexport function SubscribersListPage() {\n const { locale } = useI18n();\n const tr = useTr();\n const navigate = useNavigate();\n const { productId } = useNewsletter();\n const { hasPermission, isLoading: permissionsLoading, permissions } = usePermissions();\n const { subscriberFilter, updateSubscriberFilter } = useNewsletterStore();\n\n // Permission checks\n const permsRegistered = (\n Array.isArray(permissions) ? permissions : permissions?.permissionStrings\n )?.some?.((p: string) => p.startsWith('tenantmodule-newsletter:subscribers:'));\n const canList = permsRegistered ? hasPermission(NEWSLETTER_PERMISSIONS.SUBSCRIBER_LIST) : true;\n const canCreate = permsRegistered\n ? hasPermission(NEWSLETTER_PERMISSIONS.SUBSCRIBER_CREATE)\n : true;\n const canDelete = permsRegistered\n ? hasPermission(NEWSLETTER_PERMISSIONS.SUBSCRIBER_DELETE)\n : true;\n const canImport = permsRegistered\n ? hasPermission(NEWSLETTER_PERMISSIONS.SUBSCRIBER_IMPORT)\n : true;\n const canExport = permsRegistered\n ? hasPermission(NEWSLETTER_PERMISSIONS.SUBSCRIBER_EXPORT)\n : true;\n\n // Local state\n const [showAddModal, setShowAddModal] = useState(false);\n const [showImportModal, setShowImportModal] = useState(false);\n const [newEmail, setNewEmail] = useState('');\n const [csvData, setCsvData] = useState('');\n const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set());\n const [notification, setNotification] = useState<{\n type: 'success' | 'error';\n message: string;\n } | null>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n // Determine subscribed filter based on status\n const getSubscribedFilter = () => {\n if (subscriberFilter.status === 'ACTIVE') return true;\n if (subscriberFilter.status === 'UNSUBSCRIBED') return false;\n return undefined; // ALL\n };\n\n // GraphQL hooks\n const { subscribers, totalCount, loading, error, refetch } = useSubscribers({\n subscribed: getSubscribedFilter(),\n platformProductId: productId,\n });\n const {\n subscribe,\n unsubscribeFromProduct,\n resubscribeToProduct,\n deleteSubscriber,\n importSubscribers,\n subscribing,\n unsubscribing,\n deletingSubscriber,\n importing,\n } = useSubscriberMutations();\n const { exportSubscribers } = useExportSubscribers(undefined, productId);\n const { products } = usePlatformProducts();\n\n // Filter subscribers locally by search\n const filteredSubscribers = subscribers.filter((sub) => {\n if (!subscriberFilter.search) return true;\n const search = subscriberFilter.search.toLowerCase();\n return sub.email.toLowerCase().includes(search);\n });\n\n // At-a-glance audience health for the emphasis summary\n const activeCount = subscribers.filter(\n (sub) => sub.subscribed && sub.status !== 'UNSUBSCRIBED'\n ).length;\n const unsubscribedCount = subscribers.filter(\n (sub) => !sub.subscribed || sub.status === 'UNSUBSCRIBED'\n ).length;\n\n // Show notification helper\n const showNotification = (type: 'success' | 'error', message: string) => {\n setNotification({ type, message });\n setTimeout(() => setNotification(null), 5000);\n };\n\n const handleSearchChange = (search: string) => {\n updateSubscriberFilter({ search });\n };\n\n const handleStatusFilter = (status: string) => {\n updateSubscriberFilter({\n status: status as 'ACTIVE' | 'PAUSED' | 'UNSUBSCRIBED' | 'ALL',\n });\n };\n\n const handleExport = async () => {\n try {\n const result = await exportSubscribers();\n if (result.data?.exportSubscribers) {\n const csvContent = [\n [\n tr('newsletter.email', 'Email'),\n tr('newsletterCommon.status', 'Status'),\n tr('subscribers.subscribedAt', 'Subscribed At'),\n tr('subscribers.unsubscribedAt', 'Unsubscribed At'),\n ].join(','),\n ...result.data.exportSubscribers.map(\n (sub) => `${sub.email},${sub.status},${sub.subscribedAt},${sub.unsubscribedAt || ''}`\n ),\n ].join('\\n');\n\n const blob = new Blob([csvContent], { type: 'text/csv' });\n const url = window.URL.createObjectURL(blob);\n const a = document.createElement('a');\n a.href = url;\n a.download = `${tr('subscribers.exportFilenamePrefix', 'subscribers')}-${new Date().toISOString().split('T')[0]}.csv`;\n a.click();\n window.URL.revokeObjectURL(url);\n showNotification(\n 'success',\n tr('subscribers.exportedSuccessfully', 'Subscribers exported successfully')\n );\n }\n } catch (err) {\n showNotification(\n 'error',\n `${tr('subscribers.failedToExport', 'Failed to export')}: ${err instanceof Error ? err.message : tr('newsletter.unknownError', 'Unknown error')}`\n );\n }\n };\n\n const handleAddSubscriber = async () => {\n if (!newEmail.trim()) {\n showNotification(\n 'error',\n tr('subscribers.pleaseEnterEmail', 'Please enter an email address')\n );\n return;\n }\n\n try {\n const input: SubscribeInput = {\n email: newEmail.trim(),\n platformProductId: productId,\n };\n const result = await subscribe(input);\n showNotification(\n 'success',\n result?.alreadySubscribed\n ? `${newEmail} ${tr('subscribers.alreadySubscribedSuffix', 'is already part of this newsletter')}`\n : `${newEmail} ${tr('subscribers.addedSuccessfully', 'added successfully')}`\n );\n setNewEmail('');\n setShowAddModal(false);\n } catch (err) {\n showNotification(\n 'error',\n `${tr('subscribers.failedToAddSubscriber', 'Failed to add subscriber')}: ${err instanceof Error ? err.message : tr('newsletter.unknownError', 'Unknown error')}`\n );\n }\n };\n\n const handleImportSubscribers = async () => {\n if (!csvData.trim()) {\n showNotification(\n 'error',\n tr('subscribers.pleaseEnterEmails', 'Please enter email addresses')\n );\n return;\n }\n\n try {\n // Parse CSV data - support both comma and newline separated\n const emails = csvData\n .split(/[\\n,]/)\n .map((e) => e.trim())\n .filter((e) => e && e.includes('@'));\n\n if (emails.length === 0) {\n showNotification(\n 'error',\n tr('subscribers.noValidEmails', 'No valid email addresses found')\n );\n return;\n }\n\n const subscribersToImport: ImportSubscriberInput[] = emails.map((email) => ({\n email,\n platformProductId: productId,\n }));\n\n const result = await importSubscribers(subscribersToImport);\n if (result) {\n showNotification(\n 'success',\n `${tr('subscribers.importedPrefix', 'Imported')} ${result.imported} ${tr('subscribers.subscribersLower', 'subscribers')}. ${tr('subscribers.skipped', 'Skipped')}: ${result.skipped}, ${tr('subscribers.failed', 'Failed')}: ${result.failed}`\n );\n setCsvData('');\n setShowImportModal(false);\n }\n } catch (err) {\n showNotification(\n 'error',\n `${tr('subscribers.failedToImport', 'Failed to import')}: ${err instanceof Error ? err.message : tr('newsletter.unknownError', 'Unknown error')}`\n );\n }\n };\n\n const handleFileUpload = (event: React.ChangeEvent<HTMLInputElement>) => {\n const file = event.target.files?.[0];\n if (!file) return;\n\n const reader = new FileReader();\n reader.onload = (e) => {\n setCsvData(e.target?.result as string);\n };\n reader.readAsText(file);\n };\n\n const handleUnsubscribe = async (email: string) => {\n if (\n !confirm(\n `${tr('subscribers.confirmUnsubscribePrefix', 'Are you sure you want to unsubscribe')} ${email}?`\n )\n )\n return;\n\n try {\n await unsubscribeFromProduct(email, productId);\n showNotification(\n 'success',\n `${email} ${tr('subscribers.unsubscribedSuffix', 'unsubscribed')}`\n );\n } catch (err) {\n showNotification(\n 'error',\n `${tr('subscribers.failedToUnsubscribe', 'Failed to unsubscribe')}: ${err instanceof Error ? err.message : tr('newsletter.unknownError', 'Unknown error')}`\n );\n }\n };\n\n const handleResubscribe = async (email: string) => {\n try {\n await resubscribeToProduct(email, productId);\n showNotification(\n 'success',\n `${email} ${tr('subscribers.resubscribedSuffix', 'resubscribed')}`\n );\n } catch (err) {\n showNotification(\n 'error',\n `${tr('subscribers.failedToResubscribe', 'Failed to resubscribe')}: ${err instanceof Error ? err.message : tr('newsletter.unknownError', 'Unknown error')}`\n );\n }\n };\n\n const handleDelete = async (id: string, email: string) => {\n const confirmed = await nativeConfirm({\n title: tr('subscribers.deleteSubscriber', 'Delete Subscriber'),\n message: `${tr('subscribers.confirmDeletePrefix', 'Are you sure you want to delete')} ${email}? ${tr('newsletter.actionCannotBeUndone', 'This action cannot be undone.')}`,\n });\n if (confirmed === false) return;\n\n try {\n await deleteSubscriber(id);\n void nativeNotify('success');\n showNotification('success', `${email} ${tr('newsletter.deletedSuffix', 'deleted')}`);\n } catch (err) {\n void nativeNotify('error');\n showNotification(\n 'error',\n `${tr('templates.failedToDelete', 'Failed to delete')}: ${err instanceof Error ? err.message : tr('newsletter.unknownError', 'Unknown error')}`\n );\n }\n };\n\n const handleSelectAll = () => {\n if (selectedIds.size === filteredSubscribers.length) {\n setSelectedIds(new Set());\n } else {\n setSelectedIds(new Set(filteredSubscribers.map((s) => s.id)));\n }\n };\n\n const handleSelectOne = (id: string) => {\n const newSelected = new Set(selectedIds);\n if (newSelected.has(id)) {\n newSelected.delete(id);\n } else {\n newSelected.add(id);\n }\n setSelectedIds(newSelected);\n };\n\n const handleViewSubscriber = (id: string) => {\n navigate(id);\n };\n\n const formatDate = (dateString: string) => {\n return new Date(dateString).toLocaleDateString(locale || 'en-US', {\n month: 'short',\n day: 'numeric',\n year: 'numeric',\n });\n };\n\n // Guard: loading permissions\n if (permissionsLoading) {\n return (\n <div className=\"flex items-center justify-center h-full\">\n <div className=\"flex items-center gap-2 text-text-secondary\">\n <Loader2 className=\"animate-spin\" size={24} />\n <span>{tr('newsletterCommon.loading', 'Loading...')}</span>\n </div>\n </div>\n );\n }\n\n // Guard: access denied\n if (!permissionsLoading && permissions && permissions.permissionStrings?.length > 0 && !canList) {\n return <AccessDenied />;\n }\n\n return (\n <div className=\"flex flex-col h-full\">\n {/* Notification */}\n {notification && (\n <div\n className={`fixed top-4 right-4 z-50 flex items-center gap-2 px-4 py-3 rounded-lg shadow-[var(--shadow-pop)] ${\n notification.type === 'success'\n ? 'bg-status-success-bg-subtle text-status-success-text border border-status-success-border/20'\n : 'bg-status-error-bg-subtle text-status-error-text border border-status-error-border/20'\n }`}\n >\n {notification.type === 'success' ? <CheckCircle size={20} /> : <AlertCircle size={20} />}\n <span>{notification.message}</span>\n </div>\n )}\n\n {/* Header */}\n <div className=\"relative overflow-hidden flex items-center justify-between p-6 border-b border-border-seam\">\n <AuroraBackground intensity=\"subtle\" />\n <div>\n <h1 className=\"text-2xl font-semibold text-text-primary\">\n <GradientText>{tr('subscribers.subscribers', 'Subscribers')}</GradientText>\n </h1>\n <p className=\"mt-1 text-sm text-text-secondary tabular-nums\">\n {totalCount} {tr('subscribers.totalSubscribers', 'total subscribers')}\n </p>\n </div>\n <div className=\"flex items-center gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"icon\"\n onClick={() => refetch()}\n title={tr('newsletter.refresh', 'Refresh')}\n aria-label={tr('newsletter.refresh', 'Refresh')}\n >\n <RefreshCw size={18} className={loading ? 'animate-spin' : ''} />\n </Button>\n <CTAOverflowMenu\n primary={\n canCreate\n ? {\n label: tr('subscribers.addSubscriber', 'Add Subscriber'),\n icon: <Plus size={18} />,\n onSelect: () => setShowAddModal(true),\n }\n : undefined\n }\n actions={[\n ...(canImport\n ? [\n {\n label: tr('subscribers.import', 'Import'),\n icon: <Upload size={16} />,\n onSelect: () => setShowImportModal(true),\n },\n ]\n : []),\n ...(canExport\n ? [\n {\n label: tr('subscribers.export', 'Export'),\n icon: <Download size={16} />,\n onSelect: () => handleExport(),\n },\n ]\n : []),\n ]}\n />\n </div>\n </div>\n\n {/* Page purpose */}\n <div className=\"px-6 pt-6\">\n <PagePurpose>\n {tr(\n 'subscribers.pagePurpose',\n 'Your audience lives here — every person who can receive a newsletter for this product. Add people one at a time, bulk-import a CSV, or export the list, and keep it healthy by tracking who is active, paused, or has unsubscribed. A clean, consented list is what keeps your emails landing in inboxes.'\n )}\n </PagePurpose>\n </div>\n\n {/* Audience summary — the emphasis zone */}\n <div className=\"px-6 pt-6\">\n <EmphasisPanel className=\"flex flex-wrap items-center gap-8 p-4\">\n <div className=\"flex items-center gap-3\">\n <div className=\"p-2 bg-action-primary-bg/10 rounded-lg\">\n <Users size={20} className=\"text-primary\" />\n </div>\n <div>\n <p className=\"text-2xl font-bold text-text-primary tabular-nums\">{totalCount}</p>\n <p className=\"text-sm text-text-secondary\">\n {tr('subscribers.totalSubscribers', 'total subscribers')}\n </p>\n </div>\n </div>\n <div className=\"flex items-center gap-3\">\n <div className=\"p-2 bg-status-success-bg-subtle rounded-lg\">\n <Mail size={20} className=\"text-status-success-text\" />\n </div>\n <div>\n <p className=\"text-2xl font-bold text-text-primary tabular-nums\">{activeCount}</p>\n <p className=\"text-sm text-text-secondary\">{tr('subscribers.active', 'Active')}</p>\n </div>\n </div>\n <div className=\"flex items-center gap-3\">\n <div className=\"p-2 bg-bg-sunken rounded-lg\">\n <MailX size={20} className=\"text-text-secondary\" />\n </div>\n <div>\n <p className=\"text-2xl font-bold text-text-primary tabular-nums\">\n {unsubscribedCount}\n </p>\n <p className=\"text-sm text-text-secondary\">\n {tr('subscribers.unsubscribed', 'Unsubscribed')}\n </p>\n </div>\n </div>\n </EmphasisPanel>\n </div>\n\n {/* Filters */}\n <div className=\"flex items-center gap-4 p-6 border-b border-border-seam\">\n <div className=\"flex-1 relative\">\n <Search\n className=\"absolute left-3 top-1/2 -translate-y-1/2 text-text-secondary\"\n size={20}\n />\n <input\n type=\"text\"\n aria-label={tr('subscribers.searchByEmail', 'Search by email...')}\n placeholder={tr('subscribers.searchByEmail', 'Search by email...')}\n value={subscriberFilter.search}\n onChange={(e) => handleSearchChange(e.target.value)}\n className=\"w-full pl-10 pr-4 py-2 border border-border-subtle rounded-lg focus:ring-2 focus:ring-primary/50 focus:border-transparent\"\n />\n </div>\n <select\n value={subscriberFilter.status}\n onChange={(e) => handleStatusFilter(e.target.value)}\n className=\"px-4 py-2 border border-border-subtle rounded-lg focus:ring-2 focus:ring-primary/50 focus:border-transparent\"\n >\n <option value=\"ALL\">{tr('newsletterCommon.allStatuses', 'All Statuses')}</option>\n <option value=\"ACTIVE\">{tr('subscribers.active', 'Active')}</option>\n <option value=\"PAUSED\">{tr('subscribers.paused', 'Paused')}</option>\n <option value=\"UNSUBSCRIBED\">\n {tr('subscribers.unsubscribedStatus', 'Unsubscribed')}\n </option>\n </select>\n <div className=\"rounded-lg border border-border-subtle bg-bg-sunken px-4 py-2 text-sm text-text-secondary\">\n {tr('newsletter.product', 'Product')}:{' '}\n {getProductName(productId, tr('newsletter.notAvailable', 'N/A'), products)}\n </div>\n <button\n type=\"button\"\n className=\"flex items-center gap-2 px-4 py-2 border border-border-subtle rounded-lg hover:bg-accent transition-colors\"\n >\n <Filter size={20} />\n {tr('newsletter.moreFilters', 'More Filters')}\n </button>\n </div>\n\n {/* Subscribers List */}\n <div className=\"flex-1 overflow-auto\">\n {error ? (\n <div className=\"flex items-center justify-center h-full p-6\">\n <IllustratedEmptyState\n illustration=\"empty-generic\"\n title={tr('subscribers.failedLoadSubscribers', 'Failed to load subscribers')}\n description={error.message}\n action={\n <Button type=\"button\" onClick={() => refetch()}>\n {tr('newsletterCommon.tryAgain', 'Try Again')}\n </Button>\n }\n />\n </div>\n ) : loading && subscribers.length === 0 ? (\n <div className=\"flex items-center justify-center h-full\">\n <div className=\"flex items-center gap-2 text-text-secondary\">\n <Loader2 className=\"animate-spin\" size={24} />\n <span>{tr('subscribers.loadingSubscribers', 'Loading subscribers...')}</span>\n </div>\n </div>\n ) : filteredSubscribers.length === 0 ? (\n <div className=\"flex items-center justify-center h-full p-6\">\n <IllustratedEmptyState\n illustration={subscriberFilter.search ? 'empty-search' : 'empty-people'}\n title={\n subscriberFilter.search\n ? tr('subscribers.noSubscribersFound', 'No subscribers found')\n : tr('subscribers.noSubscribersYet', 'No subscribers yet')\n }\n description={\n subscriberFilter.search\n ? tr('newsletterCommon.tryDifferentSearch', 'Try a different search term')\n : tr(\n 'subscribers.noSubscribersDescription',\n 'Start building your subscriber list by adding subscribers manually or importing them from a CSV file.'\n )\n }\n action={\n !subscriberFilter.search ? (\n <div className=\"flex items-center gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => setShowImportModal(true)}\n >\n {tr('subscribers.importFromCsv', 'Import from CSV')}\n </Button>\n <Button type=\"button\" onClick={() => setShowAddModal(true)}>\n {tr('subscribers.addManually', 'Add Manually')}\n </Button>\n </div>\n ) : undefined\n }\n />\n </div>\n ) : (\n <table className=\"w-full\">\n <thead className=\"bg-bg-sunken border-b border-border-seam sticky top-0\">\n <tr>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider\">\n <input\n type=\"checkbox\"\n aria-label={tr('subscribers.selectAll', 'Select all subscribers')}\n checked={selectedIds.size === filteredSubscribers.length}\n onChange={handleSelectAll}\n className=\"rounded\"\n />\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider\">\n {tr('newsletter.email', 'Email')}\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider\">\n {tr('subscribers.product', 'Product')}\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider\">\n {tr('newsletterCommon.status', 'Status')}\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider\">\n {tr('subscribers.subscribed', 'Subscribed')}\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider\">\n {tr('newsletter.actions', 'Actions')}\n </th>\n </tr>\n </thead>\n <tbody className=\"bg-bg-surface divide-y divide-border\">\n {filteredSubscribers.map((subscriber) => (\n <SubscriberRow\n key={subscriber.id}\n subscriber={subscriber}\n selected={selectedIds.has(subscriber.id)}\n onSelect={() => handleSelectOne(subscriber.id)}\n onView={() => handleViewSubscriber(subscriber.id)}\n onUnsubscribe={() => handleUnsubscribe(subscriber.email)}\n onResubscribe={() => handleResubscribe(subscriber.email)}\n onDelete={\n canDelete ? () => handleDelete(subscriber.id, subscriber.email) : undefined\n }\n formatDate={formatDate}\n emptyProductLabel={tr('newsletterCommon.notAvailable', 'N/A')}\n products={products}\n isDeleting={deletingSubscriber}\n isUnsubscribing={unsubscribing}\n />\n ))}\n </tbody>\n </table>\n )}\n </div>\n\n {/* Add Subscriber Modal */}\n {showAddModal && (\n <div className=\"fixed inset-0 bg-black/50 flex items-center justify-center z-50\">\n <div className=\"bg-bg-surface rounded-lg shadow-xl w-full max-w-md p-6\">\n <div className=\"flex items-center justify-between mb-4\">\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {tr('subscribers.addSubscriber', 'Add Subscriber')}\n </h2>\n <button\n type=\"button\"\n onClick={() => setShowAddModal(false)}\n className=\"p-1 hover:bg-accent rounded\"\n >\n <X size={20} />\n </button>\n </div>\n <div className=\"mb-4\">\n <label className=\"block text-sm font-medium text-text-primary mb-1\">\n {tr('subscribers.emailAddress', 'Email Address')}\n </label>\n <input\n type=\"email\"\n aria-label={tr('subscribers.emailAddress', 'Email address')}\n value={newEmail}\n onChange={(e) => setNewEmail(e.target.value)}\n placeholder={tr('subscribers.emailPlaceholder', 'subscriber@example.com')}\n className=\"w-full px-3 py-2 border border-border-subtle rounded-lg focus:ring-2 focus:ring-primary/50 focus:border-transparent\"\n onKeyDown={(e) => e.key === 'Enter' && handleAddSubscriber()}\n />\n </div>\n <div className=\"flex justify-end gap-2\">\n <button\n type=\"button\"\n onClick={() => setShowAddModal(false)}\n className=\"px-4 py-2 border border-border-subtle rounded-lg hover:bg-accent transition-colors\"\n >\n {tr('newsletterCommon.cancel', 'Cancel')}\n </button>\n <button\n type=\"button\"\n onClick={handleAddSubscriber}\n disabled={subscribing}\n className=\"flex items-center gap-2 px-4 py-2 bg-action-primary-bg text-action-primary-text rounded-lg hover:bg-action-primary-bg/90 transition-colors disabled:opacity-50\"\n >\n {subscribing ? <Loader2 size={16} className=\"animate-spin\" /> : <Plus size={16} />}\n {tr('subscribers.addSubscriber', 'Add Subscriber')}\n </button>\n </div>\n </div>\n </div>\n )}\n\n {/* Import Modal */}\n {showImportModal && (\n <div className=\"fixed inset-0 bg-black/50 flex items-center justify-center z-50\">\n <div className=\"bg-bg-surface rounded-lg shadow-xl w-full max-w-lg p-6\">\n <div className=\"flex items-center justify-between mb-4\">\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {tr('subscribers.importSubscribers', 'Import Subscribers')}\n </h2>\n <button\n type=\"button\"\n onClick={() => setShowImportModal(false)}\n className=\"p-1 hover:bg-accent rounded\"\n >\n <X size={20} />\n </button>\n </div>\n <div className=\"mb-4\">\n <div className=\"flex items-center justify-between mb-2\">\n <label className=\"block text-sm font-medium text-text-primary\">\n {tr('subscribers.emailAddresses', 'Email Addresses')}\n </label>\n <button\n type=\"button\"\n onClick={() => fileInputRef.current?.click()}\n className=\"text-sm text-primary hover:text-primary/80\"\n >\n {tr('subscribers.uploadCsv', 'Upload CSV')}\n </button>\n <input\n ref={fileInputRef}\n type=\"file\"\n aria-label={tr('subscribers.uploadCsvFile', 'Upload CSV file')}\n accept=\".csv,.txt\"\n onChange={handleFileUpload}\n className=\"hidden\"\n />\n </div>\n <textarea\n aria-label={tr('subscribers.csvData', 'CSV data')}\n value={csvData}\n onChange={(e) => setCsvData(e.target.value)}\n placeholder={tr(\n 'subscribers.csvPlaceholder',\n 'Enter email addresses (one per line or comma-separated)\\n\\nemail1@example.com\\nemail2@example.com\\nemail3@example.com'\n )}\n rows={8}\n className=\"w-full px-3 py-2 border border-border-subtle rounded-lg focus:ring-2 focus:ring-primary/50 focus:border-transparent font-mono text-sm\"\n />\n <p className=\"mt-1 text-xs text-text-secondary\">\n {tr(\n 'subscribers.supportedFormats',\n 'Supported formats: one email per line, comma-separated, or CSV file'\n )}\n </p>\n </div>\n <div className=\"flex justify-end gap-2\">\n <button\n type=\"button\"\n onClick={() => setShowImportModal(false)}\n className=\"px-4 py-2 border border-border-subtle rounded-lg hover:bg-accent transition-colors\"\n >\n {tr('newsletterCommon.cancel', 'Cancel')}\n </button>\n <button\n type=\"button\"\n onClick={handleImportSubscribers}\n disabled={importing}\n className=\"flex items-center gap-2 px-4 py-2 bg-action-primary-bg text-action-primary-text rounded-lg hover:bg-action-primary-bg/90 transition-colors disabled:opacity-50\"\n >\n {importing ? <Loader2 size={16} className=\"animate-spin\" /> : <Upload size={16} />}\n {tr('subscribers.import', 'Import')}\n </button>\n </div>\n </div>\n </div>\n )}\n </div>\n );\n}\n\n/**\n * Subscriber row component\n */\ninterface SubscriberRowProps {\n subscriber: Subscriber;\n selected: boolean;\n onSelect: () => void;\n onView: () => void;\n onUnsubscribe: () => void;\n onResubscribe: () => void;\n onDelete?: () => void;\n formatDate: (date: string) => string;\n emptyProductLabel: string;\n products: Array<{ id: string; name: string }>;\n isDeleting: boolean;\n isUnsubscribing: boolean;\n}\n\nfunction SubscriberRow({\n subscriber,\n selected,\n onSelect,\n onView,\n onUnsubscribe,\n onResubscribe,\n onDelete,\n formatDate,\n emptyProductLabel,\n products,\n}: SubscriberRowProps) {\n const tr = useTr();\n const getStatusBadge = (status: string, subscribed: boolean) => {\n if (!subscribed || status === 'UNSUBSCRIBED') {\n return (\n <span className=\"inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium bg-bg-sunken text-text-secondary\">\n <MailX size={12} />\n {tr('subscribers.unsubscribed', 'Unsubscribed')}\n </span>\n );\n }\n if (status === 'PAUSED') {\n return (\n <span className=\"inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium bg-status-warning-bg-subtle text-status-warning-text\">\n {tr('subscribers.paused', 'Paused')}\n </span>\n );\n }\n return (\n <span className=\"inline-flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium bg-status-success-bg-subtle text-status-success-text\">\n <span className=\"size-1.5 rounded-full bg-status-success-text motion-safe:animate-vc-glow-pulse\" />\n <Mail size={12} />\n {tr('subscribers.active', 'Active')}\n </span>\n );\n };\n\n return (\n <tr className=\"hover:bg-accent\">\n <td className=\"px-6 py-4\">\n <input\n type=\"checkbox\"\n aria-label={`Select ${subscriber.email}`}\n checked={selected}\n onChange={onSelect}\n className=\"rounded\"\n />\n </td>\n <td className=\"px-6 py-4\">\n <button\n type=\"button\"\n onClick={onView}\n className=\"text-text-primary hover:text-primary font-medium\"\n >\n {subscriber.email}\n </button>\n </td>\n <td className=\"px-6 py-4 text-sm text-text-secondary\">\n {getProductName(subscriber.platformProductId, emptyProductLabel, products)}\n </td>\n <td className=\"px-6 py-4\">{getStatusBadge(subscriber.status, subscriber.subscribed)}</td>\n <td className=\"px-6 py-4 text-sm text-text-secondary\">\n {formatDate(subscriber.subscribedAt)}\n </td>\n <td className=\"px-6 py-4\">\n <div className=\"flex items-center gap-2\">\n {subscriber.subscribed ? (\n <button\n type=\"button\"\n onClick={onUnsubscribe}\n className=\"text-xs text-status-warning-text hover:opacity-80\"\n title={tr('subscribers.unsubscribe', 'Unsubscribe')}\n >\n {tr('subscribers.unsubscribe', 'Unsubscribe')}\n </button>\n ) : (\n <button\n type=\"button\"\n onClick={onResubscribe}\n className=\"text-xs text-status-success-text hover:opacity-80\"\n title={tr('subscribers.resubscribe', 'Resubscribe')}\n >\n {tr('subscribers.resubscribe', 'Resubscribe')}\n </button>\n )}\n {onDelete && (\n <button\n type=\"button\"\n onClick={onDelete}\n className=\"p-1 text-status-error-text hover:text-status-error-text/80 hover:bg-status-error-bg/10 rounded\"\n title={tr('newsletter.delete', 'Delete')}\n >\n <Trash2 size={14} />\n </button>\n )}\n </div>\n </td>\n </tr>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AA8CA,SAAS,EACP,GACA,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WAAU;cACX,EAAW,EAAW,aAAa;IACjC,CAAA;GACL,kBAAC,MAAD;IAAI,WAAU;cACZ,kBAAC,OAAD;KAAK,WAAU;eAAf,CACG,EAAW,aACV,kBAAC,UAAD;MACE,MAAK;MACL,SAAS;MACT,WAAU;MACV,OAAO,EAAG,2BAA2B,cAAc;gBAElD,EAAG,2BAA2B,cAAc;MACtC,CAAA,GAET,kBAAC,UAAD;MACE,MAAK;MACL,SAAS;MACT,WAAU;MACV,OAAO,EAAG,2BAA2B,cAAc;gBAElD,EAAG,2BAA2B,cAAc;MACtC,CAAA,EAEV,KACC,kBAAC,UAAD;MACE,MAAK;MACL,SAAS;MACT,WAAU;MACV,OAAO,EAAG,qBAAqB,SAAS;gBAExC,kBAAC,GAAD,EAAQ,MAAM,IAAM,CAAA;MACb,CAAA,CAEP;;IACH,CAAA;GACF"}
|
|
1
|
+
{"version":3,"file":"SubscribersListPage.js","names":[],"sources":["../../../src/newsletter/pages/SubscribersListPage.tsx"],"sourcesContent":["import { useState, useRef } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { useNavigate } from 'react-router';\nimport {\n Plus,\n Search,\n Filter,\n Upload,\n Download,\n Users,\n Loader2,\n AlertCircle,\n CheckCircle,\n Trash2,\n Mail,\n MailX,\n RefreshCw,\n X,\n} from 'lucide-react';\nimport { useNewsletter } from '../providers/NewsletterProvider';\nimport { useNewsletterStore } from '../store/newsletterStore';\nimport {\n useSubscribers,\n useSubscriberMutations,\n useExportSubscribers,\n usePlatformProducts,\n type Subscriber,\n type SubscribeInput,\n type ImportSubscriberInput,\n} from '../hooks/useNewsletterOperations';\n\nimport {\n GradientText,\n AuroraBackground,\n CTAOverflowMenu,\n IllustratedEmptyState,\n EmphasisPanel,\n Button,\n PagePurpose,\n} from '@burdenoff/fe-libs/ui';\nimport { AccessDenied } from '@burdenoff/fe-libs/shared/components';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { NEWSLETTER_PERMISSIONS } from '../constants/permissions';\nimport { useTr } from '../shared/hooks/useTr';\nimport { nativeConfirm, nativeNotify } from '../../utils/nativeBridge';\n\nfunction getProductName(\n pid: string | null | undefined,\n emptyLabel: string,\n products: Array<{ id: string; name: string }>\n): string {\n if (!pid) return emptyLabel;\n return products.find((product) => product.id === pid)?.name ?? pid.slice(0, 8);\n}\n\n/**\n * SubscribersListPage - Manage newsletter subscribers\n *\n * **Features**:\n * - List all subscribers with status (active, unsubscribed, bounced, complained)\n * - Search subscribers by email, name\n * - Filter by status, tags, segments\n * - Add subscribers manually (individual or bulk CSV import)\n * - Export subscribers to CSV/Excel\n * - Bulk actions (tag, untag, delete, export)\n * - View subscriber engagement metrics\n * - Create and manage segments\n *\n * **RBAC**: Requires `tenantmodule-newsletter:subscribers:read` scope\n */\nexport function SubscribersListPage() {\n const { locale } = useI18n();\n const tr = useTr();\n const navigate = useNavigate();\n const { productId } = useNewsletter();\n const { hasPermission, isLoading: permissionsLoading, permissions } = usePermissions();\n const { subscriberFilter, updateSubscriberFilter } = useNewsletterStore();\n\n // Permission checks\n const permsRegistered = (\n Array.isArray(permissions) ? permissions : permissions?.permissionStrings\n )?.some?.((p: string) => p.startsWith('tenantmodule-newsletter:subscribers:'));\n const canList = permsRegistered ? hasPermission(NEWSLETTER_PERMISSIONS.SUBSCRIBER_LIST) : true;\n const canCreate = permsRegistered\n ? hasPermission(NEWSLETTER_PERMISSIONS.SUBSCRIBER_CREATE)\n : true;\n const canDelete = permsRegistered\n ? hasPermission(NEWSLETTER_PERMISSIONS.SUBSCRIBER_DELETE)\n : true;\n const canImport = permsRegistered\n ? hasPermission(NEWSLETTER_PERMISSIONS.SUBSCRIBER_IMPORT)\n : true;\n const canExport = permsRegistered\n ? hasPermission(NEWSLETTER_PERMISSIONS.SUBSCRIBER_EXPORT)\n : true;\n\n // Local state\n const [showAddModal, setShowAddModal] = useState(false);\n const [showImportModal, setShowImportModal] = useState(false);\n const [newEmail, setNewEmail] = useState('');\n const [csvData, setCsvData] = useState('');\n const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set());\n const [notification, setNotification] = useState<{\n type: 'success' | 'error';\n message: string;\n } | null>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n // Determine subscribed filter based on status\n const getSubscribedFilter = () => {\n if (subscriberFilter.status === 'ACTIVE') return true;\n if (subscriberFilter.status === 'UNSUBSCRIBED') return false;\n return undefined; // ALL\n };\n\n // GraphQL hooks\n const { subscribers, totalCount, loading, error, refetch } = useSubscribers({\n subscribed: getSubscribedFilter(),\n platformProductId: productId,\n });\n const {\n subscribe,\n unsubscribeFromProduct,\n resubscribeToProduct,\n deleteSubscriber,\n importSubscribers,\n subscribing,\n unsubscribing,\n deletingSubscriber,\n importing,\n } = useSubscriberMutations();\n const { exportSubscribers } = useExportSubscribers(undefined, productId);\n const { products } = usePlatformProducts();\n\n // Filter subscribers locally by search\n const filteredSubscribers = subscribers.filter((sub) => {\n if (!subscriberFilter.search) return true;\n const search = subscriberFilter.search.toLowerCase();\n return sub.email.toLowerCase().includes(search);\n });\n\n // At-a-glance audience health for the emphasis summary\n const activeCount = subscribers.filter(\n (sub) => sub.subscribed && sub.status !== 'UNSUBSCRIBED'\n ).length;\n const unsubscribedCount = subscribers.filter(\n (sub) => !sub.subscribed || sub.status === 'UNSUBSCRIBED'\n ).length;\n\n // Show notification helper\n const showNotification = (type: 'success' | 'error', message: string) => {\n setNotification({ type, message });\n setTimeout(() => setNotification(null), 5000);\n };\n\n const handleSearchChange = (search: string) => {\n updateSubscriberFilter({ search });\n };\n\n const handleStatusFilter = (status: string) => {\n updateSubscriberFilter({\n status: status as 'ACTIVE' | 'PAUSED' | 'UNSUBSCRIBED' | 'ALL',\n });\n };\n\n const handleExport = async () => {\n try {\n const result = await exportSubscribers();\n if (result.data?.exportSubscribers) {\n const csvContent = [\n [\n tr('newsletter.email', 'Email'),\n tr('newsletterCommon.status', 'Status'),\n tr('subscribers.subscribedAt', 'Subscribed At'),\n tr('subscribers.unsubscribedAt', 'Unsubscribed At'),\n ].join(','),\n ...result.data.exportSubscribers.map(\n (sub) => `${sub.email},${sub.status},${sub.subscribedAt},${sub.unsubscribedAt || ''}`\n ),\n ].join('\\n');\n\n const blob = new Blob([csvContent], { type: 'text/csv' });\n const url = window.URL.createObjectURL(blob);\n const a = document.createElement('a');\n a.href = url;\n a.download = `${tr('subscribers.exportFilenamePrefix', 'subscribers')}-${new Date().toISOString().split('T')[0]}.csv`;\n a.click();\n window.URL.revokeObjectURL(url);\n showNotification(\n 'success',\n tr('subscribers.exportedSuccessfully', 'Subscribers exported successfully')\n );\n }\n } catch (err) {\n showNotification(\n 'error',\n `${tr('subscribers.failedToExport', 'Failed to export')}: ${err instanceof Error ? err.message : tr('newsletter.unknownError', 'Unknown error')}`\n );\n }\n };\n\n const handleAddSubscriber = async () => {\n if (!newEmail.trim()) {\n showNotification(\n 'error',\n tr('subscribers.pleaseEnterEmail', 'Please enter an email address')\n );\n return;\n }\n\n try {\n const input: SubscribeInput = {\n email: newEmail.trim(),\n platformProductId: productId,\n };\n const result = await subscribe(input);\n showNotification(\n 'success',\n result?.alreadySubscribed\n ? `${newEmail} ${tr('subscribers.alreadySubscribedSuffix', 'is already part of this newsletter')}`\n : `${newEmail} ${tr('subscribers.addedSuccessfully', 'added successfully')}`\n );\n setNewEmail('');\n setShowAddModal(false);\n } catch (err) {\n showNotification(\n 'error',\n `${tr('subscribers.failedToAddSubscriber', 'Failed to add subscriber')}: ${err instanceof Error ? err.message : tr('newsletter.unknownError', 'Unknown error')}`\n );\n }\n };\n\n const handleImportSubscribers = async () => {\n if (!csvData.trim()) {\n showNotification(\n 'error',\n tr('subscribers.pleaseEnterEmails', 'Please enter email addresses')\n );\n return;\n }\n\n try {\n // Parse CSV data - support both comma and newline separated\n const emails = csvData\n .split(/[\\n,]/)\n .map((e) => e.trim())\n .filter((e) => e && e.includes('@'));\n\n if (emails.length === 0) {\n showNotification(\n 'error',\n tr('subscribers.noValidEmails', 'No valid email addresses found')\n );\n return;\n }\n\n const subscribersToImport: ImportSubscriberInput[] = emails.map((email) => ({\n email,\n platformProductId: productId,\n }));\n\n const result = await importSubscribers(subscribersToImport);\n if (result) {\n showNotification(\n 'success',\n `${tr('subscribers.importedPrefix', 'Imported')} ${result.imported} ${tr('subscribers.subscribersLower', 'subscribers')}. ${tr('subscribers.skipped', 'Skipped')}: ${result.skipped}, ${tr('subscribers.failed', 'Failed')}: ${result.failed}`\n );\n setCsvData('');\n setShowImportModal(false);\n }\n } catch (err) {\n showNotification(\n 'error',\n `${tr('subscribers.failedToImport', 'Failed to import')}: ${err instanceof Error ? err.message : tr('newsletter.unknownError', 'Unknown error')}`\n );\n }\n };\n\n const handleFileUpload = (event: React.ChangeEvent<HTMLInputElement>) => {\n const file = event.target.files?.[0];\n if (!file) return;\n\n const reader = new FileReader();\n reader.onload = (e) => {\n setCsvData(e.target?.result as string);\n };\n reader.readAsText(file);\n };\n\n const handleUnsubscribe = async (email: string) => {\n if (\n !confirm(\n `${tr('subscribers.confirmUnsubscribePrefix', 'Are you sure you want to unsubscribe')} ${email}?`\n )\n )\n return;\n\n try {\n await unsubscribeFromProduct(email, productId);\n showNotification(\n 'success',\n `${email} ${tr('subscribers.unsubscribedSuffix', 'unsubscribed')}`\n );\n } catch (err) {\n showNotification(\n 'error',\n `${tr('subscribers.failedToUnsubscribe', 'Failed to unsubscribe')}: ${err instanceof Error ? err.message : tr('newsletter.unknownError', 'Unknown error')}`\n );\n }\n };\n\n const handleResubscribe = async (email: string) => {\n try {\n await resubscribeToProduct(email, productId);\n showNotification(\n 'success',\n `${email} ${tr('subscribers.resubscribedSuffix', 'resubscribed')}`\n );\n } catch (err) {\n showNotification(\n 'error',\n `${tr('subscribers.failedToResubscribe', 'Failed to resubscribe')}: ${err instanceof Error ? err.message : tr('newsletter.unknownError', 'Unknown error')}`\n );\n }\n };\n\n const handleDelete = async (id: string, email: string) => {\n const confirmed = await nativeConfirm({\n title: tr('subscribers.deleteSubscriber', 'Delete Subscriber'),\n message: `${tr('subscribers.confirmDeletePrefix', 'Are you sure you want to delete')} ${email}? ${tr('newsletter.actionCannotBeUndone', 'This action cannot be undone.')}`,\n });\n if (confirmed === false) return;\n\n try {\n await deleteSubscriber(id);\n void nativeNotify('success');\n showNotification('success', `${email} ${tr('newsletter.deletedSuffix', 'deleted')}`);\n } catch (err) {\n void nativeNotify('error');\n showNotification(\n 'error',\n `${tr('templates.failedToDelete', 'Failed to delete')}: ${err instanceof Error ? err.message : tr('newsletter.unknownError', 'Unknown error')}`\n );\n }\n };\n\n const handleSelectAll = () => {\n if (selectedIds.size === filteredSubscribers.length) {\n setSelectedIds(new Set());\n } else {\n setSelectedIds(new Set(filteredSubscribers.map((s) => s.id)));\n }\n };\n\n const handleSelectOne = (id: string) => {\n const newSelected = new Set(selectedIds);\n if (newSelected.has(id)) {\n newSelected.delete(id);\n } else {\n newSelected.add(id);\n }\n setSelectedIds(newSelected);\n };\n\n const handleViewSubscriber = (id: string) => {\n navigate(id);\n };\n\n const formatDate = (dateString: string) => {\n return new Date(dateString).toLocaleDateString(locale || 'en-US', {\n month: 'short',\n day: 'numeric',\n year: 'numeric',\n });\n };\n\n // Guard: loading permissions\n if (permissionsLoading) {\n return (\n <div className=\"flex items-center justify-center h-full\">\n <div className=\"flex items-center gap-2 text-text-secondary\">\n <Loader2 className=\"animate-spin\" size={24} />\n <span>{tr('newsletterCommon.loading', 'Loading...')}</span>\n </div>\n </div>\n );\n }\n\n // Guard: access denied\n if (!permissionsLoading && permissions && permissions.permissionStrings?.length > 0 && !canList) {\n return <AccessDenied />;\n }\n\n return (\n <div className=\"flex flex-col h-full\">\n {/* Notification */}\n {notification && (\n <div\n className={`fixed top-4 right-4 z-50 flex items-center gap-2 px-4 py-3 rounded-lg shadow-[var(--shadow-pop)] ${\n notification.type === 'success'\n ? 'bg-status-success-bg-subtle text-status-success-text border border-status-success-border/20'\n : 'bg-status-error-bg-subtle text-status-error-text border border-status-error-border/20'\n }`}\n >\n {notification.type === 'success' ? <CheckCircle size={20} /> : <AlertCircle size={20} />}\n <span>{notification.message}</span>\n </div>\n )}\n\n {/* Header */}\n <div className=\"relative overflow-hidden flex items-center justify-between p-6 border-b border-border-seam\">\n <AuroraBackground intensity=\"subtle\" />\n <div>\n <h1 className=\"text-2xl font-semibold text-text-primary\">\n <GradientText>{tr('subscribers.subscribers', 'Subscribers')}</GradientText>\n </h1>\n <p className=\"mt-1 text-sm text-text-secondary tabular-nums\">\n {totalCount} {tr('subscribers.totalSubscribers', 'total subscribers')}\n </p>\n </div>\n <div className=\"flex items-center gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"icon\"\n onClick={() => refetch()}\n title={tr('newsletter.refresh', 'Refresh')}\n aria-label={tr('newsletter.refresh', 'Refresh')}\n >\n <RefreshCw size={18} className={loading ? 'animate-spin' : ''} />\n </Button>\n <CTAOverflowMenu\n primary={\n canCreate\n ? {\n label: tr('subscribers.addSubscriber', 'Add Subscriber'),\n icon: <Plus size={18} />,\n onSelect: () => setShowAddModal(true),\n }\n : undefined\n }\n actions={[\n ...(canImport\n ? [\n {\n label: tr('subscribers.import', 'Import'),\n icon: <Upload size={16} />,\n onSelect: () => setShowImportModal(true),\n },\n ]\n : []),\n ...(canExport\n ? [\n {\n label: tr('subscribers.export', 'Export'),\n icon: <Download size={16} />,\n onSelect: () => handleExport(),\n },\n ]\n : []),\n ]}\n />\n </div>\n </div>\n\n {/* Page purpose */}\n <div className=\"px-6 pt-6\">\n <PagePurpose>\n {tr(\n 'subscribers.pagePurpose',\n 'Your audience lives here — every person who can receive a newsletter for this product. Add people one at a time, bulk-import a CSV, or export the list, and keep it healthy by tracking who is active, paused, or has unsubscribed. A clean, consented list is what keeps your emails landing in inboxes.'\n )}\n </PagePurpose>\n </div>\n\n {/* Audience summary — the emphasis zone */}\n <div className=\"px-6 pt-6\">\n <EmphasisPanel className=\"flex flex-wrap items-center gap-8 p-4\">\n <div className=\"flex items-center gap-3\">\n <div className=\"p-2 bg-action-primary-bg/10 rounded-lg\">\n <Users size={20} className=\"text-primary\" />\n </div>\n <div>\n <p className=\"text-2xl font-bold text-text-primary tabular-nums\">{totalCount}</p>\n <p className=\"text-sm text-text-secondary\">\n {tr('subscribers.totalSubscribers', 'total subscribers')}\n </p>\n </div>\n </div>\n <div className=\"flex items-center gap-3\">\n <div className=\"p-2 bg-status-success-bg-subtle rounded-lg\">\n <Mail size={20} className=\"text-status-success-text\" />\n </div>\n <div>\n <p className=\"text-2xl font-bold text-text-primary tabular-nums\">{activeCount}</p>\n <p className=\"text-sm text-text-secondary\">{tr('subscribers.active', 'Active')}</p>\n </div>\n </div>\n <div className=\"flex items-center gap-3\">\n <div className=\"p-2 bg-bg-sunken rounded-lg\">\n <MailX size={20} className=\"text-text-secondary\" />\n </div>\n <div>\n <p className=\"text-2xl font-bold text-text-primary tabular-nums\">\n {unsubscribedCount}\n </p>\n <p className=\"text-sm text-text-secondary\">\n {tr('subscribers.unsubscribed', 'Unsubscribed')}\n </p>\n </div>\n </div>\n </EmphasisPanel>\n </div>\n\n {/* Filters */}\n <div className=\"flex items-center gap-4 p-6 border-b border-border-seam\">\n <div className=\"flex-1 relative\">\n <Search\n className=\"absolute left-3 top-1/2 -translate-y-1/2 text-text-secondary\"\n size={20}\n />\n <input\n type=\"text\"\n aria-label={tr('subscribers.searchByEmail', 'Search by email...')}\n placeholder={tr('subscribers.searchByEmail', 'Search by email...')}\n value={subscriberFilter.search}\n onChange={(e) => handleSearchChange(e.target.value)}\n className=\"w-full pl-10 pr-4 py-2 border border-border-subtle rounded-lg focus:ring-2 focus:ring-primary/50 focus:border-transparent\"\n />\n </div>\n <select\n value={subscriberFilter.status}\n onChange={(e) => handleStatusFilter(e.target.value)}\n className=\"px-4 py-2 border border-border-subtle rounded-lg focus:ring-2 focus:ring-primary/50 focus:border-transparent scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"ALL\">{tr('newsletterCommon.allStatuses', 'All Statuses')}</option>\n <option value=\"ACTIVE\">{tr('subscribers.active', 'Active')}</option>\n <option value=\"PAUSED\">{tr('subscribers.paused', 'Paused')}</option>\n <option value=\"UNSUBSCRIBED\">\n {tr('subscribers.unsubscribedStatus', 'Unsubscribed')}\n </option>\n </select>\n <div className=\"rounded-lg border border-border-subtle bg-bg-sunken px-4 py-2 text-sm text-text-secondary\">\n {tr('newsletter.product', 'Product')}:{' '}\n {getProductName(productId, tr('newsletter.notAvailable', 'N/A'), products)}\n </div>\n <button\n type=\"button\"\n className=\"flex items-center gap-2 px-4 py-2 border border-border-subtle rounded-lg hover:bg-accent transition-colors\"\n >\n <Filter size={20} />\n {tr('newsletter.moreFilters', 'More Filters')}\n </button>\n </div>\n\n {/* Subscribers List */}\n <div className=\"flex-1 overflow-auto\">\n {error ? (\n <div className=\"flex items-center justify-center h-full p-6\">\n <IllustratedEmptyState\n illustration=\"empty-generic\"\n title={tr('subscribers.failedLoadSubscribers', 'Failed to load subscribers')}\n description={error.message}\n action={\n <Button type=\"button\" onClick={() => refetch()}>\n {tr('newsletterCommon.tryAgain', 'Try Again')}\n </Button>\n }\n />\n </div>\n ) : loading && subscribers.length === 0 ? (\n <div className=\"flex items-center justify-center h-full\">\n <div className=\"flex items-center gap-2 text-text-secondary\">\n <Loader2 className=\"animate-spin\" size={24} />\n <span>{tr('subscribers.loadingSubscribers', 'Loading subscribers...')}</span>\n </div>\n </div>\n ) : filteredSubscribers.length === 0 ? (\n <div className=\"flex items-center justify-center h-full p-6\">\n <IllustratedEmptyState\n illustration={subscriberFilter.search ? 'empty-search' : 'empty-people'}\n title={\n subscriberFilter.search\n ? tr('subscribers.noSubscribersFound', 'No subscribers found')\n : tr('subscribers.noSubscribersYet', 'No subscribers yet')\n }\n description={\n subscriberFilter.search\n ? tr('newsletterCommon.tryDifferentSearch', 'Try a different search term')\n : tr(\n 'subscribers.noSubscribersDescription',\n 'Start building your subscriber list by adding subscribers manually or importing them from a CSV file.'\n )\n }\n action={\n !subscriberFilter.search ? (\n <div className=\"flex items-center gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => setShowImportModal(true)}\n >\n {tr('subscribers.importFromCsv', 'Import from CSV')}\n </Button>\n <Button type=\"button\" onClick={() => setShowAddModal(true)}>\n {tr('subscribers.addManually', 'Add Manually')}\n </Button>\n </div>\n ) : undefined\n }\n />\n </div>\n ) : (\n <table className=\"w-full\">\n <thead className=\"bg-bg-sunken border-b border-border-seam sticky top-0\">\n <tr>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider\">\n <input\n type=\"checkbox\"\n aria-label={tr('subscribers.selectAll', 'Select all subscribers')}\n checked={selectedIds.size === filteredSubscribers.length}\n onChange={handleSelectAll}\n className=\"rounded\"\n />\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider\">\n {tr('newsletter.email', 'Email')}\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider\">\n {tr('subscribers.product', 'Product')}\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider\">\n {tr('newsletterCommon.status', 'Status')}\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider\">\n {tr('subscribers.subscribed', 'Subscribed')}\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider\">\n {tr('newsletter.actions', 'Actions')}\n </th>\n </tr>\n </thead>\n <tbody className=\"bg-bg-surface divide-y divide-border\">\n {filteredSubscribers.map((subscriber) => (\n <SubscriberRow\n key={subscriber.id}\n subscriber={subscriber}\n selected={selectedIds.has(subscriber.id)}\n onSelect={() => handleSelectOne(subscriber.id)}\n onView={() => handleViewSubscriber(subscriber.id)}\n onUnsubscribe={() => handleUnsubscribe(subscriber.email)}\n onResubscribe={() => handleResubscribe(subscriber.email)}\n onDelete={\n canDelete ? () => handleDelete(subscriber.id, subscriber.email) : undefined\n }\n formatDate={formatDate}\n emptyProductLabel={tr('newsletterCommon.notAvailable', 'N/A')}\n products={products}\n isDeleting={deletingSubscriber}\n isUnsubscribing={unsubscribing}\n />\n ))}\n </tbody>\n </table>\n )}\n </div>\n\n {/* Add Subscriber Modal */}\n {showAddModal && (\n <div className=\"fixed inset-0 bg-black/50 flex items-center justify-center z-50\">\n <div className=\"bg-bg-surface rounded-lg shadow-xl w-full max-w-md p-6\">\n <div className=\"flex items-center justify-between mb-4\">\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {tr('subscribers.addSubscriber', 'Add Subscriber')}\n </h2>\n <button\n type=\"button\"\n onClick={() => setShowAddModal(false)}\n className=\"p-1 hover:bg-accent rounded\"\n >\n <X size={20} />\n </button>\n </div>\n <div className=\"mb-4\">\n <label className=\"block text-sm font-medium text-text-primary mb-1\">\n {tr('subscribers.emailAddress', 'Email Address')}\n </label>\n <input\n type=\"email\"\n aria-label={tr('subscribers.emailAddress', 'Email address')}\n value={newEmail}\n onChange={(e) => setNewEmail(e.target.value)}\n placeholder={tr('subscribers.emailPlaceholder', 'subscriber@example.com')}\n className=\"w-full px-3 py-2 border border-border-subtle rounded-lg focus:ring-2 focus:ring-primary/50 focus:border-transparent\"\n onKeyDown={(e) => e.key === 'Enter' && handleAddSubscriber()}\n />\n </div>\n <div className=\"flex justify-end gap-2\">\n <button\n type=\"button\"\n onClick={() => setShowAddModal(false)}\n className=\"px-4 py-2 border border-border-subtle rounded-lg hover:bg-accent transition-colors\"\n >\n {tr('newsletterCommon.cancel', 'Cancel')}\n </button>\n <button\n type=\"button\"\n onClick={handleAddSubscriber}\n disabled={subscribing}\n className=\"flex items-center gap-2 px-4 py-2 bg-action-primary-bg text-action-primary-text rounded-lg hover:bg-action-primary-bg/90 transition-colors disabled:opacity-50\"\n >\n {subscribing ? <Loader2 size={16} className=\"animate-spin\" /> : <Plus size={16} />}\n {tr('subscribers.addSubscriber', 'Add Subscriber')}\n </button>\n </div>\n </div>\n </div>\n )}\n\n {/* Import Modal */}\n {showImportModal && (\n <div className=\"fixed inset-0 bg-black/50 flex items-center justify-center z-50\">\n <div className=\"bg-bg-surface rounded-lg shadow-xl w-full max-w-lg p-6\">\n <div className=\"flex items-center justify-between mb-4\">\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {tr('subscribers.importSubscribers', 'Import Subscribers')}\n </h2>\n <button\n type=\"button\"\n onClick={() => setShowImportModal(false)}\n className=\"p-1 hover:bg-accent rounded\"\n >\n <X size={20} />\n </button>\n </div>\n <div className=\"mb-4\">\n <div className=\"flex items-center justify-between mb-2\">\n <label className=\"block text-sm font-medium text-text-primary\">\n {tr('subscribers.emailAddresses', 'Email Addresses')}\n </label>\n <button\n type=\"button\"\n onClick={() => fileInputRef.current?.click()}\n className=\"text-sm text-primary hover:text-primary/80\"\n >\n {tr('subscribers.uploadCsv', 'Upload CSV')}\n </button>\n <input\n ref={fileInputRef}\n type=\"file\"\n aria-label={tr('subscribers.uploadCsvFile', 'Upload CSV file')}\n accept=\".csv,.txt\"\n onChange={handleFileUpload}\n className=\"hidden\"\n />\n </div>\n <textarea\n aria-label={tr('subscribers.csvData', 'CSV data')}\n value={csvData}\n onChange={(e) => setCsvData(e.target.value)}\n placeholder={tr(\n 'subscribers.csvPlaceholder',\n 'Enter email addresses (one per line or comma-separated)\\n\\nemail1@example.com\\nemail2@example.com\\nemail3@example.com'\n )}\n rows={8}\n className=\"w-full px-3 py-2 border border-border-subtle rounded-lg focus:ring-2 focus:ring-primary/50 focus:border-transparent font-mono text-sm\"\n />\n <p className=\"mt-1 text-xs text-text-secondary\">\n {tr(\n 'subscribers.supportedFormats',\n 'Supported formats: one email per line, comma-separated, or CSV file'\n )}\n </p>\n </div>\n <div className=\"flex justify-end gap-2\">\n <button\n type=\"button\"\n onClick={() => setShowImportModal(false)}\n className=\"px-4 py-2 border border-border-subtle rounded-lg hover:bg-accent transition-colors\"\n >\n {tr('newsletterCommon.cancel', 'Cancel')}\n </button>\n <button\n type=\"button\"\n onClick={handleImportSubscribers}\n disabled={importing}\n className=\"flex items-center gap-2 px-4 py-2 bg-action-primary-bg text-action-primary-text rounded-lg hover:bg-action-primary-bg/90 transition-colors disabled:opacity-50\"\n >\n {importing ? <Loader2 size={16} className=\"animate-spin\" /> : <Upload size={16} />}\n {tr('subscribers.import', 'Import')}\n </button>\n </div>\n </div>\n </div>\n )}\n </div>\n );\n}\n\n/**\n * Subscriber row component\n */\ninterface SubscriberRowProps {\n subscriber: Subscriber;\n selected: boolean;\n onSelect: () => void;\n onView: () => void;\n onUnsubscribe: () => void;\n onResubscribe: () => void;\n onDelete?: () => void;\n formatDate: (date: string) => string;\n emptyProductLabel: string;\n products: Array<{ id: string; name: string }>;\n isDeleting: boolean;\n isUnsubscribing: boolean;\n}\n\nfunction SubscriberRow({\n subscriber,\n selected,\n onSelect,\n onView,\n onUnsubscribe,\n onResubscribe,\n onDelete,\n formatDate,\n emptyProductLabel,\n products,\n}: SubscriberRowProps) {\n const tr = useTr();\n const getStatusBadge = (status: string, subscribed: boolean) => {\n if (!subscribed || status === 'UNSUBSCRIBED') {\n return (\n <span className=\"inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium bg-bg-sunken text-text-secondary\">\n <MailX size={12} />\n {tr('subscribers.unsubscribed', 'Unsubscribed')}\n </span>\n );\n }\n if (status === 'PAUSED') {\n return (\n <span className=\"inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium bg-status-warning-bg-subtle text-status-warning-text\">\n {tr('subscribers.paused', 'Paused')}\n </span>\n );\n }\n return (\n <span className=\"inline-flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium bg-status-success-bg-subtle text-status-success-text\">\n <span className=\"size-1.5 rounded-full bg-status-success-text motion-safe:animate-vc-glow-pulse\" />\n <Mail size={12} />\n {tr('subscribers.active', 'Active')}\n </span>\n );\n };\n\n return (\n <tr className=\"hover:bg-accent\">\n <td className=\"px-6 py-4\">\n <input\n type=\"checkbox\"\n aria-label={`Select ${subscriber.email}`}\n checked={selected}\n onChange={onSelect}\n className=\"rounded\"\n />\n </td>\n <td className=\"px-6 py-4\">\n <button\n type=\"button\"\n onClick={onView}\n className=\"text-text-primary hover:text-primary font-medium\"\n >\n {subscriber.email}\n </button>\n </td>\n <td className=\"px-6 py-4 text-sm text-text-secondary\">\n {getProductName(subscriber.platformProductId, emptyProductLabel, products)}\n </td>\n <td className=\"px-6 py-4\">{getStatusBadge(subscriber.status, subscriber.subscribed)}</td>\n <td className=\"px-6 py-4 text-sm text-text-secondary\">\n {formatDate(subscriber.subscribedAt)}\n </td>\n <td className=\"px-6 py-4\">\n <div className=\"flex items-center gap-2\">\n {subscriber.subscribed ? (\n <button\n type=\"button\"\n onClick={onUnsubscribe}\n className=\"text-xs text-status-warning-text hover:opacity-80\"\n title={tr('subscribers.unsubscribe', 'Unsubscribe')}\n >\n {tr('subscribers.unsubscribe', 'Unsubscribe')}\n </button>\n ) : (\n <button\n type=\"button\"\n onClick={onResubscribe}\n className=\"text-xs text-status-success-text hover:opacity-80\"\n title={tr('subscribers.resubscribe', 'Resubscribe')}\n >\n {tr('subscribers.resubscribe', 'Resubscribe')}\n </button>\n )}\n {onDelete && (\n <button\n type=\"button\"\n onClick={onDelete}\n className=\"p-1 text-status-error-text hover:text-status-error-text/80 hover:bg-status-error-bg/10 rounded\"\n title={tr('newsletter.delete', 'Delete')}\n >\n <Trash2 size={14} />\n </button>\n )}\n </div>\n </td>\n </tr>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AA8CA,SAAS,EACP,GACA,GACA,GACQ;AAER,QADK,IACE,EAAS,MAAM,MAAY,EAAQ,OAAO,EAAI,EAAE,QAAQ,EAAI,MAAM,GAAG,EAAE,GAD7D;;AAmBnB,SAAgB,IAAsB;CACpC,IAAM,EAAE,cAAW,IAAS,EACtB,IAAK,GAAO,EACZ,KAAW,IAAa,EACxB,EAAE,iBAAc,GAAe,EAC/B,EAAE,kBAAe,WAAW,GAAoB,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D;MACE,MAAK;MACL,SAAS;MACT,WAAU;MACV,OAAO,EAAG,2BAA2B,cAAc;gBAElD,EAAG,2BAA2B,cAAc;MACtC,CAAA,EAEV,KACC,kBAAC,UAAD;MACE,MAAK;MACL,SAAS;MACT,WAAU;MACV,OAAO,EAAG,qBAAqB,SAAS;gBAExC,kBAAC,GAAD,EAAQ,MAAM,IAAM,CAAA;MACb,CAAA,CAEP;;IACH,CAAA;GACF"}
|
|
@@ -285,7 +285,7 @@ function m() {
|
|
|
285
285
|
}), /* @__PURE__ */ d("select", {
|
|
286
286
|
value: j,
|
|
287
287
|
onChange: (e) => J(e.target.value),
|
|
288
|
-
className: "w-full px-3 py-2 border border-border-seam rounded-lg bg-bg-surface focus:ring-2 focus:ring-primary/50 focus:border-transparent",
|
|
288
|
+
className: "w-full px-3 py-2 border border-border-seam rounded-lg bg-bg-surface focus:ring-2 focus:ring-primary/50 focus:border-transparent scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary",
|
|
289
289
|
children: [
|
|
290
290
|
/* @__PURE__ */ u("option", {
|
|
291
291
|
value: "ANNOUNCEMENT",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateEditorPage.js","names":[],"sources":["../../../src/newsletter/pages/TemplateEditorPage.tsx"],"sourcesContent":["import { useParams, useNavigate } from 'react-router';\nimport { useState } from 'react';\nimport {\n Save,\n Eye,\n ArrowLeft,\n Code,\n PanelsTopLeft,\n Monitor,\n Tablet,\n Smartphone,\n Loader2,\n AlertCircle,\n CheckCircle,\n Copy,\n Trash2,\n} from 'lucide-react';\nimport { useNewsletter } from '../providers/NewsletterProvider';\nimport {\n useTemplate,\n useTemplateMutations,\n type CreateTemplateInput,\n type UpdateTemplateInput,\n} from '../hooks/useNewsletterOperations';\nimport { useNewsletterStore } from '../store/newsletterStore';\nimport { AccessDenied } from '@burdenoff/fe-libs/shared/components';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { NEWSLETTER_PERMISSIONS } from '../constants/permissions';\nimport { useTr } from '../shared/hooks/useTr';\nimport { nativeConfirm, nativeNotify } from '../../utils/nativeBridge';\nimport {\n GlassCard,\n GradientText,\n AuroraBackground,\n IllustratedEmptyState,\n CTAOverflowMenu,\n Button,\n PagePurpose,\n NextSteps,\n} from '@burdenoff/fe-libs/ui';\n\n// Empty HTML template for new templates - use content blocks to build\nconst DEFAULT_HTML = '';\n\n/**\n * TemplateEditorPage - Create or edit email template\n *\n * **Features**:\n * - Template name and description\n * - Category selection\n * - Visual drag-drop template builder\n * - Code editor for advanced users\n * - Live preview (desktop, tablet, mobile)\n * - Reusable content blocks\n * - Brand kit integration\n * - Save and publish template\n *\n * **RBAC**: Requires `tenantmodule-newsletter:templates:write` scope\n */\nexport function TemplateEditorPage() {\n const tr = useTr();\n const { templateId } = useParams<{ templateId: string }>();\n const navigate = useNavigate();\n const { productId } = useNewsletter();\n const { hasPermission, isLoading: permissionsLoading, permissions } = usePermissions();\n const { editorMode, setEditorMode, previewMode, setPreviewMode } = useNewsletterStore();\n\n const isNewTemplate = !templateId || templateId === 'new';\n\n // Permission checks\n const permsRegistered = (\n Array.isArray(permissions) ? permissions : permissions?.permissionStrings\n )?.some?.((p: string) => p.startsWith('tenantmodule-newsletter:templates:'));\n const canCreate = permsRegistered ? hasPermission(NEWSLETTER_PERMISSIONS.TEMPLATE_CREATE) : true;\n const canUpdate = permsRegistered ? hasPermission(NEWSLETTER_PERMISSIONS.TEMPLATE_UPDATE) : true;\n\n // Form state\n const [name, setName] = useState('');\n const [description, setDescription] = useState('');\n const [category, setCategory] = useState('CUSTOM');\n const [html, setHtml] = useState(DEFAULT_HTML);\n const [isDirty, setIsDirty] = useState(false);\n\n // UI state\n const [showPreview, setShowPreview] = useState(false);\n const [notification, setNotification] = useState<{\n type: 'success' | 'error';\n message: string;\n } | null>(null);\n\n // GraphQL hooks\n const { template, loading, error } = useTemplate(isNewTemplate ? '' : templateId || '');\n const { createTemplate, updateTemplate, deleteTemplate, creating, updating, deleting } =\n useTemplateMutations();\n\n // Track synced template using state (React-recommended pattern for syncing external data)\n const [syncedTemplateId, setSyncedTemplateId] = useState<string | null>(null);\n\n // Sync template data during render - React recommended pattern for \"adjusting state when props change\"\n if (template && !isNewTemplate && template.id !== syncedTemplateId) {\n setSyncedTemplateId(template.id);\n setName(template.name);\n setDescription(template.description || '');\n setCategory(template.category || 'CUSTOM');\n setHtml(template.html);\n setIsDirty(false);\n }\n\n // Mark as dirty on changes\n const handleNameChange = (value: string) => {\n setName(value);\n setIsDirty(true);\n };\n\n const handleDescriptionChange = (value: string) => {\n setDescription(value);\n setIsDirty(true);\n };\n\n const handleCategoryChange = (value: string) => {\n setCategory(value);\n setIsDirty(true);\n };\n\n const handleHtmlChange = (value: string) => {\n setHtml(value);\n setIsDirty(true);\n };\n\n // Show notification helper\n const showNotification = (type: 'success' | 'error', message: string) => {\n setNotification({ type, message });\n setTimeout(() => setNotification(null), 5000);\n };\n\n const handleBack = () => {\n if (\n isDirty &&\n !confirm(\n tr(\n 'templates.unsavedChangesConfirm',\n 'You have unsaved changes. Are you sure you want to leave?'\n )\n )\n ) {\n return;\n }\n navigate('../templates');\n };\n\n const handleSave = async () => {\n if (!name.trim()) {\n showNotification('error', tr('templates.nameRequired', 'Template name is required'));\n return;\n }\n\n if (!html.trim()) {\n showNotification('error', tr('templates.htmlRequired', 'Template HTML content is required'));\n return;\n }\n\n try {\n if (isNewTemplate) {\n const input: CreateTemplateInput = {\n name: name.trim(),\n description: description.trim() || undefined,\n platformProductId: productId,\n category,\n html,\n };\n const result = await createTemplate(input);\n showNotification(\n 'success',\n tr('templates.templateCreatedSuccessfully', 'Template created successfully')\n );\n setIsDirty(false);\n // Navigate to edit mode for the new template\n if (result?.id) {\n navigate(`../templates/${result.id}`, { replace: true });\n }\n } else {\n const input: UpdateTemplateInput = {\n name: name.trim(),\n description: description.trim() || undefined,\n category,\n html,\n };\n await updateTemplate(templateId!, input);\n showNotification(\n 'success',\n tr('templates.templateSavedSuccessfully', 'Template saved successfully')\n );\n setIsDirty(false);\n }\n } catch (err) {\n showNotification(\n 'error',\n `${tr('newsletter.failedToSave', 'Failed to save')}: ${err instanceof Error ? err.message : tr('newsletter.unknownError', 'Unknown error')}`\n );\n }\n };\n\n const handleDelete = async () => {\n if (isNewTemplate) return;\n const confirmed = await nativeConfirm({\n title: tr('templates.deleteTemplate', 'Delete Template'),\n message: `${tr('templates.confirmDelete', 'Are you sure you want to delete')} \"${name}\"? ${tr('newsletter.actionCannotBeUndone', 'This action cannot be undone.')}`,\n });\n if (confirmed === false) return;\n\n try {\n await deleteTemplate(templateId!);\n void nativeNotify('success');\n showNotification('success', tr('templates.templateDeleted', 'Template deleted'));\n setTimeout(() => navigate('../templates'), 1500);\n } catch (err) {\n void nativeNotify('error');\n showNotification(\n 'error',\n `${tr('templates.failedToDelete', 'Failed to delete')}: ${err instanceof Error ? err.message : tr('newsletter.unknownError', 'Unknown error')}`\n );\n }\n };\n\n const handleDuplicate = async () => {\n if (isNewTemplate) return;\n try {\n const input: CreateTemplateInput = {\n name: `${name} (${tr('newsletter.copyShort', 'Copy')})`,\n description: description || undefined,\n platformProductId: productId,\n category,\n html,\n };\n const result = await createTemplate(input);\n showNotification('success', tr('templates.templateDuplicated', 'Template duplicated'));\n if (result?.id) {\n navigate(`../templates/${result.id}`, { replace: true });\n }\n } catch (err) {\n showNotification(\n 'error',\n `${tr('templates.failedToDuplicate', 'Failed to duplicate')}: ${err instanceof Error ? err.message : tr('newsletter.unknownError', 'Unknown error')}`\n );\n }\n };\n\n // Insert content block at cursor\n const insertBlock = (blockHtml: string) => {\n setHtml((prev) => prev + '\\n' + blockHtml);\n setIsDirty(true);\n };\n\n // Get preview width based on device\n const getPreviewWidth = () => {\n switch (previewMode) {\n case 'MOBILE':\n return '375px';\n case 'TABLET':\n return '768px';\n default:\n return '100%';\n }\n };\n\n // Guard: loading permissions\n if (permissionsLoading) {\n return (\n <div className=\"flex items-center justify-center h-full\">\n <div className=\"flex items-center gap-2 text-text-secondary\">\n <Loader2 className=\"animate-spin\" size={24} />\n <span>{tr('newsletterCommon.loading', 'Loading...')}</span>\n </div>\n </div>\n );\n }\n\n // Guard: access denied - need create for new, update for existing\n const requiredPermission = isNewTemplate ? canCreate : canUpdate;\n if (\n !permissionsLoading &&\n permissions &&\n permissions.permissionStrings?.length > 0 &&\n !requiredPermission\n ) {\n return <AccessDenied />;\n }\n\n // Loading state for edit mode\n if (!isNewTemplate && loading) {\n return (\n <div className=\"flex items-center justify-center h-full\">\n <div className=\"flex items-center gap-2 text-text-secondary\">\n <Loader2 className=\"animate-spin\" size={24} />\n <span>{tr('templates.loadingTemplate', 'Loading template...')}</span>\n </div>\n </div>\n );\n }\n\n // Error state for edit mode\n if (!isNewTemplate && error) {\n return (\n <div className=\"flex items-center justify-center h-full p-6\">\n <IllustratedEmptyState\n illustration=\"empty-generic\"\n title={tr('templates.failedLoadTemplate', 'Failed to load template')}\n description={error.message}\n action={\n <Button type=\"button\" onClick={handleBack}>\n {tr('templates.backToTemplates', 'Back to Templates')}\n </Button>\n }\n />\n </div>\n );\n }\n\n // Not found state\n if (!isNewTemplate && !template && !loading) {\n return (\n <div className=\"flex items-center justify-center h-full p-6\">\n <IllustratedEmptyState\n illustration=\"empty-files\"\n title={tr('templates.templateNotFound', 'Template not found')}\n description={tr(\n 'templates.templateNotFoundDescription',\n \"The template you're looking for doesn't exist or has been deleted.\"\n )}\n action={\n <Button type=\"button\" onClick={handleBack}>\n {tr('templates.backToTemplates', 'Back to Templates')}\n </Button>\n }\n />\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-col h-full\">\n {/* Notification */}\n {notification && (\n <div\n className={`fixed top-4 right-4 z-50 flex items-center gap-2 px-4 py-3 rounded-lg shadow-pop ${\n notification.type === 'success'\n ? 'bg-status-success-bg/10 text-status-success-text border border-status-success-border/20'\n : 'bg-status-error-bg/10 text-status-error-text border border-status-error-border/20'\n }`}\n >\n {notification.type === 'success' ? <CheckCircle size={20} /> : <AlertCircle size={20} />}\n <span>{notification.message}</span>\n </div>\n )}\n\n {/* Header */}\n <div className=\"relative overflow-hidden flex items-center justify-between gap-4 p-4 border-b border-border-seam\">\n <AuroraBackground intensity=\"subtle\" />\n <div className=\"flex items-center gap-4 min-w-0\">\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n onClick={handleBack}\n aria-label={tr('templates.backToTemplates', 'Back to Templates')}\n >\n <ArrowLeft size={20} />\n </Button>\n <div className=\"min-w-0\">\n <h1 className=\"text-xl font-semibold text-text-primary\">\n <GradientText>\n {isNewTemplate\n ? tr('templates.createTemplate', 'Create Template')\n : tr('templates.editTemplate', 'Edit Template')}\n </GradientText>\n </h1>\n {!isNewTemplate && template && (\n <p className=\"text-sm text-text-secondary\">v{template.version}</p>\n )}\n </div>\n </div>\n <div className=\"flex items-center gap-2\">\n {/* Editor Mode Toggle */}\n <div className=\"flex border border-border-seam rounded-lg overflow-hidden\">\n <button\n type=\"button\"\n onClick={() => setEditorMode('VISUAL')}\n className={`p-2 ${\n editorMode === 'VISUAL' ? 'bg-action-primary-bg/10 text-primary' : 'hover:bg-accent'\n }`}\n title={tr('templates.visualEditor', 'Visual Editor')}\n >\n <PanelsTopLeft size={18} />\n </button>\n <button\n type=\"button\"\n onClick={() => setEditorMode('CODE')}\n className={`p-2 ${\n editorMode === 'CODE' ? 'bg-action-primary-bg/10 text-primary' : 'hover:bg-accent'\n }`}\n title={tr('templates.codeEditor', 'Code Editor')}\n >\n <Code size={18} />\n </button>\n </div>\n\n {/* Preview Toggle */}\n <Button\n type=\"button\"\n variant={showPreview ? 'secondary' : 'outline'}\n size=\"icon\"\n onClick={() => setShowPreview(!showPreview)}\n title={tr('newsletter.togglePreview', 'Toggle Preview')}\n aria-label={tr('newsletter.togglePreview', 'Toggle Preview')}\n >\n <Eye size={20} />\n </Button>\n\n {/* Save Button */}\n <Button\n type=\"button\"\n onClick={handleSave}\n disabled={creating || updating || !isDirty}\n className=\"gap-2\"\n >\n {creating || updating ? (\n <Loader2 size={20} className=\"animate-spin\" />\n ) : (\n <Save size={20} />\n )}\n {isNewTemplate\n ? tr('newsletter.create', 'Create')\n : tr('newsletterCommon.save', 'Save')}\n </Button>\n\n {/* Secondary actions (edit only) */}\n {!isNewTemplate && (\n <CTAOverflowMenu\n actions={[\n {\n label: tr('templates.duplicateTemplate', 'Duplicate Template'),\n onSelect: () => {\n void handleDuplicate();\n },\n disabled: creating,\n icon: <Copy size={16} />,\n },\n {\n label: tr('templates.deleteTemplate', 'Delete Template'),\n onSelect: () => {\n void handleDelete();\n },\n disabled: deleting,\n intent: 'destructive',\n icon: deleting ? (\n <Loader2 size={16} className=\"animate-spin\" />\n ) : (\n <Trash2 size={16} />\n ),\n },\n ]}\n />\n )}\n </div>\n </div>\n\n {/* Template Settings */}\n <div className=\"p-4 border-b border-border-seam space-y-4\">\n <PagePurpose>\n {tr(\n 'templates.editorPurpose',\n 'Design a reusable email layout once and reuse it across many campaigns. Build it visually or in HTML, give it a clear name and category, and check the live preview so it looks right everywhere. A good template keeps every newsletter consistent and saves you from rebuilding the same structure each time.'\n )}\n </PagePurpose>\n <NextSteps\n storageKey=\"newsletter-template-editor\"\n steps={[\n {\n id: 'name',\n label: tr('templates.nextStepName', 'Name and categorise it'),\n description: tr(\n 'templates.nextStepNameDesc',\n 'Give the template a clear name and pick a category so you can find it later.'\n ),\n icon: <PanelsTopLeft size={16} />,\n done: name.trim().length > 0,\n },\n {\n id: 'build',\n label: tr('templates.nextStepBuild', 'Build the layout'),\n description: tr(\n 'templates.nextStepBuildDesc',\n 'Drop in content blocks or switch to code mode and write the HTML.'\n ),\n icon: <Code size={16} />,\n onClick: () => setEditorMode('VISUAL'),\n done: html.trim().length > 0,\n },\n {\n id: 'preview',\n label: tr('templates.nextStepPreview', 'Preview before saving'),\n description: tr(\n 'templates.nextStepPreviewDesc',\n 'Open the preview to check how it looks on desktop, tablet, and mobile.'\n ),\n icon: <Eye size={16} />,\n onClick: () => setShowPreview(true),\n done: showPreview,\n },\n {\n id: 'save',\n label: isNewTemplate\n ? tr('templates.nextStepCreate', 'Create the template')\n : tr('templates.nextStepSave', 'Save your changes'),\n description: tr(\n 'templates.nextStepSaveDesc',\n 'Store the template so any campaign can reuse it.'\n ),\n icon: <Save size={16} />,\n onClick: () => void handleSave(),\n },\n ]}\n />\n <div className=\"grid grid-cols-1 md:grid-cols-3 gap-4\">\n <div>\n <label className=\"block text-sm font-medium text-text-primary mb-1\">\n {tr('templates.templateName', 'Template Name')} *\n </label>\n <input\n type=\"text\"\n aria-label={tr('templates.templateName', 'Template Name')}\n value={name}\n onChange={(e) => handleNameChange(e.target.value)}\n placeholder={tr('templates.enterTemplateName', 'Enter template name...')}\n className=\"w-full px-3 py-2 border border-border-seam rounded-lg bg-bg-surface focus:ring-2 focus:ring-primary/50 focus:border-transparent\"\n />\n </div>\n <div>\n <label className=\"block text-sm font-medium text-text-primary mb-1\">\n {tr('templates.category', 'Category')}\n </label>\n <select\n value={category}\n onChange={(e) => handleCategoryChange(e.target.value)}\n className=\"w-full px-3 py-2 border border-border-seam rounded-lg bg-bg-surface focus:ring-2 focus:ring-primary/50 focus:border-transparent\"\n >\n <option value=\"ANNOUNCEMENT\">{tr('templates.announcement', 'Announcement')}</option>\n <option value=\"PROMOTION\">{tr('templates.promotion', 'Promotion')}</option>\n <option value=\"DIGEST\">{tr('templates.digest', 'Digest')}</option>\n <option value=\"EVENT\">{tr('templates.event', 'Event')}</option>\n <option value=\"CUSTOM\">{tr('templates.custom', 'Custom')}</option>\n </select>\n </div>\n <div>\n <label className=\"block text-sm font-medium text-text-primary mb-1\">\n {tr('templates.description', 'Description')}\n </label>\n <input\n type=\"text\"\n aria-label={tr('templates.description', 'Description')}\n value={description}\n onChange={(e) => handleDescriptionChange(e.target.value)}\n placeholder={tr(\n 'templates.descriptionPlaceholder',\n 'Brief description of the template...'\n )}\n className=\"w-full px-3 py-2 border border-border-seam rounded-lg bg-bg-surface focus:ring-2 focus:ring-primary/50 focus:border-transparent\"\n />\n </div>\n </div>\n </div>\n\n {/* Editor Area */}\n <div className=\"flex-1 flex overflow-hidden\">\n {/* Editor Panel */}\n <div className={`flex-1 flex flex-col ${showPreview ? 'w-1/2' : 'w-full'}`}>\n {editorMode === 'VISUAL' ? (\n <div className=\"flex-1 flex\">\n {/* Block Palette */}\n <div className=\"w-48 border-r border-border-seam p-4 overflow-auto bg-bg-sunken\">\n <h3 className=\"text-sm font-medium text-text-primary mb-3\">\n {tr('templates.contentBlocks', 'Content Blocks')}\n </h3>\n <div className=\"space-y-2\">\n <button\n type=\"button\"\n onClick={() =>\n insertBlock(`<div style=\"padding: 20px; text-align: center;\">\n <h2>Section Header</h2>\n</div>`)\n }\n className=\"w-full text-left px-3 py-2 text-sm border border-border-seam rounded hover:bg-bg-surface transition-colors\"\n >\n {tr('templates.blockHeader', 'Header')}\n </button>\n <button\n type=\"button\"\n onClick={() =>\n insertBlock(`<div style=\"padding: 20px;\">\n <p>Add your paragraph text here...</p>\n</div>`)\n }\n className=\"w-full text-left px-3 py-2 text-sm border border-border-seam rounded hover:bg-bg-surface transition-colors\"\n >\n {tr('templates.blockParagraph', 'Paragraph')}\n </button>\n <button\n type=\"button\"\n onClick={() =>\n insertBlock(`<div style=\"padding: 20px; text-align: center;\">\n <img src=\"https://via.placeholder.com/600x200\" alt=\"Image\" style=\"max-width: 100%;\" />\n</div>`)\n }\n className=\"w-full text-left px-3 py-2 text-sm border border-border-seam rounded hover:bg-bg-surface transition-colors\"\n >\n {tr('templates.blockImage', 'Image')}\n </button>\n <button\n type=\"button\"\n onClick={() =>\n // Email-client compatibility: hex colors are required inside the\n // generated email HTML — CSS variables don't resolve in most clients.\n insertBlock(`<div style=\"padding: 20px; text-align: center;\">\n <a href=\"#\" style=\"display: inline-block; padding: 12px 24px; background-color: #3b82f6; color: white; text-decoration: none; border-radius: 6px;\">\n Click Here\n </a>\n</div>`)\n }\n className=\"w-full text-left px-3 py-2 text-sm border border-border-seam rounded hover:bg-bg-surface transition-colors\"\n >\n {tr('templates.blockButton', 'Button')}\n </button>\n <button\n type=\"button\"\n onClick={() =>\n // Email-client compatibility: hex border required for the generated email HTML.\n insertBlock(`<div style=\"padding: 20px;\">\n <hr style=\"border: none; border-top: 1px solid #e5e7eb;\" />\n</div>`)\n }\n className=\"w-full text-left px-3 py-2 text-sm border border-border-seam rounded hover:bg-bg-surface transition-colors\"\n >\n {tr('templates.blockDivider', 'Divider')}\n </button>\n <button\n type=\"button\"\n onClick={() => insertBlock(`<div style=\"height: 20px;\"></div>`)}\n className=\"w-full text-left px-3 py-2 text-sm border border-border-seam rounded hover:bg-bg-surface transition-colors\"\n >\n {tr('templates.blockSpacer', 'Spacer')}\n </button>\n <button\n type=\"button\"\n onClick={() =>\n insertBlock(`<table width=\"100%\" style=\"padding: 20px;\">\n <tr>\n <td style=\"width: 50%; padding: 10px;\">Column 1</td>\n <td style=\"width: 50%; padding: 10px;\">Column 2</td>\n </tr>\n</table>`)\n }\n className=\"w-full text-left px-3 py-2 text-sm border border-border-seam rounded hover:bg-bg-surface transition-colors\"\n >\n {tr('templates.block2Columns', '2 Columns')}\n </button>\n <button\n type=\"button\"\n onClick={() =>\n insertBlock(`<div style=\"padding: 20px; text-align: center;\">\n <a href=\"#\" style=\"margin: 0 8px;\">Facebook</a>\n <a href=\"#\" style=\"margin: 0 8px;\">Twitter</a>\n <a href=\"#\" style=\"margin: 0 8px;\">LinkedIn</a>\n</div>`)\n }\n className=\"w-full text-left px-3 py-2 text-sm border border-border-seam rounded hover:bg-bg-surface transition-colors\"\n >\n {tr('templates.blockSocialLinks', 'Social Links')}\n </button>\n </div>\n\n <h3 className=\"text-sm font-medium text-text-primary mt-6 mb-3\">\n {tr('templates.variables', 'Variables')}\n </h3>\n <div className=\"space-y-1 text-xs text-text-secondary\">\n <div>\n {'{{name}}'} - {tr('templates.varSubscriberName', 'Subscriber name')}\n </div>\n <div>\n {'{{email}}'} - {tr('templates.varSubscriberEmail', 'Subscriber email')}\n </div>\n <div>\n {'{{subject}}'} - {tr('templates.varEmailSubject', 'Email subject')}\n </div>\n <div>\n {'{{unsubscribe_url}}'} -{' '}\n {tr('templates.varUnsubscribeLink', 'Unsubscribe link')}\n </div>\n <div>\n {'{{year}}'} - {tr('templates.varCurrentYear', 'Current year')}\n </div>\n </div>\n </div>\n\n {/* Visual Editor */}\n <div className=\"flex-1 p-4 overflow-auto\">\n <GlassCard treatment=\"glass\" glow className=\"min-h-full border-border-seam\">\n <textarea\n aria-label={tr('templates.htmlTemplate', 'HTML template')}\n value={html}\n onChange={(e) => handleHtmlChange(e.target.value)}\n className=\"w-full h-full min-h-[500px] p-4 font-mono text-sm border-0 focus:ring-0 resize-none\"\n placeholder={tr('templates.enterHtmlTemplate', 'Enter your HTML template...')}\n />\n </GlassCard>\n </div>\n </div>\n ) : (\n /* Code Editor */\n <div className=\"flex-1 p-4 overflow-auto\">\n <textarea\n aria-label={tr('templates.htmlTemplate', 'HTML template')}\n value={html}\n onChange={(e) => handleHtmlChange(e.target.value)}\n className=\"w-full h-full min-h-[500px] p-4 font-mono text-sm border border-border-seam rounded-lg bg-bg-surface text-text-primary font-mono focus:ring-2 focus:ring-primary/50\"\n placeholder={tr('templates.enterHtmlTemplate', 'Enter your HTML template...')}\n spellCheck={false}\n />\n </div>\n )}\n </div>\n\n {/* Preview Panel */}\n {showPreview && (\n <div className=\"w-1/2 border-l border-border-seam flex flex-col\">\n {/* Preview Controls */}\n <div className=\"flex items-center justify-between px-4 py-2 border-b border-border-seam bg-bg-sunken\">\n <span className=\"text-sm font-medium text-text-primary\">\n {tr('newsletter.preview', 'Preview')}\n </span>\n <div className=\"flex border border-border-seam rounded-lg overflow-hidden\">\n <button\n type=\"button\"\n onClick={() => setPreviewMode('DESKTOP')}\n className={`p-1.5 ${\n previewMode === 'DESKTOP'\n ? 'bg-action-primary-bg/10 text-primary'\n : 'hover:bg-accent'\n }`}\n title={tr('templates.desktopPreview', 'Desktop Preview')}\n >\n <Monitor size={16} />\n </button>\n <button\n type=\"button\"\n onClick={() => setPreviewMode('TABLET')}\n className={`p-1.5 ${\n previewMode === 'TABLET'\n ? 'bg-action-primary-bg/10 text-primary'\n : 'hover:bg-accent'\n }`}\n title={tr('templates.tabletPreview', 'Tablet Preview')}\n >\n <Tablet size={16} />\n </button>\n <button\n type=\"button\"\n onClick={() => setPreviewMode('MOBILE')}\n className={`p-1.5 ${\n previewMode === 'MOBILE'\n ? 'bg-action-primary-bg/10 text-primary'\n : 'hover:bg-accent'\n }`}\n title={tr('templates.mobilePreview', 'Mobile Preview')}\n >\n <Smartphone size={16} />\n </button>\n </div>\n </div>\n\n {/* Preview Frame */}\n <div className=\"flex-1 overflow-auto p-4 bg-bg-sunken\">\n <div\n className=\"bg-bg-surface mx-auto shadow-lg rounded-lg overflow-hidden transition-all\"\n style={{ width: getPreviewWidth(), maxWidth: '100%' }}\n >\n <div dangerouslySetInnerHTML={{ __html: html }} />\n </div>\n </div>\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA0CA,IAAM,KAAe;AAiBrB,SAAgB,IAAqB;CACnC,IAAM,IAAK,IAAO,EACZ,EAAE,kBAAe,IAAmC,EACpD,IAAW,IAAa,EACxB,EAAE,iBAAc,IAAe,EAC/B,EAAE,kBAAe,WAAW,GAAoB,mBAAgB,IAAgB,EAChF,EAAE,eAAY,kBAAe,gBAAa,sBAAmB,GAAoB,EAEjF,IAAgB,CAAC,KAAc,MAAe,OAG9C,KACJ,MAAM,QAAQ,EAAY,GAAG,IAAc,GAAa,oBACvD,QAAQ,MAAc,EAAE,WAAW,qCAAqC,CAAC,EACtE,KAAY,IAAkB,EAAc,EAAuB,gBAAgB,GAAG,IACtF,KAAY,IAAkB,EAAc,EAAuB,gBAAgB,GAAG,IAGtF,CAAC,GAAM,KAAW,EAAS,GAAG,EAC9B,CAAC,GAAa,KAAkB,EAAS,GAAG,EAC5C,CAAC,GAAU,KAAe,EAAS,SAAS,EAC5C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iB;mBAEtD,kBAAC,IAAD,EAAY,MAAM,IAAM,CAAA;SACjB,CAAA;QACL;SACF;SAGN,kBAAC,OAAD;MAAK,WAAU;gBACb,kBAAC,OAAD;OACE,WAAU;OACV,OAAO;QAAE,OAAO,IAAiB;QAAE,UAAU;QAAQ;iBAErD,kBAAC,OAAD,EAAK,yBAAyB,EAAE,QAAQ,GAAM,EAAI,CAAA;OAC9C,CAAA;MACF,CAAA,CACF;OAEJ;;GACF"}
|
|
1
|
+
{"version":3,"file":"TemplateEditorPage.js","names":[],"sources":["../../../src/newsletter/pages/TemplateEditorPage.tsx"],"sourcesContent":["import { useParams, useNavigate } from 'react-router';\nimport { useState } from 'react';\nimport {\n Save,\n Eye,\n ArrowLeft,\n Code,\n PanelsTopLeft,\n Monitor,\n Tablet,\n Smartphone,\n Loader2,\n AlertCircle,\n CheckCircle,\n Copy,\n Trash2,\n} from 'lucide-react';\nimport { useNewsletter } from '../providers/NewsletterProvider';\nimport {\n useTemplate,\n useTemplateMutations,\n type CreateTemplateInput,\n type UpdateTemplateInput,\n} from '../hooks/useNewsletterOperations';\nimport { useNewsletterStore } from '../store/newsletterStore';\nimport { AccessDenied } from '@burdenoff/fe-libs/shared/components';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { NEWSLETTER_PERMISSIONS } from '../constants/permissions';\nimport { useTr } from '../shared/hooks/useTr';\nimport { nativeConfirm, nativeNotify } from '../../utils/nativeBridge';\nimport {\n GlassCard,\n GradientText,\n AuroraBackground,\n IllustratedEmptyState,\n CTAOverflowMenu,\n Button,\n PagePurpose,\n NextSteps,\n} from '@burdenoff/fe-libs/ui';\n\n// Empty HTML template for new templates - use content blocks to build\nconst DEFAULT_HTML = '';\n\n/**\n * TemplateEditorPage - Create or edit email template\n *\n * **Features**:\n * - Template name and description\n * - Category selection\n * - Visual drag-drop template builder\n * - Code editor for advanced users\n * - Live preview (desktop, tablet, mobile)\n * - Reusable content blocks\n * - Brand kit integration\n * - Save and publish template\n *\n * **RBAC**: Requires `tenantmodule-newsletter:templates:write` scope\n */\nexport function TemplateEditorPage() {\n const tr = useTr();\n const { templateId } = useParams<{ templateId: string }>();\n const navigate = useNavigate();\n const { productId } = useNewsletter();\n const { hasPermission, isLoading: permissionsLoading, permissions } = usePermissions();\n const { editorMode, setEditorMode, previewMode, setPreviewMode } = useNewsletterStore();\n\n const isNewTemplate = !templateId || templateId === 'new';\n\n // Permission checks\n const permsRegistered = (\n Array.isArray(permissions) ? permissions : permissions?.permissionStrings\n )?.some?.((p: string) => p.startsWith('tenantmodule-newsletter:templates:'));\n const canCreate = permsRegistered ? hasPermission(NEWSLETTER_PERMISSIONS.TEMPLATE_CREATE) : true;\n const canUpdate = permsRegistered ? hasPermission(NEWSLETTER_PERMISSIONS.TEMPLATE_UPDATE) : true;\n\n // Form state\n const [name, setName] = useState('');\n const [description, setDescription] = useState('');\n const [category, setCategory] = useState('CUSTOM');\n const [html, setHtml] = useState(DEFAULT_HTML);\n const [isDirty, setIsDirty] = useState(false);\n\n // UI state\n const [showPreview, setShowPreview] = useState(false);\n const [notification, setNotification] = useState<{\n type: 'success' | 'error';\n message: string;\n } | null>(null);\n\n // GraphQL hooks\n const { template, loading, error } = useTemplate(isNewTemplate ? '' : templateId || '');\n const { createTemplate, updateTemplate, deleteTemplate, creating, updating, deleting } =\n useTemplateMutations();\n\n // Track synced template using state (React-recommended pattern for syncing external data)\n const [syncedTemplateId, setSyncedTemplateId] = useState<string | null>(null);\n\n // Sync template data during render - React recommended pattern for \"adjusting state when props change\"\n if (template && !isNewTemplate && template.id !== syncedTemplateId) {\n setSyncedTemplateId(template.id);\n setName(template.name);\n setDescription(template.description || '');\n setCategory(template.category || 'CUSTOM');\n setHtml(template.html);\n setIsDirty(false);\n }\n\n // Mark as dirty on changes\n const handleNameChange = (value: string) => {\n setName(value);\n setIsDirty(true);\n };\n\n const handleDescriptionChange = (value: string) => {\n setDescription(value);\n setIsDirty(true);\n };\n\n const handleCategoryChange = (value: string) => {\n setCategory(value);\n setIsDirty(true);\n };\n\n const handleHtmlChange = (value: string) => {\n setHtml(value);\n setIsDirty(true);\n };\n\n // Show notification helper\n const showNotification = (type: 'success' | 'error', message: string) => {\n setNotification({ type, message });\n setTimeout(() => setNotification(null), 5000);\n };\n\n const handleBack = () => {\n if (\n isDirty &&\n !confirm(\n tr(\n 'templates.unsavedChangesConfirm',\n 'You have unsaved changes. Are you sure you want to leave?'\n )\n )\n ) {\n return;\n }\n navigate('../templates');\n };\n\n const handleSave = async () => {\n if (!name.trim()) {\n showNotification('error', tr('templates.nameRequired', 'Template name is required'));\n return;\n }\n\n if (!html.trim()) {\n showNotification('error', tr('templates.htmlRequired', 'Template HTML content is required'));\n return;\n }\n\n try {\n if (isNewTemplate) {\n const input: CreateTemplateInput = {\n name: name.trim(),\n description: description.trim() || undefined,\n platformProductId: productId,\n category,\n html,\n };\n const result = await createTemplate(input);\n showNotification(\n 'success',\n tr('templates.templateCreatedSuccessfully', 'Template created successfully')\n );\n setIsDirty(false);\n // Navigate to edit mode for the new template\n if (result?.id) {\n navigate(`../templates/${result.id}`, { replace: true });\n }\n } else {\n const input: UpdateTemplateInput = {\n name: name.trim(),\n description: description.trim() || undefined,\n category,\n html,\n };\n await updateTemplate(templateId!, input);\n showNotification(\n 'success',\n tr('templates.templateSavedSuccessfully', 'Template saved successfully')\n );\n setIsDirty(false);\n }\n } catch (err) {\n showNotification(\n 'error',\n `${tr('newsletter.failedToSave', 'Failed to save')}: ${err instanceof Error ? err.message : tr('newsletter.unknownError', 'Unknown error')}`\n );\n }\n };\n\n const handleDelete = async () => {\n if (isNewTemplate) return;\n const confirmed = await nativeConfirm({\n title: tr('templates.deleteTemplate', 'Delete Template'),\n message: `${tr('templates.confirmDelete', 'Are you sure you want to delete')} \"${name}\"? ${tr('newsletter.actionCannotBeUndone', 'This action cannot be undone.')}`,\n });\n if (confirmed === false) return;\n\n try {\n await deleteTemplate(templateId!);\n void nativeNotify('success');\n showNotification('success', tr('templates.templateDeleted', 'Template deleted'));\n setTimeout(() => navigate('../templates'), 1500);\n } catch (err) {\n void nativeNotify('error');\n showNotification(\n 'error',\n `${tr('templates.failedToDelete', 'Failed to delete')}: ${err instanceof Error ? err.message : tr('newsletter.unknownError', 'Unknown error')}`\n );\n }\n };\n\n const handleDuplicate = async () => {\n if (isNewTemplate) return;\n try {\n const input: CreateTemplateInput = {\n name: `${name} (${tr('newsletter.copyShort', 'Copy')})`,\n description: description || undefined,\n platformProductId: productId,\n category,\n html,\n };\n const result = await createTemplate(input);\n showNotification('success', tr('templates.templateDuplicated', 'Template duplicated'));\n if (result?.id) {\n navigate(`../templates/${result.id}`, { replace: true });\n }\n } catch (err) {\n showNotification(\n 'error',\n `${tr('templates.failedToDuplicate', 'Failed to duplicate')}: ${err instanceof Error ? err.message : tr('newsletter.unknownError', 'Unknown error')}`\n );\n }\n };\n\n // Insert content block at cursor\n const insertBlock = (blockHtml: string) => {\n setHtml((prev) => prev + '\\n' + blockHtml);\n setIsDirty(true);\n };\n\n // Get preview width based on device\n const getPreviewWidth = () => {\n switch (previewMode) {\n case 'MOBILE':\n return '375px';\n case 'TABLET':\n return '768px';\n default:\n return '100%';\n }\n };\n\n // Guard: loading permissions\n if (permissionsLoading) {\n return (\n <div className=\"flex items-center justify-center h-full\">\n <div className=\"flex items-center gap-2 text-text-secondary\">\n <Loader2 className=\"animate-spin\" size={24} />\n <span>{tr('newsletterCommon.loading', 'Loading...')}</span>\n </div>\n </div>\n );\n }\n\n // Guard: access denied - need create for new, update for existing\n const requiredPermission = isNewTemplate ? canCreate : canUpdate;\n if (\n !permissionsLoading &&\n permissions &&\n permissions.permissionStrings?.length > 0 &&\n !requiredPermission\n ) {\n return <AccessDenied />;\n }\n\n // Loading state for edit mode\n if (!isNewTemplate && loading) {\n return (\n <div className=\"flex items-center justify-center h-full\">\n <div className=\"flex items-center gap-2 text-text-secondary\">\n <Loader2 className=\"animate-spin\" size={24} />\n <span>{tr('templates.loadingTemplate', 'Loading template...')}</span>\n </div>\n </div>\n );\n }\n\n // Error state for edit mode\n if (!isNewTemplate && error) {\n return (\n <div className=\"flex items-center justify-center h-full p-6\">\n <IllustratedEmptyState\n illustration=\"empty-generic\"\n title={tr('templates.failedLoadTemplate', 'Failed to load template')}\n description={error.message}\n action={\n <Button type=\"button\" onClick={handleBack}>\n {tr('templates.backToTemplates', 'Back to Templates')}\n </Button>\n }\n />\n </div>\n );\n }\n\n // Not found state\n if (!isNewTemplate && !template && !loading) {\n return (\n <div className=\"flex items-center justify-center h-full p-6\">\n <IllustratedEmptyState\n illustration=\"empty-files\"\n title={tr('templates.templateNotFound', 'Template not found')}\n description={tr(\n 'templates.templateNotFoundDescription',\n \"The template you're looking for doesn't exist or has been deleted.\"\n )}\n action={\n <Button type=\"button\" onClick={handleBack}>\n {tr('templates.backToTemplates', 'Back to Templates')}\n </Button>\n }\n />\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-col h-full\">\n {/* Notification */}\n {notification && (\n <div\n className={`fixed top-4 right-4 z-50 flex items-center gap-2 px-4 py-3 rounded-lg shadow-pop ${\n notification.type === 'success'\n ? 'bg-status-success-bg/10 text-status-success-text border border-status-success-border/20'\n : 'bg-status-error-bg/10 text-status-error-text border border-status-error-border/20'\n }`}\n >\n {notification.type === 'success' ? <CheckCircle size={20} /> : <AlertCircle size={20} />}\n <span>{notification.message}</span>\n </div>\n )}\n\n {/* Header */}\n <div className=\"relative overflow-hidden flex items-center justify-between gap-4 p-4 border-b border-border-seam\">\n <AuroraBackground intensity=\"subtle\" />\n <div className=\"flex items-center gap-4 min-w-0\">\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n onClick={handleBack}\n aria-label={tr('templates.backToTemplates', 'Back to Templates')}\n >\n <ArrowLeft size={20} />\n </Button>\n <div className=\"min-w-0\">\n <h1 className=\"text-xl font-semibold text-text-primary\">\n <GradientText>\n {isNewTemplate\n ? tr('templates.createTemplate', 'Create Template')\n : tr('templates.editTemplate', 'Edit Template')}\n </GradientText>\n </h1>\n {!isNewTemplate && template && (\n <p className=\"text-sm text-text-secondary\">v{template.version}</p>\n )}\n </div>\n </div>\n <div className=\"flex items-center gap-2\">\n {/* Editor Mode Toggle */}\n <div className=\"flex border border-border-seam rounded-lg overflow-hidden\">\n <button\n type=\"button\"\n onClick={() => setEditorMode('VISUAL')}\n className={`p-2 ${\n editorMode === 'VISUAL' ? 'bg-action-primary-bg/10 text-primary' : 'hover:bg-accent'\n }`}\n title={tr('templates.visualEditor', 'Visual Editor')}\n >\n <PanelsTopLeft size={18} />\n </button>\n <button\n type=\"button\"\n onClick={() => setEditorMode('CODE')}\n className={`p-2 ${\n editorMode === 'CODE' ? 'bg-action-primary-bg/10 text-primary' : 'hover:bg-accent'\n }`}\n title={tr('templates.codeEditor', 'Code Editor')}\n >\n <Code size={18} />\n </button>\n </div>\n\n {/* Preview Toggle */}\n <Button\n type=\"button\"\n variant={showPreview ? 'secondary' : 'outline'}\n size=\"icon\"\n onClick={() => setShowPreview(!showPreview)}\n title={tr('newsletter.togglePreview', 'Toggle Preview')}\n aria-label={tr('newsletter.togglePreview', 'Toggle Preview')}\n >\n <Eye size={20} />\n </Button>\n\n {/* Save Button */}\n <Button\n type=\"button\"\n onClick={handleSave}\n disabled={creating || updating || !isDirty}\n className=\"gap-2\"\n >\n {creating || updating ? (\n <Loader2 size={20} className=\"animate-spin\" />\n ) : (\n <Save size={20} />\n )}\n {isNewTemplate\n ? tr('newsletter.create', 'Create')\n : tr('newsletterCommon.save', 'Save')}\n </Button>\n\n {/* Secondary actions (edit only) */}\n {!isNewTemplate && (\n <CTAOverflowMenu\n actions={[\n {\n label: tr('templates.duplicateTemplate', 'Duplicate Template'),\n onSelect: () => {\n void handleDuplicate();\n },\n disabled: creating,\n icon: <Copy size={16} />,\n },\n {\n label: tr('templates.deleteTemplate', 'Delete Template'),\n onSelect: () => {\n void handleDelete();\n },\n disabled: deleting,\n intent: 'destructive',\n icon: deleting ? (\n <Loader2 size={16} className=\"animate-spin\" />\n ) : (\n <Trash2 size={16} />\n ),\n },\n ]}\n />\n )}\n </div>\n </div>\n\n {/* Template Settings */}\n <div className=\"p-4 border-b border-border-seam space-y-4\">\n <PagePurpose>\n {tr(\n 'templates.editorPurpose',\n 'Design a reusable email layout once and reuse it across many campaigns. Build it visually or in HTML, give it a clear name and category, and check the live preview so it looks right everywhere. A good template keeps every newsletter consistent and saves you from rebuilding the same structure each time.'\n )}\n </PagePurpose>\n <NextSteps\n storageKey=\"newsletter-template-editor\"\n steps={[\n {\n id: 'name',\n label: tr('templates.nextStepName', 'Name and categorise it'),\n description: tr(\n 'templates.nextStepNameDesc',\n 'Give the template a clear name and pick a category so you can find it later.'\n ),\n icon: <PanelsTopLeft size={16} />,\n done: name.trim().length > 0,\n },\n {\n id: 'build',\n label: tr('templates.nextStepBuild', 'Build the layout'),\n description: tr(\n 'templates.nextStepBuildDesc',\n 'Drop in content blocks or switch to code mode and write the HTML.'\n ),\n icon: <Code size={16} />,\n onClick: () => setEditorMode('VISUAL'),\n done: html.trim().length > 0,\n },\n {\n id: 'preview',\n label: tr('templates.nextStepPreview', 'Preview before saving'),\n description: tr(\n 'templates.nextStepPreviewDesc',\n 'Open the preview to check how it looks on desktop, tablet, and mobile.'\n ),\n icon: <Eye size={16} />,\n onClick: () => setShowPreview(true),\n done: showPreview,\n },\n {\n id: 'save',\n label: isNewTemplate\n ? tr('templates.nextStepCreate', 'Create the template')\n : tr('templates.nextStepSave', 'Save your changes'),\n description: tr(\n 'templates.nextStepSaveDesc',\n 'Store the template so any campaign can reuse it.'\n ),\n icon: <Save size={16} />,\n onClick: () => void handleSave(),\n },\n ]}\n />\n <div className=\"grid grid-cols-1 md:grid-cols-3 gap-4\">\n <div>\n <label className=\"block text-sm font-medium text-text-primary mb-1\">\n {tr('templates.templateName', 'Template Name')} *\n </label>\n <input\n type=\"text\"\n aria-label={tr('templates.templateName', 'Template Name')}\n value={name}\n onChange={(e) => handleNameChange(e.target.value)}\n placeholder={tr('templates.enterTemplateName', 'Enter template name...')}\n className=\"w-full px-3 py-2 border border-border-seam rounded-lg bg-bg-surface focus:ring-2 focus:ring-primary/50 focus:border-transparent\"\n />\n </div>\n <div>\n <label className=\"block text-sm font-medium text-text-primary mb-1\">\n {tr('templates.category', 'Category')}\n </label>\n <select\n value={category}\n onChange={(e) => handleCategoryChange(e.target.value)}\n className=\"w-full px-3 py-2 border border-border-seam rounded-lg bg-bg-surface focus:ring-2 focus:ring-primary/50 focus:border-transparent scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"ANNOUNCEMENT\">{tr('templates.announcement', 'Announcement')}</option>\n <option value=\"PROMOTION\">{tr('templates.promotion', 'Promotion')}</option>\n <option value=\"DIGEST\">{tr('templates.digest', 'Digest')}</option>\n <option value=\"EVENT\">{tr('templates.event', 'Event')}</option>\n <option value=\"CUSTOM\">{tr('templates.custom', 'Custom')}</option>\n </select>\n </div>\n <div>\n <label className=\"block text-sm font-medium text-text-primary mb-1\">\n {tr('templates.description', 'Description')}\n </label>\n <input\n type=\"text\"\n aria-label={tr('templates.description', 'Description')}\n value={description}\n onChange={(e) => handleDescriptionChange(e.target.value)}\n placeholder={tr(\n 'templates.descriptionPlaceholder',\n 'Brief description of the template...'\n )}\n className=\"w-full px-3 py-2 border border-border-seam rounded-lg bg-bg-surface focus:ring-2 focus:ring-primary/50 focus:border-transparent\"\n />\n </div>\n </div>\n </div>\n\n {/* Editor Area */}\n <div className=\"flex-1 flex overflow-hidden\">\n {/* Editor Panel */}\n <div className={`flex-1 flex flex-col ${showPreview ? 'w-1/2' : 'w-full'}`}>\n {editorMode === 'VISUAL' ? (\n <div className=\"flex-1 flex\">\n {/* Block Palette */}\n <div className=\"w-48 border-r border-border-seam p-4 overflow-auto bg-bg-sunken\">\n <h3 className=\"text-sm font-medium text-text-primary mb-3\">\n {tr('templates.contentBlocks', 'Content Blocks')}\n </h3>\n <div className=\"space-y-2\">\n <button\n type=\"button\"\n onClick={() =>\n insertBlock(`<div style=\"padding: 20px; text-align: center;\">\n <h2>Section Header</h2>\n</div>`)\n }\n className=\"w-full text-left px-3 py-2 text-sm border border-border-seam rounded hover:bg-bg-surface transition-colors\"\n >\n {tr('templates.blockHeader', 'Header')}\n </button>\n <button\n type=\"button\"\n onClick={() =>\n insertBlock(`<div style=\"padding: 20px;\">\n <p>Add your paragraph text here...</p>\n</div>`)\n }\n className=\"w-full text-left px-3 py-2 text-sm border border-border-seam rounded hover:bg-bg-surface transition-colors\"\n >\n {tr('templates.blockParagraph', 'Paragraph')}\n </button>\n <button\n type=\"button\"\n onClick={() =>\n insertBlock(`<div style=\"padding: 20px; text-align: center;\">\n <img src=\"https://via.placeholder.com/600x200\" alt=\"Image\" style=\"max-width: 100%;\" />\n</div>`)\n }\n className=\"w-full text-left px-3 py-2 text-sm border border-border-seam rounded hover:bg-bg-surface transition-colors\"\n >\n {tr('templates.blockImage', 'Image')}\n </button>\n <button\n type=\"button\"\n onClick={() =>\n // Email-client compatibility: hex colors are required inside the\n // generated email HTML — CSS variables don't resolve in most clients.\n insertBlock(`<div style=\"padding: 20px; text-align: center;\">\n <a href=\"#\" style=\"display: inline-block; padding: 12px 24px; background-color: #3b82f6; color: white; text-decoration: none; border-radius: 6px;\">\n Click Here\n </a>\n</div>`)\n }\n className=\"w-full text-left px-3 py-2 text-sm border border-border-seam rounded hover:bg-bg-surface transition-colors\"\n >\n {tr('templates.blockButton', 'Button')}\n </button>\n <button\n type=\"button\"\n onClick={() =>\n // Email-client compatibility: hex border required for the generated email HTML.\n insertBlock(`<div style=\"padding: 20px;\">\n <hr style=\"border: none; border-top: 1px solid #e5e7eb;\" />\n</div>`)\n }\n className=\"w-full text-left px-3 py-2 text-sm border border-border-seam rounded hover:bg-bg-surface transition-colors\"\n >\n {tr('templates.blockDivider', 'Divider')}\n </button>\n <button\n type=\"button\"\n onClick={() => insertBlock(`<div style=\"height: 20px;\"></div>`)}\n className=\"w-full text-left px-3 py-2 text-sm border border-border-seam rounded hover:bg-bg-surface transition-colors\"\n >\n {tr('templates.blockSpacer', 'Spacer')}\n </button>\n <button\n type=\"button\"\n onClick={() =>\n insertBlock(`<table width=\"100%\" style=\"padding: 20px;\">\n <tr>\n <td style=\"width: 50%; padding: 10px;\">Column 1</td>\n <td style=\"width: 50%; padding: 10px;\">Column 2</td>\n </tr>\n</table>`)\n }\n className=\"w-full text-left px-3 py-2 text-sm border border-border-seam rounded hover:bg-bg-surface transition-colors\"\n >\n {tr('templates.block2Columns', '2 Columns')}\n </button>\n <button\n type=\"button\"\n onClick={() =>\n insertBlock(`<div style=\"padding: 20px; text-align: center;\">\n <a href=\"#\" style=\"margin: 0 8px;\">Facebook</a>\n <a href=\"#\" style=\"margin: 0 8px;\">Twitter</a>\n <a href=\"#\" style=\"margin: 0 8px;\">LinkedIn</a>\n</div>`)\n }\n className=\"w-full text-left px-3 py-2 text-sm border border-border-seam rounded hover:bg-bg-surface transition-colors\"\n >\n {tr('templates.blockSocialLinks', 'Social Links')}\n </button>\n </div>\n\n <h3 className=\"text-sm font-medium text-text-primary mt-6 mb-3\">\n {tr('templates.variables', 'Variables')}\n </h3>\n <div className=\"space-y-1 text-xs text-text-secondary\">\n <div>\n {'{{name}}'} - {tr('templates.varSubscriberName', 'Subscriber name')}\n </div>\n <div>\n {'{{email}}'} - {tr('templates.varSubscriberEmail', 'Subscriber email')}\n </div>\n <div>\n {'{{subject}}'} - {tr('templates.varEmailSubject', 'Email subject')}\n </div>\n <div>\n {'{{unsubscribe_url}}'} -{' '}\n {tr('templates.varUnsubscribeLink', 'Unsubscribe link')}\n </div>\n <div>\n {'{{year}}'} - {tr('templates.varCurrentYear', 'Current year')}\n </div>\n </div>\n </div>\n\n {/* Visual Editor */}\n <div className=\"flex-1 p-4 overflow-auto\">\n <GlassCard treatment=\"glass\" glow className=\"min-h-full border-border-seam\">\n <textarea\n aria-label={tr('templates.htmlTemplate', 'HTML template')}\n value={html}\n onChange={(e) => handleHtmlChange(e.target.value)}\n className=\"w-full h-full min-h-[500px] p-4 font-mono text-sm border-0 focus:ring-0 resize-none\"\n placeholder={tr('templates.enterHtmlTemplate', 'Enter your HTML template...')}\n />\n </GlassCard>\n </div>\n </div>\n ) : (\n /* Code Editor */\n <div className=\"flex-1 p-4 overflow-auto\">\n <textarea\n aria-label={tr('templates.htmlTemplate', 'HTML template')}\n value={html}\n onChange={(e) => handleHtmlChange(e.target.value)}\n className=\"w-full h-full min-h-[500px] p-4 font-mono text-sm border border-border-seam rounded-lg bg-bg-surface text-text-primary font-mono focus:ring-2 focus:ring-primary/50\"\n placeholder={tr('templates.enterHtmlTemplate', 'Enter your HTML template...')}\n spellCheck={false}\n />\n </div>\n )}\n </div>\n\n {/* Preview Panel */}\n {showPreview && (\n <div className=\"w-1/2 border-l border-border-seam flex flex-col\">\n {/* Preview Controls */}\n <div className=\"flex items-center justify-between px-4 py-2 border-b border-border-seam bg-bg-sunken\">\n <span className=\"text-sm font-medium text-text-primary\">\n {tr('newsletter.preview', 'Preview')}\n </span>\n <div className=\"flex border border-border-seam rounded-lg overflow-hidden\">\n <button\n type=\"button\"\n onClick={() => setPreviewMode('DESKTOP')}\n className={`p-1.5 ${\n previewMode === 'DESKTOP'\n ? 'bg-action-primary-bg/10 text-primary'\n : 'hover:bg-accent'\n }`}\n title={tr('templates.desktopPreview', 'Desktop Preview')}\n >\n <Monitor size={16} />\n </button>\n <button\n type=\"button\"\n onClick={() => setPreviewMode('TABLET')}\n className={`p-1.5 ${\n previewMode === 'TABLET'\n ? 'bg-action-primary-bg/10 text-primary'\n : 'hover:bg-accent'\n }`}\n title={tr('templates.tabletPreview', 'Tablet Preview')}\n >\n <Tablet size={16} />\n </button>\n <button\n type=\"button\"\n onClick={() => setPreviewMode('MOBILE')}\n className={`p-1.5 ${\n previewMode === 'MOBILE'\n ? 'bg-action-primary-bg/10 text-primary'\n : 'hover:bg-accent'\n }`}\n title={tr('templates.mobilePreview', 'Mobile Preview')}\n >\n <Smartphone size={16} />\n </button>\n </div>\n </div>\n\n {/* Preview Frame */}\n <div className=\"flex-1 overflow-auto p-4 bg-bg-sunken\">\n <div\n className=\"bg-bg-surface mx-auto shadow-lg rounded-lg overflow-hidden transition-all\"\n style={{ width: getPreviewWidth(), maxWidth: '100%' }}\n >\n <div dangerouslySetInnerHTML={{ __html: html }} />\n </div>\n </div>\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA0CA,IAAM,KAAe;AAiBrB,SAAgB,IAAqB;CACnC,IAAM,IAAK,IAAO,EACZ,EAAE,kBAAe,IAAmC,EACpD,IAAW,IAAa,EACxB,EAAE,iBAAc,IAAe,EAC/B,EAAE,kBAAe,WAAW,GAAoB,mBAAgB,IAAgB,EAChF,EAAE,eAAY,kBAAe,gBAAa,sBAAmB,GAAoB,EAEjF,IAAgB,CAAC,KAAc,MAAe,OAG9C,KACJ,MAAM,QAAQ,EAAY,GAAG,IAAc,GAAa,oBACvD,QAAQ,MAAc,EAAE,WAAW,qCAAqC,CAAC,EACtE,KAAY,IAAkB,EAAc,EAAuB,gBAAgB,GAAG,IACtF,KAAY,IAAkB,EAAc,EAAuB,gBAAgB,GAAG,IAGtF,CAAC,GAAM,KAAW,EAAS,GAAG,EAC9B,CAAC,GAAa,KAAkB,EAAS,GAAG,EAC5C,CAAC,GAAU,KAAe,EAAS,SAAS,EAC5C,CAAC,GAAM,KAAW,EAAS,GAAa,EACxC,CAAC,GAAS,KAAc,EAAS,GAAM,EAGvC,CAAC,GAAa,KAAkB,EAAS,GAAM,EAC/C,CAAC,GAAc,KAAmB,EAG9B,KAAK,EAGT,EAAE,aAAU,YAAS,aAAU,EAAY,IAAgB,KAAK,KAAc,GAAG,EACjF,EAAE,mBAAgB,oBAAgB,oBAAgB,aAAU,aAAU,gBAC1E,IAAsB,EAGlB,CAAC,IAAkB,MAAuB,EAAwB,KAAK;AAG7E,CAAI,KAAY,CAAC,KAAiB,EAAS,OAAO,OAChD,GAAoB,EAAS,GAAG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
177
|
onChange: (e) => V(e.target.value),
|
|
178
|
-
className: "px-4 py-2 border border-border-subtle rounded-lg focus:ring-2 focus:ring-primary/50 focus:border-transparent",
|
|
178
|
+
className: "px-4 py-2 border border-border-subtle rounded-lg focus:ring-2 focus:ring-primary/50 focus:border-transparent scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary",
|
|
179
179
|
children: [
|
|
180
180
|
/* @__PURE__ */ y("option", {
|
|
181
181
|
value: "ALL",
|