@escalated-dev/escalated 0.5.0 → 0.7.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 (136) hide show
  1. package/README.md +102 -0
  2. package/package.json +37 -6
  3. package/src/components/ActivityTimeline.stories.js +55 -0
  4. package/src/components/ActivityTimeline.vue +83 -66
  5. package/src/components/AdminDashboard.stories.js +1095 -0
  6. package/src/components/AgentLoadIndicator.stories.js +37 -0
  7. package/src/components/AgentLoadIndicator.vue +49 -0
  8. package/src/components/AgentPerformanceCard.vue +44 -0
  9. package/src/components/ArticleEditor.vue +82 -0
  10. package/src/components/AssigneeSelect.vue +37 -23
  11. package/src/components/AttachmentList.vue +53 -37
  12. package/src/components/AuditLogEntry.vue +95 -0
  13. package/src/components/BulkActionBar.vue +99 -30
  14. package/src/components/CategoryTree.vue +89 -0
  15. package/src/components/ChartWidget.vue +46 -0
  16. package/src/components/CollisionWarning.stories.js +30 -0
  17. package/src/components/CollisionWarning.vue +68 -0
  18. package/src/components/ConditionalFieldRules.vue +135 -0
  19. package/src/components/ContextPanel.vue +66 -0
  20. package/src/components/ContextPanelSection.vue +65 -0
  21. package/src/components/CustomFieldRenderer.vue +159 -0
  22. package/src/components/EscalatedLayout.vue +400 -69
  23. package/src/components/FileDropzone.vue +57 -41
  24. package/src/components/FollowButton.stories.js +30 -0
  25. package/src/components/FollowButton.vue +53 -28
  26. package/src/components/KeyboardShortcutHelp.vue +129 -39
  27. package/src/components/KnowledgePanel.vue +122 -0
  28. package/src/components/KpiCard.stories.js +32 -0
  29. package/src/components/KpiCard.vue +88 -0
  30. package/src/components/MacroDropdown.vue +95 -35
  31. package/src/components/PermissionMatrix.vue +107 -0
  32. package/src/components/PinnedNotes.vue +75 -33
  33. package/src/components/PresenceIndicator.vue +93 -27
  34. package/src/components/PriorityBadge.stories.js +33 -0
  35. package/src/components/PriorityBadge.vue +46 -39
  36. package/src/components/QuickFilters.vue +65 -49
  37. package/src/components/ReplyComposer.vue +273 -159
  38. package/src/components/ReplyThread.vue +78 -23
  39. package/src/components/SatisfactionRating.vue +98 -46
  40. package/src/components/ScheduleEditor.vue +104 -0
  41. package/src/components/SideConversation.vue +165 -0
  42. package/src/components/SideConversationList.vue +147 -0
  43. package/src/components/SkillTagManager.vue +79 -0
  44. package/src/components/SlaComplianceChart.vue +53 -0
  45. package/src/components/SlaTimer.stories.js +35 -0
  46. package/src/components/SlaTimer.vue +62 -49
  47. package/src/components/StatsCard.stories.js +24 -0
  48. package/src/components/StatsCard.vue +58 -46
  49. package/src/components/StatusBadge.stories.js +53 -0
  50. package/src/components/StatusBadge.vue +78 -46
  51. package/src/components/TagSelect.vue +84 -53
  52. package/src/components/TicketFilters.vue +225 -69
  53. package/src/components/TicketLinkPanel.vue +193 -0
  54. package/src/components/TicketList.vue +594 -193
  55. package/src/components/TicketMergeDialog.vue +157 -0
  56. package/src/components/TicketSidebar.vue +167 -99
  57. package/src/components/TicketTypeSelector.vue +21 -0
  58. package/src/components/TotpInput.stories.js +9 -0
  59. package/src/components/TotpInput.vue +81 -0
  60. package/src/components/TwoFactorSetup.vue +113 -0
  61. package/src/composables/useDebouncedSearch.js +38 -0
  62. package/src/composables/useI18n.js +80 -0
  63. package/src/composables/usePluginExtensions.js +95 -3
  64. package/src/composables/usePluginHooks.js +65 -0
  65. package/src/defineEscalatedPlugin.js +34 -8
  66. package/src/index.js +72 -35
  67. package/src/locales/de.json +442 -0
  68. package/src/locales/en.json +467 -0
  69. package/src/locales/es.json +442 -0
  70. package/src/locales/fr.json +442 -0
  71. package/src/locales/index.js +6 -0
  72. package/src/pages/Admin/ApiTokens/Index.vue +231 -67
  73. package/src/pages/Admin/AuditLog/Index.vue +154 -0
  74. package/src/pages/Admin/Automations/Form.vue +184 -0
  75. package/src/pages/Admin/Automations/Index.vue +129 -0
  76. package/src/pages/Admin/BusinessHours/Form.vue +172 -0
  77. package/src/pages/Admin/BusinessHours/Index.vue +113 -0
  78. package/src/pages/Admin/CannedResponses/Index.vue +127 -70
  79. package/src/pages/Admin/Capacity/Index.vue +134 -0
  80. package/src/pages/Admin/CustomFields/Form.vue +195 -0
  81. package/src/pages/Admin/CustomFields/Index.vue +134 -0
  82. package/src/pages/Admin/CustomObjects/Form.vue +202 -0
  83. package/src/pages/Admin/CustomObjects/Index.vue +127 -0
  84. package/src/pages/Admin/CustomObjects/Records.vue +228 -0
  85. package/src/pages/Admin/Departments/Form.vue +75 -51
  86. package/src/pages/Admin/Departments/Index.vue +109 -57
  87. package/src/pages/Admin/EscalationRules/Form.vue +157 -96
  88. package/src/pages/Admin/EscalationRules/Index.vue +178 -57
  89. package/src/pages/Admin/Import/Connect.vue +96 -0
  90. package/src/pages/Admin/Import/Index.vue +102 -0
  91. package/src/pages/Admin/Import/Mapping.vue +110 -0
  92. package/src/pages/Admin/Import/Progress.vue +153 -0
  93. package/src/pages/Admin/Import/Review.vue +76 -0
  94. package/src/pages/Admin/KnowledgeBase/Articles/Form.vue +142 -0
  95. package/src/pages/Admin/KnowledgeBase/Articles/Index.vue +195 -0
  96. package/src/pages/Admin/KnowledgeBase/Categories/Index.vue +193 -0
  97. package/src/pages/Admin/Macros/Index.vue +250 -89
  98. package/src/pages/Admin/Plugins/Index.vue +205 -75
  99. package/src/pages/Admin/Reports/AgentMetrics.vue +115 -0
  100. package/src/pages/Admin/Reports/CsatReport.vue +127 -0
  101. package/src/pages/Admin/Reports/Dashboard.vue +211 -0
  102. package/src/pages/Admin/Reports/SlaReport.vue +166 -0
  103. package/src/pages/Admin/Reports.vue +139 -34
  104. package/src/pages/Admin/Roles/Form.vue +71 -0
  105. package/src/pages/Admin/Roles/Index.vue +122 -0
  106. package/src/pages/Admin/Settings/CsatSettings.vue +165 -0
  107. package/src/pages/Admin/Settings/DataRetention.vue +182 -0
  108. package/src/pages/Admin/Settings/EmailSettings.vue +243 -0
  109. package/src/pages/Admin/Settings/Sandbox.vue +135 -0
  110. package/src/pages/Admin/Settings/SsoSettings.vue +218 -0
  111. package/src/pages/Admin/Settings/TwoFactor.vue +110 -0
  112. package/src/pages/Admin/Settings.vue +468 -260
  113. package/src/pages/Admin/Skills/Form.vue +53 -0
  114. package/src/pages/Admin/Skills/Index.vue +94 -0
  115. package/src/pages/Admin/SlaPolicies/Form.vue +118 -75
  116. package/src/pages/Admin/SlaPolicies/Index.vue +120 -59
  117. package/src/pages/Admin/Statuses/Form.vue +114 -0
  118. package/src/pages/Admin/Statuses/Index.vue +153 -0
  119. package/src/pages/Admin/Tags/Index.vue +191 -105
  120. package/src/pages/Admin/Tickets/Index.vue +91 -39
  121. package/src/pages/Admin/Tickets/Show.vue +101 -37
  122. package/src/pages/Admin/Webhooks/DeliveryLog.vue +120 -0
  123. package/src/pages/Admin/Webhooks/Form.vue +110 -0
  124. package/src/pages/Admin/Webhooks/Index.vue +136 -0
  125. package/src/pages/Agent/Dashboard.vue +311 -186
  126. package/src/pages/Agent/TicketIndex.vue +88 -38
  127. package/src/pages/Agent/TicketShow.vue +258 -51
  128. package/src/pages/Customer/Create.vue +36 -9
  129. package/src/pages/Customer/Index.vue +31 -24
  130. package/src/pages/Customer/KnowledgeBase/Article.vue +127 -0
  131. package/src/pages/Customer/KnowledgeBase/Index.vue +151 -0
  132. package/src/plugin.js +86 -1
  133. package/src/utils/constants.js +30 -0
  134. package/src/utils/formatting.js +35 -0
  135. package/src/utils/sanitizeHtml.js +64 -0
  136. package/src/pages/Admin/Plugins.vue +0 -129
@@ -7,7 +7,10 @@ const props = defineProps({
7
7
  existingRating: { type: Object, default: null },
8
8
  });
9
9
 
10
- const escDark = inject('esc-dark', computed(() => false));
10
+ const escDark = inject(
11
+ 'esc-dark',
12
+ computed(() => false),
13
+ );
11
14
  const hoveredStar = ref(0);
12
15
  const selectedRating = ref(props.existingRating?.rating || 0);
13
16
  const comment = ref(props.existingRating?.comment || '');
@@ -41,86 +44,135 @@ function leaveStars() {
41
44
  function submit() {
42
45
  if (!selectedRating.value || processing.value || isReadOnly.value) return;
43
46
  processing.value = true;
44
- router.post(props.action, {
45
- rating: selectedRating.value,
46
- comment: comment.value || null,
47
- }, {
48
- preserveScroll: true,
49
- onSuccess: () => {
50
- submitted.value = true;
47
+ router.post(
48
+ props.action,
49
+ {
50
+ rating: selectedRating.value,
51
+ comment: comment.value || null,
51
52
  },
52
- onFinish: () => {
53
- processing.value = false;
53
+ {
54
+ preserveScroll: true,
55
+ onSuccess: () => {
56
+ submitted.value = true;
57
+ },
58
+ onFinish: () => {
59
+ processing.value = false;
60
+ },
54
61
  },
55
- });
62
+ );
56
63
  }
57
64
  </script>
58
65
 
59
66
  <template>
60
- <div :class="['rounded-xl border p-5',
61
- escDark ? 'border-white/[0.06] bg-neutral-900/60' : 'border-gray-200 bg-white']">
62
- <h3 :class="['text-sm font-semibold',
63
- escDark ? 'text-neutral-200' : 'text-gray-900']">
67
+ <div
68
+ :class="[
69
+ 'rounded-xl border p-5',
70
+ escDark ? 'border-[var(--esc-panel-border)] bg-[var(--esc-panel-surface)]' : 'border-gray-200 bg-white',
71
+ ]"
72
+ >
73
+ <h3 :class="['text-sm font-semibold', escDark ? 'text-[var(--esc-panel-text-secondary)]' : 'text-gray-900']">
64
74
  {{ isReadOnly ? 'Customer Rating' : 'How was your experience?' }}
65
75
  </h3>
66
76
 
67
77
  <!-- Stars -->
68
78
  <div class="mt-3 flex items-center gap-1" @mouseleave="leaveStars">
69
- <button v-for="star in 5" :key="star"
70
- @click="selectStar(star)"
71
- @mouseenter="hoverStar(star)"
72
- :disabled="isReadOnly"
73
- :class="['transition-transform', !isReadOnly && 'hover:scale-110', isReadOnly && 'cursor-default']">
79
+ <button
80
+ v-for="star in 5"
81
+ :key="star"
82
+ :disabled="isReadOnly"
83
+ :aria-label="'Rate ' + star + ' star' + (star !== 1 ? 's' : '')"
84
+ :class="['transition-transform', !isReadOnly && 'hover:scale-110', isReadOnly && 'cursor-default']"
85
+ @click="selectStar(star)"
86
+ @mouseenter="hoverStar(star)"
87
+ >
74
88
  <!-- Filled star -->
75
- <svg v-if="star <= displayRating" class="h-7 w-7" viewBox="0 0 24 24" fill="currentColor"
76
- :class="escDark ? 'text-amber-400' : 'text-yellow-400'">
77
- <path d="M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z" />
89
+ <svg
90
+ v-if="star <= displayRating"
91
+ class="h-7 w-7"
92
+ viewBox="0 0 24 24"
93
+ fill="currentColor"
94
+ :class="escDark ? 'text-amber-400' : 'text-yellow-400'"
95
+ >
96
+ <path
97
+ d="M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z"
98
+ />
78
99
  </svg>
79
100
  <!-- Empty star -->
80
- <svg v-else class="h-7 w-7" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24"
81
- :class="escDark ? 'text-neutral-600' : 'text-gray-300'">
82
- <path stroke-linecap="round" stroke-linejoin="round" d="M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z" />
101
+ <svg
102
+ v-else
103
+ class="h-7 w-7"
104
+ fill="none"
105
+ stroke="currentColor"
106
+ stroke-width="1.5"
107
+ viewBox="0 0 24 24"
108
+ :class="escDark ? 'text-[var(--esc-panel-text-muted)]' : 'text-gray-300'"
109
+ >
110
+ <path
111
+ stroke-linecap="round"
112
+ stroke-linejoin="round"
113
+ d="M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z"
114
+ />
83
115
  </svg>
84
116
  </button>
85
- <span v-if="displayRating > 0"
86
- :class="['ml-2 text-sm font-medium',
87
- escDark ? 'text-neutral-400' : 'text-gray-500']">
117
+ <span
118
+ v-if="displayRating > 0"
119
+ :class="[
120
+ 'ml-2 text-sm font-medium',
121
+ escDark ? 'text-[var(--esc-panel-text-tertiary)]' : 'text-gray-500',
122
+ ]"
123
+ >
88
124
  {{ ratingLabels[displayRating] }}
89
125
  </span>
90
126
  </div>
91
127
 
92
128
  <!-- Comment -->
93
129
  <div v-if="!isReadOnly" class="mt-4">
94
- <textarea v-model="comment" rows="3"
95
- placeholder="Any additional feedback? (optional)"
96
- :class="['w-full rounded-lg border px-3 py-2 text-sm focus:outline-none',
97
- escDark
98
- ? 'border-white/10 bg-neutral-950 text-neutral-200 placeholder-neutral-600 focus:border-white/20 focus:ring-1 focus:ring-white/10'
99
- : 'border-gray-300 text-gray-900 placeholder-gray-400 focus:border-blue-500 focus:ring-1 focus:ring-blue-500']">
130
+ <textarea
131
+ v-model="comment"
132
+ rows="3"
133
+ placeholder="Any additional feedback? (optional)"
134
+ :class="[
135
+ 'w-full rounded-lg border px-3 py-2 text-sm focus:outline-none',
136
+ escDark
137
+ ? 'border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface-alt)] text-[var(--esc-panel-text-secondary)] placeholder-[var(--esc-panel-text-muted)] focus:border-[var(--esc-panel-border-input)] focus:ring-1 focus:ring-[var(--esc-panel-border-input)]'
138
+ : 'border-gray-300 text-gray-900 placeholder-gray-400 focus:border-blue-500 focus:ring-1 focus:ring-blue-500',
139
+ ]"
140
+ >
100
141
  </textarea>
101
142
  </div>
102
143
 
103
144
  <!-- Read-only comment display -->
104
145
  <div v-if="isReadOnly && existingRating.comment" class="mt-3">
105
- <p :class="['text-sm italic', escDark ? 'text-neutral-400' : 'text-gray-600']">
146
+ <p :class="['text-sm italic', escDark ? 'text-[var(--esc-panel-text-tertiary)]' : 'text-gray-600']">
106
147
  "{{ existingRating.comment }}"
107
148
  </p>
108
149
  </div>
109
150
 
110
151
  <!-- Submit -->
111
152
  <div v-if="!isReadOnly" class="mt-3">
112
- <div v-if="submitted"
113
- :class="['rounded-lg px-3 py-2 text-sm font-medium',
114
- escDark ? 'bg-emerald-500/10 text-emerald-400 ring-1 ring-emerald-500/20' : 'bg-green-50 text-green-700']">
153
+ <div
154
+ v-if="submitted"
155
+ :class="[
156
+ 'rounded-lg px-3 py-2 text-sm font-medium',
157
+ escDark
158
+ ? 'bg-emerald-500/10 text-emerald-400 ring-1 ring-emerald-500/20'
159
+ : 'bg-green-50 text-green-700',
160
+ ]"
161
+ >
115
162
  Thank you for your feedback!
116
163
  </div>
117
- <button v-else @click="submit"
118
- :disabled="!selectedRating || processing"
119
- :class="['rounded-lg px-4 py-2 text-sm font-medium text-white transition-all',
120
- escDark
121
- ? 'bg-gradient-to-r from-cyan-500 to-violet-500 hover:from-cyan-400 hover:to-violet-400'
122
- : 'bg-blue-600 hover:bg-blue-700',
123
- (!selectedRating || processing) && 'cursor-not-allowed opacity-40']">
164
+ <button
165
+ v-else
166
+ :disabled="!selectedRating || processing"
167
+ :class="[
168
+ 'rounded-lg px-4 py-2 text-sm font-medium text-white transition-all',
169
+ escDark
170
+ ? 'bg-gradient-to-r from-[var(--esc-panel-accent)] to-[var(--esc-panel-accent-secondary)] hover:from-[var(--esc-panel-accent-hover)] hover:to-[var(--esc-panel-accent-secondary-hover)]'
171
+ : 'bg-blue-600 hover:bg-blue-700',
172
+ (!selectedRating || processing) && 'cursor-not-allowed opacity-40',
173
+ ]"
174
+ @click="submit"
175
+ >
124
176
  Submit Rating
125
177
  </button>
126
178
  </div>
@@ -0,0 +1,104 @@
1
+ <script setup>
2
+ import { computed } from 'vue';
3
+
4
+ const props = defineProps({
5
+ modelValue: {
6
+ type: Object,
7
+ default: () => ({
8
+ monday: { start: '09:00', end: '17:00' },
9
+ tuesday: { start: '09:00', end: '17:00' },
10
+ wednesday: { start: '09:00', end: '17:00' },
11
+ thursday: { start: '09:00', end: '17:00' },
12
+ friday: { start: '09:00', end: '17:00' },
13
+ saturday: { start: '', end: '' },
14
+ sunday: { start: '', end: '' },
15
+ }),
16
+ },
17
+ });
18
+
19
+ const emit = defineEmits(['update:modelValue']);
20
+
21
+ const days = [
22
+ { key: 'monday', label: 'Monday' },
23
+ { key: 'tuesday', label: 'Tuesday' },
24
+ { key: 'wednesday', label: 'Wednesday' },
25
+ { key: 'thursday', label: 'Thursday' },
26
+ { key: 'friday', label: 'Friday' },
27
+ { key: 'saturday', label: 'Saturday' },
28
+ { key: 'sunday', label: 'Sunday' },
29
+ ];
30
+
31
+ const timeOptions = computed(() => {
32
+ const options = [];
33
+ for (let h = 0; h < 24; h++) {
34
+ for (let m = 0; m < 60; m += 30) {
35
+ const hh = String(h).padStart(2, '0');
36
+ const mm = String(m).padStart(2, '0');
37
+ options.push(`${hh}:${mm}`);
38
+ }
39
+ }
40
+ options.push('24:00');
41
+ return options;
42
+ });
43
+
44
+ function updateDay(dayKey, field, value) {
45
+ const updated = { ...props.modelValue };
46
+ updated[dayKey] = { ...(updated[dayKey] || { start: '', end: '' }), [field]: value };
47
+ emit('update:modelValue', updated);
48
+ }
49
+
50
+ function toggleDay(dayKey) {
51
+ const updated = { ...props.modelValue };
52
+ const current = updated[dayKey];
53
+ if (current && current.start) {
54
+ updated[dayKey] = { start: '', end: '' };
55
+ } else {
56
+ updated[dayKey] = { start: '09:00', end: '17:00' };
57
+ }
58
+ emit('update:modelValue', updated);
59
+ }
60
+
61
+ function isDayEnabled(dayKey) {
62
+ const day = props.modelValue[dayKey];
63
+ return day && day.start;
64
+ }
65
+ </script>
66
+
67
+ <template>
68
+ <div class="space-y-2">
69
+ <div
70
+ v-for="day in days"
71
+ :key="day.key"
72
+ class="flex items-center gap-3 rounded-lg border border-white/[0.06] bg-neutral-950/50 px-3 py-2"
73
+ >
74
+ <label class="flex w-28 items-center gap-2">
75
+ <input
76
+ type="checkbox"
77
+ :checked="isDayEnabled(day.key)"
78
+ class="rounded border-white/20 bg-neutral-900 text-cyan-500 focus:ring-white/10"
79
+ @change="toggleDay(day.key)"
80
+ />
81
+ <span class="text-sm font-medium text-neutral-300">{{ day.label }}</span>
82
+ </label>
83
+
84
+ <template v-if="isDayEnabled(day.key)">
85
+ <select
86
+ :value="modelValue[day.key]?.start || '09:00'"
87
+ class="rounded-lg border border-white/10 bg-neutral-950 px-2 py-1 text-sm text-neutral-200 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10"
88
+ @change="updateDay(day.key, 'start', $event.target.value)"
89
+ >
90
+ <option v-for="t in timeOptions" :key="'s-' + t" :value="t">{{ t }}</option>
91
+ </select>
92
+ <span class="text-xs text-neutral-500">to</span>
93
+ <select
94
+ :value="modelValue[day.key]?.end || '17:00'"
95
+ class="rounded-lg border border-white/10 bg-neutral-950 px-2 py-1 text-sm text-neutral-200 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10"
96
+ @change="updateDay(day.key, 'end', $event.target.value)"
97
+ >
98
+ <option v-for="t in timeOptions" :key="'e-' + t" :value="t">{{ t }}</option>
99
+ </select>
100
+ </template>
101
+ <span v-else class="text-xs text-neutral-500">Closed</span>
102
+ </div>
103
+ </div>
104
+ </template>
@@ -0,0 +1,165 @@
1
+ <script setup>
2
+ import { ref, inject, computed } from 'vue';
3
+ import { router } from '@inertiajs/vue3';
4
+
5
+ const escDark = inject(
6
+ 'esc-dark',
7
+ computed(() => false),
8
+ );
9
+
10
+ const props = defineProps({
11
+ conversation: { type: Object, required: true },
12
+ ticketReference: { type: String, required: true },
13
+ });
14
+
15
+ const emit = defineEmits(['updated']);
16
+ const replyBody = ref('');
17
+ const submitting = ref(false);
18
+ const expanded = ref(false);
19
+
20
+ function submitReply() {
21
+ if (!replyBody.value.trim() || submitting.value) return;
22
+ submitting.value = true;
23
+
24
+ router.post(
25
+ route('escalated.admin.tickets.side-conversations.reply', [props.ticketReference, props.conversation.id]),
26
+ { body: replyBody.value },
27
+ {
28
+ preserveScroll: true,
29
+ onSuccess: () => {
30
+ replyBody.value = '';
31
+ emit('updated');
32
+ },
33
+ onFinish: () => {
34
+ submitting.value = false;
35
+ },
36
+ },
37
+ );
38
+ }
39
+
40
+ function closeConversation() {
41
+ router.post(
42
+ route('escalated.admin.tickets.side-conversations.close', [props.ticketReference, props.conversation.id]),
43
+ {},
44
+ {
45
+ preserveScroll: true,
46
+ onSuccess: () => emit('updated'),
47
+ },
48
+ );
49
+ }
50
+ </script>
51
+
52
+ <template>
53
+ <div
54
+ :class="[
55
+ 'rounded-lg border p-3',
56
+ escDark ? 'border-white/[0.06] bg-white/[0.02]' : 'border-gray-200 bg-gray-50',
57
+ ]"
58
+ >
59
+ <button
60
+ class="flex w-full items-center justify-between"
61
+ :aria-expanded="expanded"
62
+ @click="expanded = !expanded"
63
+ >
64
+ <div class="flex items-center gap-2">
65
+ <span
66
+ :class="[
67
+ 'inline-flex h-5 items-center rounded px-1.5 text-[10px] font-semibold uppercase',
68
+ conversation.status === 'open'
69
+ ? escDark
70
+ ? 'bg-emerald-500/15 text-emerald-400'
71
+ : 'bg-emerald-100 text-emerald-700'
72
+ : escDark
73
+ ? 'bg-neutral-500/15 text-neutral-400'
74
+ : 'bg-gray-100 text-gray-500',
75
+ ]"
76
+ >
77
+ {{ conversation.status }}
78
+ </span>
79
+ <span :class="['text-sm font-medium', escDark ? 'text-neutral-200' : 'text-gray-900']">
80
+ {{ conversation.subject }}
81
+ </span>
82
+ <span :class="['text-xs', escDark ? 'text-neutral-500' : 'text-gray-400']">
83
+ {{ conversation.channel }}
84
+ </span>
85
+ </div>
86
+ <svg
87
+ :class="[
88
+ 'h-4 w-4 transition-transform',
89
+ escDark ? 'text-neutral-500' : 'text-gray-400',
90
+ expanded && 'rotate-180',
91
+ ]"
92
+ fill="none"
93
+ stroke="currentColor"
94
+ stroke-width="1.5"
95
+ viewBox="0 0 24 24"
96
+ >
97
+ <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />
98
+ </svg>
99
+ </button>
100
+
101
+ <div v-if="expanded" class="mt-3 space-y-3">
102
+ <!-- Replies -->
103
+ <div
104
+ v-for="reply in conversation.replies"
105
+ :key="reply.id"
106
+ :class="['border-l-2 pl-3', escDark ? 'border-white/[0.06]' : 'border-gray-200']"
107
+ >
108
+ <div class="flex items-center gap-2">
109
+ <span :class="['text-xs font-medium', escDark ? 'text-neutral-300' : 'text-gray-700']">
110
+ {{ reply.author?.name || 'System' }}
111
+ </span>
112
+ <span :class="['text-xs', escDark ? 'text-neutral-500' : 'text-gray-400']">
113
+ {{ reply.created_at }}
114
+ </span>
115
+ </div>
116
+ <p :class="['mt-1 whitespace-pre-wrap text-sm', escDark ? 'text-neutral-400' : 'text-gray-600']">
117
+ {{ reply.body }}
118
+ </p>
119
+ </div>
120
+
121
+ <div
122
+ v-if="!conversation.replies?.length"
123
+ :class="['text-xs', escDark ? 'text-neutral-500' : 'text-gray-400']"
124
+ >
125
+ No replies yet.
126
+ </div>
127
+
128
+ <!-- Reply form -->
129
+ <div v-if="conversation.status === 'open'" class="pt-2">
130
+ <textarea
131
+ v-model="replyBody"
132
+ rows="2"
133
+ placeholder="Write a reply..."
134
+ :class="[
135
+ 'w-full rounded-lg border px-3 py-2 text-sm focus:outline-none focus:ring-1',
136
+ escDark
137
+ ? 'border-white/10 bg-neutral-950 text-neutral-200 placeholder-neutral-500 focus:border-white/20 focus:ring-white/10'
138
+ : 'border-gray-300 bg-white text-gray-900 placeholder-gray-400 focus:border-blue-400 focus:ring-blue-200',
139
+ ]"
140
+ ></textarea>
141
+ <div class="mt-2 flex items-center gap-2">
142
+ <button
143
+ :disabled="!replyBody.trim() || submitting"
144
+ :class="[
145
+ 'rounded-lg bg-gradient-to-r from-cyan-500 to-violet-500 px-3 py-1.5 text-xs font-medium text-white transition-all hover:from-cyan-400 hover:to-violet-400',
146
+ (!replyBody.trim() || submitting) && 'cursor-not-allowed opacity-40',
147
+ ]"
148
+ @click="submitReply"
149
+ >
150
+ Reply
151
+ </button>
152
+ <button
153
+ :class="[
154
+ 'rounded-lg px-3 py-1.5 text-xs',
155
+ escDark ? 'text-neutral-400 hover:text-neutral-300' : 'text-gray-500 hover:text-gray-700',
156
+ ]"
157
+ @click="closeConversation"
158
+ >
159
+ Close
160
+ </button>
161
+ </div>
162
+ </div>
163
+ </div>
164
+ </div>
165
+ </template>
@@ -0,0 +1,147 @@
1
+ <script setup>
2
+ import { ref, onMounted } from 'vue';
3
+ import { router } from '@inertiajs/vue3';
4
+ import SideConversation from './SideConversation.vue';
5
+
6
+ const props = defineProps({
7
+ ticketReference: { type: String, required: true },
8
+ });
9
+
10
+ const conversations = ref([]);
11
+ const expanded = ref(true);
12
+ const showNew = ref(false);
13
+ const newSubject = ref('');
14
+ const newChannel = ref('internal');
15
+ const newBody = ref('');
16
+ const creating = ref(false);
17
+
18
+ onMounted(() => {
19
+ fetchConversations();
20
+ });
21
+
22
+ async function fetchConversations() {
23
+ try {
24
+ const response = await fetch(route('escalated.admin.tickets.side-conversations.index', props.ticketReference), {
25
+ headers: {
26
+ Accept: 'application/json',
27
+ 'X-Requested-With': 'XMLHttpRequest',
28
+ 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.content || '',
29
+ },
30
+ });
31
+ if (response.ok) {
32
+ const data = await response.json();
33
+ conversations.value = data.conversations || [];
34
+ }
35
+ } catch {
36
+ // silently ignore
37
+ }
38
+ }
39
+
40
+ function createConversation() {
41
+ if (!newSubject.value.trim() || !newBody.value.trim() || creating.value) return;
42
+ creating.value = true;
43
+
44
+ router.post(
45
+ route('escalated.admin.tickets.side-conversations.store', props.ticketReference),
46
+ {
47
+ subject: newSubject.value,
48
+ channel: newChannel.value,
49
+ body: newBody.value,
50
+ },
51
+ {
52
+ preserveScroll: true,
53
+ onSuccess: () => {
54
+ newSubject.value = '';
55
+ newBody.value = '';
56
+ newChannel.value = 'internal';
57
+ showNew.value = false;
58
+ fetchConversations();
59
+ },
60
+ onFinish: () => {
61
+ creating.value = false;
62
+ },
63
+ },
64
+ );
65
+ }
66
+ </script>
67
+
68
+ <template>
69
+ <div class="rounded-xl border border-white/[0.06] bg-neutral-900/60 p-4">
70
+ <button
71
+ class="flex w-full items-center justify-between text-sm font-semibold text-neutral-200"
72
+ @click="expanded = !expanded"
73
+ >
74
+ <span>Side Conversations ({{ conversations.length }})</span>
75
+ <svg
76
+ :class="['h-4 w-4 text-neutral-500 transition-transform', expanded && 'rotate-180']"
77
+ fill="none"
78
+ stroke="currentColor"
79
+ stroke-width="1.5"
80
+ viewBox="0 0 24 24"
81
+ >
82
+ <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />
83
+ </svg>
84
+ </button>
85
+
86
+ <div v-if="expanded" class="mt-3 space-y-3">
87
+ <SideConversation
88
+ v-for="conv in conversations"
89
+ :key="conv.id"
90
+ :conversation="conv"
91
+ :ticket-reference="ticketReference"
92
+ @updated="fetchConversations"
93
+ />
94
+
95
+ <div v-if="!conversations.length && !showNew" class="text-xs text-neutral-500">No side conversations.</div>
96
+
97
+ <!-- New conversation form -->
98
+ <div v-if="showNew" class="rounded-lg border border-white/[0.06] bg-white/[0.02] p-3 space-y-2">
99
+ <input
100
+ v-model="newSubject"
101
+ type="text"
102
+ placeholder="Subject..."
103
+ class="w-full rounded-lg border border-white/10 bg-neutral-950 px-3 py-2 text-sm text-neutral-200 placeholder-neutral-500 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10"
104
+ />
105
+ <select
106
+ v-model="newChannel"
107
+ class="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"
108
+ >
109
+ <option value="internal">Internal</option>
110
+ <option value="email">Email</option>
111
+ </select>
112
+ <textarea
113
+ v-model="newBody"
114
+ rows="3"
115
+ placeholder="Write the first message..."
116
+ class="w-full rounded-lg border border-white/10 bg-neutral-950 px-3 py-2 text-sm text-neutral-200 placeholder-neutral-500 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10"
117
+ ></textarea>
118
+ <div class="flex gap-2">
119
+ <button
120
+ :disabled="!newSubject.trim() || !newBody.trim() || creating"
121
+ :class="[
122
+ 'rounded-lg bg-gradient-to-r from-cyan-500 to-violet-500 px-3 py-1.5 text-xs font-medium text-white transition-all hover:from-cyan-400 hover:to-violet-400',
123
+ (!newSubject.trim() || !newBody.trim() || creating) && 'cursor-not-allowed opacity-40',
124
+ ]"
125
+ @click="createConversation"
126
+ >
127
+ Create
128
+ </button>
129
+ <button
130
+ class="rounded-lg px-3 py-1.5 text-xs text-neutral-400 hover:text-neutral-300"
131
+ @click="showNew = false"
132
+ >
133
+ Cancel
134
+ </button>
135
+ </div>
136
+ </div>
137
+
138
+ <button
139
+ v-if="!showNew"
140
+ class="w-full rounded-lg border border-dashed border-white/[0.08] py-2 text-xs text-neutral-400 transition-colors hover:border-white/[0.15] hover:text-neutral-300"
141
+ @click="showNew = true"
142
+ >
143
+ + New Side Conversation
144
+ </button>
145
+ </div>
146
+ </div>
147
+ </template>