@escalated-dev/escalated 0.7.1 → 0.9.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.
- package/LICENSE +21 -21
- package/README.md +380 -357
- package/package.json +85 -81
- package/src/components/ActiveChatsPanel.vue +246 -246
- package/src/components/AdminDashboard.stories.js +1423 -1423
- package/src/components/AttachmentList.vue +65 -65
- package/src/components/ChatActionBar.vue +226 -226
- package/src/components/ChatBubble.vue +162 -162
- package/src/components/ChatComposer.vue +308 -308
- package/src/components/ChatQueue.vue +222 -222
- package/src/components/ChatThread.vue +197 -197
- package/src/components/CustomTicketActions.stories.js +71 -0
- package/src/components/CustomTicketActions.vue +101 -0
- package/src/components/EscalatedLayout.vue +619 -598
- package/src/components/FollowButton.vue +20 -1
- package/src/components/MentionDropdown.vue +154 -154
- package/src/components/MetricComparison.vue +89 -89
- package/src/components/PercentileChart.vue +67 -67
- package/src/components/PeriodSelector.vue +98 -98
- package/src/components/PresenceIndicator.vue +228 -213
- package/src/components/ReplyComposer.vue +336 -336
- package/src/components/ReplyThread.vue +153 -153
- package/src/components/ReportChart.vue +395 -395
- package/src/components/ReportExportButton.vue +108 -108
- package/src/components/SaveViewDialog.vue +172 -172
- package/src/components/SavedViewSidebar.vue +208 -208
- package/src/components/SkillTagManager.vue +29 -22
- package/src/components/SnoozeButton.vue +247 -247
- package/src/components/TicketFilters.vue +270 -270
- package/src/components/TicketList.vue +655 -655
- package/src/components/TicketSidebar.vue +4 -0
- package/src/components/TicketSplitDialog.vue +98 -98
- package/src/components/TicketSubjects.stories.js +63 -0
- package/src/components/TicketSubjects.vue +107 -0
- package/src/components/TwoFactorSetup.vue +1 -37
- package/src/components/VariableTokenInput.vue +111 -111
- package/src/components/WorkflowActionConfig.vue +287 -287
- package/src/components/WorkflowActionList.vue +350 -350
- package/src/components/WorkflowConditionBuilder.vue +265 -265
- package/src/components/WorkflowTriggerSelector.vue +125 -125
- package/src/components/admin/newsletters/AnalyticsTiles.stories.js +14 -0
- package/src/components/admin/newsletters/AnalyticsTiles.vue +55 -0
- package/src/components/admin/newsletters/DeliveriesTable.stories.js +28 -0
- package/src/components/admin/newsletters/DeliveriesTable.vue +104 -0
- package/src/components/admin/newsletters/DynamicFilterBuilder.stories.js +11 -0
- package/src/components/admin/newsletters/DynamicFilterBuilder.vue +53 -0
- package/src/components/admin/newsletters/ListMemberTable.stories.js +12 -0
- package/src/components/admin/newsletters/ListMemberTable.vue +53 -0
- package/src/components/admin/newsletters/MarkdownEditor.stories.js +6 -0
- package/src/components/admin/newsletters/MarkdownEditor.vue +53 -0
- package/src/components/admin/newsletters/MergeFieldDropdown.stories.js +6 -0
- package/src/components/admin/newsletters/MergeFieldDropdown.vue +84 -0
- package/src/components/admin/newsletters/PreviewIframe.stories.js +7 -0
- package/src/components/admin/newsletters/PreviewIframe.vue +40 -0
- package/src/components/admin/newsletters/SummaryTiles.stories.js +8 -0
- package/src/components/admin/newsletters/SummaryTiles.vue +63 -0
- package/src/composables/useChat.js +187 -187
- package/src/composables/useI18n.js +30 -8
- package/src/composables/useMentions.js +134 -134
- package/src/composables/usePermissions.js +31 -0
- package/src/composables/useRealtime.js +182 -182
- package/src/index.js +85 -84
- package/src/locales/README.md +13 -0
- package/src/locales/ar.json +727 -727
- package/src/locales/de.json +690 -690
- package/src/locales/en.json +889 -729
- package/src/locales/es.json +691 -691
- package/src/locales/fr.json +691 -691
- package/src/locales/index.js +16 -16
- package/src/locales/it.json +727 -727
- package/src/locales/ja.json +727 -727
- package/src/locales/ko.json +727 -727
- package/src/locales/nl.json +727 -727
- package/src/locales/pl.json +727 -727
- package/src/locales/pt-BR.json +727 -727
- package/src/locales/ru.json +727 -727
- package/src/locales/tr.json +727 -727
- package/src/locales/zh-CN.json +727 -727
- package/src/pages/Admin/Newsletters/Compose.vue +192 -0
- package/src/pages/Admin/Newsletters/Edit.vue +24 -0
- package/src/pages/Admin/Newsletters/Index.vue +141 -0
- package/src/pages/Admin/Newsletters/Lists/Create.vue +64 -0
- package/src/pages/Admin/Newsletters/Lists/Index.vue +59 -0
- package/src/pages/Admin/Newsletters/Lists/Show.vue +53 -0
- package/src/pages/Admin/Newsletters/Settings.vue +85 -0
- package/src/pages/Admin/Newsletters/Show.vue +140 -0
- package/src/pages/Admin/Newsletters/Templates/Create.vue +11 -0
- package/src/pages/Admin/Newsletters/Templates/Index.vue +54 -0
- package/src/pages/Admin/Newsletters/Templates/Show.vue +65 -0
- package/src/pages/Admin/Newsletters/usePreview.js +44 -0
- package/src/pages/Admin/Reports/AgentDetail.vue +132 -132
- package/src/pages/Admin/Reports/AgentRanking.vue +246 -246
- package/src/pages/Admin/Reports/Cohorts.vue +180 -180
- package/src/pages/Admin/Reports/Comparison.vue +141 -141
- package/src/pages/Admin/Reports/Dashboard.vue +226 -226
- package/src/pages/Admin/Reports/ResolutionTimes.vue +164 -164
- package/src/pages/Admin/Reports/ResponseTimes.vue +164 -164
- package/src/pages/Admin/Reports/SlaTrends.vue +183 -183
- package/src/pages/Admin/Settings/SsoSettings.vue +157 -4
- package/src/pages/Admin/Settings/TwoFactor.vue +32 -6
- package/src/pages/Admin/Settings.vue +1008 -1008
- package/src/pages/Admin/Skills/Form.vue +164 -4
- package/src/pages/Admin/Skills/Index.vue +14 -3
- package/src/pages/Admin/Tickets/Index.vue +126 -126
- package/src/pages/Admin/Tickets/Show.vue +254 -249
- package/src/pages/Admin/Users/Index.vue +145 -0
- package/src/pages/Admin/Workflows/Builder.vue +207 -207
- package/src/pages/Admin/Workflows/Index.vue +235 -235
- package/src/pages/Admin/Workflows/Logs.vue +286 -286
- package/src/pages/Agent/TicketIndex.vue +112 -112
- package/src/pages/Agent/TicketShow.vue +547 -494
- package/src/pages/Customer/Index.vue +26 -1
- package/src/pages/Customer/KnowledgeBase/Article.vue +129 -129
- package/src/plugin.js +175 -175
- package/src/utils/mentionHighlight.js +24 -24
- package/src/widget/EscalatedWidget.vue +804 -804
- package/src/widget/index.js +254 -254
|
@@ -1,246 +1,246 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import { ref, computed, inject, onMounted, onUnmounted } from 'vue';
|
|
3
|
-
import { usePage } from '@inertiajs/vue3';
|
|
4
|
-
import { useI18n } from '../composables/useI18n';
|
|
5
|
-
import { useChat } from '../composables/useChat';
|
|
6
|
-
import { timeAgo } from '../utils/formatting';
|
|
7
|
-
|
|
8
|
-
const props = defineProps({
|
|
9
|
-
chats: { type: Array, default: () => [] },
|
|
10
|
-
agentId: { type: [String, Number], default: null },
|
|
11
|
-
agentStatus: { type: String, default: 'online' },
|
|
12
|
-
navigateRoute: { type: String, default: '' },
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const emit = defineEmits(['navigate', 'status-change']);
|
|
16
|
-
|
|
17
|
-
const escDark = inject(
|
|
18
|
-
'esc-dark',
|
|
19
|
-
computed(() => false),
|
|
20
|
-
);
|
|
21
|
-
const { t } = useI18n();
|
|
22
|
-
|
|
23
|
-
const isOpen = ref(false);
|
|
24
|
-
const currentStatus = ref(props.agentStatus);
|
|
25
|
-
|
|
26
|
-
const statusOptions = [
|
|
27
|
-
{ value: 'online', label: 'Online', color: 'bg-emerald-500' },
|
|
28
|
-
{ value: 'away', label: 'Away', color: 'bg-amber-500' },
|
|
29
|
-
{ value: 'offline', label: 'Offline', color: 'bg-neutral-500' },
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
const currentStatusOption = computed(
|
|
33
|
-
() => statusOptions.find((s) => s.value === currentStatus.value) || statusOptions[0],
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
function changeStatus(status) {
|
|
37
|
-
currentStatus.value = status;
|
|
38
|
-
emit('status-change', status);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const totalUnread = computed(() => {
|
|
42
|
-
return props.chats.reduce((sum, chat) => sum + (chat.unread_count || 0), 0);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// Activity state for each chat
|
|
46
|
-
const now = ref(Date.now());
|
|
47
|
-
let timerInterval = null;
|
|
48
|
-
|
|
49
|
-
onMounted(() => {
|
|
50
|
-
timerInterval = setInterval(() => {
|
|
51
|
-
now.value = Date.now();
|
|
52
|
-
}, 10000);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
onUnmounted(() => {
|
|
56
|
-
clearInterval(timerInterval);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
function chatActivityState(chat) {
|
|
60
|
-
if (!chat.last_message_at) return 'new';
|
|
61
|
-
const diffMs = now.value - new Date(chat.last_message_at).getTime();
|
|
62
|
-
if (diffMs > 2 * 60 * 1000) return 'idle';
|
|
63
|
-
return 'active';
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function activityDotClass(chat) {
|
|
67
|
-
const state = chatActivityState(chat);
|
|
68
|
-
if (state === 'new') return 'bg-blue-500 animate-pulse';
|
|
69
|
-
if (state === 'idle') return 'bg-amber-500';
|
|
70
|
-
return 'bg-emerald-500';
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function navigateToChat(chat) {
|
|
74
|
-
emit('navigate', chat);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function truncate(str, len = 40) {
|
|
78
|
-
if (!str) return '';
|
|
79
|
-
return str.length > len ? str.slice(0, len) + '...' : str;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function chatInitials(chat) {
|
|
83
|
-
const name = chat.customer_name || 'U';
|
|
84
|
-
return name
|
|
85
|
-
.split(' ')
|
|
86
|
-
.map((w) => w[0])
|
|
87
|
-
.join('')
|
|
88
|
-
.toUpperCase()
|
|
89
|
-
.slice(0, 2);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Real-time: listen for new chats assigned to this agent. Read the
|
|
93
|
-
// host framework's route prefix from Inertia page props (default
|
|
94
|
-
// 'support') so chat API calls resolve correctly on NestJS backends
|
|
95
|
-
// that use '/escalated/widget' instead of '/support/widget'.
|
|
96
|
-
const page = usePage();
|
|
97
|
-
const routePrefix = page.props.escalated?.prefix || 'support';
|
|
98
|
-
const { subscribeToChatQueue } = useChat({ widgetPath: `/${routePrefix}/widget` });
|
|
99
|
-
|
|
100
|
-
onMounted(() => {
|
|
101
|
-
subscribeToChatQueue({
|
|
102
|
-
onNewChat() {
|
|
103
|
-
// Parent should refresh chat list
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
</script>
|
|
108
|
-
|
|
109
|
-
<template>
|
|
110
|
-
<!-- Toggle button -->
|
|
111
|
-
<button
|
|
112
|
-
:class="[
|
|
113
|
-
'fixed right-4 bottom-20 z-40 flex h-12 w-12 items-center justify-center rounded-full shadow-lg transition-all',
|
|
114
|
-
escDark
|
|
115
|
-
? 'bg-gradient-to-r from-cyan-500 to-violet-500 text-white hover:from-cyan-400 hover:to-violet-400'
|
|
116
|
-
: 'bg-blue-600 text-white hover:bg-blue-500',
|
|
117
|
-
]"
|
|
118
|
-
:aria-label="isOpen ? t('chat.close_panel') : t('chat.open_panel')"
|
|
119
|
-
@click="isOpen = !isOpen"
|
|
120
|
-
>
|
|
121
|
-
<svg class="h-5 w-5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
|
122
|
-
<path
|
|
123
|
-
stroke-linecap="round"
|
|
124
|
-
stroke-linejoin="round"
|
|
125
|
-
d="M8.625 12a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H8.25m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H12m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0h-.375M21 12c0 4.556-4.03 8.25-9 8.25a9.764 9.764 0 01-2.555-.337A5.972 5.972 0 015.41 20.97a5.969 5.969 0 01-.474-.065 4.48 4.48 0 00.978-2.025c.09-.457-.133-.901-.467-1.226C3.93 16.178 3 14.189 3 12c0-4.556 4.03-8.25 9-8.25s9 3.694 9 8.25z"
|
|
126
|
-
/>
|
|
127
|
-
</svg>
|
|
128
|
-
<!-- Unread badge -->
|
|
129
|
-
<span
|
|
130
|
-
v-if="totalUnread > 0"
|
|
131
|
-
class="absolute -right-1 -top-1 flex h-5 min-w-[20px] items-center justify-center rounded-full bg-rose-500 px-1 text-[10px] font-bold text-white"
|
|
132
|
-
>
|
|
133
|
-
{{ totalUnread > 99 ? '99+' : totalUnread }}
|
|
134
|
-
</span>
|
|
135
|
-
</button>
|
|
136
|
-
|
|
137
|
-
<!-- Panel -->
|
|
138
|
-
<div
|
|
139
|
-
v-if="isOpen"
|
|
140
|
-
:class="[
|
|
141
|
-
'fixed right-4 bottom-36 z-40 w-80 rounded-xl border shadow-2xl',
|
|
142
|
-
escDark ? 'border-white/[0.08] bg-neutral-900' : 'border-gray-200 bg-white',
|
|
143
|
-
]"
|
|
144
|
-
style="max-height: calc(100vh - 200px)"
|
|
145
|
-
>
|
|
146
|
-
<!-- Header -->
|
|
147
|
-
<div
|
|
148
|
-
:class="[
|
|
149
|
-
'flex items-center justify-between border-b px-4 py-3',
|
|
150
|
-
escDark ? 'border-white/[0.06]' : 'border-gray-200',
|
|
151
|
-
]"
|
|
152
|
-
>
|
|
153
|
-
<div class="flex items-center gap-2">
|
|
154
|
-
<h3 :class="['text-sm font-semibold', escDark ? 'text-white' : 'text-gray-900']">
|
|
155
|
-
{{ t('chat.active_chats') }}
|
|
156
|
-
</h3>
|
|
157
|
-
<span
|
|
158
|
-
v-if="chats.length"
|
|
159
|
-
:class="[
|
|
160
|
-
'rounded-full px-1.5 py-0.5 text-[10px] font-medium',
|
|
161
|
-
escDark ? 'bg-white/[0.06] text-neutral-400' : 'bg-gray-100 text-gray-500',
|
|
162
|
-
]"
|
|
163
|
-
>
|
|
164
|
-
{{ chats.length }}
|
|
165
|
-
</span>
|
|
166
|
-
</div>
|
|
167
|
-
<!-- Status dropdown -->
|
|
168
|
-
<div class="relative">
|
|
169
|
-
<button
|
|
170
|
-
:class="[
|
|
171
|
-
'flex items-center gap-1.5 rounded-lg px-2 py-1 text-xs font-medium transition-colors',
|
|
172
|
-
escDark ? 'hover:bg-white/[0.06] text-neutral-400' : 'hover:bg-gray-100 text-gray-500',
|
|
173
|
-
]"
|
|
174
|
-
@click="
|
|
175
|
-
const idx = statusOptions.findIndex((s) => s.value === currentStatus);
|
|
176
|
-
changeStatus(statusOptions[(idx + 1) % statusOptions.length].value);
|
|
177
|
-
"
|
|
178
|
-
>
|
|
179
|
-
<span :class="['h-2 w-2 rounded-full', currentStatusOption.color]"></span>
|
|
180
|
-
{{ currentStatusOption.label }}
|
|
181
|
-
</button>
|
|
182
|
-
</div>
|
|
183
|
-
</div>
|
|
184
|
-
|
|
185
|
-
<!-- Chat list -->
|
|
186
|
-
<div class="overflow-y-auto" style="max-height: 400px">
|
|
187
|
-
<div
|
|
188
|
-
v-if="!chats.length"
|
|
189
|
-
:class="['p-6 text-center text-sm', escDark ? 'text-neutral-600' : 'text-gray-400']"
|
|
190
|
-
>
|
|
191
|
-
{{ t('chat.no_active_chats') }}
|
|
192
|
-
</div>
|
|
193
|
-
<button
|
|
194
|
-
v-for="chat in chats"
|
|
195
|
-
:key="chat.id"
|
|
196
|
-
:class="[
|
|
197
|
-
'flex w-full items-start gap-3 px-4 py-3 text-left transition-colors',
|
|
198
|
-
escDark ? 'hover:bg-white/[0.04]' : 'hover:bg-gray-50',
|
|
199
|
-
]"
|
|
200
|
-
@click="navigateToChat(chat)"
|
|
201
|
-
>
|
|
202
|
-
<!-- Avatar with status dot -->
|
|
203
|
-
<div class="relative flex-shrink-0">
|
|
204
|
-
<div
|
|
205
|
-
:class="[
|
|
206
|
-
'flex h-9 w-9 items-center justify-center rounded-full text-xs font-semibold',
|
|
207
|
-
escDark ? 'bg-neutral-800 text-neutral-300' : 'bg-gray-200 text-gray-600',
|
|
208
|
-
]"
|
|
209
|
-
>
|
|
210
|
-
{{ chatInitials(chat) }}
|
|
211
|
-
</div>
|
|
212
|
-
<span
|
|
213
|
-
:class="[
|
|
214
|
-
'absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2',
|
|
215
|
-
escDark ? 'border-neutral-900' : 'border-white',
|
|
216
|
-
activityDotClass(chat),
|
|
217
|
-
]"
|
|
218
|
-
></span>
|
|
219
|
-
</div>
|
|
220
|
-
|
|
221
|
-
<!-- Chat info -->
|
|
222
|
-
<div class="min-w-0 flex-1">
|
|
223
|
-
<div class="flex items-center justify-between">
|
|
224
|
-
<span :class="['truncate text-sm font-medium', escDark ? 'text-neutral-200' : 'text-gray-900']">
|
|
225
|
-
{{ chat.customer_name || t('ticket.unknown') }}
|
|
226
|
-
</span>
|
|
227
|
-
<span :class="['flex-shrink-0 text-[10px]', escDark ? 'text-neutral-600' : 'text-gray-400']">
|
|
228
|
-
{{ chat.last_message_at ? timeAgo(chat.last_message_at) : '' }}
|
|
229
|
-
</span>
|
|
230
|
-
</div>
|
|
231
|
-
<div class="flex items-center justify-between">
|
|
232
|
-
<span :class="['truncate text-xs', escDark ? 'text-neutral-500' : 'text-gray-500']">
|
|
233
|
-
{{ truncate(chat.last_message) }}
|
|
234
|
-
</span>
|
|
235
|
-
<span
|
|
236
|
-
v-if="chat.unread_count"
|
|
237
|
-
class="ml-2 flex h-4 min-w-[16px] flex-shrink-0 items-center justify-center rounded-full bg-cyan-500 px-1 text-[10px] font-bold text-white"
|
|
238
|
-
>
|
|
239
|
-
{{ chat.unread_count }}
|
|
240
|
-
</span>
|
|
241
|
-
</div>
|
|
242
|
-
</div>
|
|
243
|
-
</button>
|
|
244
|
-
</div>
|
|
245
|
-
</div>
|
|
246
|
-
</template>
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, computed, inject, onMounted, onUnmounted } from 'vue';
|
|
3
|
+
import { usePage } from '@inertiajs/vue3';
|
|
4
|
+
import { useI18n } from '../composables/useI18n';
|
|
5
|
+
import { useChat } from '../composables/useChat';
|
|
6
|
+
import { timeAgo } from '../utils/formatting';
|
|
7
|
+
|
|
8
|
+
const props = defineProps({
|
|
9
|
+
chats: { type: Array, default: () => [] },
|
|
10
|
+
agentId: { type: [String, Number], default: null },
|
|
11
|
+
agentStatus: { type: String, default: 'online' },
|
|
12
|
+
navigateRoute: { type: String, default: '' },
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const emit = defineEmits(['navigate', 'status-change']);
|
|
16
|
+
|
|
17
|
+
const escDark = inject(
|
|
18
|
+
'esc-dark',
|
|
19
|
+
computed(() => false),
|
|
20
|
+
);
|
|
21
|
+
const { t } = useI18n();
|
|
22
|
+
|
|
23
|
+
const isOpen = ref(false);
|
|
24
|
+
const currentStatus = ref(props.agentStatus);
|
|
25
|
+
|
|
26
|
+
const statusOptions = [
|
|
27
|
+
{ value: 'online', label: 'Online', color: 'bg-emerald-500' },
|
|
28
|
+
{ value: 'away', label: 'Away', color: 'bg-amber-500' },
|
|
29
|
+
{ value: 'offline', label: 'Offline', color: 'bg-neutral-500' },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const currentStatusOption = computed(
|
|
33
|
+
() => statusOptions.find((s) => s.value === currentStatus.value) || statusOptions[0],
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
function changeStatus(status) {
|
|
37
|
+
currentStatus.value = status;
|
|
38
|
+
emit('status-change', status);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const totalUnread = computed(() => {
|
|
42
|
+
return props.chats.reduce((sum, chat) => sum + (chat.unread_count || 0), 0);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Activity state for each chat
|
|
46
|
+
const now = ref(Date.now());
|
|
47
|
+
let timerInterval = null;
|
|
48
|
+
|
|
49
|
+
onMounted(() => {
|
|
50
|
+
timerInterval = setInterval(() => {
|
|
51
|
+
now.value = Date.now();
|
|
52
|
+
}, 10000);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
onUnmounted(() => {
|
|
56
|
+
clearInterval(timerInterval);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
function chatActivityState(chat) {
|
|
60
|
+
if (!chat.last_message_at) return 'new';
|
|
61
|
+
const diffMs = now.value - new Date(chat.last_message_at).getTime();
|
|
62
|
+
if (diffMs > 2 * 60 * 1000) return 'idle';
|
|
63
|
+
return 'active';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function activityDotClass(chat) {
|
|
67
|
+
const state = chatActivityState(chat);
|
|
68
|
+
if (state === 'new') return 'bg-blue-500 animate-pulse';
|
|
69
|
+
if (state === 'idle') return 'bg-amber-500';
|
|
70
|
+
return 'bg-emerald-500';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function navigateToChat(chat) {
|
|
74
|
+
emit('navigate', chat);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function truncate(str, len = 40) {
|
|
78
|
+
if (!str) return '';
|
|
79
|
+
return str.length > len ? str.slice(0, len) + '...' : str;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function chatInitials(chat) {
|
|
83
|
+
const name = chat.customer_name || 'U';
|
|
84
|
+
return name
|
|
85
|
+
.split(' ')
|
|
86
|
+
.map((w) => w[0])
|
|
87
|
+
.join('')
|
|
88
|
+
.toUpperCase()
|
|
89
|
+
.slice(0, 2);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Real-time: listen for new chats assigned to this agent. Read the
|
|
93
|
+
// host framework's route prefix from Inertia page props (default
|
|
94
|
+
// 'support') so chat API calls resolve correctly on NestJS backends
|
|
95
|
+
// that use '/escalated/widget' instead of '/support/widget'.
|
|
96
|
+
const page = usePage();
|
|
97
|
+
const routePrefix = page.props.escalated?.prefix || 'support';
|
|
98
|
+
const { subscribeToChatQueue } = useChat({ widgetPath: `/${routePrefix}/widget` });
|
|
99
|
+
|
|
100
|
+
onMounted(() => {
|
|
101
|
+
subscribeToChatQueue({
|
|
102
|
+
onNewChat() {
|
|
103
|
+
// Parent should refresh chat list
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<template>
|
|
110
|
+
<!-- Toggle button -->
|
|
111
|
+
<button
|
|
112
|
+
:class="[
|
|
113
|
+
'fixed right-4 bottom-20 z-40 flex h-12 w-12 items-center justify-center rounded-full shadow-lg transition-all',
|
|
114
|
+
escDark
|
|
115
|
+
? 'bg-gradient-to-r from-cyan-500 to-violet-500 text-white hover:from-cyan-400 hover:to-violet-400'
|
|
116
|
+
: 'bg-blue-600 text-white hover:bg-blue-500',
|
|
117
|
+
]"
|
|
118
|
+
:aria-label="isOpen ? t('chat.close_panel') : t('chat.open_panel')"
|
|
119
|
+
@click="isOpen = !isOpen"
|
|
120
|
+
>
|
|
121
|
+
<svg class="h-5 w-5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
|
122
|
+
<path
|
|
123
|
+
stroke-linecap="round"
|
|
124
|
+
stroke-linejoin="round"
|
|
125
|
+
d="M8.625 12a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H8.25m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H12m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0h-.375M21 12c0 4.556-4.03 8.25-9 8.25a9.764 9.764 0 01-2.555-.337A5.972 5.972 0 015.41 20.97a5.969 5.969 0 01-.474-.065 4.48 4.48 0 00.978-2.025c.09-.457-.133-.901-.467-1.226C3.93 16.178 3 14.189 3 12c0-4.556 4.03-8.25 9-8.25s9 3.694 9 8.25z"
|
|
126
|
+
/>
|
|
127
|
+
</svg>
|
|
128
|
+
<!-- Unread badge -->
|
|
129
|
+
<span
|
|
130
|
+
v-if="totalUnread > 0"
|
|
131
|
+
class="absolute -right-1 -top-1 flex h-5 min-w-[20px] items-center justify-center rounded-full bg-rose-500 px-1 text-[10px] font-bold text-white"
|
|
132
|
+
>
|
|
133
|
+
{{ totalUnread > 99 ? '99+' : totalUnread }}
|
|
134
|
+
</span>
|
|
135
|
+
</button>
|
|
136
|
+
|
|
137
|
+
<!-- Panel -->
|
|
138
|
+
<div
|
|
139
|
+
v-if="isOpen"
|
|
140
|
+
:class="[
|
|
141
|
+
'fixed right-4 bottom-36 z-40 w-80 rounded-xl border shadow-2xl',
|
|
142
|
+
escDark ? 'border-white/[0.08] bg-neutral-900' : 'border-gray-200 bg-white',
|
|
143
|
+
]"
|
|
144
|
+
style="max-height: calc(100vh - 200px)"
|
|
145
|
+
>
|
|
146
|
+
<!-- Header -->
|
|
147
|
+
<div
|
|
148
|
+
:class="[
|
|
149
|
+
'flex items-center justify-between border-b px-4 py-3',
|
|
150
|
+
escDark ? 'border-white/[0.06]' : 'border-gray-200',
|
|
151
|
+
]"
|
|
152
|
+
>
|
|
153
|
+
<div class="flex items-center gap-2">
|
|
154
|
+
<h3 :class="['text-sm font-semibold', escDark ? 'text-white' : 'text-gray-900']">
|
|
155
|
+
{{ t('chat.active_chats') }}
|
|
156
|
+
</h3>
|
|
157
|
+
<span
|
|
158
|
+
v-if="chats.length"
|
|
159
|
+
:class="[
|
|
160
|
+
'rounded-full px-1.5 py-0.5 text-[10px] font-medium',
|
|
161
|
+
escDark ? 'bg-white/[0.06] text-neutral-400' : 'bg-gray-100 text-gray-500',
|
|
162
|
+
]"
|
|
163
|
+
>
|
|
164
|
+
{{ chats.length }}
|
|
165
|
+
</span>
|
|
166
|
+
</div>
|
|
167
|
+
<!-- Status dropdown -->
|
|
168
|
+
<div class="relative">
|
|
169
|
+
<button
|
|
170
|
+
:class="[
|
|
171
|
+
'flex items-center gap-1.5 rounded-lg px-2 py-1 text-xs font-medium transition-colors',
|
|
172
|
+
escDark ? 'hover:bg-white/[0.06] text-neutral-400' : 'hover:bg-gray-100 text-gray-500',
|
|
173
|
+
]"
|
|
174
|
+
@click="
|
|
175
|
+
const idx = statusOptions.findIndex((s) => s.value === currentStatus);
|
|
176
|
+
changeStatus(statusOptions[(idx + 1) % statusOptions.length].value);
|
|
177
|
+
"
|
|
178
|
+
>
|
|
179
|
+
<span :class="['h-2 w-2 rounded-full', currentStatusOption.color]"></span>
|
|
180
|
+
{{ currentStatusOption.label }}
|
|
181
|
+
</button>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
<!-- Chat list -->
|
|
186
|
+
<div class="overflow-y-auto" style="max-height: 400px">
|
|
187
|
+
<div
|
|
188
|
+
v-if="!chats.length"
|
|
189
|
+
:class="['p-6 text-center text-sm', escDark ? 'text-neutral-600' : 'text-gray-400']"
|
|
190
|
+
>
|
|
191
|
+
{{ t('chat.no_active_chats') }}
|
|
192
|
+
</div>
|
|
193
|
+
<button
|
|
194
|
+
v-for="chat in chats"
|
|
195
|
+
:key="chat.id"
|
|
196
|
+
:class="[
|
|
197
|
+
'flex w-full items-start gap-3 px-4 py-3 text-left transition-colors',
|
|
198
|
+
escDark ? 'hover:bg-white/[0.04]' : 'hover:bg-gray-50',
|
|
199
|
+
]"
|
|
200
|
+
@click="navigateToChat(chat)"
|
|
201
|
+
>
|
|
202
|
+
<!-- Avatar with status dot -->
|
|
203
|
+
<div class="relative flex-shrink-0">
|
|
204
|
+
<div
|
|
205
|
+
:class="[
|
|
206
|
+
'flex h-9 w-9 items-center justify-center rounded-full text-xs font-semibold',
|
|
207
|
+
escDark ? 'bg-neutral-800 text-neutral-300' : 'bg-gray-200 text-gray-600',
|
|
208
|
+
]"
|
|
209
|
+
>
|
|
210
|
+
{{ chatInitials(chat) }}
|
|
211
|
+
</div>
|
|
212
|
+
<span
|
|
213
|
+
:class="[
|
|
214
|
+
'absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2',
|
|
215
|
+
escDark ? 'border-neutral-900' : 'border-white',
|
|
216
|
+
activityDotClass(chat),
|
|
217
|
+
]"
|
|
218
|
+
></span>
|
|
219
|
+
</div>
|
|
220
|
+
|
|
221
|
+
<!-- Chat info -->
|
|
222
|
+
<div class="min-w-0 flex-1">
|
|
223
|
+
<div class="flex items-center justify-between">
|
|
224
|
+
<span :class="['truncate text-sm font-medium', escDark ? 'text-neutral-200' : 'text-gray-900']">
|
|
225
|
+
{{ chat.customer_name || t('ticket.unknown') }}
|
|
226
|
+
</span>
|
|
227
|
+
<span :class="['flex-shrink-0 text-[10px]', escDark ? 'text-neutral-600' : 'text-gray-400']">
|
|
228
|
+
{{ chat.last_message_at ? timeAgo(chat.last_message_at) : '' }}
|
|
229
|
+
</span>
|
|
230
|
+
</div>
|
|
231
|
+
<div class="flex items-center justify-between">
|
|
232
|
+
<span :class="['truncate text-xs', escDark ? 'text-neutral-500' : 'text-gray-500']">
|
|
233
|
+
{{ truncate(chat.last_message) }}
|
|
234
|
+
</span>
|
|
235
|
+
<span
|
|
236
|
+
v-if="chat.unread_count"
|
|
237
|
+
class="ml-2 flex h-4 min-w-[16px] flex-shrink-0 items-center justify-center rounded-full bg-cyan-500 px-1 text-[10px] font-bold text-white"
|
|
238
|
+
>
|
|
239
|
+
{{ chat.unread_count }}
|
|
240
|
+
</span>
|
|
241
|
+
</div>
|
|
242
|
+
</div>
|
|
243
|
+
</button>
|
|
244
|
+
</div>
|
|
245
|
+
</div>
|
|
246
|
+
</template>
|