@escalated-dev/escalated 0.2.1 → 0.4.0

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 (45) hide show
  1. package/package.json +1 -1
  2. package/src/components/ActivityTimeline.vue +8 -4
  3. package/src/components/AssigneeSelect.vue +6 -2
  4. package/src/components/AttachmentList.vue +9 -3
  5. package/src/components/BulkActionBar.vue +97 -0
  6. package/src/components/EscalatedLayout.vue +101 -94
  7. package/src/components/FileDropzone.vue +9 -4
  8. package/src/components/FollowButton.vue +63 -0
  9. package/src/components/KeyboardShortcutHelp.vue +123 -0
  10. package/src/components/MacroDropdown.vue +90 -0
  11. package/src/components/PinnedNotes.vue +87 -0
  12. package/src/components/PresenceIndicator.vue +103 -0
  13. package/src/components/PriorityBadge.vue +20 -2
  14. package/src/components/QuickFilters.vue +49 -0
  15. package/src/components/ReplyComposer.vue +52 -3
  16. package/src/components/ReplyThread.vue +60 -30
  17. package/src/components/SatisfactionRating.vue +128 -0
  18. package/src/components/SlaTimer.vue +12 -6
  19. package/src/components/StatsCard.vue +26 -6
  20. package/src/components/StatusBadge.vue +24 -2
  21. package/src/components/TagSelect.vue +8 -4
  22. package/src/components/TicketFilters.vue +69 -52
  23. package/src/components/TicketList.vue +193 -51
  24. package/src/components/TicketSidebar.vue +99 -70
  25. package/src/composables/useKeyboardShortcuts.js +46 -0
  26. package/src/index.js +11 -0
  27. package/src/pages/Admin/CannedResponses/Index.vue +29 -17
  28. package/src/pages/Admin/Departments/Form.vue +12 -11
  29. package/src/pages/Admin/Departments/Index.vue +26 -18
  30. package/src/pages/Admin/EscalationRules/Form.vue +21 -20
  31. package/src/pages/Admin/EscalationRules/Index.vue +26 -18
  32. package/src/pages/Admin/Macros/Index.vue +287 -0
  33. package/src/pages/Admin/Reports.vue +101 -52
  34. package/src/pages/Admin/Settings.vue +260 -0
  35. package/src/pages/Admin/SlaPolicies/Form.vue +21 -20
  36. package/src/pages/Admin/SlaPolicies/Index.vue +28 -20
  37. package/src/pages/Admin/Tags/Index.vue +48 -23
  38. package/src/pages/Admin/Tickets/Index.vue +39 -0
  39. package/src/pages/Admin/Tickets/Show.vue +145 -0
  40. package/src/pages/Agent/Dashboard.vue +156 -51
  41. package/src/pages/Agent/TicketIndex.vue +38 -21
  42. package/src/pages/Agent/TicketShow.vue +144 -108
  43. package/src/pages/Customer/Show.vue +63 -55
  44. package/src/pages/Guest/Create.vue +97 -0
  45. package/src/pages/Guest/Show.vue +93 -0
@@ -14,32 +14,40 @@ function destroy(id) {
14
14
  <template>
15
15
  <EscalatedLayout title="Departments">
16
16
  <div class="mb-4 flex justify-end">
17
- <Link :href="route('escalated.admin.departments.create')" class="rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700">
17
+ <Link :href="route('escalated.admin.departments.create')"
18
+ class="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">
18
19
  Add Department
19
20
  </Link>
20
21
  </div>
21
- <div class="overflow-hidden rounded-lg border border-gray-200 bg-white">
22
- <table class="min-w-full divide-y divide-gray-200">
23
- <thead class="bg-gray-50">
24
- <tr>
25
- <th class="px-4 py-3 text-left text-xs font-medium uppercase text-gray-500">Name</th>
26
- <th class="px-4 py-3 text-left text-xs font-medium uppercase text-gray-500">Tickets</th>
27
- <th class="px-4 py-3 text-left text-xs font-medium uppercase text-gray-500">Agents</th>
28
- <th class="px-4 py-3 text-left text-xs font-medium uppercase text-gray-500">Active</th>
29
- <th class="px-4 py-3 text-right text-xs font-medium uppercase text-gray-500">Actions</th>
22
+ <div class="overflow-hidden rounded-xl border border-white/[0.06] bg-neutral-900/60">
23
+ <table class="min-w-full divide-y divide-white/[0.06]">
24
+ <thead>
25
+ <tr class="bg-white/[0.02]">
26
+ <th class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-neutral-500">Name</th>
27
+ <th class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-neutral-500">Tickets</th>
28
+ <th class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-neutral-500">Agents</th>
29
+ <th class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-neutral-500">Active</th>
30
+ <th class="px-4 py-3 text-right text-[11px] font-semibold uppercase tracking-wider text-neutral-500">Actions</th>
30
31
  </tr>
31
32
  </thead>
32
- <tbody class="divide-y divide-gray-200">
33
- <tr v-for="dept in departments" :key="dept.id">
34
- <td class="px-4 py-3 text-sm font-medium text-gray-900">{{ dept.name }}</td>
35
- <td class="px-4 py-3 text-sm text-gray-500">{{ dept.tickets_count }}</td>
36
- <td class="px-4 py-3 text-sm text-gray-500">{{ dept.agents_count }}</td>
33
+ <tbody class="divide-y divide-white/[0.04]">
34
+ <tr v-for="dept in departments" :key="dept.id" class="transition-colors hover:bg-white/[0.03]">
35
+ <td class="px-4 py-3 text-sm font-medium text-neutral-200">{{ dept.name }}</td>
36
+ <td class="px-4 py-3 text-sm text-neutral-400">{{ dept.tickets_count }}</td>
37
+ <td class="px-4 py-3 text-sm text-neutral-400">{{ dept.agents_count }}</td>
37
38
  <td class="px-4 py-3 text-sm">
38
- <span :class="dept.is_active ? 'text-green-600' : 'text-gray-400'">{{ dept.is_active ? 'Yes' : 'No' }}</span>
39
+ <span :class="dept.is_active ? 'text-emerald-400' : 'text-neutral-500'">{{ dept.is_active ? 'Yes' : 'No' }}</span>
39
40
  </td>
40
41
  <td class="px-4 py-3 text-right text-sm">
41
- <Link :href="route('escalated.admin.departments.edit', dept.id)" class="text-indigo-600 hover:text-indigo-900">Edit</Link>
42
- <button @click="destroy(dept.id)" class="ml-3 text-red-600 hover:text-red-900">Delete</button>
42
+ <Link :href="route('escalated.admin.departments.edit', dept.id)" class="text-neutral-300 hover:text-white">Edit</Link>
43
+ <button @click="destroy(dept.id)" class="ml-3 text-rose-400 hover:text-rose-300">Delete</button>
44
+ </td>
45
+ </tr>
46
+ <tr v-if="!departments?.length">
47
+ <td colspan="5" class="px-4 py-12 text-center">
48
+ <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"><path stroke-linecap="round" stroke-linejoin="round" d="M2.25 7.125C2.25 6.504 2.754 6 3.375 6h6c.621 0 1.125.504 1.125 1.125v3.75c0 .621-.504 1.125-1.125 1.125h-6a1.125 1.125 0 01-1.125-1.125v-3.75zM14.25 8.625c0-.621.504-1.125 1.125-1.125h5.25c.621 0 1.125.504 1.125 1.125v8.25c0 .621-.504 1.125-1.125 1.125h-5.25a1.125 1.125 0 01-1.125-1.125v-8.25zM3.75 16.125c0-.621.504-1.125 1.125-1.125h5.25c.621 0 1.125.504 1.125 1.125v2.25c0 .621-.504 1.125-1.125 1.125h-5.25a1.125 1.125 0 01-1.125-1.125v-2.25z" /></svg>
49
+ <p class="text-sm text-neutral-500">No departments yet</p>
50
+ <p class="mt-1 text-xs text-neutral-600">Create your first department to organize tickets</p>
43
51
  </td>
44
52
  </tr>
45
53
  </tbody>
@@ -30,14 +30,14 @@ function submit() {
30
30
 
31
31
  <template>
32
32
  <EscalatedLayout :title="rule ? 'Edit Escalation Rule' : 'New Escalation Rule'">
33
- <form @submit.prevent="submit" class="mx-auto max-w-lg space-y-4 rounded-lg border border-gray-200 bg-white p-6">
33
+ <form @submit.prevent="submit" class="mx-auto max-w-lg space-y-5 rounded-xl border border-white/[0.06] bg-neutral-900/60 p-6">
34
34
  <div>
35
- <label class="block text-sm font-medium text-gray-700">Name</label>
36
- <input v-model="form.name" type="text" required class="mt-1 w-full rounded-lg border-gray-300 shadow-sm" />
35
+ <label class="block text-sm font-medium text-neutral-300">Name</label>
36
+ <input v-model="form.name" type="text" required class="mt-1 w-full 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" />
37
37
  </div>
38
38
  <div>
39
- <label class="block text-sm font-medium text-gray-700">Trigger Type</label>
40
- <select v-model="form.trigger_type" class="mt-1 w-full rounded-lg border-gray-300 shadow-sm">
39
+ <label class="block text-sm font-medium text-neutral-300">Trigger Type</label>
40
+ <select v-model="form.trigger_type" class="mt-1 w-full 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">
41
41
  <option value="time_based">Time Based</option>
42
42
  <option value="sla_breach">SLA Breach</option>
43
43
  <option value="priority_based">Priority Based</option>
@@ -45,11 +45,11 @@ function submit() {
45
45
  </div>
46
46
  <div>
47
47
  <div class="mb-2 flex items-center justify-between">
48
- <label class="text-sm font-medium text-gray-700">Conditions</label>
49
- <button type="button" @click="addCondition" class="text-sm text-indigo-600">+ Add</button>
48
+ <label class="text-sm font-medium text-neutral-300">Conditions</label>
49
+ <button type="button" @click="addCondition" class="text-sm text-neutral-300 hover:text-white">+ Add</button>
50
50
  </div>
51
51
  <div v-for="(cond, idx) in form.conditions" :key="idx" class="mb-2 flex gap-2">
52
- <select v-model="cond.field" class="w-1/2 rounded border-gray-300 text-sm">
52
+ <select v-model="cond.field" class="w-1/2 rounded-lg border border-white/10 bg-neutral-950 px-2 py-1.5 text-sm text-neutral-200 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10">
53
53
  <option value="status">Status</option>
54
54
  <option value="priority">Priority</option>
55
55
  <option value="assigned">Assignment</option>
@@ -57,36 +57,37 @@ function submit() {
57
57
  <option value="no_response_hours">No Response (hours)</option>
58
58
  <option value="sla_breached">SLA Breached</option>
59
59
  </select>
60
- <input v-model="cond.value" class="w-1/2 rounded border-gray-300 text-sm" placeholder="Value" />
61
- <button type="button" @click="removeCondition(idx)" class="text-red-500">&times;</button>
60
+ <input v-model="cond.value" class="w-1/2 rounded-lg border border-white/10 bg-neutral-950 px-2 py-1.5 text-sm text-neutral-200 placeholder-gray-500 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10" placeholder="Value" />
61
+ <button type="button" @click="removeCondition(idx)" class="text-rose-400 hover:text-rose-300">&times;</button>
62
62
  </div>
63
63
  </div>
64
64
  <div>
65
65
  <div class="mb-2 flex items-center justify-between">
66
- <label class="text-sm font-medium text-gray-700">Actions</label>
67
- <button type="button" @click="addAction" class="text-sm text-indigo-600">+ Add</button>
66
+ <label class="text-sm font-medium text-neutral-300">Actions</label>
67
+ <button type="button" @click="addAction" class="text-sm text-neutral-300 hover:text-white">+ Add</button>
68
68
  </div>
69
69
  <div v-for="(action, idx) in form.actions" :key="idx" class="mb-2 flex gap-2">
70
- <select v-model="action.type" class="w-1/2 rounded border-gray-300 text-sm">
70
+ <select v-model="action.type" class="w-1/2 rounded-lg border border-white/10 bg-neutral-950 px-2 py-1.5 text-sm text-neutral-200 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10">
71
71
  <option value="escalate">Escalate</option>
72
72
  <option value="change_priority">Change Priority</option>
73
73
  <option value="assign_to">Assign To</option>
74
74
  <option value="change_department">Change Department</option>
75
75
  </select>
76
- <input v-model="action.value" class="w-1/2 rounded border-gray-300 text-sm" placeholder="Value" />
77
- <button type="button" @click="removeAction(idx)" class="text-red-500">&times;</button>
76
+ <input v-model="action.value" class="w-1/2 rounded-lg border border-white/10 bg-neutral-950 px-2 py-1.5 text-sm text-neutral-200 placeholder-gray-500 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10" placeholder="Value" />
77
+ <button type="button" @click="removeAction(idx)" class="text-rose-400 hover:text-rose-300">&times;</button>
78
78
  </div>
79
79
  </div>
80
80
  <div>
81
- <label class="block text-sm font-medium text-gray-700">Order</label>
82
- <input v-model.number="form.order" type="number" min="0" class="mt-1 w-24 rounded-lg border-gray-300 shadow-sm" />
81
+ <label class="block text-sm font-medium text-neutral-300">Order</label>
82
+ <input v-model.number="form.order" type="number" min="0" class="mt-1 w-24 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" />
83
83
  </div>
84
84
  <label class="flex items-center gap-2">
85
- <input v-model="form.is_active" type="checkbox" class="rounded border-gray-300" />
86
- <span class="text-sm text-gray-700">Active</span>
85
+ <input v-model="form.is_active" type="checkbox" class="rounded border-white/20 bg-neutral-900 text-white focus:ring-white/10" />
86
+ <span class="text-sm text-neutral-300">Active</span>
87
87
  </label>
88
88
  <div class="flex justify-end">
89
- <button type="submit" :disabled="form.processing" class="rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 disabled:opacity-50">
89
+ <button type="submit" :disabled="form.processing"
90
+ 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">
90
91
  {{ rule ? 'Update' : 'Create' }}
91
92
  </button>
92
93
  </div>
@@ -14,32 +14,40 @@ function destroy(id) {
14
14
  <template>
15
15
  <EscalatedLayout title="Escalation Rules">
16
16
  <div class="mb-4 flex justify-end">
17
- <Link :href="route('escalated.admin.escalation-rules.create')" class="rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700">
17
+ <Link :href="route('escalated.admin.escalation-rules.create')"
18
+ class="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">
18
19
  Add Rule
19
20
  </Link>
20
21
  </div>
21
- <div class="overflow-hidden rounded-lg border border-gray-200 bg-white">
22
- <table class="min-w-full divide-y divide-gray-200">
23
- <thead class="bg-gray-50">
24
- <tr>
25
- <th class="px-4 py-3 text-left text-xs font-medium uppercase text-gray-500">Order</th>
26
- <th class="px-4 py-3 text-left text-xs font-medium uppercase text-gray-500">Name</th>
27
- <th class="px-4 py-3 text-left text-xs font-medium uppercase text-gray-500">Trigger</th>
28
- <th class="px-4 py-3 text-left text-xs font-medium uppercase text-gray-500">Active</th>
29
- <th class="px-4 py-3 text-right text-xs font-medium uppercase text-gray-500">Actions</th>
22
+ <div class="overflow-hidden rounded-xl border border-white/[0.06] bg-neutral-900/60">
23
+ <table class="min-w-full divide-y divide-white/[0.06]">
24
+ <thead>
25
+ <tr class="bg-white/[0.02]">
26
+ <th class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-neutral-500">Order</th>
27
+ <th class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-neutral-500">Name</th>
28
+ <th class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-neutral-500">Trigger</th>
29
+ <th class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-neutral-500">Active</th>
30
+ <th class="px-4 py-3 text-right text-[11px] font-semibold uppercase tracking-wider text-neutral-500">Actions</th>
30
31
  </tr>
31
32
  </thead>
32
- <tbody class="divide-y divide-gray-200">
33
- <tr v-for="rule in rules" :key="rule.id">
34
- <td class="px-4 py-3 text-sm text-gray-500">{{ rule.order }}</td>
35
- <td class="px-4 py-3 text-sm font-medium text-gray-900">{{ rule.name }}</td>
36
- <td class="px-4 py-3 text-sm text-gray-500">{{ rule.trigger_type }}</td>
33
+ <tbody class="divide-y divide-white/[0.04]">
34
+ <tr v-if="!rules?.length">
35
+ <td colspan="5" class="px-4 py-12 text-center">
36
+ <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"><path stroke-linecap="round" stroke-linejoin="round" d="M3 4.5h14.25M3 9h9.75M3 13.5h5.25m5.25-.75L17.25 9m0 0L21 12.75M17.25 9v12" /></svg>
37
+ <p class="text-sm text-neutral-500">No escalation rules yet</p>
38
+ <p class="mt-1 text-xs text-neutral-600">Set up automatic escalation for overdue tickets</p>
39
+ </td>
40
+ </tr>
41
+ <tr v-for="rule in rules" :key="rule.id" class="transition-colors hover:bg-white/[0.03]">
42
+ <td class="px-4 py-3 text-sm text-neutral-400">{{ rule.order }}</td>
43
+ <td class="px-4 py-3 text-sm font-medium text-neutral-200">{{ rule.name }}</td>
44
+ <td class="px-4 py-3 text-sm text-neutral-400">{{ rule.trigger_type }}</td>
37
45
  <td class="px-4 py-3 text-sm">
38
- <span :class="rule.is_active ? 'text-green-600' : 'text-gray-400'">{{ rule.is_active ? 'Yes' : 'No' }}</span>
46
+ <span :class="rule.is_active ? 'text-emerald-400' : 'text-neutral-500'">{{ rule.is_active ? 'Yes' : 'No' }}</span>
39
47
  </td>
40
48
  <td class="px-4 py-3 text-right text-sm">
41
- <Link :href="route('escalated.admin.escalation-rules.edit', rule.id)" class="text-indigo-600 hover:text-indigo-900">Edit</Link>
42
- <button @click="destroy(rule.id)" class="ml-3 text-red-600 hover:text-red-900">Delete</button>
49
+ <Link :href="route('escalated.admin.escalation-rules.edit', rule.id)" class="text-neutral-300 hover:text-white">Edit</Link>
50
+ <button @click="destroy(rule.id)" class="ml-3 text-rose-400 hover:text-rose-300">Delete</button>
43
51
  </td>
44
52
  </tr>
45
53
  </tbody>
@@ -0,0 +1,287 @@
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>