@burdenoff/microfe-support 2026.520.1 → 2026.521.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/generated/global-operations.js +16 -48
- package/dist/generated/global-operations.js.map +1 -1
- package/dist/index.js +8 -7
- package/dist/node_modules/marked/lib/marked.esm.js +1 -1
- package/dist/support/SupportAdminRoot.js +35 -26
- package/dist/support/SupportAdminRoot.js.map +1 -1
- package/dist/support/SupportUserRoot.js +29 -20
- package/dist/support/SupportUserRoot.js.map +1 -1
- package/dist/support/components/NotificationToast.js +1 -1
- package/dist/support/components/NotificationToast.js.map +1 -1
- package/dist/support/components/analytics/CategoryBreakdown.js +22 -37
- package/dist/support/components/analytics/CategoryBreakdown.js.map +1 -1
- package/dist/support/components/analytics/PriorityBreakdown.js +28 -33
- package/dist/support/components/analytics/PriorityBreakdown.js.map +1 -1
- package/dist/support/components/analytics/TopAgents.js +35 -42
- package/dist/support/components/analytics/TopAgents.js.map +1 -1
- package/dist/support/components/kb/ArticleForm.js +26 -13
- package/dist/support/components/kb/ArticleForm.js.map +1 -1
- package/dist/support/components/settings/CannedResponsesSettings.js +9 -7
- package/dist/support/components/settings/CannedResponsesSettings.js.map +1 -1
- package/dist/support/components/settings/SLAPoliciesSettings.js +10 -8
- package/dist/support/components/settings/SLAPoliciesSettings.js.map +1 -1
- package/dist/support/components/settings/TicketCategoriesSettings.js +169 -168
- package/dist/support/components/settings/TicketCategoriesSettings.js.map +1 -1
- package/dist/support/components/tickets/MessageComposer.js +4 -3
- package/dist/support/components/tickets/MessageComposer.js.map +1 -1
- package/dist/support/components/tickets/MessageThread.js +1 -1
- package/dist/support/components/tickets/MessageThread.js.map +1 -1
- package/dist/support/components/tickets/TicketDetailHeader.js +41 -52
- package/dist/support/components/tickets/TicketDetailHeader.js.map +1 -1
- package/dist/support/components/tickets/TicketHeader.js +70 -80
- package/dist/support/components/tickets/TicketHeader.js.map +1 -1
- package/dist/support/components/tickets/TicketSidebar.js +77 -82
- package/dist/support/components/tickets/TicketSidebar.js.map +1 -1
- package/dist/support/events/rybbit.js +35 -0
- package/dist/support/events/rybbit.js.map +1 -0
- package/dist/support/hooks/useAnalyticsOperations.js +41 -41
- package/dist/support/hooks/useAnalyticsOperations.js.map +1 -1
- package/dist/support/hooks/useKnowledgeBaseOperations.js +50 -52
- package/dist/support/hooks/useKnowledgeBaseOperations.js.map +1 -1
- package/dist/support/hooks/useTicketListOperations.js +51 -0
- package/dist/support/hooks/useTicketListOperations.js.map +1 -0
- package/dist/support/hooks/useTicketOperations.js +74 -109
- package/dist/support/hooks/useTicketOperations.js.map +1 -1
- package/dist/support/index.js +2 -1
- package/dist/support/pages/ArticleDetailAdminPage.js +148 -151
- package/dist/support/pages/ArticleDetailAdminPage.js.map +1 -1
- package/dist/support/pages/ArticleDetailUserPage.js +67 -72
- package/dist/support/pages/ArticleDetailUserPage.js.map +1 -1
- package/dist/support/pages/ContactInquiriesPage.js +11 -11
- package/dist/support/pages/ContactInquiriesPage.js.map +1 -1
- package/dist/support/pages/ContactInquiryDetailPage.js +200 -195
- package/dist/support/pages/ContactInquiryDetailPage.js.map +1 -1
- package/dist/support/pages/CreateArticlePage.js +42 -42
- package/dist/support/pages/CreateArticlePage.js.map +1 -1
- package/dist/support/pages/CreateTicketPage.js +20 -11
- package/dist/support/pages/CreateTicketPage.js.map +1 -1
- package/dist/support/pages/EditArticlePage.js +66 -64
- package/dist/support/pages/EditArticlePage.js.map +1 -1
- package/dist/support/pages/KnowledgeBaseAdminPage.js +80 -85
- package/dist/support/pages/KnowledgeBaseAdminPage.js.map +1 -1
- package/dist/support/pages/KnowledgeBaseUserPage.js +73 -78
- package/dist/support/pages/KnowledgeBaseUserPage.js.map +1 -1
- package/dist/support/pages/SettingsPage.js +3 -3
- package/dist/support/pages/SettingsPage.js.map +1 -1
- package/dist/support/pages/TicketDetailAdminPage.js +28 -21
- package/dist/support/pages/TicketDetailAdminPage.js.map +1 -1
- package/dist/support/pages/TicketDetailUserPage.js +121 -111
- package/dist/support/pages/TicketDetailUserPage.js.map +1 -1
- package/dist/support/pages/TicketListPage.js +170 -196
- package/dist/support/pages/TicketListPage.js.map +1 -1
- package/dist/support/store/supportStore.js +43 -34
- package/dist/support/store/supportStore.js.map +1 -1
- package/dist/support/utils/categoryColors.js +64 -0
- package/dist/support/utils/categoryColors.js.map +1 -0
- package/dist/support/utils/index.js +21 -12
- package/dist/support/utils/index.js.map +1 -1
- package/dist/support/utils/ticketFilters.js +43 -0
- package/dist/support/utils/ticketFilters.js.map +1 -0
- package/dist/support/utils/uiTokens.js +44 -0
- package/dist/support/utils/uiTokens.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TicketCategoriesSettings.js","names":[],"sources":["../../../../src/support/components/settings/TicketCategoriesSettings.tsx"],"sourcesContent":["import { useState } from 'react';\nimport {\n FolderOpen,\n Plus,\n Edit2,\n Trash2,\n X,\n Loader2,\n AlertCircle,\n CheckCircle,\n ToggleLeft,\n ToggleRight,\n GripVertical,\n} from 'lucide-react';\n\ninterface TicketCategory {\n id?: string;\n name: string;\n slug: string;\n description?: string;\n color?: string;\n icon?: string;\n displayOrder?: number;\n isActive?: boolean;\n articleCount?: number;\n parentId?: string;\n}\n\ninterface TicketCategoriesSettingsProps {\n categories: TicketCategory[];\n onCreate: (\n input: Omit<TicketCategory, 'id' | 'articleCount'>\n ) => Promise<TicketCategory | null | undefined>;\n onUpdate: (\n id: string,\n input: Partial<TicketCategory>\n ) => Promise<TicketCategory | null | undefined>;\n onDelete: (id: string) => Promise<boolean | null | undefined>;\n}\n\nconst COLOR_PRESETS = [\n '#ef4444', // red\n '#f97316', // orange\n '#eab308', // yellow\n '#22c55e', // green\n '#14b8a6', // teal\n '#3b82f6', // blue\n '#8b5cf6', // violet\n '#ec4899', // pink\n '#6b7280', // gray\n];\n\nconst generateSlug = (name: string): string => {\n return name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/(^-|-$)/g, '');\n};\n\nconst initialFormData: Omit<TicketCategory, 'id' | 'articleCount'> = {\n name: '',\n slug: '',\n description: '',\n color: '#3b82f6',\n icon: '',\n isActive: true,\n};\n\nexport function TicketCategoriesSettings({\n categories,\n onCreate,\n onUpdate,\n onDelete,\n}: TicketCategoriesSettingsProps) {\n const [isModalOpen, setIsModalOpen] = useState(false);\n const [editingCategory, setEditingCategory] = useState<TicketCategory | null>(null);\n const [formData, setFormData] =\n useState<Omit<TicketCategory, 'id' | 'articleCount'>>(initialFormData);\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [isDeleting, setIsDeleting] = useState<string | null>(null);\n const [notification, setNotification] = useState<{\n type: 'success' | 'error';\n message: string;\n } | null>(null);\n\n const showNotification = (type: 'success' | 'error', message: string) => {\n setNotification({ type, message });\n setTimeout(() => setNotification(null), 3000);\n };\n\n const openCreateModal = () => {\n setEditingCategory(null);\n setFormData(initialFormData);\n setIsModalOpen(true);\n };\n\n const openEditModal = (category: TicketCategory) => {\n setEditingCategory(category);\n setFormData({\n name: category.name,\n slug: category.slug,\n description: category.description || '',\n color: category.color || '#3b82f6',\n icon: category.icon || '',\n isActive: category.isActive ?? true,\n parentId: category.parentId,\n });\n setIsModalOpen(true);\n };\n\n const closeModal = () => {\n setIsModalOpen(false);\n setEditingCategory(null);\n setFormData(initialFormData);\n };\n\n const handleNameChange = (name: string) => {\n setFormData({\n ...formData,\n name,\n slug: editingCategory ? formData.slug : generateSlug(name),\n });\n };\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n if (!formData.name.trim() || !formData.slug.trim()) return;\n\n setIsSubmitting(true);\n try {\n if (editingCategory?.id) {\n await onUpdate(editingCategory.id, formData);\n showNotification('success', 'Category updated successfully!');\n } else {\n await onCreate(formData);\n showNotification('success', 'Category created successfully!');\n }\n closeModal();\n } catch {\n showNotification('error', `Failed to ${editingCategory ? 'update' : 'create'} category.`);\n } finally {\n setIsSubmitting(false);\n }\n };\n\n const handleDelete = async (id: string, articleCount: number) => {\n if (articleCount > 0) {\n showNotification(\n 'error',\n `Cannot delete category with ${articleCount} articles. Move articles first.`\n );\n return;\n }\n if (!confirm('Are you sure you want to delete this category?')) return;\n\n setIsDeleting(id);\n try {\n await onDelete(id);\n showNotification('success', 'Category deleted successfully!');\n } catch {\n showNotification('error', 'Failed to delete category.');\n } finally {\n setIsDeleting(null);\n }\n };\n\n const handleToggleActive = async (category: TicketCategory) => {\n if (!category.id) return;\n try {\n await onUpdate(category.id, { isActive: !category.isActive });\n showNotification(\n 'success',\n `Category ${category.isActive ? 'deactivated' : 'activated'} successfully!`\n );\n } catch {\n showNotification('error', 'Failed to update category status.');\n }\n };\n\n // Sort categories by displayOrder\n const sortedCategories = [...categories].sort(\n (a, b) => (a.displayOrder ?? 0) - (b.displayOrder ?? 0)\n );\n\n return (\n <div className=\"space-y-6\">\n {/* Notification */}\n {notification && (\n <div\n className={`fixed top-4 right-4 z-50 flex items-center gap-3 px-5 py-3 rounded-xl shadow-2xl border-2 animate-in slide-in-from-top-4 duration-300 ${\n notification.type === 'success'\n ? 'bg-status-success-bg-subtle text-status-success-text border-border-subtle'\n : 'bg-status-error-bg-subtle text-status-error-text border-border-subtle'\n }`}\n >\n {notification.type === 'success' ? (\n <CheckCircle size={20} className=\"text-status-success-text\" />\n ) : (\n <AlertCircle size={20} className=\"text-destructive\" />\n )}\n <span className=\"font-medium\">{notification.message}</span>\n </div>\n )}\n\n {/* Modal */}\n {isModalOpen && (\n <div\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-overlay\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"ticket-category-modal-title\"\n >\n <div className=\"bg-background rounded-xl p-6 w-full max-w-lg mx-4 shadow-2xl border max-h-[90vh] overflow-y-auto\">\n <div className=\"flex items-center justify-between mb-6\">\n <h3\n id=\"ticket-category-modal-title\"\n className=\"text-xl font-semibold text-foreground\"\n >\n {editingCategory ? 'Edit Category' : 'Create Category'}\n </h3>\n <button\n onClick={closeModal}\n className=\"p-2 rounded-lg hover:bg-muted text-muted-foreground\"\n >\n <X size={20} />\n </button>\n </div>\n\n <form onSubmit={handleSubmit} className=\"space-y-5\">\n {/* Name */}\n <div>\n <label className=\"block text-sm font-medium text-foreground mb-2\">\n Category Name <span className=\"text-destructive\">*</span>\n </label>\n <input\n type=\"text\"\n value={formData.name}\n onChange={(e) => handleNameChange(e.target.value)}\n placeholder=\"e.g., Technical Support\"\n className=\"w-full px-4 py-2.5 rounded-lg border border-input bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary\"\n required\n />\n </div>\n\n {/* Slug */}\n <div>\n <label className=\"block text-sm font-medium text-foreground mb-2\">\n Slug <span className=\"text-destructive\">*</span>\n </label>\n <input\n type=\"text\"\n value={formData.slug}\n onChange={(e) => setFormData({ ...formData, slug: e.target.value })}\n placeholder=\"technical-support\"\n className=\"w-full px-4 py-2.5 rounded-lg border border-input bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary\"\n required\n />\n <p className=\"text-xs text-muted-foreground mt-1\">\n URL-friendly identifier (auto-generated from name)\n </p>\n </div>\n\n {/* Description */}\n <div>\n <label className=\"block text-sm font-medium text-foreground mb-2\">\n Description\n </label>\n <textarea\n value={formData.description}\n onChange={(e) => setFormData({ ...formData, description: e.target.value })}\n placeholder=\"Brief description of this category...\"\n rows={3}\n className=\"w-full px-4 py-2.5 rounded-lg border border-input bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary resize-none\"\n />\n </div>\n\n {/* Color */}\n <div>\n <label className=\"block text-sm font-medium text-foreground mb-2\">Color</label>\n <div className=\"flex items-center gap-3\">\n <div className=\"flex gap-2\">\n {COLOR_PRESETS.map((color) => (\n <button\n key={color}\n type=\"button\"\n onClick={() => setFormData({ ...formData, color })}\n className={`w-8 h-8 rounded-full border-2 transition-all ${\n formData.color === color\n ? 'border-foreground scale-110'\n : 'border-transparent hover:scale-105'\n }`}\n style={{ backgroundColor: color }}\n />\n ))}\n </div>\n <input\n type=\"color\"\n value={formData.color}\n onChange={(e) => setFormData({ ...formData, color: e.target.value })}\n className=\"w-10 h-10 rounded cursor-pointer border-0\"\n />\n </div>\n </div>\n\n {/* Icon */}\n <div>\n <label className=\"block text-sm font-medium text-foreground mb-2\">\n Icon (emoji)\n </label>\n <input\n type=\"text\"\n value={formData.icon}\n onChange={(e) => setFormData({ ...formData, icon: e.target.value })}\n placeholder=\"e.g., 🛠️\"\n className=\"w-full px-4 py-2.5 rounded-lg border border-input bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary\"\n maxLength={4}\n />\n </div>\n\n {/* Active Toggle */}\n <label className=\"flex items-center gap-3 cursor-pointer\">\n <input\n type=\"checkbox\"\n checked={formData.isActive}\n onChange={(e) => setFormData({ ...formData, isActive: e.target.checked })}\n className=\"w-4 h-4 rounded border-input text-primary focus:ring-primary\"\n />\n <span className=\"text-sm text-foreground\">Active</span>\n </label>\n\n {/* Actions */}\n <div className=\"flex gap-3 pt-4\">\n <button\n type=\"submit\"\n disabled={isSubmitting || !formData.name.trim() || !formData.slug.trim()}\n className=\"flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors\"\n >\n {isSubmitting ? (\n <>\n <Loader2 size={18} className=\"animate-spin\" />\n {editingCategory ? 'Updating...' : 'Creating...'}\n </>\n ) : (\n <>{editingCategory ? 'Update Category' : 'Create Category'}</>\n )}\n </button>\n <button\n type=\"button\"\n onClick={closeModal}\n className=\"px-4 py-2.5 rounded-lg border border-input hover:bg-muted transition-colors\"\n >\n Cancel\n </button>\n </div>\n </form>\n </div>\n </div>\n )}\n\n {/* Header */}\n <div className=\"flex items-center justify-between\">\n <div>\n <h2 className=\"text-xl font-semibold mb-2 text-foreground\">Ticket Categories</h2>\n <p className=\"text-sm text-muted-foreground\">\n Organize tickets and knowledge base articles by category\n </p>\n </div>\n <button\n onClick={openCreateModal}\n className=\"flex items-center gap-2 px-4 py-2 rounded-lg transition-colors bg-primary text-primary-foreground hover:bg-primary/90\"\n >\n <Plus size={20} />\n New Category\n </button>\n </div>\n\n {/* Categories List */}\n <div className=\"space-y-2\">\n {sortedCategories.map((category) => (\n <div\n key={category.id}\n className={`p-4 rounded-lg border bg-background flex items-center gap-4 ${\n category.isActive === false ? 'border-border/50 opacity-60' : 'border-border'\n }`}\n >\n {/* Drag Handle (visual only for now) */}\n <div className=\"text-muted-foreground cursor-grab\">\n <GripVertical size={20} />\n </div>\n\n {/* Color & Icon */}\n <div\n className={\n 'w-10 h-10 rounded-lg flex items-center justify-center text-on-accent text-xl flex-shrink-0' +\n (category.color ? '' : ' bg-muted text-muted-foreground')\n }\n style={category.color ? { backgroundColor: category.color } : undefined}\n >\n {category.icon || <FolderOpen size={20} />}\n </div>\n\n {/* Info */}\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-2\">\n <h3 className=\"font-semibold text-foreground\">{category.name}</h3>\n {category.isActive === false && (\n <span className=\"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground\">\n Inactive\n </span>\n )}\n </div>\n <p className=\"text-sm text-muted-foreground\">\n /{category.slug} • {category.articleCount ?? 0} articles\n </p>\n {category.description && (\n <p className=\"text-xs text-muted-foreground mt-1 line-clamp-1\">\n {category.description}\n </p>\n )}\n </div>\n\n {/* Actions */}\n <div className=\"flex items-center gap-1\">\n <button\n onClick={() => handleToggleActive(category)}\n className=\"p-2 rounded hover:bg-muted text-muted-foreground transition-colors\"\n title={category.isActive ? 'Deactivate' : 'Activate'}\n >\n {category.isActive ? (\n <ToggleRight size={20} className=\"text-status-success-text\" />\n ) : (\n <ToggleLeft size={20} />\n )}\n </button>\n <button\n onClick={() => openEditModal(category)}\n className=\"p-2 rounded hover:bg-muted text-muted-foreground transition-colors\"\n title=\"Edit category\"\n >\n <Edit2 size={18} />\n </button>\n <button\n onClick={() => category.id && handleDelete(category.id, category.articleCount ?? 0)}\n disabled={isDeleting === category.id}\n className=\"p-2 rounded hover:bg-muted text-status-error-text transition-colors disabled:opacity-50\"\n title=\"Delete category\"\n >\n {isDeleting === category.id ? (\n <Loader2 size={18} className=\"animate-spin\" />\n ) : (\n <Trash2 size={18} />\n )}\n </button>\n </div>\n </div>\n ))}\n\n {categories.length === 0 && (\n <div className=\"text-center py-12 border border-dashed border-border rounded-lg\">\n <FolderOpen size={48} className=\"text-muted-foreground mx-auto\" />\n <p className=\"mt-4 text-muted-foreground\">No categories configured</p>\n <button onClick={openCreateModal} className=\"mt-4 text-primary hover:underline\">\n Create your first category\n </button>\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;AAwCA,IAAM,IAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,EAEK,KAAgB,MACb,EACJ,aAAa,CACb,QAAQ,eAAe,IAAI,CAC3B,QAAQ,YAAY,GAAG,EAGtB,IAA+D;CACnE,MAAM;CACN,MAAM;CACN,aAAa;CACb,OAAO;CACP,MAAM;CACN,UAAU;CACX;AAED,SAAgB,EAAyB,EACvC,eACA,aACA,aACA,eACgC;CAChC,IAAM,CAAC,GAAa,KAAkB,EAAS,GAAM,EAC/C,CAAC,GAAiB,KAAsB,EAAgC,KAAK,EAC7E,CAAC,GAAU,KACf,EAAsD,EAAgB,EAClE,CAAC,GAAc,KAAmB,EAAS,GAAM,EACjD,CAAC,GAAY,KAAiB,EAAwB,KAAK,EAC3D,CAAC,GAAc,KAAmB,EAG9B,KAAK,EAET,KAAoB,GAA2B,MAAoB;AAEvE,EADA,EAAgB;GAAE;GAAM;GAAS,CAAC,EAClC,iBAAiB,EAAgB,KAAK,EAAE,IAAK;IAGzC,UAAwB;AAG5B,EAFA,EAAmB,KAAK,EACxB,EAAY,EAAgB,EAC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QACL;;MACF;OA1EC,EAAS,GA0EV,CACN,EAED,EAAW,WAAW,KACrB,kBAAC,OAAD;KAAK,WAAU;eAAf;MACE,kBAAC,GAAD;OAAY,MAAM;OAAI,WAAU;OAAkC,CAAA;MAClE,kBAAC,KAAD;OAAG,WAAU;iBAA6B;OAA4B,CAAA;MACtE,kBAAC,UAAD;OAAQ,SAAS;OAAiB,WAAU;iBAAoC;OAEvE,CAAA;MACL;OAEJ;;GACF"}
|
|
1
|
+
{"version":3,"file":"TicketCategoriesSettings.js","names":[],"sources":["../../../../src/support/components/settings/TicketCategoriesSettings.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport {\n FolderOpen,\n Plus,\n Edit2,\n Trash2,\n X,\n Loader2,\n AlertCircle,\n CheckCircle,\n ToggleLeft,\n ToggleRight,\n GripVertical,\n} from 'lucide-react';\nimport {\n CATEGORY_COLOR_OPTIONS,\n getCategoryColorOption,\n getCategorySwatchClass,\n} from '../../utils/categoryColors';\n\ninterface TicketCategory {\n id?: string;\n name: string;\n slug: string;\n description?: string;\n color?: string;\n icon?: string;\n displayOrder?: number;\n isActive?: boolean;\n articleCount?: number;\n parentId?: string;\n}\n\ninterface TicketCategoriesSettingsProps {\n categories: TicketCategory[];\n onCreate: (\n input: Omit<TicketCategory, 'id' | 'articleCount'>\n ) => Promise<TicketCategory | null | undefined>;\n onUpdate: (\n id: string,\n input: Partial<TicketCategory>\n ) => Promise<TicketCategory | null | undefined>;\n onDelete: (id: string) => Promise<boolean | null | undefined>;\n}\n\nconst generateSlug = (name: string): string => {\n return name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/(^-|-$)/g, '');\n};\n\nconst initialFormData: Omit<TicketCategory, 'id' | 'articleCount'> = {\n name: '',\n slug: '',\n description: '',\n color: CATEGORY_COLOR_OPTIONS[0].value,\n icon: '',\n isActive: true,\n};\n\nexport function TicketCategoriesSettings({\n categories,\n onCreate,\n onUpdate,\n onDelete,\n}: TicketCategoriesSettingsProps) {\n const [isModalOpen, setIsModalOpen] = useState(false);\n const [editingCategory, setEditingCategory] = useState<TicketCategory | null>(null);\n const [formData, setFormData] =\n useState<Omit<TicketCategory, 'id' | 'articleCount'>>(initialFormData);\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [isDeleting, setIsDeleting] = useState<string | null>(null);\n const [notification, setNotification] = useState<{\n type: 'success' | 'error';\n message: string;\n } | null>(null);\n const notificationTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n return () => {\n if (notificationTimerRef.current) clearTimeout(notificationTimerRef.current);\n };\n }, []);\n\n const showNotification = (type: 'success' | 'error', message: string) => {\n setNotification({ type, message });\n if (notificationTimerRef.current) clearTimeout(notificationTimerRef.current);\n notificationTimerRef.current = setTimeout(() => setNotification(null), 3000);\n };\n\n const openCreateModal = () => {\n setEditingCategory(null);\n setFormData(initialFormData);\n setIsModalOpen(true);\n };\n\n const openEditModal = (category: TicketCategory) => {\n setEditingCategory(category);\n setFormData({\n name: category.name,\n slug: category.slug,\n description: category.description || '',\n color: getCategoryColorOption(category.color).value,\n icon: category.icon || '',\n isActive: category.isActive ?? true,\n parentId: category.parentId,\n });\n setIsModalOpen(true);\n };\n\n const closeModal = () => {\n setIsModalOpen(false);\n setEditingCategory(null);\n setFormData(initialFormData);\n };\n\n const handleNameChange = (name: string) => {\n setFormData({\n ...formData,\n name,\n slug: editingCategory ? formData.slug : generateSlug(name),\n });\n };\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n if (!formData.name.trim() || !formData.slug.trim()) return;\n\n setIsSubmitting(true);\n try {\n if (editingCategory?.id) {\n await onUpdate(editingCategory.id, formData);\n showNotification('success', 'Category updated successfully!');\n } else {\n await onCreate(formData);\n showNotification('success', 'Category created successfully!');\n }\n closeModal();\n } catch {\n showNotification('error', `Failed to ${editingCategory ? 'update' : 'create'} category.`);\n } finally {\n setIsSubmitting(false);\n }\n };\n\n const handleDelete = async (id: string, articleCount: number) => {\n if (articleCount > 0) {\n showNotification(\n 'error',\n `Cannot delete category with ${articleCount} articles. Move articles first.`\n );\n return;\n }\n if (!confirm('Are you sure you want to delete this category?')) return;\n\n setIsDeleting(id);\n try {\n await onDelete(id);\n showNotification('success', 'Category deleted successfully!');\n } catch {\n showNotification('error', 'Failed to delete category.');\n } finally {\n setIsDeleting(null);\n }\n };\n\n const handleToggleActive = async (category: TicketCategory) => {\n if (!category.id) return;\n try {\n await onUpdate(category.id, { isActive: !category.isActive });\n showNotification(\n 'success',\n `Category ${category.isActive ? 'deactivated' : 'activated'} successfully!`\n );\n } catch {\n showNotification('error', 'Failed to update category status.');\n }\n };\n\n // Sort categories by displayOrder\n const sortedCategories = [...categories].sort(\n (a, b) => (a.displayOrder ?? 0) - (b.displayOrder ?? 0)\n );\n\n return (\n <div className=\"space-y-6\">\n {/* Notification */}\n {notification && (\n <div\n className={`fixed right-4 top-[calc(var(--header-height,4rem)+1rem)] z-[200] flex items-center gap-3 px-5 py-3 rounded-xl shadow-2xl border-2 animate-in slide-in-from-top-4 duration-300 ${\n notification.type === 'success'\n ? 'bg-status-success-bg-subtle text-status-success-text border-border-subtle'\n : 'bg-status-error-bg-subtle text-status-error-text border-border-subtle'\n }`}\n >\n {notification.type === 'success' ? (\n <CheckCircle size={20} className=\"text-status-success-text\" />\n ) : (\n <AlertCircle size={20} className=\"text-destructive\" />\n )}\n <span className=\"font-medium\">{notification.message}</span>\n </div>\n )}\n\n {/* Modal */}\n {isModalOpen && (\n <div\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-overlay\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"ticket-category-modal-title\"\n >\n <div className=\"bg-background rounded-xl p-6 w-full max-w-lg mx-4 shadow-2xl border max-h-[90vh] overflow-y-auto\">\n <div className=\"flex items-center justify-between mb-6\">\n <h3\n id=\"ticket-category-modal-title\"\n className=\"text-xl font-semibold text-foreground\"\n >\n {editingCategory ? 'Edit Category' : 'Create Category'}\n </h3>\n <button\n onClick={closeModal}\n className=\"min-h-11 min-w-11 p-2 rounded-lg hover:bg-muted text-muted-foreground\"\n aria-label=\"Close category dialog\"\n >\n <X size={20} />\n </button>\n </div>\n\n <form onSubmit={handleSubmit} className=\"space-y-5\">\n {/* Name */}\n <div>\n <label className=\"block text-sm font-medium text-foreground mb-2\">\n Category Name <span className=\"text-destructive\">*</span>\n </label>\n <input\n type=\"text\"\n value={formData.name}\n onChange={(e) => handleNameChange(e.target.value)}\n placeholder=\"e.g., Technical Support\"\n className=\"w-full px-4 py-2.5 rounded-lg border border-input bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary\"\n required\n />\n </div>\n\n {/* Slug */}\n <div>\n <label className=\"block text-sm font-medium text-foreground mb-2\">\n Slug <span className=\"text-destructive\">*</span>\n </label>\n <input\n type=\"text\"\n value={formData.slug}\n onChange={(e) => setFormData({ ...formData, slug: e.target.value })}\n placeholder=\"technical-support\"\n className=\"w-full px-4 py-2.5 rounded-lg border border-input bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary\"\n required\n />\n <p className=\"text-xs text-muted-foreground mt-1\">\n URL-friendly identifier (auto-generated from name)\n </p>\n </div>\n\n {/* Description */}\n <div>\n <label className=\"block text-sm font-medium text-foreground mb-2\">\n Description\n </label>\n <textarea\n value={formData.description}\n onChange={(e) => setFormData({ ...formData, description: e.target.value })}\n placeholder=\"Brief description of this category...\"\n rows={3}\n className=\"w-full px-4 py-2.5 rounded-lg border border-input bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary resize-none\"\n />\n </div>\n\n {/* Color */}\n <div>\n <label className=\"block text-sm font-medium text-foreground mb-2\">Color</label>\n <div className=\"flex flex-col gap-3 sm:flex-row sm:items-center\">\n <div className=\"flex flex-wrap gap-2\">\n {CATEGORY_COLOR_OPTIONS.map((option) => (\n <button\n key={option.value}\n type=\"button\"\n onClick={() => setFormData({ ...formData, color: option.value })}\n className={`min-h-11 min-w-11 rounded-full border-2 transition-all ${option.swatchClass} ${\n formData.color === option.value\n ? 'border-foreground scale-110'\n : 'border-transparent hover:scale-105'\n }`}\n aria-label={`Use ${option.label} category color`}\n />\n ))}\n </div>\n <select\n value={formData.color}\n onChange={(e) => setFormData({ ...formData, color: e.target.value })}\n className=\"min-h-11 rounded-lg border border-input bg-background px-3 text-sm text-foreground\"\n >\n {CATEGORY_COLOR_OPTIONS.map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n </div>\n </div>\n\n {/* Icon */}\n <div>\n <label className=\"block text-sm font-medium text-foreground mb-2\">\n Icon (emoji)\n </label>\n <input\n type=\"text\"\n value={formData.icon}\n onChange={(e) => setFormData({ ...formData, icon: e.target.value })}\n placeholder=\"e.g., 🛠️\"\n className=\"w-full px-4 py-2.5 rounded-lg border border-input bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary\"\n maxLength={4}\n />\n </div>\n\n {/* Active Toggle */}\n <label className=\"flex items-center gap-3 cursor-pointer\">\n <input\n type=\"checkbox\"\n checked={formData.isActive}\n onChange={(e) => setFormData({ ...formData, isActive: e.target.checked })}\n className=\"w-4 h-4 rounded border-input text-primary focus:ring-primary\"\n />\n <span className=\"text-sm text-foreground\">Active</span>\n </label>\n\n {/* Actions */}\n <div className=\"flex flex-col gap-3 pt-4 sm:flex-row\">\n <button\n type=\"submit\"\n disabled={isSubmitting || !formData.name.trim() || !formData.slug.trim()}\n className=\"min-h-11 flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors\"\n >\n {isSubmitting ? (\n <>\n <Loader2 size={18} className=\"animate-spin\" />\n {editingCategory ? 'Updating...' : 'Creating...'}\n </>\n ) : (\n <>{editingCategory ? 'Update Category' : 'Create Category'}</>\n )}\n </button>\n <button\n type=\"button\"\n onClick={closeModal}\n className=\"min-h-11 px-4 py-2.5 rounded-lg border border-input hover:bg-muted transition-colors\"\n >\n Cancel\n </button>\n </div>\n </form>\n </div>\n </div>\n )}\n\n {/* Header */}\n <div className=\"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between\">\n <div>\n <h2 className=\"text-xl font-semibold mb-2 text-foreground\">Ticket Categories</h2>\n <p className=\"text-sm text-muted-foreground\">\n Organize tickets and knowledge base articles by category\n </p>\n </div>\n <button\n onClick={openCreateModal}\n className=\"min-h-11 inline-flex items-center justify-center gap-2 px-4 py-2 rounded-lg transition-colors bg-primary text-primary-foreground hover:bg-primary/90\"\n >\n <Plus size={20} />\n New Category\n </button>\n </div>\n\n {/* Categories List */}\n <div className=\"space-y-2\">\n {sortedCategories.map((category) => (\n <div\n key={category.id}\n className={`p-4 rounded-lg border bg-background flex flex-col gap-4 sm:flex-row sm:items-center ${\n category.isActive === false ? 'border-border/50 opacity-60' : 'border-border'\n }`}\n >\n {/* Drag Handle (visual only for now) */}\n <div className=\"text-muted-foreground cursor-grab\">\n <GripVertical size={20} />\n </div>\n\n {/* Color & Icon */}\n <div\n className={`w-10 h-10 rounded-lg flex items-center justify-center text-on-accent text-xl flex-shrink-0 ${getCategorySwatchClass(category.color)}`}\n >\n {category.icon || <FolderOpen size={20} />}\n </div>\n\n {/* Info */}\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-2\">\n <h3 className=\"font-semibold text-foreground\">{category.name}</h3>\n {category.isActive === false && (\n <span className=\"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground\">\n Inactive\n </span>\n )}\n </div>\n <p className=\"text-sm text-muted-foreground\">\n /{category.slug} • {category.articleCount ?? 0} articles\n </p>\n {category.description && (\n <p className=\"text-xs text-muted-foreground mt-1 line-clamp-1\">\n {category.description}\n </p>\n )}\n </div>\n\n {/* Actions */}\n <div className=\"flex w-full items-center justify-end gap-1 sm:w-auto\">\n <button\n onClick={() => handleToggleActive(category)}\n className=\"min-h-11 min-w-11 p-2 rounded hover:bg-muted text-muted-foreground transition-colors\"\n title={category.isActive ? 'Deactivate' : 'Activate'}\n aria-label={category.isActive ? 'Deactivate category' : 'Activate category'}\n >\n {category.isActive ? (\n <ToggleRight size={20} className=\"text-status-success-text\" />\n ) : (\n <ToggleLeft size={20} />\n )}\n </button>\n <button\n onClick={() => openEditModal(category)}\n className=\"min-h-11 min-w-11 p-2 rounded hover:bg-muted text-muted-foreground transition-colors\"\n title=\"Edit category\"\n aria-label=\"Edit category\"\n >\n <Edit2 size={18} />\n </button>\n <button\n onClick={() => category.id && handleDelete(category.id, category.articleCount ?? 0)}\n disabled={isDeleting === category.id}\n className=\"min-h-11 min-w-11 p-2 rounded hover:bg-muted text-status-error-text transition-colors disabled:opacity-50\"\n title=\"Delete category\"\n aria-label=\"Delete category\"\n >\n {isDeleting === category.id ? (\n <Loader2 size={18} className=\"animate-spin\" />\n ) : (\n <Trash2 size={18} />\n )}\n </button>\n </div>\n </div>\n ))}\n\n {categories.length === 0 && (\n <div className=\"text-center py-12 border border-dashed border-border rounded-lg\">\n <FolderOpen size={48} className=\"text-muted-foreground mx-auto\" />\n <p className=\"mt-4 text-muted-foreground\">No categories configured</p>\n <button onClick={openCreateModal} className=\"mt-4 text-primary hover:underline\">\n Create your first category\n </button>\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;AA6CA,IAAM,KAAgB,MACb,EACJ,aAAa,CACb,QAAQ,eAAe,IAAI,CAC3B,QAAQ,YAAY,GAAG,EAGtB,IAA+D;CACnE,MAAM;CACN,MAAM;CACN,aAAa;CACb,OAAO,EAAuB,GAAG;CACjC,MAAM;CACN,UAAU;CACX;AAED,SAAgB,EAAyB,EACvC,eACA,aACA,aACA,eACgC;CAChC,IAAM,CAAC,GAAa,KAAkB,EAAS,GAAM,EAC/C,CAAC,GAAiB,KAAsB,EAAgC,KAAK,EAC7E,CAAC,GAAU,KACf,E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Ae,EAAmB,EAAS;SAC3C,WAAU;SACV,OAAO,EAAS,WAAW,eAAe;SAC1C,cAAY,EAAS,WAAW,wBAAwB;mBAEvD,EAAS,WACR,kBAAC,GAAD;UAAa,MAAM;UAAI,WAAU;UAA6B,CAAA,GAE9D,kBAAC,GAAD,EAAY,MAAM,IAAM,CAAA;SAEnB,CAAA;QACT,kBAAC,UAAD;SACE,eAAe,EAAc,EAAS;SACtC,WAAU;SACV,OAAM;SACN,cAAW;mBAEX,kBAAC,GAAD,EAAO,MAAM,IAAM,CAAA;SACZ,CAAA;QACT,kBAAC,UAAD;SACE,eAAe,EAAS,MAAM,EAAa,EAAS,IAAI,EAAS,gBAAgB,EAAE;SACnF,UAAU,MAAe,EAAS;SAClC,WAAU;SACV,OAAM;SACN,cAAW;mBAEV,MAAe,EAAS,KACvB,kBAAC,GAAD;UAAS,MAAM;UAAI,WAAU;UAAiB,CAAA,GAE9C,kBAAC,GAAD,EAAQ,MAAM,IAAM,CAAA;SAEf,CAAA;QACL;;MACF;OAzEC,EAAS,GAyEV,CACN,EAED,EAAW,WAAW,KACrB,kBAAC,OAAD;KAAK,WAAU;eAAf;MACE,kBAAC,GAAD;OAAY,MAAM;OAAI,WAAU;OAAkC,CAAA;MAClE,kBAAC,KAAD;OAAG,WAAU;iBAA6B;OAA4B,CAAA;MACtE,kBAAC,UAAD;OAAQ,SAAS;OAAiB,WAAU;iBAAoC;OAEvE,CAAA;MACL;OAEJ;;GACF"}
|
|
@@ -115,7 +115,8 @@ var f = ({ ticketId: f, onSendMessage: p, placeholder: m = "Type your message...
|
|
|
115
115
|
/* @__PURE__ */ l("button", {
|
|
116
116
|
type: "button",
|
|
117
117
|
onClick: () => P(t),
|
|
118
|
-
className: "text-muted-foreground hover:text-foreground
|
|
118
|
+
className: "flex min-h-11 min-w-11 items-center justify-center rounded text-muted-foreground transition-colors hover:text-foreground",
|
|
119
|
+
"aria-label": `Remove attachment ${e.name}`,
|
|
119
120
|
children: "×"
|
|
120
121
|
})
|
|
121
122
|
]
|
|
@@ -126,7 +127,7 @@ var f = ({ ticketId: f, onSendMessage: p, placeholder: m = "Type your message...
|
|
|
126
127
|
children: [/* @__PURE__ */ u("button", {
|
|
127
128
|
type: "button",
|
|
128
129
|
onClick: M,
|
|
129
|
-
className: "flex items-center gap-2 px-3 py-2 rounded-lg transition-colors text-muted-foreground hover:bg-muted",
|
|
130
|
+
className: "min-h-11 inline-flex items-center gap-2 px-3 py-2 rounded-lg transition-colors text-muted-foreground hover:bg-muted",
|
|
130
131
|
disabled: h || w,
|
|
131
132
|
children: [
|
|
132
133
|
/* @__PURE__ */ l(o, { size: 18 }),
|
|
@@ -147,7 +148,7 @@ var f = ({ ticketId: f, onSendMessage: p, placeholder: m = "Type your message...
|
|
|
147
148
|
}), /* @__PURE__ */ l("button", {
|
|
148
149
|
type: "submit",
|
|
149
150
|
disabled: !b.trim() && E.length === 0 || h || w,
|
|
150
|
-
className: `flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${S ? "bg-status-warning-bg hover:bg-status-warning-bg/90 text-on-accent" : "bg-primary hover:bg-primary/90 text-primary-foreground"}`,
|
|
151
|
+
className: `min-h-11 inline-flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${S ? "bg-status-warning-bg hover:bg-status-warning-bg/90 text-on-accent" : "bg-primary hover:bg-primary/90 text-primary-foreground"}`,
|
|
151
152
|
children: w ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(i, {
|
|
152
153
|
size: 18,
|
|
153
154
|
className: "animate-spin"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageComposer.js","names":[],"sources":["../../../../src/support/components/tickets/MessageComposer.tsx"],"sourcesContent":["import { useState, useRef, useEffect, type FC } from 'react';\nimport { Send, Paperclip, Lock, Loader2 } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { tWithFallback } from '../../utils/i18n';\n\nexport interface MessageComposerSendResult {\n preserveAttachedFiles?: boolean;\n preserveMessage?: boolean;\n}\n\ninterface MessageComposerProps {\n ticketId: string;\n onSendMessage: (\n content: string,\n isInternal: boolean,\n files: File[]\n ) => Promise<MessageComposerSendResult | void>;\n placeholder?: string;\n disabled?: boolean;\n allowInternalNotes?: boolean;\n cannedResponses?: CannedResponseOption[];\n cannedResponsesLoading?: boolean;\n}\n\nexport interface CannedResponseOption {\n id: string;\n title: string;\n content: string;\n shortcut?: string | null;\n}\n\nexport const MessageComposer: FC<MessageComposerProps> = ({\n ticketId: _ticketId,\n onSendMessage,\n placeholder = 'Type your message...',\n disabled = false,\n allowInternalNotes = false,\n cannedResponses = [],\n cannedResponsesLoading = false,\n}) => {\n const { t } = useI18n();\n const [message, setMessage] = useState('');\n const [isInternal, setIsInternal] = useState(false);\n const [isSending, setIsSending] = useState(false);\n const [attachedFiles, setAttachedFiles] = useState<File[]>([]);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n // Auto-resize textarea as content changes\n useEffect(() => {\n const textarea = textareaRef.current;\n if (textarea) {\n // Reset height to auto to get the correct scrollHeight\n textarea.style.height = 'auto';\n // Set height to scrollHeight (content height) but respect CSS max-height\n textarea.style.height = `${textarea.scrollHeight}px`;\n }\n }, [message]);\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n if ((!message.trim() && attachedFiles.length === 0) || isSending) return;\n\n setIsSending(true);\n try {\n const result = await onSendMessage(message.trim(), isInternal, attachedFiles);\n if (!result?.preserveMessage) {\n setMessage('');\n }\n setIsInternal(false);\n if (!result?.preserveAttachedFiles) {\n setAttachedFiles([]);\n }\n } catch (error) {\n console.error('Failed to send message:', error);\n } finally {\n setIsSending(false);\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n handleSubmit(e);\n }\n };\n\n const handleAttachFiles = () => {\n fileInputRef.current?.click();\n };\n\n const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const files = Array.from(e.target.files || []);\n setAttachedFiles((prev) => [...prev, ...files]);\n // Reset input so the same file can be selected again\n e.target.value = '';\n };\n\n const handleRemoveFile = (index: number) => {\n setAttachedFiles((prev) => prev.filter((_, i) => i !== index));\n };\n\n const handleInsertCannedResponse = (responseId: string) => {\n const selectedResponse = cannedResponses.find((response) => response.id === responseId);\n if (!selectedResponse) return;\n\n setMessage((currentMessage) => {\n const trimmedMessage = currentMessage.trimEnd();\n return trimmedMessage\n ? `${trimmedMessage}\\n\\n${selectedResponse.content}`\n : selectedResponse.content;\n });\n\n requestAnimationFrame(() => textareaRef.current?.focus());\n };\n\n return (\n <div className=\"shrink-0 border-t border-border bg-background\">\n <form onSubmit={handleSubmit} className=\"p-4\">\n {/* Internal note toggle */}\n {allowInternalNotes && (\n <div className=\"flex items-center gap-2 mb-3\">\n <label className=\"flex items-center gap-2 cursor-pointer\">\n <input\n type=\"checkbox\"\n checked={isInternal}\n onChange={(e) => setIsInternal(e.target.checked)}\n className=\"rounded border-border\"\n disabled={disabled}\n />\n <span className=\"text-sm flex items-center gap-1 text-muted-foreground\">\n <Lock size={14} />\n {tWithFallback(\n t,\n 'support.messageComposer.internalNote',\n 'Internal Note (not visible to customer)'\n )}\n </span>\n </label>\n </div>\n )}\n\n {allowInternalNotes && (\n <div className=\"mb-3 flex flex-col gap-1 sm:max-w-sm\">\n <label\n htmlFor=\"support-canned-response\"\n className=\"text-sm font-medium text-foreground\"\n >\n {tWithFallback(t, 'support.messageComposer.cannedResponses', 'Canned responses')}\n </label>\n <select\n id=\"support-canned-response\"\n value=\"\"\n onChange={(event) => handleInsertCannedResponse(event.target.value)}\n disabled={\n disabled || isSending || cannedResponsesLoading || cannedResponses.length === 0\n }\n className=\"rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground transition-colors focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20 disabled:cursor-not-allowed disabled:opacity-50\"\n >\n <option value=\"\">\n {cannedResponsesLoading\n ? tWithFallback(\n t,\n 'support.messageComposer.loadingCannedResponses',\n 'Loading saved replies...'\n )\n : cannedResponses.length > 0\n ? tWithFallback(\n t,\n 'support.messageComposer.selectCannedResponse',\n 'Insert a saved reply'\n )\n : tWithFallback(\n t,\n 'support.messageComposer.noCannedResponses',\n 'No saved replies available'\n )}\n </option>\n {cannedResponses.map((response) => (\n <option key={response.id} value={response.id}>\n {response.shortcut ? `${response.title} (${response.shortcut})` : response.title}\n </option>\n ))}\n </select>\n </div>\n )}\n\n {/* Message input */}\n <div className=\"relative\">\n <textarea\n ref={textareaRef}\n value={message}\n onChange={(e) => setMessage(e.target.value)}\n onKeyDown={handleKeyDown}\n placeholder={tWithFallback(t, 'support.messageComposer.placeholder', placeholder)}\n disabled={disabled || isSending}\n rows={1}\n className={`auto-resize w-full px-4 py-3 rounded-lg border resize-none transition-colors ${\n isInternal\n ? 'border-status-warning-bg bg-status-warning-bg-subtle'\n : 'border-border bg-background'\n } text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary`}\n />\n\n {/* Hidden file input */}\n <input\n ref={fileInputRef}\n type=\"file\"\n multiple\n onChange={handleFileChange}\n className=\"hidden\"\n accept=\"image/*,.pdf,.doc,.docx,.txt\"\n />\n\n {/* Attached files display */}\n {attachedFiles.length > 0 && (\n <div className=\"flex flex-wrap gap-2 mt-2\">\n {attachedFiles.map((file, index) => (\n <div\n key={`${file.name}-${index}`}\n className=\"flex items-center gap-2 px-3 py-1 rounded-lg bg-muted text-sm\"\n >\n <Paperclip size={14} />\n <span className=\"max-w-[200px] truncate\">{file.name}</span>\n <button\n type=\"button\"\n onClick={() => handleRemoveFile(index)}\n className=\"text-muted-foreground hover:text-foreground transition-colors\"\n >\n ×\n </button>\n </div>\n ))}\n </div>\n )}\n\n {/* Actions */}\n <div className=\"flex items-center justify-between mt-3\">\n <button\n type=\"button\"\n onClick={handleAttachFiles}\n className=\"flex items-center gap-2 px-3 py-2 rounded-lg transition-colors text-muted-foreground hover:bg-muted\"\n disabled={disabled || isSending}\n >\n <Paperclip size={18} />\n <span className=\"text-sm\">\n {tWithFallback(t, 'support.messageComposer.attachFiles', 'Attach files')}\n </span>\n {attachedFiles.length > 0 && (\n <span className=\"text-xs bg-primary text-primary-foreground rounded-full px-2 py-0.5\">\n {attachedFiles.length}\n </span>\n )}\n </button>\n\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-muted-foreground hidden sm:inline\">\n {tWithFallback(\n t,\n 'support.messageComposer.hint',\n 'Markdown supported. Press Enter to send, Shift+Enter for new line'\n )}\n </span>\n <button\n type=\"submit\"\n disabled={(!message.trim() && attachedFiles.length === 0) || disabled || isSending}\n className={`flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${\n isInternal\n ? 'bg-status-warning-bg hover:bg-status-warning-bg/90 text-on-accent'\n : 'bg-primary hover:bg-primary/90 text-primary-foreground'\n }`}\n >\n {isSending ? (\n <>\n <Loader2 size={18} className=\"animate-spin\" />\n {tWithFallback(t, 'support.messageComposer.sending', 'Sending...')}\n </>\n ) : (\n <>\n <Send size={18} />\n {tWithFallback(t, 'support.messageComposer.send', 'Send')}\n </>\n )}\n </button>\n </div>\n </div>\n </div>\n </form>\n </div>\n );\n};\n"],"mappings":";;;;;;AA+BA,IAAa,KAA6C,EACxD,UAAU,GACV,kBACA,iBAAc,wBACd,cAAW,IACX,wBAAqB,IACrB,qBAAkB,EAAE,EACpB,4BAAyB,SACrB;CACJ,IAAM,EAAE,SAAM,GAAS,EACjB,CAAC,GAAS,KAAc,EAAS,GAAG,EACpC,CAAC,GAAY,KAAiB,EAAS,GAAM,EAC7C,CAAC,GAAW,KAAgB,EAAS,GAAM,EAC3C,CAAC,GAAe,KAAoB,EAAiB,EAAE,CAAC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ACF;;MACF;;IACD;;EACH,CAAA"}
|
|
1
|
+
{"version":3,"file":"MessageComposer.js","names":[],"sources":["../../../../src/support/components/tickets/MessageComposer.tsx"],"sourcesContent":["import { useState, useRef, useEffect, type FC } from 'react';\nimport { Send, Paperclip, Lock, Loader2 } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { tWithFallback } from '../../utils/i18n';\n\nexport interface MessageComposerSendResult {\n preserveAttachedFiles?: boolean;\n preserveMessage?: boolean;\n}\n\ninterface MessageComposerProps {\n ticketId: string;\n onSendMessage: (\n content: string,\n isInternal: boolean,\n files: File[]\n ) => Promise<MessageComposerSendResult | void>;\n placeholder?: string;\n disabled?: boolean;\n allowInternalNotes?: boolean;\n cannedResponses?: CannedResponseOption[];\n cannedResponsesLoading?: boolean;\n}\n\nexport interface CannedResponseOption {\n id: string;\n title: string;\n content: string;\n shortcut?: string | null;\n}\n\nexport const MessageComposer: FC<MessageComposerProps> = ({\n ticketId: _ticketId,\n onSendMessage,\n placeholder = 'Type your message...',\n disabled = false,\n allowInternalNotes = false,\n cannedResponses = [],\n cannedResponsesLoading = false,\n}) => {\n const { t } = useI18n();\n const [message, setMessage] = useState('');\n const [isInternal, setIsInternal] = useState(false);\n const [isSending, setIsSending] = useState(false);\n const [attachedFiles, setAttachedFiles] = useState<File[]>([]);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n // Auto-resize textarea as content changes\n useEffect(() => {\n const textarea = textareaRef.current;\n if (textarea) {\n // Reset height to auto to get the correct scrollHeight\n textarea.style.height = 'auto';\n // Set height to scrollHeight (content height) but respect CSS max-height\n textarea.style.height = `${textarea.scrollHeight}px`;\n }\n }, [message]);\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n if ((!message.trim() && attachedFiles.length === 0) || isSending) return;\n\n setIsSending(true);\n try {\n const result = await onSendMessage(message.trim(), isInternal, attachedFiles);\n if (!result?.preserveMessage) {\n setMessage('');\n }\n setIsInternal(false);\n if (!result?.preserveAttachedFiles) {\n setAttachedFiles([]);\n }\n } catch (error) {\n console.error('Failed to send message:', error);\n } finally {\n setIsSending(false);\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n handleSubmit(e);\n }\n };\n\n const handleAttachFiles = () => {\n fileInputRef.current?.click();\n };\n\n const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const files = Array.from(e.target.files || []);\n setAttachedFiles((prev) => [...prev, ...files]);\n // Reset input so the same file can be selected again\n e.target.value = '';\n };\n\n const handleRemoveFile = (index: number) => {\n setAttachedFiles((prev) => prev.filter((_, i) => i !== index));\n };\n\n const handleInsertCannedResponse = (responseId: string) => {\n const selectedResponse = cannedResponses.find((response) => response.id === responseId);\n if (!selectedResponse) return;\n\n setMessage((currentMessage) => {\n const trimmedMessage = currentMessage.trimEnd();\n return trimmedMessage\n ? `${trimmedMessage}\\n\\n${selectedResponse.content}`\n : selectedResponse.content;\n });\n\n requestAnimationFrame(() => textareaRef.current?.focus());\n };\n\n return (\n <div className=\"shrink-0 border-t border-border bg-background\">\n <form onSubmit={handleSubmit} className=\"p-4\">\n {/* Internal note toggle */}\n {allowInternalNotes && (\n <div className=\"flex items-center gap-2 mb-3\">\n <label className=\"flex items-center gap-2 cursor-pointer\">\n <input\n type=\"checkbox\"\n checked={isInternal}\n onChange={(e) => setIsInternal(e.target.checked)}\n className=\"rounded border-border\"\n disabled={disabled}\n />\n <span className=\"text-sm flex items-center gap-1 text-muted-foreground\">\n <Lock size={14} />\n {tWithFallback(\n t,\n 'support.messageComposer.internalNote',\n 'Internal Note (not visible to customer)'\n )}\n </span>\n </label>\n </div>\n )}\n\n {allowInternalNotes && (\n <div className=\"mb-3 flex flex-col gap-1 sm:max-w-sm\">\n <label\n htmlFor=\"support-canned-response\"\n className=\"text-sm font-medium text-foreground\"\n >\n {tWithFallback(t, 'support.messageComposer.cannedResponses', 'Canned responses')}\n </label>\n <select\n id=\"support-canned-response\"\n value=\"\"\n onChange={(event) => handleInsertCannedResponse(event.target.value)}\n disabled={\n disabled || isSending || cannedResponsesLoading || cannedResponses.length === 0\n }\n className=\"rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground transition-colors focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20 disabled:cursor-not-allowed disabled:opacity-50\"\n >\n <option value=\"\">\n {cannedResponsesLoading\n ? tWithFallback(\n t,\n 'support.messageComposer.loadingCannedResponses',\n 'Loading saved replies...'\n )\n : cannedResponses.length > 0\n ? tWithFallback(\n t,\n 'support.messageComposer.selectCannedResponse',\n 'Insert a saved reply'\n )\n : tWithFallback(\n t,\n 'support.messageComposer.noCannedResponses',\n 'No saved replies available'\n )}\n </option>\n {cannedResponses.map((response) => (\n <option key={response.id} value={response.id}>\n {response.shortcut ? `${response.title} (${response.shortcut})` : response.title}\n </option>\n ))}\n </select>\n </div>\n )}\n\n {/* Message input */}\n <div className=\"relative\">\n <textarea\n ref={textareaRef}\n value={message}\n onChange={(e) => setMessage(e.target.value)}\n onKeyDown={handleKeyDown}\n placeholder={tWithFallback(t, 'support.messageComposer.placeholder', placeholder)}\n disabled={disabled || isSending}\n rows={1}\n className={`auto-resize w-full px-4 py-3 rounded-lg border resize-none transition-colors ${\n isInternal\n ? 'border-status-warning-bg bg-status-warning-bg-subtle'\n : 'border-border bg-background'\n } text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary`}\n />\n\n {/* Hidden file input */}\n <input\n ref={fileInputRef}\n type=\"file\"\n multiple\n onChange={handleFileChange}\n className=\"hidden\"\n accept=\"image/*,.pdf,.doc,.docx,.txt\"\n />\n\n {/* Attached files display */}\n {attachedFiles.length > 0 && (\n <div className=\"flex flex-wrap gap-2 mt-2\">\n {attachedFiles.map((file, index) => (\n <div\n key={`${file.name}-${index}`}\n className=\"flex items-center gap-2 px-3 py-1 rounded-lg bg-muted text-sm\"\n >\n <Paperclip size={14} />\n <span className=\"max-w-[200px] truncate\">{file.name}</span>\n <button\n type=\"button\"\n onClick={() => handleRemoveFile(index)}\n className=\"flex min-h-11 min-w-11 items-center justify-center rounded text-muted-foreground transition-colors hover:text-foreground\"\n aria-label={`Remove attachment ${file.name}`}\n >\n ×\n </button>\n </div>\n ))}\n </div>\n )}\n\n {/* Actions */}\n <div className=\"flex items-center justify-between mt-3\">\n <button\n type=\"button\"\n onClick={handleAttachFiles}\n className=\"min-h-11 inline-flex items-center gap-2 px-3 py-2 rounded-lg transition-colors text-muted-foreground hover:bg-muted\"\n disabled={disabled || isSending}\n >\n <Paperclip size={18} />\n <span className=\"text-sm\">\n {tWithFallback(t, 'support.messageComposer.attachFiles', 'Attach files')}\n </span>\n {attachedFiles.length > 0 && (\n <span className=\"text-xs bg-primary text-primary-foreground rounded-full px-2 py-0.5\">\n {attachedFiles.length}\n </span>\n )}\n </button>\n\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-muted-foreground hidden sm:inline\">\n {tWithFallback(\n t,\n 'support.messageComposer.hint',\n 'Markdown supported. Press Enter to send, Shift+Enter for new line'\n )}\n </span>\n <button\n type=\"submit\"\n disabled={(!message.trim() && attachedFiles.length === 0) || disabled || isSending}\n className={`min-h-11 inline-flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${\n isInternal\n ? 'bg-status-warning-bg hover:bg-status-warning-bg/90 text-on-accent'\n : 'bg-primary hover:bg-primary/90 text-primary-foreground'\n }`}\n >\n {isSending ? (\n <>\n <Loader2 size={18} className=\"animate-spin\" />\n {tWithFallback(t, 'support.messageComposer.sending', 'Sending...')}\n </>\n ) : (\n <>\n <Send size={18} />\n {tWithFallback(t, 'support.messageComposer.send', 'Send')}\n </>\n )}\n </button>\n </div>\n </div>\n </div>\n </form>\n </div>\n );\n};\n"],"mappings":";;;;;;A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KAAM,KAAY;SACzE,WAAW,8IACT,IACI,sEACA;mBAGL,IACC,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,GAAD;UAAS,MAAM;UAAI,WAAU;UAAiB,CAAA,EAC7C,EAAc,GAAG,mCAAmC,aAAa,CACjE,EAAA,CAAA,GAEH,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,GAAD,EAAM,MAAM,IAAM,CAAA,EACjB,EAAc,GAAG,gCAAgC,OAAO,CACxD,EAAA,CAAA;SAEE,CAAA,CACL;UACF;;MACF;;IACD;;EACH,CAAA"}
|
|
@@ -38,7 +38,7 @@ var o = {
|
|
|
38
38
|
return /* @__PURE__ */ i("div", {
|
|
39
39
|
className: `flex ${g ? "justify-end" : "justify-start"}`,
|
|
40
40
|
children: /* @__PURE__ */ a("div", {
|
|
41
|
-
className: `max-w-[
|
|
41
|
+
className: `max-w-[90%] rounded-lg p-4 sm:max-w-[70%] ${_ ? "border-2 border-status-warning-bg bg-status-warning-bg-subtle" : m ? "bg-muted" : "bg-primary/10"}`,
|
|
42
42
|
children: [
|
|
43
43
|
/* @__PURE__ */ a("div", {
|
|
44
44
|
className: "flex items-center gap-2 mb-2",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageThread.js","names":[],"sources":["../../../../src/support/components/tickets/MessageThread.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { User, Lock } from 'lucide-react';\nimport type { SupportMessage, MessageType } from '../../../generated/global-types';\nimport { AttachmentList } from './AttachmentList';\nimport { MarkdownContent } from './MarkdownContent';\n\ninterface MessageThreadProps {\n ticketId: string;\n messages: SupportMessage[];\n currentUserId?: string;\n viewerRole?: 'customer' | 'agent';\n showInternalMessages?: boolean;\n showRealAgentIdentity?: boolean;\n}\n\n// Message type display configuration\nconst messageTypeConfig: Record<MessageType, { label: string; isAgent: boolean }> = {\n CUSTOMER_REPLY: { label: 'Customer', isAgent: false },\n AGENT_REPLY: { label: 'Agent', isAgent: true },\n INTERNAL_NOTE: { label: 'Internal Note', isAgent: true },\n SYSTEM_MESSAGE: { label: 'System', isAgent: true },\n};\n\nexport const MessageThread: FC<MessageThreadProps> = ({\n ticketId,\n messages,\n currentUserId,\n viewerRole = 'customer',\n showInternalMessages = false,\n showRealAgentIdentity = false,\n}) => {\n const visibleMessages = showInternalMessages\n ? messages\n : messages.filter((msg) => !msg.isInternal);\n\n if (!visibleMessages || visibleMessages.length === 0) {\n return (\n <div className=\"flex flex-col items-center justify-center py-12\">\n <p className=\"text-lg text-muted-foreground\">No messages yet</p>\n <p className=\"text-sm mt-2 text-muted-foreground/70\">\n Start the conversation by sending a message\n </p>\n </div>\n );\n }\n\n return (\n <div className=\"space-y-4\">\n {visibleMessages.map((msg) => {\n const isCurrentUser = msg.authorId === currentUserId;\n const typeConfig = messageTypeConfig[msg.type] || messageTypeConfig.SYSTEM_MESSAGE;\n const isCustomer = msg.type === 'CUSTOMER_REPLY';\n const isAgentMessage = typeConfig.isAgent && msg.type !== 'SYSTEM_MESSAGE';\n const alignEnd = viewerRole === 'agent' ? isAgentMessage : isCustomer;\n const isInternal = msg.isInternal || msg.type === 'INTERNAL_NOTE';\n const customContext =\n (msg.context?.custom as Record<string, unknown> | null | undefined) ?? undefined;\n // Privacy: prefer the backend-resolved `author` projection — it gates\n // real-vs-alias identity by viewer actor type. Fall back to the legacy\n // `context.custom` snapshot for older messages where `author` is null.\n const author =\n (\n msg as {\n author?: {\n displayName: string;\n avatar: string;\n isAnonymized: boolean;\n kind: string;\n } | null;\n }\n ).author ?? null;\n // The backend has the AUTHORITATIVE privacy decision. If it says\n // `isAnonymized`, we MUST NOT reach back into `context.custom` to\n // recover the real name — the prop `showRealAgentIdentity` is only a\n // UI preference for callers that are already in the admin context.\n const backendAnonymized = author ? author.isAnonymized : true;\n const agentAlias =\n author?.displayName ??\n (customContext?.authorAlias as string | undefined) ??\n 'Support Agent';\n const realAgentName = backendAnonymized\n ? agentAlias\n : author\n ? author.displayName\n : showRealAgentIdentity\n ? ((customContext?.authorName as string | undefined) ??\n (customContext?.authorEmail as string | undefined) ??\n msg.authorId)\n : agentAlias;\n const displayName =\n msg.type === 'AGENT_REPLY'\n ? showRealAgentIdentity && !backendAnonymized\n ? realAgentName\n : agentAlias\n : msg.type === 'CUSTOMER_REPLY'\n ? isCurrentUser\n ? 'You'\n : 'Customer'\n : typeConfig.label;\n\n return (\n <div key={msg.id} className={`flex ${alignEnd ? 'justify-end' : 'justify-start'}`}>\n <div\n className={`max-w-[
|
|
1
|
+
{"version":3,"file":"MessageThread.js","names":[],"sources":["../../../../src/support/components/tickets/MessageThread.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { User, Lock } from 'lucide-react';\nimport type { SupportMessage, MessageType } from '../../../generated/global-types';\nimport { AttachmentList } from './AttachmentList';\nimport { MarkdownContent } from './MarkdownContent';\n\ninterface MessageThreadProps {\n ticketId: string;\n messages: SupportMessage[];\n currentUserId?: string;\n viewerRole?: 'customer' | 'agent';\n showInternalMessages?: boolean;\n showRealAgentIdentity?: boolean;\n}\n\n// Message type display configuration\nconst messageTypeConfig: Record<MessageType, { label: string; isAgent: boolean }> = {\n CUSTOMER_REPLY: { label: 'Customer', isAgent: false },\n AGENT_REPLY: { label: 'Agent', isAgent: true },\n INTERNAL_NOTE: { label: 'Internal Note', isAgent: true },\n SYSTEM_MESSAGE: { label: 'System', isAgent: true },\n};\n\nexport const MessageThread: FC<MessageThreadProps> = ({\n ticketId,\n messages,\n currentUserId,\n viewerRole = 'customer',\n showInternalMessages = false,\n showRealAgentIdentity = false,\n}) => {\n const visibleMessages = showInternalMessages\n ? messages\n : messages.filter((msg) => !msg.isInternal);\n\n if (!visibleMessages || visibleMessages.length === 0) {\n return (\n <div className=\"flex flex-col items-center justify-center py-12\">\n <p className=\"text-lg text-muted-foreground\">No messages yet</p>\n <p className=\"text-sm mt-2 text-muted-foreground/70\">\n Start the conversation by sending a message\n </p>\n </div>\n );\n }\n\n return (\n <div className=\"space-y-4\">\n {visibleMessages.map((msg) => {\n const isCurrentUser = msg.authorId === currentUserId;\n const typeConfig = messageTypeConfig[msg.type] || messageTypeConfig.SYSTEM_MESSAGE;\n const isCustomer = msg.type === 'CUSTOMER_REPLY';\n const isAgentMessage = typeConfig.isAgent && msg.type !== 'SYSTEM_MESSAGE';\n const alignEnd = viewerRole === 'agent' ? isAgentMessage : isCustomer;\n const isInternal = msg.isInternal || msg.type === 'INTERNAL_NOTE';\n const customContext =\n (msg.context?.custom as Record<string, unknown> | null | undefined) ?? undefined;\n // Privacy: prefer the backend-resolved `author` projection — it gates\n // real-vs-alias identity by viewer actor type. Fall back to the legacy\n // `context.custom` snapshot for older messages where `author` is null.\n const author =\n (\n msg as {\n author?: {\n displayName: string;\n avatar: string;\n isAnonymized: boolean;\n kind: string;\n } | null;\n }\n ).author ?? null;\n // The backend has the AUTHORITATIVE privacy decision. If it says\n // `isAnonymized`, we MUST NOT reach back into `context.custom` to\n // recover the real name — the prop `showRealAgentIdentity` is only a\n // UI preference for callers that are already in the admin context.\n const backendAnonymized = author ? author.isAnonymized : true;\n const agentAlias =\n author?.displayName ??\n (customContext?.authorAlias as string | undefined) ??\n 'Support Agent';\n const realAgentName = backendAnonymized\n ? agentAlias\n : author\n ? author.displayName\n : showRealAgentIdentity\n ? ((customContext?.authorName as string | undefined) ??\n (customContext?.authorEmail as string | undefined) ??\n msg.authorId)\n : agentAlias;\n const displayName =\n msg.type === 'AGENT_REPLY'\n ? showRealAgentIdentity && !backendAnonymized\n ? realAgentName\n : agentAlias\n : msg.type === 'CUSTOMER_REPLY'\n ? isCurrentUser\n ? 'You'\n : 'Customer'\n : typeConfig.label;\n\n return (\n <div key={msg.id} className={`flex ${alignEnd ? 'justify-end' : 'justify-start'}`}>\n <div\n className={`max-w-[90%] rounded-lg p-4 sm:max-w-[70%] ${\n isInternal\n ? 'border-2 border-status-warning-bg bg-status-warning-bg-subtle'\n : isCustomer\n ? 'bg-muted'\n : 'bg-primary/10'\n }`}\n >\n {/* Message header */}\n <div className=\"flex items-center gap-2 mb-2\">\n <div\n className={`w-8 h-8 rounded-full flex items-center justify-center transition-colors duration-200 ${\n isCustomer ? 'bg-accent/10' : 'bg-primary/20'\n }`}\n >\n <User size={16} className={isCustomer ? 'text-accent' : 'text-primary'} />\n </div>\n <div className=\"flex-1\">\n <div className=\"flex items-center gap-2\">\n <span className=\"font-medium text-sm text-foreground\">{displayName}</span>\n {isInternal && (\n <span className=\"text-xs px-2 py-0.5 rounded flex items-center gap-1 bg-status-warning-bg text-on-accent\">\n <Lock size={10} />\n Internal\n </span>\n )}\n </div>\n <span className=\"text-xs text-muted-foreground\">\n {new Date(msg.createdAt).toLocaleString()}\n </span>\n </div>\n </div>\n\n {/* Message content */}\n <MarkdownContent content={msg.message} className=\"text-sm\" />\n\n <div className=\"mt-3\">\n <AttachmentList fileIds={msg.attachments || []} ticketId={ticketId} />\n </div>\n </div>\n </div>\n );\n })}\n </div>\n );\n};\n"],"mappings":";;;;;AAgBA,IAAM,IAA8E;CAClF,gBAAgB;EAAE,OAAO;EAAY,SAAS;EAAO;CACrD,aAAa;EAAE,OAAO;EAAS,SAAS;EAAM;CAC9C,eAAe;EAAE,OAAO;EAAiB,SAAS;EAAM;CACxD,gBAAgB;EAAE,OAAO;EAAU,SAAS;EAAM;CACnD,EAEY,KAAyC,EACpD,aACA,aACA,kBACA,gBAAa,YACb,0BAAuB,IACvB,2BAAwB,SACpB;CACJ,IAAM,IAAkB,IACpB,IACA,EAAS,QAAQ,MAAQ,CAAC,EAAI,WAAW;AAa7C,QAXI,CAAC,KAAmB,EAAgB,WAAW,IAE/C,kBAAC,OAAD;EAAK,WAAU;YAAf,CACE,kBAAC,KAAD;GAAG,WAAU;aAAgC;GAAmB,CAAA,EAChE,kBAAC,KAAD;GAAG,WAAU;aAAwC;GAEjD,CAAA,CACA;MAKR,kBAAC,OAAD;EAAK,WAAU;YACZ,EAAgB,KAAK,MAAQ;GAC5B,IAAM,IAAgB,EAAI,aAAa,GACjC,IAAa,EAA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E;QAAY;QAAY,CAAA;OAClE,CAAA;MACF;;IACF,EA1CI,EAAI,GA0CR;IAER;EACE,CAAA"}
|
|
@@ -1,82 +1,71 @@
|
|
|
1
1
|
import { Badge as e, Button as t } from "../ui.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ticketPriorityBadgeClasses as n, ticketStatusBadgeClasses as r } from "../../utils/uiTokens.js";
|
|
3
|
+
import { AlertCircle as i, ArrowLeft as a, CheckCircle2 as o, Clock as s, RotateCcw as c } from "lucide-react";
|
|
4
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
4
5
|
//#region src/support/components/tickets/TicketDetailHeader.tsx
|
|
5
|
-
var
|
|
6
|
+
var d = {
|
|
6
7
|
NEW: "New",
|
|
7
8
|
IN_PROGRESS: "In Progress",
|
|
8
9
|
WAITING_CUSTOMER: "Waiting on Customer",
|
|
9
10
|
RESOLVED: "Resolved",
|
|
10
11
|
CLOSED: "Closed",
|
|
11
12
|
REOPENED: "Reopened"
|
|
12
|
-
}, u = {
|
|
13
|
-
NEW: "bg-blue-500/10 text-blue-500",
|
|
14
|
-
IN_PROGRESS: "bg-amber-500/10 text-amber-500",
|
|
15
|
-
WAITING_CUSTOMER: "bg-purple-500/10 text-purple-500",
|
|
16
|
-
RESOLVED: "bg-green-500/10 text-green-500",
|
|
17
|
-
CLOSED: "bg-zinc-500/10 text-zinc-500",
|
|
18
|
-
REOPENED: "bg-orange-500/10 text-orange-500"
|
|
19
|
-
}, d = {
|
|
20
|
-
CRITICAL: "text-red-500",
|
|
21
|
-
HIGH: "text-orange-500",
|
|
22
|
-
NORMAL: "text-blue-500",
|
|
23
|
-
LOW: "text-zinc-500"
|
|
24
13
|
}, f = {
|
|
25
|
-
NEW:
|
|
26
|
-
IN_PROGRESS:
|
|
27
|
-
WAITING_CUSTOMER:
|
|
28
|
-
RESOLVED:
|
|
29
|
-
CLOSED:
|
|
30
|
-
REOPENED:
|
|
31
|
-
}, p = ({ ticket:
|
|
32
|
-
let _ = f[
|
|
14
|
+
NEW: i,
|
|
15
|
+
IN_PROGRESS: s,
|
|
16
|
+
WAITING_CUSTOMER: s,
|
|
17
|
+
RESOLVED: o,
|
|
18
|
+
CLOSED: o,
|
|
19
|
+
REOPENED: c
|
|
20
|
+
}, p = ({ ticket: i, onBack: s, onCloseTicket: p, onReopenTicket: m, onCreateNewTicket: h, actionsDisabled: g = !1 }) => {
|
|
21
|
+
let _ = f[i.status], v = (i.metadata != null && typeof i.metadata == "object" ? i.metadata : null)?.reopenCount, y = (() => {
|
|
33
22
|
if (typeof v == "number" && Number.isFinite(v)) return v;
|
|
34
23
|
if (typeof v == "string") {
|
|
35
24
|
let e = Number.parseInt(v, 10);
|
|
36
25
|
return Number.isFinite(e) ? e : 0;
|
|
37
26
|
}
|
|
38
27
|
return 0;
|
|
39
|
-
})(), b = y >= 3, x =
|
|
40
|
-
return /* @__PURE__ */
|
|
28
|
+
})(), b = y >= 3, x = i.status !== "CLOSED" && !!p, S = (i.status === "CLOSED" || i.status === "RESOLVED") && !b && !!m;
|
|
29
|
+
return /* @__PURE__ */ u("div", {
|
|
41
30
|
className: "border-b border-border bg-card p-4",
|
|
42
31
|
children: [
|
|
43
|
-
/* @__PURE__ */
|
|
44
|
-
className: "flex items-center justify-between mb-3",
|
|
45
|
-
children: [/* @__PURE__ */
|
|
32
|
+
/* @__PURE__ */ u("div", {
|
|
33
|
+
className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-3",
|
|
34
|
+
children: [/* @__PURE__ */ u(t, {
|
|
46
35
|
variant: "ghost",
|
|
47
36
|
size: "sm",
|
|
48
|
-
onClick:
|
|
49
|
-
children: [/* @__PURE__ */
|
|
50
|
-
}), /* @__PURE__ */
|
|
51
|
-
className: "flex items-center gap-2",
|
|
37
|
+
onClick: s,
|
|
38
|
+
children: [/* @__PURE__ */ l(a, { size: 20 }), "Back to Tickets"]
|
|
39
|
+
}), /* @__PURE__ */ u("div", {
|
|
40
|
+
className: "flex flex-wrap items-center gap-2",
|
|
52
41
|
children: [
|
|
53
|
-
S && /* @__PURE__ */
|
|
42
|
+
S && /* @__PURE__ */ u(t, {
|
|
54
43
|
variant: "outline",
|
|
55
44
|
size: "sm",
|
|
56
45
|
onClick: () => void m?.(),
|
|
57
46
|
disabled: g,
|
|
58
|
-
children: [/* @__PURE__ */
|
|
47
|
+
children: [/* @__PURE__ */ l(c, { size: 16 }), "Reopen"]
|
|
59
48
|
}),
|
|
60
|
-
x && /* @__PURE__ */
|
|
49
|
+
x && /* @__PURE__ */ u(t, {
|
|
61
50
|
variant: "outline",
|
|
62
51
|
size: "sm",
|
|
63
52
|
onClick: () => void p?.(),
|
|
64
53
|
disabled: g,
|
|
65
|
-
children: [/* @__PURE__ */
|
|
54
|
+
children: [/* @__PURE__ */ l(o, { size: 16 }), "Close Ticket"]
|
|
66
55
|
}),
|
|
67
|
-
/* @__PURE__ */
|
|
68
|
-
className:
|
|
69
|
-
children: [/* @__PURE__ */
|
|
56
|
+
/* @__PURE__ */ u(e, {
|
|
57
|
+
className: r[i.status],
|
|
58
|
+
children: [/* @__PURE__ */ l(_, {
|
|
70
59
|
size: 14,
|
|
71
60
|
className: "mr-1"
|
|
72
|
-
}),
|
|
61
|
+
}), d[i.status]]
|
|
73
62
|
}),
|
|
74
|
-
/* @__PURE__ */
|
|
63
|
+
/* @__PURE__ */ l(e, {
|
|
75
64
|
variant: "outline",
|
|
76
|
-
className:
|
|
77
|
-
children:
|
|
65
|
+
className: n[i.priority],
|
|
66
|
+
children: i.priority
|
|
78
67
|
}),
|
|
79
|
-
y > 0 && /* @__PURE__ */
|
|
68
|
+
y > 0 && /* @__PURE__ */ u(e, {
|
|
80
69
|
variant: "outline",
|
|
81
70
|
className: "text-muted-foreground",
|
|
82
71
|
children: [
|
|
@@ -89,24 +78,24 @@ var l = {
|
|
|
89
78
|
]
|
|
90
79
|
})]
|
|
91
80
|
}),
|
|
92
|
-
/* @__PURE__ */
|
|
81
|
+
/* @__PURE__ */ l("h1", {
|
|
93
82
|
className: "text-xl font-bold text-foreground",
|
|
94
|
-
children:
|
|
83
|
+
children: i.subject
|
|
95
84
|
}),
|
|
96
|
-
/* @__PURE__ */
|
|
85
|
+
/* @__PURE__ */ u("p", {
|
|
97
86
|
className: "text-sm text-muted-foreground mt-1",
|
|
98
87
|
children: [
|
|
99
88
|
"#",
|
|
100
|
-
|
|
89
|
+
i.ticketNumber,
|
|
101
90
|
" · Created ",
|
|
102
|
-
new Date(
|
|
91
|
+
new Date(i.createdAt).toLocaleDateString()
|
|
103
92
|
]
|
|
104
93
|
}),
|
|
105
|
-
b &&
|
|
94
|
+
b && i.status === "CLOSED" && /* @__PURE__ */ u("div", {
|
|
106
95
|
className: "mt-3 rounded-lg border border-warning/40 bg-warning/10 p-3 text-sm text-warning",
|
|
107
|
-
children: [/* @__PURE__ */
|
|
96
|
+
children: [/* @__PURE__ */ l("p", { children: "You have reopened this ticket the maximum number of times. Please create a new ticket to continue the conversation." }), /* @__PURE__ */ l("div", {
|
|
108
97
|
className: "mt-3",
|
|
109
|
-
children: /* @__PURE__ */
|
|
98
|
+
children: /* @__PURE__ */ l(t, {
|
|
110
99
|
variant: "outline",
|
|
111
100
|
size: "sm",
|
|
112
101
|
onClick: h,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TicketDetailHeader.js","names":[],"sources":["../../../../src/support/components/tickets/TicketDetailHeader.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { ArrowLeft, AlertCircle, Clock, CheckCircle2, RotateCcw } from 'lucide-react';\nimport { Button, Badge } from '../ui';\nimport type {
|
|
1
|
+
{"version":3,"file":"TicketDetailHeader.js","names":[],"sources":["../../../../src/support/components/tickets/TicketDetailHeader.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { ArrowLeft, AlertCircle, Clock, CheckCircle2, RotateCcw } from 'lucide-react';\nimport { Button, Badge } from '../ui';\nimport type { SupportTicket, SupportTicketStatus } from '../../../generated/global-types';\nimport { MAX_REOPEN_COUNT } from '../../constants';\nimport { ticketPriorityBadgeClasses, ticketStatusBadgeClasses } from '../../utils/uiTokens';\n\ninterface TicketDetailHeaderProps {\n ticket: SupportTicket;\n onBack: () => void;\n onCloseTicket?: () => Promise<void>;\n onReopenTicket?: () => Promise<void>;\n onCreateNewTicket?: () => void;\n actionsDisabled?: boolean;\n}\n\nconst statusLabels: Record<SupportTicketStatus, string> = {\n NEW: 'New',\n IN_PROGRESS: 'In Progress',\n WAITING_CUSTOMER: 'Waiting on Customer',\n RESOLVED: 'Resolved',\n CLOSED: 'Closed',\n REOPENED: 'Reopened',\n};\n\nconst statusIcons: Record<SupportTicketStatus, typeof AlertCircle> = {\n NEW: AlertCircle,\n IN_PROGRESS: Clock,\n WAITING_CUSTOMER: Clock,\n RESOLVED: CheckCircle2,\n CLOSED: CheckCircle2,\n REOPENED: RotateCcw,\n};\n\n/**\n * Read-only ticket header for user-facing pages.\n * Displays ticket info, status, and priority without admin controls\n * (no status change dropdown, no assignment).\n */\nexport const TicketDetailHeader: FC<TicketDetailHeaderProps> = ({\n ticket,\n onBack,\n onCloseTicket,\n onReopenTicket,\n onCreateNewTicket,\n actionsDisabled = false,\n}) => {\n const StatusIcon = statusIcons[ticket.status];\n const metadata =\n ticket.metadata != null && typeof ticket.metadata === 'object'\n ? (ticket.metadata as Record<string, unknown>)\n : null;\n // `metadata` is JSONB on the server side so `reopenCount` may have landed\n // as a number OR a numeric string (`\"3\"`) depending on how it was written.\n // Coerce both to a safe number, falling back to 0 for anything else.\n const rawReopenCount = metadata?.reopenCount;\n const reopenCount = (() => {\n if (typeof rawReopenCount === 'number' && Number.isFinite(rawReopenCount)) {\n return rawReopenCount;\n }\n if (typeof rawReopenCount === 'string') {\n const parsed = Number.parseInt(rawReopenCount, 10);\n return Number.isFinite(parsed) ? parsed : 0;\n }\n return 0;\n })();\n const reopenCapReached = reopenCount >= MAX_REOPEN_COUNT;\n // BUG-007 adopted the broad \"self-close any non-closed ticket\" behavior for\n // end users, not just NEW tickets, so preserve that here.\n const canClose = ticket.status !== 'CLOSED' && Boolean(onCloseTicket);\n // Allow reopen from both CLOSED and RESOLVED. If the agent prematurely\n // marks a ticket RESOLVED the user gets a single \"Reopen\" button rather\n // than having to Close → Reopen in two clicks. This matches the pre-Round\n // 1 behavior and addresses the regression flagged in PR #11 review.\n const canReopen =\n (ticket.status === 'CLOSED' || ticket.status === 'RESOLVED') &&\n !reopenCapReached &&\n Boolean(onReopenTicket);\n\n return (\n <div className=\"border-b border-border bg-card p-4\">\n <div className=\"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-3\">\n <Button variant=\"ghost\" size=\"sm\" onClick={onBack}>\n <ArrowLeft size={20} />\n Back to Tickets\n </Button>\n <div className=\"flex flex-wrap items-center gap-2\">\n {canReopen && (\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => void onReopenTicket?.()}\n disabled={actionsDisabled}\n >\n <RotateCcw size={16} />\n Reopen\n </Button>\n )}\n {canClose && (\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => void onCloseTicket?.()}\n disabled={actionsDisabled}\n >\n <CheckCircle2 size={16} />\n Close Ticket\n </Button>\n )}\n <Badge className={ticketStatusBadgeClasses[ticket.status]}>\n <StatusIcon size={14} className=\"mr-1\" />\n {statusLabels[ticket.status]}\n </Badge>\n <Badge variant=\"outline\" className={ticketPriorityBadgeClasses[ticket.priority]}>\n {ticket.priority}\n </Badge>\n {reopenCount > 0 && (\n <Badge variant=\"outline\" className=\"text-muted-foreground\">\n Reopen {reopenCount}/{MAX_REOPEN_COUNT}\n </Badge>\n )}\n </div>\n </div>\n <h1 className=\"text-xl font-bold text-foreground\">{ticket.subject}</h1>\n <p className=\"text-sm text-muted-foreground mt-1\">\n #{ticket.ticketNumber} · Created {new Date(ticket.createdAt).toLocaleDateString()}\n </p>\n {reopenCapReached && ticket.status === 'CLOSED' && (\n <div className=\"mt-3 rounded-lg border border-warning/40 bg-warning/10 p-3 text-sm text-warning\">\n <p>\n You have reopened this ticket the maximum number of times. Please create a new ticket to\n continue the conversation.\n </p>\n <div className=\"mt-3\">\n <Button variant=\"outline\" size=\"sm\" onClick={onCreateNewTicket}>\n Create New Ticket\n </Button>\n </div>\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;AAgBA,IAAM,IAAoD;CACxD,KAAK;CACL,aAAa;CACb,kBAAkB;CAClB,UAAU;CACV,QAAQ;CACR,UAAU;CACX,EAEK,IAA+D;CACnE,KAAK;CACL,aAAa;CACb,kBAAkB;CAClB,UAAU;CACV,QAAQ;CACR,UAAU;CACX,EAOY,KAAmD,EAC9D,WACA,WACA,kBACA,mBACA,sBACA,qBAAkB,SACd;CACJ,IAAM,IAAa,EAAY,EAAO,SAQhC,KANJ,EAAO,YAAY,QAAQ,OAAO,EAAO,YAAa,WACjD,EAAO,WACR,OAI2B,aAC3B,WAAqB;AACzB,MAAI,OAAO,KAAmB,YAAY,OAAO,SAAS,EAAe,CACvE,QAAO;AAET,MAAI,OAAO,KAAmB,UAAU;GACtC,IAAM,IAAS,OAAO,SAAS,GAAgB,GAAG;AAClD,UAAO,OAAO,SAAS,EAAO,GAAG,IAAS;;AAE5C,SAAO;KACL,EACE,IAAmB,KAAA,GAGnB,IAAW,EAAO,WAAW,YAAY,EAAQ,GAKjD,KACH,EAAO,WAAW,YAAY,EAAO,WAAW,eACjD,CAAC,KACD,EAAQ;AAEV,QACE,kBAAC,OAAD;EAAK,WAAU;YAAf;GACE,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,GAAD;KAAQ,SAAQ;KAAQ,MAAK;KAAK,SAAS;eAA3C,CACE,kBAAC,GAAD,EAAW,MAAM,IAAM,CAAA,EAAA,kBAEhB;QACT,kBAAC,OAAD;KAAK,WAAU;eAAf;MACG,KACC,kBAAC,GAAD;OACE,SAAQ;OACR,MAAK;OACL,eAAe,KAAK,KAAkB;OACtC,UAAU;iBAJZ,CAME,kBAAC,GAAD,EAAW,MA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