@escalated-dev/escalated 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +31 -0
  3. package/package.json +12 -6
  4. package/src/components/ActiveChatsPanel.vue +246 -0
  5. package/src/components/ActivityTimeline.stories.js +55 -55
  6. package/src/components/ActivityTimeline.vue +83 -83
  7. package/src/components/AdminDashboard.stories.js +1423 -1095
  8. package/src/components/AgentLoadIndicator.stories.js +37 -37
  9. package/src/components/AgentLoadIndicator.vue +49 -49
  10. package/src/components/AgentPerformanceCard.vue +44 -44
  11. package/src/components/ArticleEditor.vue +82 -82
  12. package/src/components/AssigneeSelect.vue +37 -37
  13. package/src/components/AttachmentList.vue +13 -1
  14. package/src/components/AuditLogEntry.vue +95 -95
  15. package/src/components/BulkActionBar.vue +166 -166
  16. package/src/components/CategoryTree.vue +89 -89
  17. package/src/components/ChartWidget.vue +46 -46
  18. package/src/components/ChatActionBar.vue +226 -0
  19. package/src/components/ChatBubble.vue +162 -0
  20. package/src/components/ChatComposer.vue +308 -0
  21. package/src/components/ChatQueue.vue +222 -0
  22. package/src/components/ChatThread.vue +197 -0
  23. package/src/components/CollisionWarning.stories.js +30 -30
  24. package/src/components/CollisionWarning.vue +68 -68
  25. package/src/components/ConditionalFieldRules.vue +135 -135
  26. package/src/components/ContextPanel.vue +66 -66
  27. package/src/components/ContextPanelSection.vue +65 -65
  28. package/src/components/CustomFieldRenderer.vue +159 -159
  29. package/src/components/EscalatedLayout.vue +29 -6
  30. package/src/components/FileDropzone.vue +57 -57
  31. package/src/components/FollowButton.stories.js +30 -30
  32. package/src/components/FollowButton.vue +88 -88
  33. package/src/components/KeyboardShortcutHelp.vue +213 -213
  34. package/src/components/KnowledgePanel.vue +122 -122
  35. package/src/components/KpiCard.stories.js +32 -32
  36. package/src/components/KpiCard.vue +88 -88
  37. package/src/components/MacroDropdown.vue +150 -150
  38. package/src/components/MentionDropdown.vue +154 -0
  39. package/src/components/MetricComparison.vue +89 -0
  40. package/src/components/PercentileChart.vue +67 -0
  41. package/src/components/PeriodSelector.vue +98 -0
  42. package/src/components/PermissionMatrix.vue +107 -107
  43. package/src/components/PinnedNotes.vue +129 -129
  44. package/src/components/PluginSlot.vue +68 -62
  45. package/src/components/PresenceIndicator.vue +46 -2
  46. package/src/components/PriorityBadge.stories.js +33 -33
  47. package/src/components/PriorityBadge.vue +46 -46
  48. package/src/components/ReplyComposer.vue +81 -18
  49. package/src/components/ReplyThread.vue +40 -2
  50. package/src/components/ReportChart.vue +395 -0
  51. package/src/components/ReportExportButton.vue +108 -0
  52. package/src/components/SatisfactionRating.vue +180 -180
  53. package/src/components/SaveViewDialog.vue +172 -0
  54. package/src/components/SavedViewSidebar.vue +208 -0
  55. package/src/components/ScheduleEditor.vue +104 -104
  56. package/src/components/SideConversation.vue +165 -165
  57. package/src/components/SideConversationList.vue +147 -147
  58. package/src/components/SkillTagManager.vue +79 -79
  59. package/src/components/SlaComplianceChart.vue +46 -53
  60. package/src/components/SlaTimer.stories.js +35 -35
  61. package/src/components/SlaTimer.vue +62 -62
  62. package/src/components/SnoozeButton.vue +247 -0
  63. package/src/components/StatsCard.stories.js +24 -24
  64. package/src/components/StatsCard.vue +58 -58
  65. package/src/components/StatusBadge.stories.js +53 -53
  66. package/src/components/StatusBadge.vue +78 -78
  67. package/src/components/TagSelect.vue +84 -84
  68. package/src/components/TicketFilters.vue +270 -225
  69. package/src/components/TicketLinkPanel.vue +193 -193
  70. package/src/components/TicketList.vue +655 -594
  71. package/src/components/TicketMergeDialog.vue +157 -157
  72. package/src/components/TicketSplitDialog.vue +98 -0
  73. package/src/components/TotpInput.stories.js +9 -9
  74. package/src/components/TotpInput.vue +81 -81
  75. package/src/components/TwoFactorSetup.vue +113 -113
  76. package/src/components/VariableTokenInput.vue +111 -0
  77. package/src/components/WorkflowActionConfig.vue +287 -0
  78. package/src/components/WorkflowActionList.vue +350 -0
  79. package/src/components/WorkflowConditionBuilder.vue +265 -0
  80. package/src/components/WorkflowTriggerSelector.vue +125 -0
  81. package/src/composables/useChat.js +187 -0
  82. package/src/composables/useI18n.js +80 -80
  83. package/src/composables/useKeyboardShortcuts.js +46 -46
  84. package/src/composables/useMentions.js +134 -0
  85. package/src/composables/usePluginExtensions.js +159 -159
  86. package/src/composables/usePluginHooks.js +65 -65
  87. package/src/composables/useRealtime.js +182 -0
  88. package/src/defineEscalatedPlugin.js +76 -76
  89. package/src/index.js +84 -72
  90. package/src/locales/ar.json +727 -0
  91. package/src/locales/de.json +678 -430
  92. package/src/locales/en.json +717 -455
  93. package/src/locales/es.json +679 -430
  94. package/src/locales/fr.json +680 -431
  95. package/src/locales/index.js +12 -2
  96. package/src/locales/it.json +727 -0
  97. package/src/locales/ja.json +727 -0
  98. package/src/locales/ko.json +727 -0
  99. package/src/locales/nl.json +727 -0
  100. package/src/locales/pl.json +727 -0
  101. package/src/locales/pt-BR.json +727 -0
  102. package/src/locales/ru.json +727 -0
  103. package/src/locales/tr.json +727 -0
  104. package/src/locales/zh-CN.json +727 -0
  105. package/src/pages/Admin/ApiTokens/Index.vue +381 -381
  106. package/src/pages/Admin/AuditLog/Index.vue +154 -154
  107. package/src/pages/Admin/BusinessHours/Form.vue +172 -172
  108. package/src/pages/Admin/BusinessHours/Index.vue +113 -113
  109. package/src/pages/Admin/CannedResponses/Index.vue +127 -127
  110. package/src/pages/Admin/Capacity/Index.vue +134 -134
  111. package/src/pages/Admin/CustomFields/Form.vue +195 -195
  112. package/src/pages/Admin/CustomFields/Index.vue +134 -134
  113. package/src/pages/Admin/CustomObjects/Form.vue +202 -202
  114. package/src/pages/Admin/CustomObjects/Index.vue +127 -127
  115. package/src/pages/Admin/CustomObjects/Records.vue +228 -228
  116. package/src/pages/Admin/Departments/Form.vue +75 -75
  117. package/src/pages/Admin/Departments/Index.vue +110 -109
  118. package/src/pages/Admin/EscalationRules/Form.vue +157 -157
  119. package/src/pages/Admin/EscalationRules/Index.vue +178 -178
  120. package/src/pages/Admin/Import/Connect.vue +0 -1
  121. package/src/pages/Admin/Import/Index.vue +1 -1
  122. package/src/pages/Admin/Import/Progress.vue +1 -1
  123. package/src/pages/Admin/KnowledgeBase/Articles/Form.vue +142 -142
  124. package/src/pages/Admin/KnowledgeBase/Articles/Index.vue +195 -195
  125. package/src/pages/Admin/KnowledgeBase/Categories/Index.vue +193 -193
  126. package/src/pages/Admin/Macros/Index.vue +448 -448
  127. package/src/pages/Admin/Plugins/Index.vue +327 -327
  128. package/src/pages/Admin/Reports/AgentDetail.vue +132 -0
  129. package/src/pages/Admin/Reports/AgentMetrics.vue +115 -115
  130. package/src/pages/Admin/Reports/AgentRanking.vue +246 -0
  131. package/src/pages/Admin/Reports/Cohorts.vue +180 -0
  132. package/src/pages/Admin/Reports/Comparison.vue +141 -0
  133. package/src/pages/Admin/Reports/CsatReport.vue +127 -127
  134. package/src/pages/Admin/Reports/Dashboard.vue +36 -21
  135. package/src/pages/Admin/Reports/ResolutionTimes.vue +164 -0
  136. package/src/pages/Admin/Reports/ResponseTimes.vue +164 -0
  137. package/src/pages/Admin/Reports/SlaReport.vue +162 -166
  138. package/src/pages/Admin/Reports/SlaTrends.vue +183 -0
  139. package/src/pages/Admin/Reports.vue +206 -206
  140. package/src/pages/Admin/Roles/Form.vue +71 -71
  141. package/src/pages/Admin/Roles/Index.vue +122 -122
  142. package/src/pages/Admin/Settings/CsatSettings.vue +165 -165
  143. package/src/pages/Admin/Settings/DataRetention.vue +182 -182
  144. package/src/pages/Admin/Settings/EmailSettings.vue +243 -243
  145. package/src/pages/Admin/Settings/Sandbox.vue +135 -135
  146. package/src/pages/Admin/Settings/SsoSettings.vue +218 -218
  147. package/src/pages/Admin/Settings/TwoFactor.vue +110 -110
  148. package/src/pages/Admin/Settings.vue +1008 -468
  149. package/src/pages/Admin/Skills/Form.vue +53 -53
  150. package/src/pages/Admin/Skills/Index.vue +94 -94
  151. package/src/pages/Admin/SlaPolicies/Form.vue +118 -118
  152. package/src/pages/Admin/SlaPolicies/Index.vue +121 -120
  153. package/src/pages/Admin/Statuses/Form.vue +114 -114
  154. package/src/pages/Admin/Statuses/Index.vue +153 -153
  155. package/src/pages/Admin/Tags/Index.vue +191 -191
  156. package/src/pages/Admin/Tickets/Index.vue +126 -91
  157. package/src/pages/Admin/Tickets/Show.vue +29 -0
  158. package/src/pages/Admin/Webhooks/DeliveryLog.vue +120 -120
  159. package/src/pages/Admin/Webhooks/Form.vue +110 -110
  160. package/src/pages/Admin/Webhooks/Index.vue +136 -136
  161. package/src/pages/Admin/Workflows/Builder.vue +207 -0
  162. package/src/pages/Admin/Workflows/Index.vue +235 -0
  163. package/src/pages/Admin/Workflows/Logs.vue +286 -0
  164. package/src/pages/Agent/TicketIndex.vue +112 -88
  165. package/src/pages/Agent/TicketShow.vue +192 -60
  166. package/src/pages/Customer/Create.vue +1 -1
  167. package/src/pages/Customer/Index.vue +31 -31
  168. package/src/pages/Customer/KnowledgeBase/Article.vue +4 -2
  169. package/src/pages/Customer/KnowledgeBase/Index.vue +151 -151
  170. package/src/pages/Customer/Show.vue +69 -63
  171. package/src/pages/Guest/Create.vue +40 -15
  172. package/src/pages/Guest/Show.vue +124 -93
  173. package/src/plugin.js +25 -0
  174. package/src/utils/mentionHighlight.js +24 -0
  175. package/src/utils/sanitizeHtml.js +78 -64
  176. package/src/widget/EscalatedWidget.vue +804 -0
  177. package/src/widget/index.js +254 -0
  178. package/src/pages/Admin/Automations/Form.vue +0 -184
  179. package/src/pages/Admin/Automations/Index.vue +0 -129
@@ -1,594 +1,655 @@
1
- <script setup>
2
- /* global localStorage */
3
- import { inject, computed, ref, watch } from 'vue';
4
- import StatusBadge from './StatusBadge.vue';
5
- import PriorityBadge from './PriorityBadge.vue';
6
- import { Link, router } from '@inertiajs/vue3';
7
- import { TICKET_TYPE_COLORS } from '../utils/constants';
8
- import { timeAgo, slaClass } from '../utils/formatting';
9
-
10
- const STORAGE_KEY = 'escalated-ticket-columns';
11
-
12
- const ALL_COLUMNS = [
13
- { key: 'reference', label: 'Reference' },
14
- { key: 'subject', label: 'Subject' },
15
- { key: 'requester', label: 'Requester' },
16
- { key: 'status', label: 'Status' },
17
- { key: 'priority', label: 'Priority' },
18
- { key: 'assignee', label: 'Assignee' },
19
- { key: 'department', label: 'Department' },
20
- { key: 'updated', label: 'Last Reply' },
21
- { key: 'created', label: 'Created' },
22
- { key: 'sla', label: 'SLA' },
23
- { key: 'tags', label: 'Tags' },
24
- { key: 'category', label: 'Category' },
25
- ];
26
-
27
- const props = defineProps({
28
- tickets: { type: Object, required: true },
29
- routePrefix: { type: String, default: 'escalated.customer.tickets' },
30
- /** @deprecated Use `columns` prop instead */
31
- showAssignee: { type: Boolean, default: false },
32
- columns: {
33
- type: Array,
34
- default: () => ['reference', 'subject', 'requester', 'status', 'priority', 'updated'],
35
- },
36
- selectable: { type: Boolean, default: false },
37
- selectedIds: { type: Array, default: () => [] },
38
- assignRoute: { type: String, default: '' },
39
- navigable: { type: Boolean, default: false },
40
- });
41
-
42
- const emit = defineEmits(['update:selectedIds']);
43
- const escDark = inject(
44
- 'esc-dark',
45
- computed(() => false),
46
- );
47
- const focusedIndex = ref(-1);
48
- const showColumnPicker = ref(false);
49
-
50
- // Resolve initial columns: merge prop with deprecated showAssignee, then override from localStorage
51
- function resolveDefaultColumns() {
52
- const base = [...props.columns];
53
- if (props.showAssignee && !base.includes('assignee')) {
54
- const prioIdx = base.indexOf('priority');
55
- if (prioIdx >= 0) {
56
- base.splice(prioIdx + 1, 0, 'assignee');
57
- } else {
58
- base.push('assignee');
59
- }
60
- }
61
- return base;
62
- }
63
-
64
- function loadSavedColumns() {
65
- try {
66
- const saved = localStorage.getItem(STORAGE_KEY);
67
- if (saved) {
68
- const parsed = JSON.parse(saved);
69
- if (Array.isArray(parsed) && parsed.length > 0) return parsed;
70
- }
71
- } catch {
72
- // ignore
73
- }
74
- return null;
75
- }
76
-
77
- const activeColumns = ref(loadSavedColumns() || resolveDefaultColumns());
78
-
79
- function saveColumns() {
80
- try {
81
- localStorage.setItem(STORAGE_KEY, JSON.stringify(activeColumns.value));
82
- } catch {
83
- // ignore
84
- }
85
- }
86
-
87
- function toggleColumn(key) {
88
- const idx = activeColumns.value.indexOf(key);
89
- if (idx >= 0) {
90
- if (activeColumns.value.length <= 1) return; // must keep at least one
91
- activeColumns.value.splice(idx, 1);
92
- } else {
93
- activeColumns.value.push(key);
94
- }
95
- saveColumns();
96
- }
97
-
98
- function isColumnActive(key) {
99
- return activeColumns.value.includes(key);
100
- }
101
-
102
- const visibleColumnDefs = computed(() => {
103
- return ALL_COLUMNS.filter((c) => activeColumns.value.includes(c.key));
104
- });
105
-
106
- // Close column picker on outside click
107
- function onClickOutside(e) {
108
- if (!e.target.closest('[data-column-picker]')) {
109
- showColumnPicker.value = false;
110
- }
111
- }
112
-
113
- watch(showColumnPicker, (val) => {
114
- if (val) {
115
- document.addEventListener('click', onClickOutside, true);
116
- } else {
117
- document.removeEventListener('click', onClickOutside, true);
118
- }
119
- });
120
-
121
- function moveDown() {
122
- if (!props.tickets.data?.length) return;
123
- focusedIndex.value = Math.min(focusedIndex.value + 1, props.tickets.data.length - 1);
124
- }
125
- function moveUp() {
126
- if (!props.tickets.data?.length) return;
127
- focusedIndex.value = Math.max(focusedIndex.value - 1, 0);
128
- }
129
- function toggleSelectFocused() {
130
- if (focusedIndex.value < 0 || !props.tickets.data?.length) return;
131
- toggleOne(props.tickets.data[focusedIndex.value].id);
132
- }
133
- function openFocused() {
134
- if (focusedIndex.value < 0 || !props.tickets.data?.length) return;
135
- const ticket = props.tickets.data[focusedIndex.value];
136
- router.visit(route(`${props.routePrefix}.show`, ticket.reference));
137
- }
138
-
139
- defineExpose({ moveDown, moveUp, toggleSelectFocused, openFocused });
140
-
141
- const allSelected = computed(() => {
142
- if (!props.tickets.data?.length) return false;
143
- return props.tickets.data.every((t) => props.selectedIds.includes(t.id));
144
- });
145
-
146
- function toggleAll() {
147
- if (allSelected.value) {
148
- emit('update:selectedIds', []);
149
- } else {
150
- emit(
151
- 'update:selectedIds',
152
- props.tickets.data.map((t) => t.id),
153
- );
154
- }
155
- }
156
-
157
- function toggleOne(id) {
158
- const ids = [...props.selectedIds];
159
- const idx = ids.indexOf(id);
160
- if (idx >= 0) ids.splice(idx, 1);
161
- else ids.push(id);
162
- emit('update:selectedIds', ids);
163
- }
164
-
165
- function slaLabel(ticket) {
166
- if (ticket.sla_first_response_breached || ticket.sla_resolution_breached) return 'Breached';
167
- if (ticket.first_response_due_at || ticket.resolution_due_at) {
168
- const due = ticket.resolution_due_at || ticket.first_response_due_at;
169
- const mins = Math.round((new Date(due) - Date.now()) / 60000);
170
- if (mins < 0) return 'Overdue';
171
- if (mins < 60) return `${mins}m left`;
172
- const hrs = Math.floor(mins / 60);
173
- if (hrs < 24) return `${hrs}h left`;
174
- return `${Math.floor(hrs / 24)}d left`;
175
- }
176
- return '—';
177
- }
178
-
179
- function ticketTypeLabel(type) {
180
- const entry = TICKET_TYPE_COLORS[type];
181
- if (!entry) return type || '—';
182
- // Derive label from key
183
- return type.charAt(0).toUpperCase() + type.slice(1);
184
- }
185
-
186
- function ticketTypeBadgeClass(type, dark) {
187
- const entry = TICKET_TYPE_COLORS[type];
188
- if (!entry) return '';
189
- return dark ? entry.dark : entry.light;
190
- }
191
-
192
- function truncate(str, len = 60) {
193
- if (!str) return '';
194
- return str.length > len ? str.slice(0, len) + '...' : str;
195
- }
196
-
197
- const colCount = computed(() => {
198
- let count = visibleColumnDefs.value.length;
199
- if (props.selectable) count++;
200
- return count;
201
- });
202
- </script>
203
-
204
- <template>
205
- <!-- Dark mode -->
206
- <div v-if="escDark" class="overflow-hidden rounded-xl border border-white/[0.06] bg-neutral-900/60">
207
- <table class="min-w-full divide-y divide-white/[0.06]">
208
- <thead>
209
- <tr class="bg-white/[0.02]">
210
- <th v-if="selectable" scope="col" class="w-10 px-3 py-3">
211
- <input
212
- type="checkbox"
213
- :checked="allSelected"
214
- aria-label="Select all tickets"
215
- class="h-4 w-4 rounded border-white/20 bg-neutral-950 text-cyan-500 focus:ring-cyan-500/20"
216
- @change="toggleAll"
217
- />
218
- </th>
219
- <th
220
- v-for="col in visibleColumnDefs"
221
- :key="col.key"
222
- scope="col"
223
- class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-neutral-500"
224
- >
225
- {{ col.label }}
226
- </th>
227
- <th scope="col" class="w-10 px-2 py-3 text-right">
228
- <div class="relative inline-block" data-column-picker>
229
- <button
230
- aria-label="Configure columns"
231
- :class="[
232
- 'inline-flex items-center justify-center h-7 w-7 rounded-md transition-colors',
233
- 'text-neutral-500 hover:text-neutral-300 hover:bg-white/[0.06]',
234
- ]"
235
- @click.stop="showColumnPicker = !showColumnPicker"
236
- >
237
- <svg
238
- xmlns="http://www.w3.org/2000/svg"
239
- class="h-4 w-4"
240
- viewBox="0 0 20 20"
241
- fill="currentColor"
242
- >
243
- <path
244
- fill-rule="evenodd"
245
- d="M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z"
246
- clip-rule="evenodd"
247
- />
248
- </svg>
249
- </button>
250
- <div
251
- v-if="showColumnPicker"
252
- role="menu"
253
- aria-label="Column visibility"
254
- class="absolute right-0 top-full z-50 mt-1 w-48 rounded-lg border border-white/[0.08] bg-neutral-800 py-1 shadow-xl"
255
- >
256
- <label
257
- v-for="col in ALL_COLUMNS"
258
- :key="col.key"
259
- role="menuitemcheckbox"
260
- :aria-checked="isColumnActive(col.key)"
261
- class="flex cursor-pointer items-center gap-2 px-3 py-1.5 text-sm text-neutral-300 hover:bg-white/[0.06]"
262
- >
263
- <input
264
- type="checkbox"
265
- :checked="isColumnActive(col.key)"
266
- class="h-3.5 w-3.5 rounded border-white/20 bg-neutral-900 text-cyan-500 focus:ring-cyan-500/20"
267
- @change="toggleColumn(col.key)"
268
- />
269
- {{ col.label }}
270
- </label>
271
- </div>
272
- </div>
273
- </th>
274
- </tr>
275
- </thead>
276
- <tbody class="divide-y divide-white/[0.04]">
277
- <tr
278
- v-for="(ticket, index) in tickets.data"
279
- :key="ticket.id"
280
- :class="[
281
- 'group transition-colors',
282
- navigable && focusedIndex === index ? 'bg-white/[0.06]' : 'hover:bg-white/[0.03]',
283
- ]"
284
- >
285
- <td v-if="selectable" class="w-10 px-3 py-3">
286
- <input
287
- type="checkbox"
288
- :checked="selectedIds.includes(ticket.id)"
289
- aria-label="Select ticket"
290
- class="h-4 w-4 rounded border-white/20 bg-neutral-950 text-cyan-500 focus:ring-cyan-500/20"
291
- @change="toggleOne(ticket.id)"
292
- />
293
- </td>
294
- <!-- reference -->
295
- <td v-if="isColumnActive('reference')" class="whitespace-nowrap px-4 py-3 text-sm font-medium">
296
- <div class="flex items-center gap-2">
297
- <span
298
- v-if="slaClass(ticket)"
299
- :class="['h-2 w-2 shrink-0 rounded-full', slaClass(ticket)]"
300
- ></span>
301
- <Link
302
- :href="route(`${routePrefix}.show`, ticket.reference)"
303
- class="text-white hover:text-neutral-300"
304
- >
305
- {{ ticket.reference }}
306
- </Link>
307
- </div>
308
- </td>
309
- <!-- subject -->
310
- <td v-if="isColumnActive('subject')" class="px-4 py-3 text-sm text-neutral-300">
311
- {{ truncate(ticket.subject) }}
312
- </td>
313
- <!-- requester -->
314
- <td v-if="isColumnActive('requester')" class="px-4 py-3 text-sm text-neutral-400">
315
- <div>{{ ticket.requester?.name || ticket.requester_name || 'Unknown' }}</div>
316
- <div class="truncate text-xs text-neutral-600" style="max-width: 150px">
317
- {{ ticket.requester?.email || ticket.requester_email || '' }}
318
- </div>
319
- </td>
320
- <!-- status -->
321
- <td v-if="isColumnActive('status')" class="px-4 py-3"><StatusBadge :status="ticket.status" /></td>
322
- <!-- priority -->
323
- <td v-if="isColumnActive('priority')" class="px-4 py-3">
324
- <PriorityBadge :priority="ticket.priority" />
325
- </td>
326
- <!-- assignee -->
327
- <td v-if="isColumnActive('assignee')" class="px-4 py-3 text-sm text-neutral-500">
328
- {{ ticket.assignee?.name || 'Unassigned' }}
329
- </td>
330
- <!-- department -->
331
- <td v-if="isColumnActive('department')" class="px-4 py-3 text-sm text-neutral-500">
332
- {{ ticket.department?.name || '—' }}
333
- </td>
334
- <!-- updated (last reply) -->
335
- <td v-if="isColumnActive('updated')" class="whitespace-nowrap px-4 py-3 text-sm text-neutral-600">
336
- <template v-if="ticket.latest_reply || ticket.last_reply_at">
337
- <div class="text-neutral-400">
338
- {{ timeAgo(ticket.latest_reply?.created_at || ticket.last_reply_at) }}
339
- </div>
340
- <div class="text-xs text-neutral-600">
341
- {{ ticket.latest_reply?.author?.name || ticket.last_reply_author || '' }}
342
- </div>
343
- </template>
344
- <span v-else class="text-neutral-700">—</span>
345
- </td>
346
- <!-- created -->
347
- <td v-if="isColumnActive('created')" class="whitespace-nowrap px-4 py-3 text-sm text-neutral-500">
348
- {{ timeAgo(ticket.created_at) }}
349
- </td>
350
- <!-- sla -->
351
- <td v-if="isColumnActive('sla')" class="px-4 py-3 text-sm">
352
- <span
353
- v-if="slaClass(ticket)"
354
- :class="[
355
- 'inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium text-white',
356
- slaClass(ticket),
357
- ]"
358
- >
359
- {{ slaLabel(ticket) }}
360
- </span>
361
- <span v-else class="text-neutral-700">—</span>
362
- </td>
363
- <!-- tags -->
364
- <td v-if="isColumnActive('tags')" class="px-4 py-3 text-sm">
365
- <div class="flex flex-wrap gap-1">
366
- <span
367
- v-for="tag in ticket.tags || []"
368
- :key="tag.id || tag"
369
- class="inline-block rounded-full bg-white/[0.06] px-2 py-0.5 text-xs text-neutral-400"
370
- >
371
- {{ tag.name || tag }}
372
- </span>
373
- <span v-if="!ticket.tags?.length" class="text-neutral-700">—</span>
374
- </div>
375
- </td>
376
- <!-- category (ticket type) -->
377
- <td v-if="isColumnActive('category')" class="px-4 py-3 text-sm">
378
- <span
379
- v-if="ticket.ticket_type"
380
- :class="[
381
- 'inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium',
382
- ticketTypeBadgeClass(ticket.ticket_type, true),
383
- ]"
384
- >
385
- {{ ticketTypeLabel(ticket.ticket_type) }}
386
- </span>
387
- <span v-else class="text-neutral-700">—</span>
388
- </td>
389
- <!-- spacer for gear column -->
390
- <td class="w-10 px-2 py-3"></td>
391
- </tr>
392
- <tr v-if="!tickets.data?.length">
393
- <td :colspan="colCount + 1" class="px-4 py-8 text-center text-sm text-neutral-600">
394
- No tickets found.
395
- </td>
396
- </tr>
397
- </tbody>
398
- </table>
399
- </div>
400
-
401
- <!-- Light mode -->
402
- <div v-else class="overflow-hidden rounded-lg border border-gray-200 bg-white">
403
- <table class="min-w-full divide-y divide-gray-200">
404
- <thead class="bg-gray-50">
405
- <tr>
406
- <th v-if="selectable" scope="col" class="w-10 px-3 py-3">
407
- <input
408
- type="checkbox"
409
- :checked="allSelected"
410
- aria-label="Select all tickets"
411
- class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
412
- @change="toggleAll"
413
- />
414
- </th>
415
- <th
416
- v-for="col in visibleColumnDefs"
417
- :key="col.key"
418
- scope="col"
419
- class="px-4 py-3 text-left text-xs font-medium uppercase text-gray-500"
420
- >
421
- {{ col.label }}
422
- </th>
423
- <th scope="col" class="w-10 px-2 py-3 text-right">
424
- <div class="relative inline-block" data-column-picker>
425
- <button
426
- aria-label="Configure columns"
427
- :class="[
428
- 'inline-flex items-center justify-center h-7 w-7 rounded-md transition-colors',
429
- 'text-gray-400 hover:text-gray-600 hover:bg-gray-100',
430
- ]"
431
- @click.stop="showColumnPicker = !showColumnPicker"
432
- >
433
- <svg
434
- xmlns="http://www.w3.org/2000/svg"
435
- class="h-4 w-4"
436
- viewBox="0 0 20 20"
437
- fill="currentColor"
438
- >
439
- <path
440
- fill-rule="evenodd"
441
- d="M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z"
442
- clip-rule="evenodd"
443
- />
444
- </svg>
445
- </button>
446
- <div
447
- v-if="showColumnPicker"
448
- role="menu"
449
- aria-label="Column visibility"
450
- class="absolute right-0 top-full z-50 mt-1 w-48 rounded-lg border border-gray-200 bg-white py-1 shadow-xl"
451
- >
452
- <label
453
- v-for="col in ALL_COLUMNS"
454
- :key="col.key"
455
- role="menuitemcheckbox"
456
- :aria-checked="isColumnActive(col.key)"
457
- class="flex cursor-pointer items-center gap-2 px-3 py-1.5 text-sm text-gray-700 hover:bg-gray-50"
458
- >
459
- <input
460
- type="checkbox"
461
- :checked="isColumnActive(col.key)"
462
- class="h-3.5 w-3.5 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
463
- @change="toggleColumn(col.key)"
464
- />
465
- {{ col.label }}
466
- </label>
467
- </div>
468
- </div>
469
- </th>
470
- </tr>
471
- </thead>
472
- <tbody class="divide-y divide-gray-200">
473
- <tr
474
- v-for="(ticket, index) in tickets.data"
475
- :key="ticket.id"
476
- :class="['group', navigable && focusedIndex === index ? 'bg-indigo-50' : 'hover:bg-gray-50']"
477
- >
478
- <td v-if="selectable" class="w-10 px-3 py-3">
479
- <input
480
- type="checkbox"
481
- :checked="selectedIds.includes(ticket.id)"
482
- aria-label="Select ticket"
483
- class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
484
- @change="toggleOne(ticket.id)"
485
- />
486
- </td>
487
- <!-- reference -->
488
- <td
489
- v-if="isColumnActive('reference')"
490
- class="whitespace-nowrap px-4 py-3 text-sm font-medium text-gray-900"
491
- >
492
- <div class="flex items-center gap-2">
493
- <span
494
- v-if="slaClass(ticket)"
495
- :class="['h-2 w-2 shrink-0 rounded-full', slaClass(ticket)]"
496
- ></span>
497
- <Link
498
- :href="route(`${routePrefix}.show`, ticket.reference)"
499
- class="text-indigo-600 hover:text-indigo-900"
500
- >
501
- {{ ticket.reference }}
502
- </Link>
503
- </div>
504
- </td>
505
- <!-- subject -->
506
- <td v-if="isColumnActive('subject')" class="px-4 py-3 text-sm text-gray-900">
507
- {{ truncate(ticket.subject) }}
508
- </td>
509
- <!-- requester -->
510
- <td v-if="isColumnActive('requester')" class="px-4 py-3 text-sm text-gray-500">
511
- <div>{{ ticket.requester?.name || ticket.requester_name || 'Unknown' }}</div>
512
- <div class="truncate text-xs text-gray-400" style="max-width: 150px">
513
- {{ ticket.requester?.email || ticket.requester_email || '' }}
514
- </div>
515
- </td>
516
- <!-- status -->
517
- <td v-if="isColumnActive('status')" class="px-4 py-3"><StatusBadge :status="ticket.status" /></td>
518
- <!-- priority -->
519
- <td v-if="isColumnActive('priority')" class="px-4 py-3">
520
- <PriorityBadge :priority="ticket.priority" />
521
- </td>
522
- <!-- assignee -->
523
- <td v-if="isColumnActive('assignee')" class="px-4 py-3 text-sm text-gray-500">
524
- {{ ticket.assignee?.name || 'Unassigned' }}
525
- </td>
526
- <!-- department -->
527
- <td v-if="isColumnActive('department')" class="px-4 py-3 text-sm text-gray-500">
528
- {{ ticket.department?.name || '—' }}
529
- </td>
530
- <!-- updated (last reply) -->
531
- <td v-if="isColumnActive('updated')" class="whitespace-nowrap px-4 py-3 text-sm text-gray-500">
532
- <template v-if="ticket.latest_reply || ticket.last_reply_at">
533
- <div>{{ timeAgo(ticket.latest_reply?.created_at || ticket.last_reply_at) }}</div>
534
- <div class="text-xs text-gray-400">
535
- {{ ticket.latest_reply?.author?.name || ticket.last_reply_author || '' }}
536
- </div>
537
- </template>
538
- <span v-else class="text-gray-400">—</span>
539
- </td>
540
- <!-- created -->
541
- <td v-if="isColumnActive('created')" class="whitespace-nowrap px-4 py-3 text-sm text-gray-500">
542
- {{ timeAgo(ticket.created_at) }}
543
- </td>
544
- <!-- sla -->
545
- <td v-if="isColumnActive('sla')" class="px-4 py-3 text-sm">
546
- <span
547
- v-if="slaClass(ticket)"
548
- :class="[
549
- 'inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium text-white',
550
- slaClass(ticket),
551
- ]"
552
- >
553
- {{ slaLabel(ticket) }}
554
- </span>
555
- <span v-else class="text-gray-400">—</span>
556
- </td>
557
- <!-- tags -->
558
- <td v-if="isColumnActive('tags')" class="px-4 py-3 text-sm">
559
- <div class="flex flex-wrap gap-1">
560
- <span
561
- v-for="tag in ticket.tags || []"
562
- :key="tag.id || tag"
563
- class="inline-block rounded-full bg-gray-100 px-2 py-0.5 text-xs text-gray-600"
564
- >
565
- {{ tag.name || tag }}
566
- </span>
567
- <span v-if="!ticket.tags?.length" class="text-gray-400">—</span>
568
- </div>
569
- </td>
570
- <!-- category (ticket type) -->
571
- <td v-if="isColumnActive('category')" class="px-4 py-3 text-sm">
572
- <span
573
- v-if="ticket.ticket_type"
574
- :class="[
575
- 'inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium',
576
- ticketTypeBadgeClass(ticket.ticket_type, false),
577
- ]"
578
- >
579
- {{ ticketTypeLabel(ticket.ticket_type) }}
580
- </span>
581
- <span v-else class="text-gray-400">—</span>
582
- </td>
583
- <!-- spacer for gear column -->
584
- <td class="w-10 px-2 py-3"></td>
585
- </tr>
586
- <tr v-if="!tickets.data?.length">
587
- <td :colspan="colCount + 1" class="px-4 py-8 text-center text-sm text-gray-500">
588
- No tickets found.
589
- </td>
590
- </tr>
591
- </tbody>
592
- </table>
593
- </div>
594
- </template>
1
+ <script setup>
2
+ /* global localStorage */
3
+ import { inject, computed, ref, watch } from 'vue';
4
+ import StatusBadge from './StatusBadge.vue';
5
+ import PriorityBadge from './PriorityBadge.vue';
6
+ import { Link, router } from '@inertiajs/vue3';
7
+ import { TICKET_TYPE_COLORS } from '../utils/constants';
8
+ import { timeAgo, slaClass } from '../utils/formatting';
9
+
10
+ const STORAGE_KEY = 'escalated-ticket-columns';
11
+
12
+ const ALL_COLUMNS = [
13
+ { key: 'reference', label: 'Reference' },
14
+ { key: 'subject', label: 'Subject' },
15
+ { key: 'requester', label: 'Requester' },
16
+ { key: 'status', label: 'Status' },
17
+ { key: 'priority', label: 'Priority' },
18
+ { key: 'assignee', label: 'Assignee' },
19
+ { key: 'department', label: 'Department' },
20
+ { key: 'updated', label: 'Last Reply' },
21
+ { key: 'created', label: 'Created' },
22
+ { key: 'sla', label: 'SLA' },
23
+ { key: 'tags', label: 'Tags' },
24
+ { key: 'category', label: 'Category' },
25
+ ];
26
+
27
+ const props = defineProps({
28
+ tickets: { type: Object, required: true },
29
+ routePrefix: { type: String, default: 'escalated.customer.tickets' },
30
+ /** @deprecated Use `columns` prop instead */
31
+ showAssignee: { type: Boolean, default: false },
32
+ columns: {
33
+ type: Array,
34
+ default: () => ['reference', 'subject', 'requester', 'status', 'priority', 'updated'],
35
+ },
36
+ selectable: { type: Boolean, default: false },
37
+ selectedIds: { type: Array, default: () => [] },
38
+ assignRoute: { type: String, default: '' },
39
+ navigable: { type: Boolean, default: false },
40
+ showLiveBadge: { type: Boolean, default: false },
41
+ });
42
+
43
+ const emit = defineEmits(['update:selectedIds']);
44
+ const escDark = inject(
45
+ 'esc-dark',
46
+ computed(() => false),
47
+ );
48
+ const focusedIndex = ref(-1);
49
+ const showColumnPicker = ref(false);
50
+
51
+ // Resolve initial columns: merge prop with deprecated showAssignee, then override from localStorage
52
+ function resolveDefaultColumns() {
53
+ const base = [...props.columns];
54
+ if (props.showAssignee && !base.includes('assignee')) {
55
+ const prioIdx = base.indexOf('priority');
56
+ if (prioIdx >= 0) {
57
+ base.splice(prioIdx + 1, 0, 'assignee');
58
+ } else {
59
+ base.push('assignee');
60
+ }
61
+ }
62
+ return base;
63
+ }
64
+
65
+ function loadSavedColumns() {
66
+ try {
67
+ const saved = localStorage.getItem(STORAGE_KEY);
68
+ if (saved) {
69
+ const parsed = JSON.parse(saved);
70
+ if (Array.isArray(parsed) && parsed.length > 0) return parsed;
71
+ }
72
+ } catch {
73
+ // ignore
74
+ }
75
+ return null;
76
+ }
77
+
78
+ const activeColumns = ref(loadSavedColumns() || resolveDefaultColumns());
79
+
80
+ function saveColumns() {
81
+ try {
82
+ localStorage.setItem(STORAGE_KEY, JSON.stringify(activeColumns.value));
83
+ } catch {
84
+ // ignore
85
+ }
86
+ }
87
+
88
+ function toggleColumn(key) {
89
+ const idx = activeColumns.value.indexOf(key);
90
+ if (idx >= 0) {
91
+ if (activeColumns.value.length <= 1) return; // must keep at least one
92
+ activeColumns.value.splice(idx, 1);
93
+ } else {
94
+ activeColumns.value.push(key);
95
+ }
96
+ saveColumns();
97
+ }
98
+
99
+ function isColumnActive(key) {
100
+ return activeColumns.value.includes(key);
101
+ }
102
+
103
+ const visibleColumnDefs = computed(() => {
104
+ return ALL_COLUMNS.filter((c) => activeColumns.value.includes(c.key));
105
+ });
106
+
107
+ // Close column picker on outside click
108
+ function onClickOutside(e) {
109
+ if (!e.target.closest('[data-column-picker]')) {
110
+ showColumnPicker.value = false;
111
+ }
112
+ }
113
+
114
+ watch(showColumnPicker, (val) => {
115
+ if (val) {
116
+ document.addEventListener('click', onClickOutside, true);
117
+ } else {
118
+ document.removeEventListener('click', onClickOutside, true);
119
+ }
120
+ });
121
+
122
+ function moveDown() {
123
+ if (!props.tickets.data?.length) return;
124
+ focusedIndex.value = Math.min(focusedIndex.value + 1, props.tickets.data.length - 1);
125
+ }
126
+ function moveUp() {
127
+ if (!props.tickets.data?.length) return;
128
+ focusedIndex.value = Math.max(focusedIndex.value - 1, 0);
129
+ }
130
+ function toggleSelectFocused() {
131
+ if (focusedIndex.value < 0 || !props.tickets.data?.length) return;
132
+ toggleOne(props.tickets.data[focusedIndex.value].id);
133
+ }
134
+ function openFocused() {
135
+ if (focusedIndex.value < 0 || !props.tickets.data?.length) return;
136
+ const ticket = props.tickets.data[focusedIndex.value];
137
+ router.visit(route(`${props.routePrefix}.show`, ticket.reference));
138
+ }
139
+
140
+ defineExpose({ moveDown, moveUp, toggleSelectFocused, openFocused });
141
+
142
+ const allSelected = computed(() => {
143
+ if (!props.tickets.data?.length) return false;
144
+ return props.tickets.data.every((t) => props.selectedIds.includes(t.id));
145
+ });
146
+
147
+ function toggleAll() {
148
+ if (allSelected.value) {
149
+ emit('update:selectedIds', []);
150
+ } else {
151
+ emit(
152
+ 'update:selectedIds',
153
+ props.tickets.data.map((t) => t.id),
154
+ );
155
+ }
156
+ }
157
+
158
+ function toggleOne(id) {
159
+ const ids = [...props.selectedIds];
160
+ const idx = ids.indexOf(id);
161
+ if (idx >= 0) ids.splice(idx, 1);
162
+ else ids.push(id);
163
+ emit('update:selectedIds', ids);
164
+ }
165
+
166
+ function slaLabel(ticket) {
167
+ if (ticket.sla_first_response_breached || ticket.sla_resolution_breached) return 'Breached';
168
+ if (ticket.first_response_due_at || ticket.resolution_due_at) {
169
+ const due = ticket.resolution_due_at || ticket.first_response_due_at;
170
+ const mins = Math.round((new Date(due) - Date.now()) / 60000);
171
+ if (mins < 0) return 'Overdue';
172
+ if (mins < 60) return `${mins}m left`;
173
+ const hrs = Math.floor(mins / 60);
174
+ if (hrs < 24) return `${hrs}h left`;
175
+ return `${Math.floor(hrs / 24)}d left`;
176
+ }
177
+ return '—';
178
+ }
179
+
180
+ function ticketTypeLabel(type) {
181
+ const entry = TICKET_TYPE_COLORS[type];
182
+ if (!entry) return type || '—';
183
+ // Derive label from key
184
+ return type.charAt(0).toUpperCase() + type.slice(1);
185
+ }
186
+
187
+ function ticketTypeBadgeClass(type, dark) {
188
+ const entry = TICKET_TYPE_COLORS[type];
189
+ if (!entry) return '';
190
+ return dark ? entry.dark : entry.light;
191
+ }
192
+
193
+ function truncate(str, len = 60) {
194
+ if (!str) return '';
195
+ return str.length > len ? str.slice(0, len) + '...' : str;
196
+ }
197
+
198
+ const colCount = computed(() => {
199
+ let count = visibleColumnDefs.value.length;
200
+ if (props.selectable) count++;
201
+ return count;
202
+ });
203
+ </script>
204
+
205
+ <template>
206
+ <!-- Dark mode -->
207
+ <div v-if="escDark" class="overflow-hidden rounded-xl border border-white/[0.06] bg-neutral-900/60">
208
+ <table class="min-w-full divide-y divide-white/[0.06]">
209
+ <thead>
210
+ <tr class="bg-white/[0.02]">
211
+ <th v-if="selectable" scope="col" class="w-10 px-3 py-3">
212
+ <input
213
+ type="checkbox"
214
+ :checked="allSelected"
215
+ aria-label="Select all tickets"
216
+ class="h-4 w-4 rounded border-white/20 bg-neutral-950 text-cyan-500 focus:ring-cyan-500/20"
217
+ @change="toggleAll"
218
+ />
219
+ </th>
220
+ <th
221
+ v-for="col in visibleColumnDefs"
222
+ :key="col.key"
223
+ scope="col"
224
+ class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-neutral-500"
225
+ >
226
+ {{ col.label }}
227
+ </th>
228
+ <th scope="col" class="w-10 px-2 py-3 text-right">
229
+ <div class="relative inline-block" data-column-picker>
230
+ <button
231
+ aria-label="Configure columns"
232
+ :class="[
233
+ 'inline-flex items-center justify-center h-7 w-7 rounded-md transition-colors',
234
+ 'text-neutral-500 hover:text-neutral-300 hover:bg-white/[0.06]',
235
+ ]"
236
+ @click.stop="showColumnPicker = !showColumnPicker"
237
+ >
238
+ <svg
239
+ xmlns="http://www.w3.org/2000/svg"
240
+ class="h-4 w-4"
241
+ viewBox="0 0 20 20"
242
+ fill="currentColor"
243
+ >
244
+ <path
245
+ fill-rule="evenodd"
246
+ d="M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z"
247
+ clip-rule="evenodd"
248
+ />
249
+ </svg>
250
+ </button>
251
+ <div
252
+ v-if="showColumnPicker"
253
+ role="menu"
254
+ aria-label="Column visibility"
255
+ class="absolute right-0 top-full z-50 mt-1 w-48 rounded-lg border border-white/[0.08] bg-neutral-800 py-1 shadow-xl"
256
+ >
257
+ <label
258
+ v-for="col in ALL_COLUMNS"
259
+ :key="col.key"
260
+ role="menuitemcheckbox"
261
+ :aria-checked="isColumnActive(col.key)"
262
+ class="flex cursor-pointer items-center gap-2 px-3 py-1.5 text-sm text-neutral-300 hover:bg-white/[0.06]"
263
+ >
264
+ <input
265
+ type="checkbox"
266
+ :checked="isColumnActive(col.key)"
267
+ class="h-3.5 w-3.5 rounded border-white/20 bg-neutral-900 text-cyan-500 focus:ring-cyan-500/20"
268
+ @change="toggleColumn(col.key)"
269
+ />
270
+ {{ col.label }}
271
+ </label>
272
+ </div>
273
+ </div>
274
+ </th>
275
+ </tr>
276
+ </thead>
277
+ <tbody class="divide-y divide-white/[0.04]">
278
+ <tr
279
+ v-for="(ticket, index) in tickets.data"
280
+ :key="ticket.id"
281
+ :class="[
282
+ 'group transition-colors',
283
+ navigable && focusedIndex === index ? 'bg-white/[0.06]' : 'hover:bg-white/[0.03]',
284
+ ]"
285
+ >
286
+ <td v-if="selectable" class="w-10 px-3 py-3">
287
+ <input
288
+ type="checkbox"
289
+ :checked="selectedIds.includes(ticket.id)"
290
+ aria-label="Select ticket"
291
+ class="h-4 w-4 rounded border-white/20 bg-neutral-950 text-cyan-500 focus:ring-cyan-500/20"
292
+ @change="toggleOne(ticket.id)"
293
+ />
294
+ </td>
295
+ <!-- reference -->
296
+ <td v-if="isColumnActive('reference')" class="whitespace-nowrap px-4 py-3 text-sm font-medium">
297
+ <div class="flex items-center gap-2">
298
+ <span
299
+ v-if="slaClass(ticket)"
300
+ :class="['h-2 w-2 shrink-0 rounded-full', slaClass(ticket)]"
301
+ ></span>
302
+ <Link
303
+ :href="route(`${routePrefix}.show`, ticket.reference)"
304
+ class="text-white hover:text-neutral-300"
305
+ >
306
+ {{ ticket.reference }}
307
+ </Link>
308
+ </div>
309
+ </td>
310
+ <!-- subject -->
311
+ <td v-if="isColumnActive('subject')" class="px-4 py-3 text-sm text-neutral-300">
312
+ {{ truncate(ticket.subject) }}
313
+ </td>
314
+ <!-- requester -->
315
+ <td v-if="isColumnActive('requester')" class="px-4 py-3 text-sm text-neutral-400">
316
+ <div>{{ ticket.requester?.name || ticket.requester_name || 'Unknown' }}</div>
317
+ <div class="truncate text-xs text-neutral-600" style="max-width: 150px">
318
+ {{ ticket.requester?.email || ticket.requester_email || '' }}
319
+ </div>
320
+ </td>
321
+ <!-- status -->
322
+ <td v-if="isColumnActive('status')" class="px-4 py-3">
323
+ <div class="flex items-center gap-1.5">
324
+ <StatusBadge :status="ticket.status" />
325
+ <span
326
+ v-if="showLiveBadge && ticket.channel === 'chat' && ticket.status === 'live'"
327
+ class="inline-flex items-center gap-1 rounded-full bg-emerald-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-emerald-400 ring-1 ring-emerald-500/20"
328
+ >
329
+ <span class="h-1.5 w-1.5 animate-pulse rounded-full bg-emerald-400"></span>
330
+ Live
331
+ </span>
332
+ <span
333
+ v-if="ticket.snoozed_until && new Date(ticket.snoozed_until) > Date.now()"
334
+ class="inline-flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-400 ring-1 ring-amber-500/20"
335
+ :title="'Snoozed until ' + new Date(ticket.snoozed_until).toLocaleString()"
336
+ >
337
+ <svg
338
+ xmlns="http://www.w3.org/2000/svg"
339
+ class="h-3 w-3"
340
+ viewBox="0 0 20 20"
341
+ fill="currentColor"
342
+ >
343
+ <path
344
+ fill-rule="evenodd"
345
+ d="M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.828a1 1 0 101.415-1.414L11 9.586V6z"
346
+ clip-rule="evenodd"
347
+ />
348
+ </svg>
349
+ Snoozed
350
+ </span>
351
+ </div>
352
+ </td>
353
+ <!-- priority -->
354
+ <td v-if="isColumnActive('priority')" class="px-4 py-3">
355
+ <PriorityBadge :priority="ticket.priority" />
356
+ </td>
357
+ <!-- assignee -->
358
+ <td v-if="isColumnActive('assignee')" class="px-4 py-3 text-sm text-neutral-500">
359
+ {{ ticket.assignee?.name || 'Unassigned' }}
360
+ </td>
361
+ <!-- department -->
362
+ <td v-if="isColumnActive('department')" class="px-4 py-3 text-sm text-neutral-500">
363
+ {{ ticket.department?.name || '—' }}
364
+ </td>
365
+ <!-- updated (last reply) -->
366
+ <td v-if="isColumnActive('updated')" class="whitespace-nowrap px-4 py-3 text-sm text-neutral-600">
367
+ <template v-if="ticket.latest_reply || ticket.last_reply_at">
368
+ <div class="text-neutral-400">
369
+ {{ timeAgo(ticket.latest_reply?.created_at || ticket.last_reply_at) }}
370
+ </div>
371
+ <div class="text-xs text-neutral-600">
372
+ {{ ticket.latest_reply?.author?.name || ticket.last_reply_author || '' }}
373
+ </div>
374
+ </template>
375
+ <span v-else class="text-neutral-700">—</span>
376
+ </td>
377
+ <!-- created -->
378
+ <td v-if="isColumnActive('created')" class="whitespace-nowrap px-4 py-3 text-sm text-neutral-500">
379
+ {{ timeAgo(ticket.created_at) }}
380
+ </td>
381
+ <!-- sla -->
382
+ <td v-if="isColumnActive('sla')" class="px-4 py-3 text-sm">
383
+ <span
384
+ v-if="slaClass(ticket)"
385
+ :class="[
386
+ 'inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium text-white',
387
+ slaClass(ticket),
388
+ ]"
389
+ >
390
+ {{ slaLabel(ticket) }}
391
+ </span>
392
+ <span v-else class="text-neutral-700">—</span>
393
+ </td>
394
+ <!-- tags -->
395
+ <td v-if="isColumnActive('tags')" class="px-4 py-3 text-sm">
396
+ <div class="flex flex-wrap gap-1">
397
+ <span
398
+ v-for="tag in ticket.tags || []"
399
+ :key="tag.id || tag"
400
+ class="inline-block rounded-full bg-white/[0.06] px-2 py-0.5 text-xs text-neutral-400"
401
+ >
402
+ {{ tag.name || tag }}
403
+ </span>
404
+ <span v-if="!ticket.tags?.length" class="text-neutral-700">—</span>
405
+ </div>
406
+ </td>
407
+ <!-- category (ticket type) -->
408
+ <td v-if="isColumnActive('category')" class="px-4 py-3 text-sm">
409
+ <span
410
+ v-if="ticket.ticket_type"
411
+ :class="[
412
+ 'inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium',
413
+ ticketTypeBadgeClass(ticket.ticket_type, true),
414
+ ]"
415
+ >
416
+ {{ ticketTypeLabel(ticket.ticket_type) }}
417
+ </span>
418
+ <span v-else class="text-neutral-700">—</span>
419
+ </td>
420
+ <!-- spacer for gear column -->
421
+ <td class="w-10 px-2 py-3"></td>
422
+ </tr>
423
+ <tr v-if="!tickets.data?.length">
424
+ <td :colspan="colCount + 1" class="px-4 py-8 text-center text-sm text-neutral-600">
425
+ No tickets found.
426
+ </td>
427
+ </tr>
428
+ </tbody>
429
+ </table>
430
+ </div>
431
+
432
+ <!-- Light mode -->
433
+ <div v-else class="overflow-hidden rounded-lg border border-gray-200 bg-white">
434
+ <table class="min-w-full divide-y divide-gray-200">
435
+ <thead class="bg-gray-50">
436
+ <tr>
437
+ <th v-if="selectable" scope="col" class="w-10 px-3 py-3">
438
+ <input
439
+ type="checkbox"
440
+ :checked="allSelected"
441
+ aria-label="Select all tickets"
442
+ class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
443
+ @change="toggleAll"
444
+ />
445
+ </th>
446
+ <th
447
+ v-for="col in visibleColumnDefs"
448
+ :key="col.key"
449
+ scope="col"
450
+ class="px-4 py-3 text-left text-xs font-medium uppercase text-gray-500"
451
+ >
452
+ {{ col.label }}
453
+ </th>
454
+ <th scope="col" class="w-10 px-2 py-3 text-right">
455
+ <div class="relative inline-block" data-column-picker>
456
+ <button
457
+ aria-label="Configure columns"
458
+ :class="[
459
+ 'inline-flex items-center justify-center h-7 w-7 rounded-md transition-colors',
460
+ 'text-gray-400 hover:text-gray-600 hover:bg-gray-100',
461
+ ]"
462
+ @click.stop="showColumnPicker = !showColumnPicker"
463
+ >
464
+ <svg
465
+ xmlns="http://www.w3.org/2000/svg"
466
+ class="h-4 w-4"
467
+ viewBox="0 0 20 20"
468
+ fill="currentColor"
469
+ >
470
+ <path
471
+ fill-rule="evenodd"
472
+ d="M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z"
473
+ clip-rule="evenodd"
474
+ />
475
+ </svg>
476
+ </button>
477
+ <div
478
+ v-if="showColumnPicker"
479
+ role="menu"
480
+ aria-label="Column visibility"
481
+ class="absolute right-0 top-full z-50 mt-1 w-48 rounded-lg border border-gray-200 bg-white py-1 shadow-xl"
482
+ >
483
+ <label
484
+ v-for="col in ALL_COLUMNS"
485
+ :key="col.key"
486
+ role="menuitemcheckbox"
487
+ :aria-checked="isColumnActive(col.key)"
488
+ class="flex cursor-pointer items-center gap-2 px-3 py-1.5 text-sm text-gray-700 hover:bg-gray-50"
489
+ >
490
+ <input
491
+ type="checkbox"
492
+ :checked="isColumnActive(col.key)"
493
+ class="h-3.5 w-3.5 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
494
+ @change="toggleColumn(col.key)"
495
+ />
496
+ {{ col.label }}
497
+ </label>
498
+ </div>
499
+ </div>
500
+ </th>
501
+ </tr>
502
+ </thead>
503
+ <tbody class="divide-y divide-gray-200">
504
+ <tr
505
+ v-for="(ticket, index) in tickets.data"
506
+ :key="ticket.id"
507
+ :class="['group', navigable && focusedIndex === index ? 'bg-indigo-50' : 'hover:bg-gray-50']"
508
+ >
509
+ <td v-if="selectable" class="w-10 px-3 py-3">
510
+ <input
511
+ type="checkbox"
512
+ :checked="selectedIds.includes(ticket.id)"
513
+ aria-label="Select ticket"
514
+ class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
515
+ @change="toggleOne(ticket.id)"
516
+ />
517
+ </td>
518
+ <!-- reference -->
519
+ <td
520
+ v-if="isColumnActive('reference')"
521
+ class="whitespace-nowrap px-4 py-3 text-sm font-medium text-gray-900"
522
+ >
523
+ <div class="flex items-center gap-2">
524
+ <span
525
+ v-if="slaClass(ticket)"
526
+ :class="['h-2 w-2 shrink-0 rounded-full', slaClass(ticket)]"
527
+ ></span>
528
+ <Link
529
+ :href="route(`${routePrefix}.show`, ticket.reference)"
530
+ class="text-indigo-600 hover:text-indigo-900"
531
+ >
532
+ {{ ticket.reference }}
533
+ </Link>
534
+ </div>
535
+ </td>
536
+ <!-- subject -->
537
+ <td v-if="isColumnActive('subject')" class="px-4 py-3 text-sm text-gray-900">
538
+ {{ truncate(ticket.subject) }}
539
+ </td>
540
+ <!-- requester -->
541
+ <td v-if="isColumnActive('requester')" class="px-4 py-3 text-sm text-gray-500">
542
+ <div>{{ ticket.requester?.name || ticket.requester_name || 'Unknown' }}</div>
543
+ <div class="truncate text-xs text-gray-400" style="max-width: 150px">
544
+ {{ ticket.requester?.email || ticket.requester_email || '' }}
545
+ </div>
546
+ </td>
547
+ <!-- status -->
548
+ <td v-if="isColumnActive('status')" class="px-4 py-3">
549
+ <div class="flex items-center gap-1.5">
550
+ <StatusBadge :status="ticket.status" />
551
+ <span
552
+ v-if="showLiveBadge && ticket.channel === 'chat' && ticket.status === 'live'"
553
+ class="inline-flex items-center gap-1 rounded-full bg-emerald-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-emerald-400 ring-1 ring-emerald-500/20"
554
+ >
555
+ <span class="h-1.5 w-1.5 animate-pulse rounded-full bg-emerald-400"></span>
556
+ Live
557
+ </span>
558
+ <span
559
+ v-if="ticket.snoozed_until && new Date(ticket.snoozed_until) > Date.now()"
560
+ class="inline-flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-400 ring-1 ring-amber-500/20"
561
+ :title="'Snoozed until ' + new Date(ticket.snoozed_until).toLocaleString()"
562
+ >
563
+ <svg
564
+ xmlns="http://www.w3.org/2000/svg"
565
+ class="h-3 w-3"
566
+ viewBox="0 0 20 20"
567
+ fill="currentColor"
568
+ >
569
+ <path
570
+ fill-rule="evenodd"
571
+ d="M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.828a1 1 0 101.415-1.414L11 9.586V6z"
572
+ clip-rule="evenodd"
573
+ />
574
+ </svg>
575
+ Snoozed
576
+ </span>
577
+ </div>
578
+ </td>
579
+ <!-- priority -->
580
+ <td v-if="isColumnActive('priority')" class="px-4 py-3">
581
+ <PriorityBadge :priority="ticket.priority" />
582
+ </td>
583
+ <!-- assignee -->
584
+ <td v-if="isColumnActive('assignee')" class="px-4 py-3 text-sm text-gray-500">
585
+ {{ ticket.assignee?.name || 'Unassigned' }}
586
+ </td>
587
+ <!-- department -->
588
+ <td v-if="isColumnActive('department')" class="px-4 py-3 text-sm text-gray-500">
589
+ {{ ticket.department?.name || '—' }}
590
+ </td>
591
+ <!-- updated (last reply) -->
592
+ <td v-if="isColumnActive('updated')" class="whitespace-nowrap px-4 py-3 text-sm text-gray-500">
593
+ <template v-if="ticket.latest_reply || ticket.last_reply_at">
594
+ <div>{{ timeAgo(ticket.latest_reply?.created_at || ticket.last_reply_at) }}</div>
595
+ <div class="text-xs text-gray-400">
596
+ {{ ticket.latest_reply?.author?.name || ticket.last_reply_author || '' }}
597
+ </div>
598
+ </template>
599
+ <span v-else class="text-gray-400">—</span>
600
+ </td>
601
+ <!-- created -->
602
+ <td v-if="isColumnActive('created')" class="whitespace-nowrap px-4 py-3 text-sm text-gray-500">
603
+ {{ timeAgo(ticket.created_at) }}
604
+ </td>
605
+ <!-- sla -->
606
+ <td v-if="isColumnActive('sla')" class="px-4 py-3 text-sm">
607
+ <span
608
+ v-if="slaClass(ticket)"
609
+ :class="[
610
+ 'inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium text-white',
611
+ slaClass(ticket),
612
+ ]"
613
+ >
614
+ {{ slaLabel(ticket) }}
615
+ </span>
616
+ <span v-else class="text-gray-400">—</span>
617
+ </td>
618
+ <!-- tags -->
619
+ <td v-if="isColumnActive('tags')" class="px-4 py-3 text-sm">
620
+ <div class="flex flex-wrap gap-1">
621
+ <span
622
+ v-for="tag in ticket.tags || []"
623
+ :key="tag.id || tag"
624
+ class="inline-block rounded-full bg-gray-100 px-2 py-0.5 text-xs text-gray-600"
625
+ >
626
+ {{ tag.name || tag }}
627
+ </span>
628
+ <span v-if="!ticket.tags?.length" class="text-gray-400">—</span>
629
+ </div>
630
+ </td>
631
+ <!-- category (ticket type) -->
632
+ <td v-if="isColumnActive('category')" class="px-4 py-3 text-sm">
633
+ <span
634
+ v-if="ticket.ticket_type"
635
+ :class="[
636
+ 'inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium',
637
+ ticketTypeBadgeClass(ticket.ticket_type, false),
638
+ ]"
639
+ >
640
+ {{ ticketTypeLabel(ticket.ticket_type) }}
641
+ </span>
642
+ <span v-else class="text-gray-400">—</span>
643
+ </td>
644
+ <!-- spacer for gear column -->
645
+ <td class="w-10 px-2 py-3"></td>
646
+ </tr>
647
+ <tr v-if="!tickets.data?.length">
648
+ <td :colspan="colCount + 1" class="px-4 py-8 text-center text-sm text-gray-500">
649
+ No tickets found.
650
+ </td>
651
+ </tr>
652
+ </tbody>
653
+ </table>
654
+ </div>
655
+ </template>