ahs-cti 0.0.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 (60) hide show
  1. package/LICENSE +53 -0
  2. package/LICENSE-ACHALA +80 -0
  3. package/README.md +639 -0
  4. package/dist/agentDetailReport-7TDO6MYQ.mjs +11 -0
  5. package/dist/agentDetailReport-7TDO6MYQ.mjs.map +1 -0
  6. package/dist/agentPerformanceReport-R3WY7Q7D.mjs +531 -0
  7. package/dist/agentPerformanceReport-R3WY7Q7D.mjs.map +1 -0
  8. package/dist/auditReport-CJ23LXIZ.mjs +15 -0
  9. package/dist/auditReport-CJ23LXIZ.mjs.map +1 -0
  10. package/dist/callHistory-743J7EKD.mjs +783 -0
  11. package/dist/callHistory-743J7EKD.mjs.map +1 -0
  12. package/dist/campaigns-N2RLUJHH.mjs +3005 -0
  13. package/dist/campaigns-N2RLUJHH.mjs.map +1 -0
  14. package/dist/caroQualityAuditDashboard-NRWY6SEC.mjs +66 -0
  15. package/dist/caroQualityAuditDashboard-NRWY6SEC.mjs.map +1 -0
  16. package/dist/caroVoiceAI-Z5BDDDSY.mjs +21 -0
  17. package/dist/caroVoiceAI-Z5BDDDSY.mjs.map +1 -0
  18. package/dist/cdrReport-577UYGZA.mjs +798 -0
  19. package/dist/cdrReport-577UYGZA.mjs.map +1 -0
  20. package/dist/chunk-6ICPXSN6.mjs +61 -0
  21. package/dist/chunk-6ICPXSN6.mjs.map +1 -0
  22. package/dist/chunk-BU6FMNBY.mjs +82 -0
  23. package/dist/chunk-BU6FMNBY.mjs.map +1 -0
  24. package/dist/chunk-DBSNJ3QH.mjs +1060 -0
  25. package/dist/chunk-DBSNJ3QH.mjs.map +1 -0
  26. package/dist/chunk-EJIWPC3H.mjs +747 -0
  27. package/dist/chunk-EJIWPC3H.mjs.map +1 -0
  28. package/dist/chunk-GTDWTI5S.mjs +17217 -0
  29. package/dist/chunk-GTDWTI5S.mjs.map +1 -0
  30. package/dist/chunk-L4LLUMYA.mjs +57 -0
  31. package/dist/chunk-L4LLUMYA.mjs.map +1 -0
  32. package/dist/chunk-NQL4VODC.mjs +180 -0
  33. package/dist/chunk-NQL4VODC.mjs.map +1 -0
  34. package/dist/chunk-NUYGQI7D.mjs +678 -0
  35. package/dist/chunk-NUYGQI7D.mjs.map +1 -0
  36. package/dist/chunk-RZZQ42MG.mjs +115 -0
  37. package/dist/chunk-RZZQ42MG.mjs.map +1 -0
  38. package/dist/chunk-UB5HSUGK.mjs +65 -0
  39. package/dist/chunk-UB5HSUGK.mjs.map +1 -0
  40. package/dist/chunk-VGVOMFYH.mjs +5781 -0
  41. package/dist/chunk-VGVOMFYH.mjs.map +1 -0
  42. package/dist/chunk-VZCHJLAW.mjs +61 -0
  43. package/dist/chunk-VZCHJLAW.mjs.map +1 -0
  44. package/dist/incoming-4WP3FJI4.mp3 +0 -0
  45. package/dist/incoming.mp3 +0 -0
  46. package/dist/index.d.mts +2476 -0
  47. package/dist/index.d.ts +2477 -0
  48. package/dist/index.js +41208 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/index.mjs +4641 -0
  51. package/dist/index.mjs.map +1 -0
  52. package/dist/liveStatus-IQIEZZE5.mjs +1077 -0
  53. package/dist/liveStatus-IQIEZZE5.mjs.map +1 -0
  54. package/dist/loginReport-H6XJU2MY.mjs +826 -0
  55. package/dist/loginReport-H6XJU2MY.mjs.map +1 -0
  56. package/dist/managementDashboard-NZMAJPPB.mjs +527 -0
  57. package/dist/managementDashboard-NZMAJPPB.mjs.map +1 -0
  58. package/dist/qualityAuditDashboard-ZJEEAMBS.mjs +66 -0
  59. package/dist/qualityAuditDashboard-ZJEEAMBS.mjs.map +1 -0
  60. package/package.json +114 -0
@@ -0,0 +1,826 @@
1
+ import {
2
+ ReportFilterBar,
3
+ SearchBar,
4
+ headCellSx
5
+ } from "./chunk-VGVOMFYH.mjs";
6
+ import {
7
+ SDKPermissionGuard
8
+ } from "./chunk-NQL4VODC.mjs";
9
+ import {
10
+ AdapterDayjs,
11
+ AppButton,
12
+ LocalizationProvider,
13
+ PageHeader
14
+ } from "./chunk-GTDWTI5S.mjs";
15
+ import {
16
+ SDKProvider
17
+ } from "./chunk-6ICPXSN6.mjs";
18
+ import {
19
+ END_POINT,
20
+ SDK_PERMISSIONS,
21
+ axios_default,
22
+ deepFindArray
23
+ } from "./chunk-DBSNJ3QH.mjs";
24
+ import "./chunk-UB5HSUGK.mjs";
25
+
26
+ // call-control-sdk/lib/pages/loginReport/index.tsx
27
+ import { useCallback as useCallback2, useEffect, useMemo, useRef, useState as useState2 } from "react";
28
+ import {
29
+ Alert,
30
+ Box,
31
+ Chip,
32
+ CircularProgress,
33
+ Dialog,
34
+ DialogContent,
35
+ DialogTitle,
36
+ IconButton,
37
+ Paper,
38
+ Stack,
39
+ Table,
40
+ TableBody,
41
+ TableCell,
42
+ TableContainer,
43
+ TableHead,
44
+ TableRow,
45
+ TablePagination,
46
+ TableSortLabel,
47
+ Typography
48
+ } from "@mui/material";
49
+ import CloseIcon from "@mui/icons-material/Close";
50
+ import DownloadIcon from "@mui/icons-material/Download";
51
+ import RefreshIcon from "@mui/icons-material/Refresh";
52
+ import dayjs from "dayjs";
53
+ import isoWeek from "dayjs/plugin/isoWeek";
54
+
55
+ // call-control-sdk/lib/pages/loginReport/useLoginReport.ts
56
+ import { useCallback, useState } from "react";
57
+ async function fetchQueues() {
58
+ var _a;
59
+ const res = await axios_default.get(END_POINT.MASTER_QUEUES);
60
+ if (Array.isArray(res.data)) return res.data;
61
+ if (Array.isArray((_a = res.data) == null ? void 0 : _a.data)) return res.data.data;
62
+ return [];
63
+ }
64
+ async function getQueues() {
65
+ return fetchQueues();
66
+ }
67
+ async function getLoginReport(params) {
68
+ const qs = buildLoginReportQueryString(params);
69
+ const res = await axios_default.get(`${END_POINT.LOGIN_REPORT}${qs}`);
70
+ return res.data;
71
+ }
72
+ async function getAgentLoginSessions(agentId, params) {
73
+ const qs = buildSessionQueryString(params);
74
+ const res = await axios_default.get(
75
+ `${END_POINT.LOGIN_REPORT_AGENT_SESSIONS(agentId)}${qs}`
76
+ );
77
+ return Array.isArray(res.data) ? res.data : [];
78
+ }
79
+ async function exportLoginReportToExcel(params) {
80
+ var _a;
81
+ const qs = buildLoginReportQueryString(params);
82
+ const res = await axios_default.get(`${END_POINT.LOGIN_REPORT_EXPORT_EXCEL}${qs}`, { responseType: "blob" });
83
+ triggerBlobDownload(new Blob([res.data]), `login-report-${(_a = params.start_date) != null ? _a : "export"}.xlsx`);
84
+ }
85
+ async function exportAgentLoginSessionsToExcel(agentId, params) {
86
+ const qs = buildSessionQueryString(params);
87
+ const res = await axios_default.get(
88
+ `${END_POINT.LOGIN_REPORT_AGENT_SESSIONS_EXPORT_EXCEL(agentId)}${qs}`,
89
+ { responseType: "blob" }
90
+ );
91
+ triggerBlobDownload(new Blob([res.data]), `login_sessions_${agentId}.xlsx`);
92
+ }
93
+ function buildLoginReportQueryString(params) {
94
+ const qs = new URLSearchParams();
95
+ if (params.start_date) qs.append("start_date", params.start_date);
96
+ if (params.end_date) qs.append("end_date", params.end_date);
97
+ if (params.agent_id) for (const id of params.agent_id) qs.append("agent_id", id);
98
+ if (params.queue_id) for (const id of params.queue_id) qs.append("queue_id", String(id));
99
+ if (params.process_id) for (const id of params.process_id) qs.append("process_id", String(id));
100
+ if (params.search) qs.append("search", params.search);
101
+ if (params.page) qs.append("page", String(params.page));
102
+ if (params.pageSize) qs.append("pageSize", String(params.pageSize));
103
+ const str = qs.toString();
104
+ return str ? `?${str}` : "";
105
+ }
106
+ function buildSessionQueryString(params) {
107
+ const qs = new URLSearchParams();
108
+ if (params == null ? void 0 : params.start_date) qs.append("start_date", params.start_date);
109
+ if (params == null ? void 0 : params.end_date) qs.append("end_date", params.end_date);
110
+ const str = qs.toString();
111
+ return str ? `?${str}` : "";
112
+ }
113
+ function triggerBlobDownload(blob, filename) {
114
+ const url = URL.createObjectURL(blob);
115
+ const a = document.createElement("a");
116
+ a.href = url;
117
+ a.download = filename;
118
+ document.body.appendChild(a);
119
+ a.click();
120
+ a.remove();
121
+ URL.revokeObjectURL(url);
122
+ }
123
+
124
+ // call-control-sdk/lib/pages/loginReport/index.tsx
125
+ import { jsx, jsxs } from "react/jsx-runtime";
126
+ dayjs.extend(isoWeek);
127
+ var FONT = "'Inter', 'Segoe UI', 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif";
128
+ var COLORS = {
129
+ navy: "#0d2a56",
130
+ blue: "#1565c8",
131
+ green: "#0a9a62",
132
+ amber: "#c47c00",
133
+ red: "#cc2a2a",
134
+ purple: "#6b3fbf",
135
+ bg: "transparent",
136
+ surface: "transparent"
137
+ };
138
+ var DEFAULT_ROWS_PER_PAGE = 10;
139
+ var comparator = (a, b, key) => {
140
+ const av = a[key];
141
+ const bv = b[key];
142
+ if (typeof av === "number" && typeof bv === "number") return av - bv;
143
+ return String(av != null ? av : "").localeCompare(String(bv != null ? bv : ""));
144
+ };
145
+ function LoginReportContent() {
146
+ const [startDate, setStartDate] = useState2(dayjs().startOf("day"));
147
+ const [endDate, setEndDate] = useState2(dayjs());
148
+ const [activeQuickDate, setActiveQuickDate] = useState2("today");
149
+ const [searchText, setSearchText] = useState2("");
150
+ const [selectedAgents, setSelectedAgents] = useState2([]);
151
+ const [isAllUsersSelected, setIsAllUsersSelected] = useState2(false);
152
+ const [queues, setQueues] = useState2([]);
153
+ const [selectedQueues, setSelectedQueues] = useState2([]);
154
+ const [reportData, setReportData] = useState2([]);
155
+ const [loading, setLoading] = useState2(false);
156
+ const [error, setError] = useState2("");
157
+ const [page, setPage] = useState2(0);
158
+ const [rowsPerPage, setRowsPerPage] = useState2(DEFAULT_ROWS_PER_PAGE);
159
+ const [totalCount, setTotalCount] = useState2(-1);
160
+ const [sortKey, setSortKey] = useState2("fullName");
161
+ const [sortDir, setSortDir] = useState2("asc");
162
+ const [debouncedSearch, setDebouncedSearch] = useState2("");
163
+ const debounceRef = useRef(void 0);
164
+ useEffect(() => {
165
+ debounceRef.current = setTimeout(() => setDebouncedSearch(searchText.trim()), 400);
166
+ return () => clearTimeout(debounceRef.current);
167
+ }, [searchText]);
168
+ const [dialogOpen, setDialogOpen] = useState2(false);
169
+ const [selectedRow, setSelectedRow] = useState2(null);
170
+ const [sessions, setSessions] = useState2([]);
171
+ const [sessionsLoading, setSessionsLoading] = useState2(false);
172
+ useEffect(() => {
173
+ getQueues().then((data) => setQueues(data || [])).catch(() => setError("Failed to load queues"));
174
+ }, []);
175
+ const handleQuickRangeChange = (range) => {
176
+ setActiveQuickDate(range || null);
177
+ };
178
+ const handleRefresh = () => {
179
+ if (activeQuickDate) {
180
+ const now = dayjs();
181
+ let sd = now.startOf("day");
182
+ const ed = now;
183
+ if (activeQuickDate === "week") sd = now.startOf("week").startOf("day");
184
+ else if (activeQuickDate === "month") sd = now.startOf("month").startOf("day");
185
+ setStartDate(sd);
186
+ setEndDate(ed);
187
+ } else {
188
+ fetchReport(page);
189
+ }
190
+ };
191
+ const fetchReport = useCallback2(
192
+ async (pageNum) => {
193
+ var _a, _b, _c, _d;
194
+ const sd = startDate;
195
+ const ed = endDate;
196
+ if (!sd || !ed) {
197
+ setError("Select a valid date range");
198
+ return;
199
+ }
200
+ const params = {
201
+ start_date: sd.format("YYYY-MM-DDTHH:mm:ss"),
202
+ end_date: ed.format("YYYY-MM-DDTHH:mm:ss"),
203
+ agent_id: !isAllUsersSelected && selectedAgents.length > 0 ? selectedAgents.map((a) => a.userId) : void 0,
204
+ queue_id: selectedQueues.length > 0 && selectedQueues.length < queues.length ? selectedQueues.map((q) => q.id) : void 0,
205
+ search: debouncedSearch || void 0,
206
+ page: pageNum + 1,
207
+ pageSize: rowsPerPage
208
+ };
209
+ try {
210
+ setError("");
211
+ setLoading(true);
212
+ const res = await getLoginReport(params);
213
+ const agents = deepFindArray(res, ["agents"]);
214
+ setReportData(agents);
215
+ const total = (_d = (_b = res == null ? void 0 : res.total) != null ? _b : (_a = res == null ? void 0 : res.pagination) == null ? void 0 : _a.total) != null ? _d : (_c = res == null ? void 0 : res.summary) == null ? void 0 : _c.totalAgentsLoggedIn;
216
+ setTotalCount(typeof total === "number" ? total : agents.length);
217
+ } catch (err) {
218
+ setError((err == null ? void 0 : err.message) || "Failed to fetch login report");
219
+ setReportData([]);
220
+ } finally {
221
+ setLoading(false);
222
+ }
223
+ },
224
+ [startDate, endDate, selectedAgents, isAllUsersSelected, selectedQueues, debouncedSearch, rowsPerPage]
225
+ );
226
+ useEffect(() => {
227
+ setPage(0);
228
+ fetchReport(0);
229
+ }, [fetchReport]);
230
+ const handlePageChange = useCallback2(
231
+ (_event, newPage) => {
232
+ setPage(newPage);
233
+ fetchReport(newPage);
234
+ },
235
+ [fetchReport]
236
+ );
237
+ const filteredData = useMemo(() => {
238
+ const rows = [...reportData];
239
+ rows.sort((a, b) => {
240
+ const cmp = comparator(a, b, sortKey);
241
+ return sortDir === "asc" ? cmp : -cmp;
242
+ });
243
+ return rows;
244
+ }, [reportData, sortKey, sortDir]);
245
+ const paginatedData = filteredData;
246
+ const handleSort = (key) => {
247
+ if (sortKey === key) {
248
+ setSortDir((d) => d === "asc" ? "desc" : "asc");
249
+ } else {
250
+ setSortKey(key);
251
+ setSortDir("asc");
252
+ }
253
+ };
254
+ const openDialog = async (row) => {
255
+ setSelectedRow(row);
256
+ setSessions([]);
257
+ setDialogOpen(true);
258
+ setSessionsLoading(true);
259
+ try {
260
+ const sd = startDate != null ? startDate : dayjs();
261
+ const ed = endDate != null ? endDate : dayjs();
262
+ const data = await getAgentLoginSessions(row.agentId, {
263
+ start_date: sd.format("YYYY-MM-DDTHH:mm:ss"),
264
+ end_date: ed.format("YYYY-MM-DDTHH:mm:ss")
265
+ });
266
+ setSessions(data);
267
+ } catch (e) {
268
+ setSessions([]);
269
+ } finally {
270
+ setSessionsLoading(false);
271
+ }
272
+ };
273
+ const closeDialog = () => {
274
+ setDialogOpen(false);
275
+ setTimeout(() => {
276
+ setSelectedRow(null);
277
+ setSessions([]);
278
+ }, 300);
279
+ };
280
+ const handleExportExcel = async () => {
281
+ const sd = startDate != null ? startDate : dayjs();
282
+ const ed = endDate != null ? endDate : dayjs();
283
+ const params = {
284
+ start_date: sd.format("YYYY-MM-DDTHH:mm:ss"),
285
+ end_date: ed.format("YYYY-MM-DDTHH:mm:ss"),
286
+ agent_id: !isAllUsersSelected && selectedAgents.length > 0 ? selectedAgents.map((a) => a.userId) : void 0,
287
+ queue_id: selectedQueues.length > 0 && selectedQueues.length < queues.length ? selectedQueues.map((q) => q.id) : void 0,
288
+ search: debouncedSearch || void 0
289
+ };
290
+ try {
291
+ await exportLoginReportToExcel(params);
292
+ } catch (err) {
293
+ setError((err == null ? void 0 : err.message) || "Failed to export Excel");
294
+ }
295
+ };
296
+ return /* @__PURE__ */ jsx(LocalizationProvider, { dateAdapter: AdapterDayjs, children: /* @__PURE__ */ jsxs(Box, { sx: { height: "100%", display: "flex", flexDirection: "column", fontFamily: FONT }, children: [
297
+ /* @__PURE__ */ jsx(
298
+ PageHeader,
299
+ {
300
+ title: "Login Report",
301
+ actions: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, children: [
302
+ /* @__PURE__ */ jsx(
303
+ SearchBar,
304
+ {
305
+ value: searchText,
306
+ onChange: (val) => {
307
+ setSearchText(val);
308
+ setPage(0);
309
+ },
310
+ placeholder: "Search name, ID...",
311
+ width: 250
312
+ }
313
+ ),
314
+ /* @__PURE__ */ jsx(
315
+ SDKPermissionGuard,
316
+ {
317
+ permissions: [SDK_PERMISSIONS.REPORTS_AGENT_LOGIN_MANAGE, SDK_PERMISSIONS.REPORTS_AGENT_LOGIN_EXPORT],
318
+ showFallback: false,
319
+ children: /* @__PURE__ */ jsx(
320
+ AppButton,
321
+ {
322
+ startIcon: /* @__PURE__ */ jsx(DownloadIcon, { sx: { fontSize: "0.95rem !important" } }),
323
+ disabled: !reportData.length,
324
+ onClick: handleExportExcel,
325
+ sx: { height: 36 },
326
+ children: "Export Excel"
327
+ }
328
+ )
329
+ }
330
+ )
331
+ ] })
332
+ }
333
+ ),
334
+ /* @__PURE__ */ jsxs(Box, { sx: { flex: 1, overflow: "auto", py: 0.8, px: 0 }, children: [
335
+ /* @__PURE__ */ jsxs(Box, { sx: { mb: 0.8 }, children: [
336
+ /* @__PURE__ */ jsx(
337
+ ReportFilterBar,
338
+ {
339
+ startDate,
340
+ endDate,
341
+ onStartChange: setStartDate,
342
+ onEndChange: setEndDate,
343
+ quickRange: activeQuickDate || "",
344
+ onQuickRangeChange: handleQuickRangeChange,
345
+ showAgentSelect: true,
346
+ selectedAgents,
347
+ onAgentsChange: setSelectedAgents,
348
+ setIsAllUsersSelected,
349
+ showQueueSelect: true,
350
+ queues,
351
+ selectedQueues,
352
+ onQueuesChange: setSelectedQueues,
353
+ extra: /* @__PURE__ */ jsx(
354
+ AppButton,
355
+ {
356
+ startIcon: /* @__PURE__ */ jsx(RefreshIcon, { sx: { fontSize: "0.9rem !important" } }),
357
+ disabled: loading,
358
+ onClick: handleRefresh,
359
+ sx: { height: 32 },
360
+ children: "Refresh"
361
+ }
362
+ )
363
+ }
364
+ ),
365
+ error && /* @__PURE__ */ jsx(Alert, { severity: "error", sx: { mt: 1, fontFamily: FONT, fontSize: "0.78rem" }, children: error })
366
+ ] }),
367
+ loading && /* @__PURE__ */ jsx(Box, { sx: { textAlign: "center", py: 2.5 }, children: /* @__PURE__ */ jsx(CircularProgress, { sx: { color: COLORS.blue }, size: 28 }) }),
368
+ /* @__PURE__ */ jsxs(
369
+ Paper,
370
+ {
371
+ elevation: 0,
372
+ sx: {
373
+ borderRadius: "8px",
374
+ border: "1px solid #e0e7ef",
375
+ overflow: "hidden",
376
+ mb: 2
377
+ },
378
+ children: [
379
+ /* @__PURE__ */ jsx(TableContainer, { children: /* @__PURE__ */ jsxs(
380
+ Table,
381
+ {
382
+ size: "small",
383
+ sx: {
384
+ minWidth: 1100,
385
+ fontFamily: FONT,
386
+ "& .MuiTableCell-root": {
387
+ fontFamily: FONT,
388
+ fontSize: "0.75rem",
389
+ borderBottom: "1px solid #eef1f6",
390
+ py: 0.6,
391
+ px: 1
392
+ }
393
+ },
394
+ children: [
395
+ /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsx(TableRow, { children: [
396
+ { id: "fullName", label: "User Name" },
397
+ { id: "agentId", label: "User ID" },
398
+ { id: "queueNames", label: "Queues" },
399
+ { id: "numLogins", label: "Logins" },
400
+ { id: "firstLoginTime", label: "First Login" },
401
+ { id: "lastLogoutTime", label: "Last Logout" },
402
+ { id: "workingDurationFormatted", label: "Working Duration" },
403
+ { id: "breakDurationFormatted", label: "Break Duration" },
404
+ { id: "loginDurationFormatted", label: "Login Duration" },
405
+ { id: "utilisationPct", label: "Utilisation %" }
406
+ ].map((col) => /* @__PURE__ */ jsx(TableCell, { sx: headCellSx, children: /* @__PURE__ */ jsx(
407
+ TableSortLabel,
408
+ {
409
+ active: sortKey === col.id,
410
+ direction: sortKey === col.id ? sortDir : "asc",
411
+ onClick: () => handleSort(col.id),
412
+ sx: {
413
+ "&.MuiTableSortLabel-root": { color: "#333" },
414
+ "&.MuiTableSortLabel-root:hover": { color: "#555" },
415
+ "&.Mui-active": { color: "#333" },
416
+ "& .MuiTableSortLabel-icon": { color: "#333 !important" }
417
+ },
418
+ children: col.label
419
+ }
420
+ ) }, col.id)) }) }),
421
+ /* @__PURE__ */ jsx(TableBody, { children: paginatedData.map((row, idx) => {
422
+ const isLoggedIn = !row.lastLogoutTime;
423
+ return /* @__PURE__ */ jsxs(
424
+ TableRow,
425
+ {
426
+ hover: true,
427
+ sx: {
428
+ backgroundColor: "#fff",
429
+ "&:hover": { backgroundColor: "#f0f7f8" }
430
+ },
431
+ children: [
432
+ /* @__PURE__ */ jsx(TableCell, { sx: { fontWeight: 600, color: COLORS.navy, fontSize: "0.75rem" }, children: row.fullName || "\u2014" }),
433
+ /* @__PURE__ */ jsx(TableCell, { sx: { fontSize: "0.73rem", color: "#4a5568" }, children: row.agentId || "\u2014" }),
434
+ /* @__PURE__ */ jsx(TableCell, { children: row.queueNames ? /* @__PURE__ */ jsx(
435
+ Chip,
436
+ {
437
+ label: row.queueNames,
438
+ size: "small",
439
+ sx: {
440
+ fontFamily: FONT,
441
+ backgroundColor: "#f0ebfa",
442
+ color: COLORS.purple,
443
+ fontWeight: 500,
444
+ fontSize: "0.67rem",
445
+ height: 22
446
+ }
447
+ }
448
+ ) : "\u2014" }),
449
+ /* @__PURE__ */ jsx(TableCell, { sx: { textAlign: "center" }, children: /* @__PURE__ */ jsx(
450
+ Chip,
451
+ {
452
+ label: row.numLogins,
453
+ size: "small",
454
+ onClick: (e) => {
455
+ e.stopPropagation();
456
+ openDialog(row);
457
+ },
458
+ sx: {
459
+ fontFamily: FONT,
460
+ backgroundColor: COLORS.navy,
461
+ color: "#fff",
462
+ fontWeight: 600,
463
+ minWidth: 28,
464
+ height: 20,
465
+ fontSize: "0.67rem",
466
+ cursor: "pointer",
467
+ "&:hover": { backgroundColor: COLORS.blue }
468
+ }
469
+ }
470
+ ) }),
471
+ /* @__PURE__ */ jsx(TableCell, { sx: { fontSize: "0.73rem", color: "#4a5568" }, children: row.firstLoginTime ? dayjs(row.firstLoginTime).format("DD MMM YYYY hh:mm A") : "\u2014" }),
472
+ /* @__PURE__ */ jsx(TableCell, { sx: { fontSize: "0.73rem", color: "#4a5568" }, children: isLoggedIn ? /* @__PURE__ */ jsx(
473
+ Chip,
474
+ {
475
+ label: "LOGGED-IN",
476
+ size: "small",
477
+ sx: {
478
+ fontFamily: FONT,
479
+ backgroundColor: COLORS.green,
480
+ color: "#fff",
481
+ fontWeight: 600,
482
+ fontSize: "0.65rem",
483
+ height: 20
484
+ }
485
+ }
486
+ ) : dayjs(row.lastLogoutTime).format("DD MMM YYYY hh:mm A") }),
487
+ /* @__PURE__ */ jsx(
488
+ TableCell,
489
+ {
490
+ sx: { fontWeight: 600, color: COLORS.blue, fontSize: "0.75rem", fontVariantNumeric: "tabular-nums" },
491
+ children: row.workingDurationFormatted || "\u2014"
492
+ }
493
+ ),
494
+ /* @__PURE__ */ jsx(
495
+ TableCell,
496
+ {
497
+ sx: { fontWeight: 500, color: COLORS.amber, fontSize: "0.75rem", fontVariantNumeric: "tabular-nums" },
498
+ children: row.breakDurationFormatted || "\u2014"
499
+ }
500
+ ),
501
+ /* @__PURE__ */ jsx(TableCell, { sx: { fontWeight: 500, fontSize: "0.75rem", fontVariantNumeric: "tabular-nums" }, children: row.loginDurationFormatted || "\u2014" }),
502
+ /* @__PURE__ */ jsx(TableCell, { sx: { minWidth: 120 }, children: row.utilisationPct != null ? (() => {
503
+ const pct = Math.min(row.utilisationPct, 100);
504
+ const barColor = pct >= 80 ? "#10b981" : pct >= 60 ? "#f59e0b" : "#ef4444";
505
+ const bgTint = pct >= 80 ? "#d1fae5" : pct >= 60 ? "#fef3c7" : "#fee2e2";
506
+ return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 0.8 }, children: [
507
+ /* @__PURE__ */ jsx(
508
+ Box,
509
+ {
510
+ sx: {
511
+ position: "relative",
512
+ flex: 1,
513
+ height: 7,
514
+ borderRadius: 4,
515
+ backgroundColor: bgTint,
516
+ overflow: "hidden"
517
+ },
518
+ children: /* @__PURE__ */ jsx(
519
+ Box,
520
+ {
521
+ sx: {
522
+ width: `${pct}%`,
523
+ height: "100%",
524
+ borderRadius: 4,
525
+ background: `linear-gradient(90deg, ${barColor}cc, ${barColor})`,
526
+ transition: "width 0.4s ease"
527
+ }
528
+ }
529
+ )
530
+ }
531
+ ),
532
+ /* @__PURE__ */ jsx(
533
+ Chip,
534
+ {
535
+ label: `${Math.round(pct)}%`,
536
+ size: "small",
537
+ sx: {
538
+ fontFamily: FONT,
539
+ height: 18,
540
+ minWidth: 38,
541
+ fontSize: "0.63rem",
542
+ fontWeight: 700,
543
+ backgroundColor: bgTint,
544
+ color: barColor,
545
+ "& .MuiChip-label": { px: 0.6 }
546
+ }
547
+ }
548
+ )
549
+ ] });
550
+ })() : "\u2014" })
551
+ ]
552
+ },
553
+ `${row.agentId}-${idx}`
554
+ );
555
+ }) })
556
+ ]
557
+ }
558
+ ) }),
559
+ /* @__PURE__ */ jsx(
560
+ TablePagination,
561
+ {
562
+ component: "div",
563
+ count: totalCount,
564
+ page,
565
+ onPageChange: handlePageChange,
566
+ rowsPerPage,
567
+ rowsPerPageOptions: [10, 15, 25, 50, 100],
568
+ onRowsPerPageChange: (e) => {
569
+ setRowsPerPage(parseInt(e.target.value, 10));
570
+ setPage(0);
571
+ },
572
+ sx: { borderTop: "1px solid #eef1f6", fontFamily: FONT, "& .MuiTablePagination-displayedRows": { fontFamily: FONT, fontSize: "0.73rem" }, "& .MuiTablePagination-selectLabel": { fontFamily: FONT, fontSize: "0.73rem" } }
573
+ }
574
+ )
575
+ ]
576
+ }
577
+ ),
578
+ /* @__PURE__ */ jsxs(
579
+ Dialog,
580
+ {
581
+ open: dialogOpen,
582
+ onClose: (_e, reason) => {
583
+ if (reason !== "backdropClick") closeDialog();
584
+ },
585
+ maxWidth: "md",
586
+ fullWidth: true,
587
+ PaperProps: {
588
+ sx: {
589
+ borderRadius: "12px",
590
+ fontFamily: FONT,
591
+ overflow: "hidden",
592
+ boxShadow: "0 8px 32px rgba(0,0,0,0.18)",
593
+ maxWidth: 450
594
+ }
595
+ },
596
+ children: [
597
+ /* @__PURE__ */ jsxs(
598
+ DialogTitle,
599
+ {
600
+ sx: {
601
+ fontFamily: FONT,
602
+ background: "linear-gradient(135deg, var(--primary-color-dark, #14505b), var(--primary-color, #1A5F6C))",
603
+ color: "#fff",
604
+ display: "flex",
605
+ justifyContent: "space-between",
606
+ alignItems: "center",
607
+ py: 1.5,
608
+ px: 2.5
609
+ },
610
+ children: [
611
+ /* @__PURE__ */ jsxs(Box, { children: [
612
+ /* @__PURE__ */ jsx(Typography, { variant: "h6", sx: { fontFamily: FONT, fontWeight: 700, fontSize: "0.95rem", letterSpacing: "0.3px" }, children: "Login Sessions" }),
613
+ /* @__PURE__ */ jsxs(
614
+ Typography,
615
+ {
616
+ variant: "body2",
617
+ sx: { fontFamily: FONT, opacity: 0.9, fontSize: "0.76rem", mt: 0.3 },
618
+ children: [
619
+ selectedRow == null ? void 0 : selectedRow.fullName,
620
+ " \u2022 ",
621
+ selectedRow == null ? void 0 : selectedRow.numLogins,
622
+ " session",
623
+ (selectedRow == null ? void 0 : selectedRow.numLogins) !== 1 ? "s" : ""
624
+ ]
625
+ }
626
+ )
627
+ ] }),
628
+ /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
629
+ /* @__PURE__ */ jsx(
630
+ AppButton,
631
+ {
632
+ size: "small",
633
+ startIcon: /* @__PURE__ */ jsx(DownloadIcon, { sx: { fontSize: "0.85rem !important" } }),
634
+ onClick: async () => {
635
+ if (!selectedRow) return;
636
+ try {
637
+ await exportAgentLoginSessionsToExcel(selectedRow.agentId, {
638
+ start_date: (startDate != null ? startDate : dayjs()).format("YYYY-MM-DDTHH:mm:ss"),
639
+ end_date: (endDate != null ? endDate : dayjs()).format("YYYY-MM-DDTHH:mm:ss")
640
+ });
641
+ } catch (err) {
642
+ setError((err == null ? void 0 : err.message) || "Failed to export Excel");
643
+ }
644
+ },
645
+ sx: { whiteSpace: "nowrap" },
646
+ children: "Export to Excel"
647
+ }
648
+ ),
649
+ /* @__PURE__ */ jsx(
650
+ IconButton,
651
+ {
652
+ onClick: closeDialog,
653
+ size: "small",
654
+ sx: {
655
+ color: "#fff",
656
+ backgroundColor: "rgba(255,255,255,0.1)",
657
+ "&:hover": { backgroundColor: "rgba(255,255,255,0.2)" }
658
+ },
659
+ children: /* @__PURE__ */ jsx(CloseIcon, { fontSize: "small" })
660
+ }
661
+ )
662
+ ] })
663
+ ]
664
+ }
665
+ ),
666
+ /* @__PURE__ */ jsx(DialogContent, { sx: { p: 0, backgroundColor: "#f8fafb" }, children: sessionsLoading ? /* @__PURE__ */ jsx(Box, { sx: { p: 4, textAlign: "center" }, children: /* @__PURE__ */ jsx(CircularProgress, { size: 28, sx: { color: "var(--primary-color, #1A5F6C)" } }) }) : sessions.length > 0 ? /* @__PURE__ */ jsx(Box, { sx: { p: 1.5, maxHeight: 300, overflowY: "auto" }, children: Object.entries(
667
+ sessions.reduce((acc, s) => {
668
+ const dateKey = s.loginTime ? dayjs(s.loginTime).format("DD MMM YYYY") : "Unknown Date";
669
+ if (!acc[dateKey]) acc[dateKey] = [];
670
+ acc[dateKey].push(s);
671
+ return acc;
672
+ }, {})
673
+ ).map(([date, dateSessions]) => /* @__PURE__ */ jsxs(
674
+ Paper,
675
+ {
676
+ elevation: 0,
677
+ sx: {
678
+ mb: 1.5,
679
+ borderRadius: "10px",
680
+ border: "1px solid #e4eaf0",
681
+ overflow: "hidden",
682
+ backgroundColor: "#fff"
683
+ },
684
+ children: [
685
+ /* @__PURE__ */ jsx(
686
+ Box,
687
+ {
688
+ sx: {
689
+ px: 1.5,
690
+ py: 0.8,
691
+ backgroundColor: "#f0f5f4",
692
+ borderBottom: "1px solid #e4eaf0"
693
+ },
694
+ children: /* @__PURE__ */ jsx(
695
+ Typography,
696
+ {
697
+ sx: {
698
+ fontFamily: FONT,
699
+ fontWeight: 700,
700
+ fontSize: "0.8rem",
701
+ color: "var(--primary-color-dark, #14505b)",
702
+ letterSpacing: "0.3px"
703
+ },
704
+ children: date
705
+ }
706
+ )
707
+ }
708
+ ),
709
+ /* @__PURE__ */ jsxs(Box, { sx: { px: 1.5, py: 1 }, children: [
710
+ /* @__PURE__ */ jsxs(
711
+ Box,
712
+ {
713
+ sx: {
714
+ display: "flex",
715
+ alignItems: "center",
716
+ gap: 2,
717
+ pb: 0.5,
718
+ mb: 0.5,
719
+ borderBottom: "1px solid #e4eaf0"
720
+ },
721
+ children: [
722
+ /* @__PURE__ */ jsx(
723
+ Typography,
724
+ {
725
+ sx: {
726
+ flex: 1,
727
+ fontFamily: FONT,
728
+ fontSize: "0.72rem",
729
+ fontWeight: 700,
730
+ color: "#555",
731
+ textTransform: "uppercase",
732
+ letterSpacing: "0.5px"
733
+ },
734
+ children: "Login"
735
+ }
736
+ ),
737
+ /* @__PURE__ */ jsx(
738
+ Typography,
739
+ {
740
+ sx: {
741
+ flex: 1,
742
+ fontFamily: FONT,
743
+ fontSize: "0.72rem",
744
+ fontWeight: 700,
745
+ color: "#555",
746
+ textTransform: "uppercase",
747
+ letterSpacing: "0.5px"
748
+ },
749
+ children: "Logout"
750
+ }
751
+ )
752
+ ]
753
+ }
754
+ ),
755
+ dateSessions.map((s, i) => /* @__PURE__ */ jsxs(
756
+ Box,
757
+ {
758
+ sx: {
759
+ display: "flex",
760
+ alignItems: "center",
761
+ gap: 2,
762
+ py: 0.6,
763
+ borderBottom: i < dateSessions.length - 1 ? "1px dashed #e8ecf0" : "none"
764
+ },
765
+ children: [
766
+ /* @__PURE__ */ jsxs(
767
+ Typography,
768
+ {
769
+ component: "span",
770
+ sx: {
771
+ flex: 1,
772
+ fontFamily: FONT,
773
+ fontSize: "0.78rem",
774
+ fontWeight: 500,
775
+ color: s.loginTime ? COLORS.green : "#9e9e9e",
776
+ display: "flex",
777
+ alignItems: "center",
778
+ gap: 0.4
779
+ },
780
+ children: [
781
+ /* @__PURE__ */ jsx("span", { style: { fontSize: "0.9rem" }, children: "\u2199" }),
782
+ s.loginTime ? dayjs(s.loginTime).format("DD MMM YYYY h:mm:ss A") : "Missing"
783
+ ]
784
+ }
785
+ ),
786
+ /* @__PURE__ */ jsxs(
787
+ Typography,
788
+ {
789
+ component: "span",
790
+ sx: {
791
+ flex: 1,
792
+ fontFamily: FONT,
793
+ fontSize: "0.78rem",
794
+ fontWeight: 500,
795
+ color: s.logoutTime ? COLORS.red : "#9e9e9e",
796
+ display: "flex",
797
+ alignItems: "center",
798
+ gap: 0.4
799
+ },
800
+ children: [
801
+ /* @__PURE__ */ jsx("span", { style: { fontSize: "0.9rem" }, children: "\u2197" }),
802
+ s.logoutTime ? dayjs(s.logoutTime).format("DD MMM YYYY h:mm:ss A") : "Missing"
803
+ ]
804
+ }
805
+ )
806
+ ]
807
+ },
808
+ i
809
+ ))
810
+ ] })
811
+ ]
812
+ },
813
+ date
814
+ )) }) : /* @__PURE__ */ jsx(Box, { sx: { p: 4, textAlign: "center" }, children: /* @__PURE__ */ jsx(Typography, { sx: { fontFamily: FONT, color: "#9e9e9e", fontStyle: "italic", fontSize: "0.82rem" }, children: "No sessions found" }) }) })
815
+ ]
816
+ }
817
+ )
818
+ ] })
819
+ ] }) });
820
+ }
821
+ var LoginReport = () => /* @__PURE__ */ jsx(SDKProvider, { children: /* @__PURE__ */ jsx(LoginReportContent, {}) });
822
+ var loginReport_default = LoginReport;
823
+ export {
824
+ loginReport_default as default
825
+ };
826
+ //# sourceMappingURL=loginReport-H6XJU2MY.mjs.map