@escalated-dev/escalated 0.6.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 (187) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +125 -2
  3. package/package.json +40 -5
  4. package/src/components/ActiveChatsPanel.vue +246 -0
  5. package/src/components/ActivityTimeline.stories.js +55 -0
  6. package/src/components/ActivityTimeline.vue +83 -66
  7. package/src/components/AdminDashboard.stories.js +1423 -0
  8. package/src/components/AgentLoadIndicator.stories.js +37 -0
  9. package/src/components/AgentLoadIndicator.vue +49 -0
  10. package/src/components/AgentPerformanceCard.vue +44 -0
  11. package/src/components/ArticleEditor.vue +82 -0
  12. package/src/components/AssigneeSelect.vue +37 -23
  13. package/src/components/AttachmentList.vue +65 -37
  14. package/src/components/AuditLogEntry.vue +95 -0
  15. package/src/components/BulkActionBar.vue +166 -97
  16. package/src/components/CategoryTree.vue +89 -0
  17. package/src/components/ChartWidget.vue +46 -0
  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 -0
  24. package/src/components/CollisionWarning.vue +68 -0
  25. package/src/components/ConditionalFieldRules.vue +135 -0
  26. package/src/components/ContextPanel.vue +66 -0
  27. package/src/components/ContextPanelSection.vue +65 -0
  28. package/src/components/CustomFieldRenderer.vue +159 -0
  29. package/src/components/EscalatedLayout.vue +424 -70
  30. package/src/components/FileDropzone.vue +57 -41
  31. package/src/components/FollowButton.stories.js +30 -0
  32. package/src/components/FollowButton.vue +88 -63
  33. package/src/components/KeyboardShortcutHelp.vue +213 -123
  34. package/src/components/KnowledgePanel.vue +122 -0
  35. package/src/components/KpiCard.stories.js +32 -0
  36. package/src/components/KpiCard.vue +88 -0
  37. package/src/components/MacroDropdown.vue +150 -90
  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 -0
  43. package/src/components/PinnedNotes.vue +129 -90
  44. package/src/components/PluginSlot.vue +68 -62
  45. package/src/components/PresenceIndicator.vue +138 -28
  46. package/src/components/PriorityBadge.stories.js +33 -0
  47. package/src/components/PriorityBadge.vue +46 -39
  48. package/src/components/QuickFilters.vue +65 -49
  49. package/src/components/ReplyComposer.vue +207 -30
  50. package/src/components/ReplyThread.vue +111 -21
  51. package/src/components/ReportChart.vue +395 -0
  52. package/src/components/ReportExportButton.vue +108 -0
  53. package/src/components/SatisfactionRating.vue +180 -128
  54. package/src/components/SaveViewDialog.vue +172 -0
  55. package/src/components/SavedViewSidebar.vue +208 -0
  56. package/src/components/ScheduleEditor.vue +104 -0
  57. package/src/components/SideConversation.vue +165 -0
  58. package/src/components/SideConversationList.vue +147 -0
  59. package/src/components/SkillTagManager.vue +79 -0
  60. package/src/components/SlaComplianceChart.vue +46 -0
  61. package/src/components/SlaTimer.stories.js +35 -0
  62. package/src/components/SlaTimer.vue +62 -49
  63. package/src/components/SnoozeButton.vue +247 -0
  64. package/src/components/StatsCard.stories.js +24 -0
  65. package/src/components/StatsCard.vue +18 -6
  66. package/src/components/StatusBadge.stories.js +53 -0
  67. package/src/components/StatusBadge.vue +78 -46
  68. package/src/components/TagSelect.vue +84 -53
  69. package/src/components/TicketFilters.vue +247 -46
  70. package/src/components/TicketLinkPanel.vue +193 -0
  71. package/src/components/TicketList.vue +536 -74
  72. package/src/components/TicketMergeDialog.vue +157 -0
  73. package/src/components/TicketSidebar.vue +167 -99
  74. package/src/components/TicketSplitDialog.vue +98 -0
  75. package/src/components/TicketTypeSelector.vue +21 -0
  76. package/src/components/TotpInput.stories.js +9 -0
  77. package/src/components/TotpInput.vue +81 -0
  78. package/src/components/TwoFactorSetup.vue +113 -0
  79. package/src/components/VariableTokenInput.vue +111 -0
  80. package/src/components/WorkflowActionConfig.vue +287 -0
  81. package/src/components/WorkflowActionList.vue +350 -0
  82. package/src/components/WorkflowConditionBuilder.vue +265 -0
  83. package/src/components/WorkflowTriggerSelector.vue +125 -0
  84. package/src/composables/useChat.js +187 -0
  85. package/src/composables/useDebouncedSearch.js +38 -0
  86. package/src/composables/useI18n.js +80 -80
  87. package/src/composables/useKeyboardShortcuts.js +46 -46
  88. package/src/composables/useMentions.js +134 -0
  89. package/src/composables/usePluginExtensions.js +159 -67
  90. package/src/composables/usePluginHooks.js +65 -0
  91. package/src/composables/useRealtime.js +182 -0
  92. package/src/defineEscalatedPlugin.js +76 -50
  93. package/src/index.js +77 -28
  94. package/src/locales/ar.json +727 -0
  95. package/src/locales/de.json +678 -430
  96. package/src/locales/en.json +717 -430
  97. package/src/locales/es.json +679 -430
  98. package/src/locales/fr.json +680 -431
  99. package/src/locales/index.js +12 -2
  100. package/src/locales/it.json +727 -0
  101. package/src/locales/ja.json +727 -0
  102. package/src/locales/ko.json +727 -0
  103. package/src/locales/nl.json +727 -0
  104. package/src/locales/pl.json +727 -0
  105. package/src/locales/pt-BR.json +727 -0
  106. package/src/locales/ru.json +727 -0
  107. package/src/locales/tr.json +727 -0
  108. package/src/locales/zh-CN.json +727 -0
  109. package/src/pages/Admin/ApiTokens/Index.vue +381 -217
  110. package/src/pages/Admin/AuditLog/Index.vue +154 -0
  111. package/src/pages/Admin/BusinessHours/Form.vue +172 -0
  112. package/src/pages/Admin/BusinessHours/Index.vue +113 -0
  113. package/src/pages/Admin/CannedResponses/Index.vue +82 -25
  114. package/src/pages/Admin/Capacity/Index.vue +134 -0
  115. package/src/pages/Admin/CustomFields/Form.vue +195 -0
  116. package/src/pages/Admin/CustomFields/Index.vue +134 -0
  117. package/src/pages/Admin/CustomObjects/Form.vue +202 -0
  118. package/src/pages/Admin/CustomObjects/Index.vue +127 -0
  119. package/src/pages/Admin/CustomObjects/Records.vue +228 -0
  120. package/src/pages/Admin/Departments/Form.vue +35 -11
  121. package/src/pages/Admin/Departments/Index.vue +74 -21
  122. package/src/pages/Admin/EscalationRules/Form.vue +86 -25
  123. package/src/pages/Admin/EscalationRules/Index.vue +158 -37
  124. package/src/pages/Admin/Import/Connect.vue +95 -0
  125. package/src/pages/Admin/Import/Index.vue +102 -0
  126. package/src/pages/Admin/Import/Mapping.vue +110 -0
  127. package/src/pages/Admin/Import/Progress.vue +153 -0
  128. package/src/pages/Admin/Import/Review.vue +76 -0
  129. package/src/pages/Admin/KnowledgeBase/Articles/Form.vue +142 -0
  130. package/src/pages/Admin/KnowledgeBase/Articles/Index.vue +195 -0
  131. package/src/pages/Admin/KnowledgeBase/Categories/Index.vue +193 -0
  132. package/src/pages/Admin/Macros/Index.vue +448 -287
  133. package/src/pages/Admin/Plugins/Index.vue +327 -197
  134. package/src/pages/Admin/Reports/AgentDetail.vue +132 -0
  135. package/src/pages/Admin/Reports/AgentMetrics.vue +115 -0
  136. package/src/pages/Admin/Reports/AgentRanking.vue +246 -0
  137. package/src/pages/Admin/Reports/Cohorts.vue +180 -0
  138. package/src/pages/Admin/Reports/Comparison.vue +141 -0
  139. package/src/pages/Admin/Reports/CsatReport.vue +127 -0
  140. package/src/pages/Admin/Reports/Dashboard.vue +226 -0
  141. package/src/pages/Admin/Reports/ResolutionTimes.vue +164 -0
  142. package/src/pages/Admin/Reports/ResponseTimes.vue +164 -0
  143. package/src/pages/Admin/Reports/SlaReport.vue +162 -0
  144. package/src/pages/Admin/Reports/SlaTrends.vue +183 -0
  145. package/src/pages/Admin/Reports.vue +206 -101
  146. package/src/pages/Admin/Roles/Form.vue +71 -0
  147. package/src/pages/Admin/Roles/Index.vue +122 -0
  148. package/src/pages/Admin/Settings/CsatSettings.vue +165 -0
  149. package/src/pages/Admin/Settings/DataRetention.vue +182 -0
  150. package/src/pages/Admin/Settings/EmailSettings.vue +243 -0
  151. package/src/pages/Admin/Settings/Sandbox.vue +135 -0
  152. package/src/pages/Admin/Settings/SsoSettings.vue +218 -0
  153. package/src/pages/Admin/Settings/TwoFactor.vue +110 -0
  154. package/src/pages/Admin/Settings.vue +847 -99
  155. package/src/pages/Admin/Skills/Form.vue +53 -0
  156. package/src/pages/Admin/Skills/Index.vue +94 -0
  157. package/src/pages/Admin/SlaPolicies/Form.vue +62 -19
  158. package/src/pages/Admin/SlaPolicies/Index.vue +85 -23
  159. package/src/pages/Admin/Statuses/Form.vue +114 -0
  160. package/src/pages/Admin/Statuses/Index.vue +153 -0
  161. package/src/pages/Admin/Tags/Index.vue +121 -35
  162. package/src/pages/Admin/Tickets/Index.vue +96 -9
  163. package/src/pages/Admin/Tickets/Show.vue +130 -37
  164. package/src/pages/Admin/Webhooks/DeliveryLog.vue +120 -0
  165. package/src/pages/Admin/Webhooks/Form.vue +110 -0
  166. package/src/pages/Admin/Webhooks/Index.vue +136 -0
  167. package/src/pages/Admin/Workflows/Builder.vue +207 -0
  168. package/src/pages/Admin/Workflows/Index.vue +235 -0
  169. package/src/pages/Admin/Workflows/Logs.vue +286 -0
  170. package/src/pages/Agent/Dashboard.vue +311 -186
  171. package/src/pages/Agent/TicketIndex.vue +80 -6
  172. package/src/pages/Agent/TicketShow.vue +399 -60
  173. package/src/pages/Customer/Create.vue +37 -10
  174. package/src/pages/Customer/Index.vue +9 -2
  175. package/src/pages/Customer/KnowledgeBase/Article.vue +129 -0
  176. package/src/pages/Customer/KnowledgeBase/Index.vue +151 -0
  177. package/src/pages/Customer/Show.vue +69 -63
  178. package/src/pages/Guest/Create.vue +40 -15
  179. package/src/pages/Guest/Show.vue +124 -93
  180. package/src/plugin.js +111 -1
  181. package/src/utils/constants.js +30 -0
  182. package/src/utils/formatting.js +35 -0
  183. package/src/utils/mentionHighlight.js +24 -0
  184. package/src/utils/sanitizeHtml.js +78 -64
  185. package/src/widget/EscalatedWidget.vue +804 -0
  186. package/src/widget/index.js +254 -0
  187. package/src/pages/Admin/Plugins.vue +0 -129
@@ -1,287 +1,448 @@
1
- <script setup>
2
- import EscalatedLayout from '../../../components/EscalatedLayout.vue';
3
- import { useForm, router } from '@inertiajs/vue3';
4
- import { ref, computed } from 'vue';
5
-
6
- defineProps({ macros: Array });
7
-
8
- const showForm = ref(false);
9
- const editingMacro = ref(null);
10
-
11
- const form = useForm({
12
- name: '',
13
- description: '',
14
- is_shared: false,
15
- actions: [],
16
- });
17
-
18
- const actionTypes = [
19
- { value: 'status', label: 'Set Status' },
20
- { value: 'priority', label: 'Set Priority' },
21
- { value: 'assign', label: 'Assign To' },
22
- { value: 'tags', label: 'Add Tags' },
23
- { value: 'department', label: 'Move to Department' },
24
- { value: 'reply', label: 'Send Reply' },
25
- { value: 'note', label: 'Add Internal Note' },
26
- ];
27
-
28
- const statusOptions = ['open', 'in_progress', 'waiting_on_customer', 'resolved', 'closed'];
29
- const priorityOptions = ['low', 'medium', 'high', 'urgent', 'critical'];
30
-
31
- function addAction() {
32
- form.actions.push({ type: 'status', value: '', order: form.actions.length });
33
- }
34
-
35
- function removeAction(index) {
36
- form.actions.splice(index, 1);
37
- form.actions.forEach((a, i) => { a.order = i; });
38
- }
39
-
40
- function moveAction(index, direction) {
41
- const newIndex = index + direction;
42
- if (newIndex < 0 || newIndex >= form.actions.length) return;
43
- const temp = form.actions[index];
44
- form.actions[index] = form.actions[newIndex];
45
- form.actions[newIndex] = temp;
46
- form.actions.forEach((a, i) => { a.order = i; });
47
- }
48
-
49
- function create() {
50
- form.post(route('escalated.admin.macros.store'), {
51
- onSuccess: () => { form.reset(); showForm.value = false; },
52
- });
53
- }
54
-
55
- function startEdit(macro) {
56
- editingMacro.value = macro.id;
57
- form.name = macro.name;
58
- form.description = macro.description || '';
59
- form.is_shared = macro.is_shared || false;
60
- form.actions = (macro.actions || []).map((a, i) => ({
61
- type: a.type,
62
- value: a.value || '',
63
- order: a.order ?? i,
64
- }));
65
- showForm.value = true;
66
- }
67
-
68
- function update() {
69
- form.put(route('escalated.admin.macros.update', editingMacro.value), {
70
- onSuccess: () => { editingMacro.value = null; form.reset(); showForm.value = false; },
71
- });
72
- }
73
-
74
- function destroy(id) {
75
- if (confirm('Delete this macro? This cannot be undone.')) {
76
- router.delete(route('escalated.admin.macros.destroy', id));
77
- }
78
- }
79
-
80
- function cancelEdit() {
81
- editingMacro.value = null;
82
- form.reset();
83
- showForm.value = false;
84
- }
85
-
86
- function handleSubmit() {
87
- if (editingMacro.value) {
88
- update();
89
- } else {
90
- create();
91
- }
92
- }
93
-
94
- const inputClass = 'w-full rounded-lg border border-white/10 bg-neutral-950 px-3 py-2 text-sm text-neutral-200 placeholder-neutral-600 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10';
95
- const selectClass = 'rounded-lg border border-white/10 bg-neutral-950 px-3 py-2 text-sm text-neutral-200 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10';
96
- </script>
97
-
98
- <template>
99
- <EscalatedLayout title="Macros">
100
- <!-- Top bar -->
101
- <div class="mb-4 flex items-center justify-between">
102
- <p class="text-sm text-neutral-500">
103
- Macros automate repetitive actions on tickets.
104
- </p>
105
- <button @click="showForm ? cancelEdit() : (showForm = true)"
106
- :class="showForm
107
- ? 'rounded-lg border border-white/10 bg-white/[0.03] px-4 py-2 text-sm font-medium text-neutral-300 transition-colors hover:bg-white/[0.06]'
108
- : 'rounded-lg bg-gradient-to-r from-cyan-500 to-violet-500 px-4 py-2 text-sm font-medium text-white shadow-lg shadow-black/20 transition-all hover:from-cyan-400 hover:to-violet-400'">
109
- {{ showForm ? 'Cancel' : 'Create Macro' }}
110
- </button>
111
- </div>
112
-
113
- <!-- Create/Edit form -->
114
- <form v-if="showForm" @submit.prevent="handleSubmit" class="mb-6 space-y-4 rounded-xl border border-white/[0.06] bg-neutral-900/60 p-5">
115
- <div class="grid grid-cols-2 gap-4">
116
- <div>
117
- <label class="mb-1 block text-sm font-medium text-neutral-300">Name</label>
118
- <input v-model="form.name" type="text" required placeholder="e.g., Close & Thank"
119
- :class="inputClass" />
120
- </div>
121
- <div>
122
- <label class="mb-1 block text-sm font-medium text-neutral-300">Description</label>
123
- <input v-model="form.description" type="text" placeholder="Optional description"
124
- :class="inputClass" />
125
- </div>
126
- </div>
127
-
128
- <div class="flex items-center gap-3">
129
- <label class="flex items-center gap-2">
130
- <input v-model="form.is_shared" type="checkbox"
131
- class="rounded border-white/20 bg-neutral-900 text-cyan-500 focus:ring-white/10" />
132
- <span class="text-sm text-neutral-300">Shared with all agents</span>
133
- </label>
134
- </div>
135
-
136
- <!-- Action builder -->
137
- <div>
138
- <div class="mb-2 flex items-center justify-between">
139
- <label class="text-sm font-medium text-neutral-300">Actions</label>
140
- <button type="button" @click="addAction"
141
- class="rounded-lg border border-white/10 bg-white/[0.03] px-3 py-1.5 text-xs font-medium text-neutral-400 transition-colors hover:bg-white/[0.06] hover:text-neutral-200">
142
- + Add Action
143
- </button>
144
- </div>
145
-
146
- <div v-if="!form.actions.length" class="rounded-lg border border-dashed border-white/10 px-4 py-6 text-center">
147
- <p class="text-sm text-neutral-600">No actions yet. Add actions to define what this macro does.</p>
148
- </div>
149
-
150
- <div v-else class="space-y-2">
151
- <div v-for="(action, index) in form.actions" :key="index"
152
- class="flex items-center gap-2 rounded-lg border border-white/[0.06] bg-white/[0.02] p-3">
153
- <!-- Order controls -->
154
- <div class="flex flex-col gap-0.5">
155
- <button type="button" @click="moveAction(index, -1)"
156
- :disabled="index === 0"
157
- class="rounded p-0.5 text-neutral-600 transition-colors hover:bg-white/[0.06] hover:text-neutral-400 disabled:opacity-30">
158
- <svg class="h-3.5 w-3.5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
159
- <path stroke-linecap="round" stroke-linejoin="round" d="M4.5 15.75l7.5-7.5 7.5 7.5" />
160
- </svg>
161
- </button>
162
- <button type="button" @click="moveAction(index, 1)"
163
- :disabled="index === form.actions.length - 1"
164
- class="rounded p-0.5 text-neutral-600 transition-colors hover:bg-white/[0.06] hover:text-neutral-400 disabled:opacity-30">
165
- <svg class="h-3.5 w-3.5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
166
- <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />
167
- </svg>
168
- </button>
169
- </div>
170
-
171
- <!-- Action number -->
172
- <span class="flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-white/[0.06] text-xs font-semibold text-neutral-500">
173
- {{ index + 1 }}
174
- </span>
175
-
176
- <!-- Type dropdown -->
177
- <select v-model="action.type" :class="selectClass">
178
- <option v-for="at in actionTypes" :key="at.value" :value="at.value">{{ at.label }}</option>
179
- </select>
180
-
181
- <!-- Value input (context-dependent) -->
182
- <select v-if="action.type === 'status'" v-model="action.value" :class="[selectClass, 'flex-1']">
183
- <option value="">Select status...</option>
184
- <option v-for="s in statusOptions" :key="s" :value="s">{{ s.replace(/_/g, ' ') }}</option>
185
- </select>
186
-
187
- <select v-else-if="action.type === 'priority'" v-model="action.value" :class="[selectClass, 'flex-1']">
188
- <option value="">Select priority...</option>
189
- <option v-for="p in priorityOptions" :key="p" :value="p">{{ p }}</option>
190
- </select>
191
-
192
- <input v-else-if="action.type === 'assign'" v-model="action.value" type="text"
193
- placeholder="Agent ID or email"
194
- :class="[inputClass, 'flex-1']" />
195
-
196
- <input v-else-if="action.type === 'tags'" v-model="action.value" type="text"
197
- placeholder="Comma-separated tag names"
198
- :class="[inputClass, 'flex-1']" />
199
-
200
- <input v-else-if="action.type === 'department'" v-model="action.value" type="text"
201
- placeholder="Department ID or name"
202
- :class="[inputClass, 'flex-1']" />
203
-
204
- <textarea v-else-if="action.type === 'reply' || action.type === 'note'"
205
- v-model="action.value" rows="2"
206
- :placeholder="action.type === 'reply' ? 'Reply message...' : 'Note content...'"
207
- :class="[inputClass, 'flex-1']">
208
- </textarea>
209
-
210
- <input v-else v-model="action.value" type="text" placeholder="Value"
211
- :class="[inputClass, 'flex-1']" />
212
-
213
- <!-- Remove -->
214
- <button type="button" @click="removeAction(index)"
215
- class="shrink-0 rounded-lg p-1.5 text-neutral-600 transition-colors hover:bg-rose-500/10 hover:text-rose-400">
216
- <svg class="h-4 w-4" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24">
217
- <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
218
- </svg>
219
- </button>
220
- </div>
221
- </div>
222
- </div>
223
-
224
- <!-- Submit -->
225
- <div class="flex justify-end">
226
- <button type="submit" :disabled="form.processing"
227
- class="rounded-lg bg-gradient-to-r from-cyan-500 to-violet-500 px-5 py-2 text-sm font-medium text-white shadow-lg shadow-black/20 transition-all hover:from-cyan-400 hover:to-violet-400 disabled:opacity-50">
228
- {{ editingMacro ? 'Update Macro' : 'Create Macro' }}
229
- </button>
230
- </div>
231
- </form>
232
-
233
- <!-- Macros table -->
234
- <div class="overflow-hidden rounded-xl border border-white/[0.06] bg-neutral-900/60">
235
- <table class="min-w-full divide-y divide-white/[0.06]">
236
- <thead>
237
- <tr class="bg-white/[0.02]">
238
- <th class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-neutral-500">Name</th>
239
- <th class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-neutral-500">Description</th>
240
- <th class="px-4 py-3 text-center text-[11px] font-semibold uppercase tracking-wider text-neutral-500">Actions</th>
241
- <th class="px-4 py-3 text-center text-[11px] font-semibold uppercase tracking-wider text-neutral-500">Shared</th>
242
- <th class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-neutral-500">Creator</th>
243
- <th class="px-4 py-3 text-right text-[11px] font-semibold uppercase tracking-wider text-neutral-500"></th>
244
- </tr>
245
- </thead>
246
- <tbody class="divide-y divide-white/[0.04]">
247
- <tr v-if="!macros?.length">
248
- <td colspan="6" class="px-4 py-12 text-center">
249
- <svg class="mx-auto mb-3 h-8 w-8 text-neutral-700" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24">
250
- <path stroke-linecap="round" stroke-linejoin="round" d="M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z" />
251
- </svg>
252
- <p class="text-sm text-neutral-500">No macros yet</p>
253
- <p class="mt-1 text-xs text-neutral-600">Create macros to automate repetitive ticket actions</p>
254
- </td>
255
- </tr>
256
- <tr v-for="macro in macros" :key="macro.id" class="transition-colors hover:bg-white/[0.03]">
257
- <td class="px-4 py-3">
258
- <span class="text-sm font-medium text-neutral-200">{{ macro.name }}</span>
259
- </td>
260
- <td class="px-4 py-3">
261
- <span class="text-sm text-neutral-400">{{ macro.description || '--' }}</span>
262
- </td>
263
- <td class="px-4 py-3 text-center">
264
- <span class="inline-flex items-center rounded-full bg-white/[0.06] px-2 py-0.5 text-xs font-medium text-neutral-400 ring-1 ring-white/[0.06]">
265
- {{ macro.actions?.length || 0 }}
266
- </span>
267
- </td>
268
- <td class="px-4 py-3 text-center">
269
- <span v-if="macro.is_shared"
270
- class="inline-flex items-center rounded-full bg-cyan-500/10 px-2 py-0.5 text-xs font-medium text-cyan-400 ring-1 ring-cyan-500/20">
271
- Shared
272
- </span>
273
- <span v-else class="text-xs text-neutral-600">Private</span>
274
- </td>
275
- <td class="px-4 py-3 text-sm text-neutral-400">
276
- {{ macro.creator?.name || macro.user?.name || '--' }}
277
- </td>
278
- <td class="px-4 py-3 text-right text-sm">
279
- <button @click="startEdit(macro)" class="text-neutral-300 hover:text-white">Edit</button>
280
- <button @click="destroy(macro.id)" class="ml-3 text-rose-400 hover:text-rose-300">Delete</button>
281
- </td>
282
- </tr>
283
- </tbody>
284
- </table>
285
- </div>
286
- </EscalatedLayout>
287
- </template>
1
+ <script setup>
2
+ import EscalatedLayout from '../../../components/EscalatedLayout.vue';
3
+ import { useForm, router } from '@inertiajs/vue3';
4
+ import { ref } from 'vue';
5
+
6
+ defineProps({ macros: Array });
7
+
8
+ const showForm = ref(false);
9
+ const editingMacro = ref(null);
10
+
11
+ const form = useForm({
12
+ name: '',
13
+ description: '',
14
+ is_shared: false,
15
+ actions: [],
16
+ });
17
+
18
+ const actionTypes = [
19
+ { value: 'status', label: 'Set Status' },
20
+ { value: 'priority', label: 'Set Priority' },
21
+ { value: 'assign', label: 'Assign To' },
22
+ { value: 'tags', label: 'Add Tags' },
23
+ { value: 'department', label: 'Move to Department' },
24
+ { value: 'reply', label: 'Send Reply' },
25
+ { value: 'note', label: 'Add Internal Note' },
26
+ ];
27
+
28
+ const statusOptions = ['open', 'in_progress', 'waiting_on_customer', 'resolved', 'closed'];
29
+ const priorityOptions = ['low', 'medium', 'high', 'urgent', 'critical'];
30
+
31
+ function addAction() {
32
+ form.actions.push({ type: 'status', value: '', order: form.actions.length });
33
+ }
34
+
35
+ function removeAction(index) {
36
+ form.actions.splice(index, 1);
37
+ form.actions.forEach((a, i) => {
38
+ a.order = i;
39
+ });
40
+ }
41
+
42
+ function moveAction(index, direction) {
43
+ const newIndex = index + direction;
44
+ if (newIndex < 0 || newIndex >= form.actions.length) return;
45
+ const temp = form.actions[index];
46
+ form.actions[index] = form.actions[newIndex];
47
+ form.actions[newIndex] = temp;
48
+ form.actions.forEach((a, i) => {
49
+ a.order = i;
50
+ });
51
+ }
52
+
53
+ function create() {
54
+ form.post(route('escalated.admin.macros.store'), {
55
+ onSuccess: () => {
56
+ form.reset();
57
+ showForm.value = false;
58
+ },
59
+ });
60
+ }
61
+
62
+ function startEdit(macro) {
63
+ editingMacro.value = macro.id;
64
+ form.name = macro.name;
65
+ form.description = macro.description || '';
66
+ form.is_shared = macro.is_shared || false;
67
+ form.actions = (macro.actions || []).map((a, i) => ({
68
+ type: a.type,
69
+ value: a.value || '',
70
+ order: a.order ?? i,
71
+ }));
72
+ showForm.value = true;
73
+ }
74
+
75
+ function update() {
76
+ form.put(route('escalated.admin.macros.update', editingMacro.value), {
77
+ onSuccess: () => {
78
+ editingMacro.value = null;
79
+ form.reset();
80
+ showForm.value = false;
81
+ },
82
+ });
83
+ }
84
+
85
+ function destroy(id) {
86
+ if (confirm('Delete this macro? This cannot be undone.')) {
87
+ router.delete(route('escalated.admin.macros.destroy', id));
88
+ }
89
+ }
90
+
91
+ function cancelEdit() {
92
+ editingMacro.value = null;
93
+ form.reset();
94
+ showForm.value = false;
95
+ }
96
+
97
+ function handleSubmit() {
98
+ if (editingMacro.value) {
99
+ update();
100
+ } else {
101
+ create();
102
+ }
103
+ }
104
+
105
+ const inputClass =
106
+ 'w-full rounded-lg border border-white/10 bg-neutral-950 px-3 py-2 text-sm text-neutral-200 placeholder-neutral-600 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10';
107
+ const selectClass =
108
+ 'rounded-lg border border-white/10 bg-neutral-950 px-3 py-2 text-sm text-neutral-200 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10';
109
+ </script>
110
+
111
+ <template>
112
+ <EscalatedLayout title="Macros">
113
+ <!-- Top bar -->
114
+ <div class="mb-4 flex items-center justify-between">
115
+ <p class="text-sm text-[var(--esc-panel-text-muted)]">Macros automate repetitive actions on tickets.</p>
116
+ <button
117
+ :class="
118
+ showForm
119
+ ? 'rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-hover)] px-4 py-2 text-sm font-medium text-[var(--esc-panel-text-secondary)] transition-colors hover:bg-[var(--esc-panel-hover)]'
120
+ : 'rounded-lg bg-gradient-to-r from-[var(--esc-panel-accent)] to-[var(--esc-panel-accent-secondary)] px-4 py-2 text-sm font-medium text-white shadow-lg shadow-[var(--esc-panel-bg)]/20 transition-all hover:from-[var(--esc-panel-accent-hover)] hover:to-[var(--esc-panel-accent-secondary-hover)]'
121
+ "
122
+ @click="showForm ? cancelEdit() : (showForm = true)"
123
+ >
124
+ {{ showForm ? 'Cancel' : 'Create Macro' }}
125
+ </button>
126
+ </div>
127
+
128
+ <!-- Create/Edit form -->
129
+ <form
130
+ v-if="showForm"
131
+ class="mb-6 space-y-4 rounded-xl border border-[var(--esc-panel-border)] bg-[var(--esc-panel-surface)] p-5"
132
+ @submit.prevent="handleSubmit"
133
+ >
134
+ <div class="grid grid-cols-2 gap-4">
135
+ <div>
136
+ <label class="mb-1 block text-sm font-medium text-[var(--esc-panel-text-secondary)]">Name</label>
137
+ <input
138
+ v-model="form.name"
139
+ type="text"
140
+ required
141
+ placeholder="e.g., Close & Thank"
142
+ :class="inputClass"
143
+ />
144
+ </div>
145
+ <div>
146
+ <label class="mb-1 block text-sm font-medium text-[var(--esc-panel-text-secondary)]"
147
+ >Description</label
148
+ >
149
+ <input
150
+ v-model="form.description"
151
+ type="text"
152
+ placeholder="Optional description"
153
+ :class="inputClass"
154
+ />
155
+ </div>
156
+ </div>
157
+
158
+ <div class="flex items-center gap-3">
159
+ <label class="flex items-center gap-2">
160
+ <input
161
+ v-model="form.is_shared"
162
+ type="checkbox"
163
+ class="rounded border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface)] text-cyan-500 focus:ring-[var(--esc-panel-border-input)]"
164
+ />
165
+ <span class="text-sm text-[var(--esc-panel-text-secondary)]">Shared with all agents</span>
166
+ </label>
167
+ </div>
168
+
169
+ <!-- Action builder -->
170
+ <div>
171
+ <div class="mb-2 flex items-center justify-between">
172
+ <label class="text-sm font-medium text-[var(--esc-panel-text-secondary)]">Actions</label>
173
+ <button
174
+ type="button"
175
+ class="rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-hover)] px-3 py-1.5 text-xs font-medium text-[var(--esc-panel-text-tertiary)] transition-colors hover:bg-[var(--esc-panel-hover)] hover:text-[var(--esc-panel-text-secondary)]"
176
+ @click="addAction"
177
+ >
178
+ + Add Action
179
+ </button>
180
+ </div>
181
+
182
+ <div
183
+ v-if="!form.actions.length"
184
+ class="rounded-lg border border-dashed border-[var(--esc-panel-border-input)] px-4 py-6 text-center"
185
+ >
186
+ <p class="text-sm text-[var(--esc-panel-text-muted)]">
187
+ No actions yet. Add actions to define what this macro does.
188
+ </p>
189
+ </div>
190
+
191
+ <div v-else class="space-y-2">
192
+ <div
193
+ v-for="(action, index) in form.actions"
194
+ :key="index"
195
+ class="flex items-center gap-2 rounded-lg border border-[var(--esc-panel-border)] bg-[var(--esc-panel-hover)] p-3"
196
+ >
197
+ <!-- Order controls -->
198
+ <div class="flex flex-col gap-0.5">
199
+ <button
200
+ type="button"
201
+ :disabled="index === 0"
202
+ class="rounded p-0.5 text-[var(--esc-panel-text-muted)] transition-colors hover:bg-[var(--esc-panel-hover)] hover:text-[var(--esc-panel-text-tertiary)] disabled:opacity-30"
203
+ @click="moveAction(index, -1)"
204
+ >
205
+ <svg
206
+ class="h-3.5 w-3.5"
207
+ fill="none"
208
+ stroke="currentColor"
209
+ stroke-width="2"
210
+ viewBox="0 0 24 24"
211
+ >
212
+ <path
213
+ stroke-linecap="round"
214
+ stroke-linejoin="round"
215
+ d="M4.5 15.75l7.5-7.5 7.5 7.5"
216
+ />
217
+ </svg>
218
+ </button>
219
+ <button
220
+ type="button"
221
+ :disabled="index === form.actions.length - 1"
222
+ class="rounded p-0.5 text-[var(--esc-panel-text-muted)] transition-colors hover:bg-[var(--esc-panel-hover)] hover:text-[var(--esc-panel-text-tertiary)] disabled:opacity-30"
223
+ @click="moveAction(index, 1)"
224
+ >
225
+ <svg
226
+ class="h-3.5 w-3.5"
227
+ fill="none"
228
+ stroke="currentColor"
229
+ stroke-width="2"
230
+ viewBox="0 0 24 24"
231
+ >
232
+ <path
233
+ stroke-linecap="round"
234
+ stroke-linejoin="round"
235
+ d="M19.5 8.25l-7.5 7.5-7.5-7.5"
236
+ />
237
+ </svg>
238
+ </button>
239
+ </div>
240
+
241
+ <!-- Action number -->
242
+ <span
243
+ class="flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-[var(--esc-panel-hover)] text-xs font-semibold text-[var(--esc-panel-text-muted)]"
244
+ >
245
+ {{ index + 1 }}
246
+ </span>
247
+
248
+ <!-- Type dropdown -->
249
+ <select v-model="action.type" :class="selectClass">
250
+ <option v-for="at in actionTypes" :key="at.value" :value="at.value">{{ at.label }}</option>
251
+ </select>
252
+
253
+ <!-- Value input (context-dependent) -->
254
+ <select v-if="action.type === 'status'" v-model="action.value" :class="[selectClass, 'flex-1']">
255
+ <option value="">Select status...</option>
256
+ <option v-for="s in statusOptions" :key="s" :value="s">{{ s.replace(/_/g, ' ') }}</option>
257
+ </select>
258
+
259
+ <select
260
+ v-else-if="action.type === 'priority'"
261
+ v-model="action.value"
262
+ :class="[selectClass, 'flex-1']"
263
+ >
264
+ <option value="">Select priority...</option>
265
+ <option v-for="p in priorityOptions" :key="p" :value="p">{{ p }}</option>
266
+ </select>
267
+
268
+ <input
269
+ v-else-if="action.type === 'assign'"
270
+ v-model="action.value"
271
+ type="text"
272
+ placeholder="Agent ID or email"
273
+ :class="[inputClass, 'flex-1']"
274
+ />
275
+
276
+ <input
277
+ v-else-if="action.type === 'tags'"
278
+ v-model="action.value"
279
+ type="text"
280
+ placeholder="Comma-separated tag names"
281
+ :class="[inputClass, 'flex-1']"
282
+ />
283
+
284
+ <input
285
+ v-else-if="action.type === 'department'"
286
+ v-model="action.value"
287
+ type="text"
288
+ placeholder="Department ID or name"
289
+ :class="[inputClass, 'flex-1']"
290
+ />
291
+
292
+ <textarea
293
+ v-else-if="action.type === 'reply' || action.type === 'note'"
294
+ v-model="action.value"
295
+ rows="2"
296
+ :placeholder="action.type === 'reply' ? 'Reply message...' : 'Note content...'"
297
+ :class="[inputClass, 'flex-1']"
298
+ >
299
+ </textarea>
300
+
301
+ <input
302
+ v-else
303
+ v-model="action.value"
304
+ type="text"
305
+ placeholder="Value"
306
+ :class="[inputClass, 'flex-1']"
307
+ />
308
+
309
+ <!-- Remove -->
310
+ <button
311
+ type="button"
312
+ class="shrink-0 rounded-lg p-1.5 text-[var(--esc-panel-text-muted)] transition-colors hover:bg-rose-500/10 hover:text-rose-400"
313
+ @click="removeAction(index)"
314
+ >
315
+ <svg
316
+ class="h-4 w-4"
317
+ fill="none"
318
+ stroke="currentColor"
319
+ stroke-width="1.5"
320
+ viewBox="0 0 24 24"
321
+ >
322
+ <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
323
+ </svg>
324
+ </button>
325
+ </div>
326
+ </div>
327
+ </div>
328
+
329
+ <!-- Submit -->
330
+ <div class="flex justify-end">
331
+ <button
332
+ type="submit"
333
+ :disabled="form.processing"
334
+ class="rounded-lg bg-gradient-to-r from-[var(--esc-panel-accent)] to-[var(--esc-panel-accent-secondary)] px-5 py-2 text-sm font-medium text-white shadow-lg shadow-[var(--esc-panel-bg)]/20 transition-all hover:from-[var(--esc-panel-accent-hover)] hover:to-[var(--esc-panel-accent-secondary-hover)] disabled:opacity-50"
335
+ >
336
+ {{ editingMacro ? 'Update Macro' : 'Create Macro' }}
337
+ </button>
338
+ </div>
339
+ </form>
340
+
341
+ <!-- Macros table -->
342
+ <div class="overflow-hidden rounded-xl border border-[var(--esc-panel-border)] bg-[var(--esc-panel-surface)]">
343
+ <table class="min-w-full divide-y divide-[var(--esc-panel-border)]">
344
+ <thead>
345
+ <tr class="bg-[var(--esc-panel-hover)]">
346
+ <th
347
+ class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
348
+ >
349
+ Name
350
+ </th>
351
+ <th
352
+ class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
353
+ >
354
+ Description
355
+ </th>
356
+ <th
357
+ class="px-4 py-3 text-center text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
358
+ >
359
+ Actions
360
+ </th>
361
+ <th
362
+ class="px-4 py-3 text-center text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
363
+ >
364
+ Shared
365
+ </th>
366
+ <th
367
+ class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
368
+ >
369
+ Creator
370
+ </th>
371
+ <th
372
+ class="px-4 py-3 text-right text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
373
+ ></th>
374
+ </tr>
375
+ </thead>
376
+ <tbody class="divide-y divide-[var(--esc-panel-border)]">
377
+ <tr v-if="!macros?.length">
378
+ <td colspan="6" class="px-4 py-12 text-center">
379
+ <svg
380
+ class="mx-auto mb-3 h-8 w-8 text-[var(--esc-panel-text-muted)]"
381
+ fill="none"
382
+ stroke="currentColor"
383
+ stroke-width="1.5"
384
+ viewBox="0 0 24 24"
385
+ >
386
+ <path
387
+ stroke-linecap="round"
388
+ stroke-linejoin="round"
389
+ d="M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z"
390
+ />
391
+ </svg>
392
+ <p class="text-sm text-[var(--esc-panel-text-muted)]">No macros yet</p>
393
+ <p class="mt-1 text-xs text-[var(--esc-panel-text-muted)]">
394
+ Create macros to automate repetitive ticket actions
395
+ </p>
396
+ </td>
397
+ </tr>
398
+ <tr
399
+ v-for="macro in macros"
400
+ :key="macro.id"
401
+ class="transition-colors hover:bg-[var(--esc-panel-hover)]"
402
+ >
403
+ <td class="px-4 py-3">
404
+ <span class="text-sm font-medium text-[var(--esc-panel-text-secondary)]">{{
405
+ macro.name
406
+ }}</span>
407
+ </td>
408
+ <td class="px-4 py-3">
409
+ <span class="text-sm text-[var(--esc-panel-text-tertiary)]">{{
410
+ macro.description || '--'
411
+ }}</span>
412
+ </td>
413
+ <td class="px-4 py-3 text-center">
414
+ <span
415
+ class="inline-flex items-center rounded-full bg-[var(--esc-panel-hover)] px-2 py-0.5 text-xs font-medium text-[var(--esc-panel-text-tertiary)] ring-1 ring-[var(--esc-panel-border)]"
416
+ >
417
+ {{ macro.actions?.length || 0 }}
418
+ </span>
419
+ </td>
420
+ <td class="px-4 py-3 text-center">
421
+ <span
422
+ v-if="macro.is_shared"
423
+ class="inline-flex items-center rounded-full bg-cyan-500/10 px-2 py-0.5 text-xs font-medium text-cyan-400 ring-1 ring-cyan-500/20"
424
+ >
425
+ Shared
426
+ </span>
427
+ <span v-else class="text-xs text-[var(--esc-panel-text-muted)]">Private</span>
428
+ </td>
429
+ <td class="px-4 py-3 text-sm text-[var(--esc-panel-text-tertiary)]">
430
+ {{ macro.creator?.name || macro.user?.name || '--' }}
431
+ </td>
432
+ <td class="px-4 py-3 text-right text-sm">
433
+ <button
434
+ class="text-[var(--esc-panel-text-secondary)] hover:text-[var(--esc-panel-text)]"
435
+ @click="startEdit(macro)"
436
+ >
437
+ Edit
438
+ </button>
439
+ <button class="ml-3 text-rose-400 hover:text-rose-300" @click="destroy(macro.id)">
440
+ Delete
441
+ </button>
442
+ </td>
443
+ </tr>
444
+ </tbody>
445
+ </table>
446
+ </div>
447
+ </EscalatedLayout>
448
+ </template>