ahs-cti 1.0.1-beta.61 → 1.0.1-beta.63

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 (61) hide show
  1. package/dist-react/agentDetailReport-PDKQKJNL.mjs +23 -0
  2. package/dist-react/agentDetailReport-PDKQKJNL.mjs.map +1 -0
  3. package/dist-react/agentPerformanceReport-MU2FASNN.mjs +544 -0
  4. package/dist-react/agentPerformanceReport-MU2FASNN.mjs.map +1 -0
  5. package/dist-react/auditReport-WH2KDNYT.mjs +25 -0
  6. package/dist-react/auditReport-WH2KDNYT.mjs.map +1 -0
  7. package/dist-react/callHistory-HXXRYUIV.mjs +832 -0
  8. package/dist-react/callHistory-HXXRYUIV.mjs.map +1 -0
  9. package/dist-react/campaigns-J7KIAATE.mjs +3139 -0
  10. package/dist-react/campaigns-J7KIAATE.mjs.map +1 -0
  11. package/dist-react/caroQualityAuditDashboard-THYPVOCP.mjs +76 -0
  12. package/dist-react/caroQualityAuditDashboard-THYPVOCP.mjs.map +1 -0
  13. package/dist-react/caroVoiceAI-XGDUETXI.mjs +31 -0
  14. package/dist-react/caroVoiceAI-XGDUETXI.mjs.map +1 -0
  15. package/dist-react/cdrReport-SX2FZAO6.mjs +858 -0
  16. package/dist-react/cdrReport-SX2FZAO6.mjs.map +1 -0
  17. package/dist-react/chunk-4YF4IDV6.mjs +72 -0
  18. package/dist-react/chunk-4YF4IDV6.mjs.map +1 -0
  19. package/dist-react/chunk-ADM2JJCP.mjs +190 -0
  20. package/dist-react/chunk-ADM2JJCP.mjs.map +1 -0
  21. package/dist-react/chunk-EN7HM2MD.mjs +688 -0
  22. package/dist-react/chunk-EN7HM2MD.mjs.map +1 -0
  23. package/dist-react/chunk-F7G2XFRU.mjs +10930 -0
  24. package/dist-react/chunk-F7G2XFRU.mjs.map +1 -0
  25. package/dist-react/chunk-GUMGXVIT.mjs +71 -0
  26. package/dist-react/chunk-GUMGXVIT.mjs.map +1 -0
  27. package/dist-react/chunk-KRXHK4AU.mjs +127 -0
  28. package/dist-react/chunk-KRXHK4AU.mjs.map +1 -0
  29. package/dist-react/chunk-LWDAC6QU.mjs +92 -0
  30. package/dist-react/chunk-LWDAC6QU.mjs.map +1 -0
  31. package/dist-react/chunk-LX6I32Y4.mjs +106 -0
  32. package/dist-react/chunk-LX6I32Y4.mjs.map +1 -0
  33. package/dist-react/chunk-MCD5FQNY.mjs +428 -0
  34. package/dist-react/chunk-MCD5FQNY.mjs.map +1 -0
  35. package/dist-react/chunk-MD472UKG.mjs +757 -0
  36. package/dist-react/chunk-MD472UKG.mjs.map +1 -0
  37. package/dist-react/chunk-ORNNWQI6.mjs +67 -0
  38. package/dist-react/chunk-ORNNWQI6.mjs.map +1 -0
  39. package/dist-react/chunk-S4J35V4B.mjs +126 -0
  40. package/dist-react/chunk-S4J35V4B.mjs.map +1 -0
  41. package/dist-react/chunk-T53WMN5A.mjs +126 -0
  42. package/dist-react/chunk-T53WMN5A.mjs.map +1 -0
  43. package/dist-react/chunk-UTSRABCL.mjs +96 -0
  44. package/dist-react/chunk-UTSRABCL.mjs.map +1 -0
  45. package/dist-react/incoming-4WP3FJI4.mp3 +0 -0
  46. package/dist-react/incoming.mp3 +0 -0
  47. package/dist-react/index.d.mts +2476 -0
  48. package/dist-react/index.d.ts +2477 -0
  49. package/dist-react/index.js +26713 -0
  50. package/dist-react/index.js.map +1 -0
  51. package/dist-react/index.mjs +4675 -0
  52. package/dist-react/index.mjs.map +1 -0
  53. package/dist-react/liveStatus-IDZ7CPYK.mjs +1087 -0
  54. package/dist-react/liveStatus-IDZ7CPYK.mjs.map +1 -0
  55. package/dist-react/loginReport-F47GUU53.mjs +990 -0
  56. package/dist-react/loginReport-F47GUU53.mjs.map +1 -0
  57. package/dist-react/managementDashboard-GC5E7NEL.mjs +540 -0
  58. package/dist-react/managementDashboard-GC5E7NEL.mjs.map +1 -0
  59. package/dist-react/qualityAuditDashboard-ZAM7HRNH.mjs +76 -0
  60. package/dist-react/qualityAuditDashboard-ZAM7HRNH.mjs.map +1 -0
  61. package/package.json +17 -2
@@ -0,0 +1,23 @@
1
+ import * as __ext_react from "react";
2
+ import * as __ext_react_dom from "react-dom";
3
+ import * as __ext_react_jsx from "react/jsx-runtime";
4
+ var __cjsExternals = { "react": __ext_react, "react-dom": __ext_react_dom, "react/jsx-runtime": __ext_react_jsx };
5
+ var require = function (id) {
6
+ var mod = __cjsExternals[id];
7
+ if (mod) return mod.default || mod;
8
+ throw new Error('Dynamic require of "' + id + '" is not supported');
9
+ };
10
+
11
+ import {
12
+ agentDetailReport_default
13
+ } from "./chunk-MD472UKG.mjs";
14
+ import "./chunk-KRXHK4AU.mjs";
15
+ import "./chunk-LX6I32Y4.mjs";
16
+ import "./chunk-UTSRABCL.mjs";
17
+ import "./chunk-4YF4IDV6.mjs";
18
+ import "./chunk-F7G2XFRU.mjs";
19
+ import "./chunk-S4J35V4B.mjs";
20
+ export {
21
+ agentDetailReport_default as default
22
+ };
23
+ //# sourceMappingURL=agentDetailReport-PDKQKJNL.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,544 @@
1
+ import * as __ext_react from "react";
2
+ import * as __ext_react_dom from "react-dom";
3
+ import * as __ext_react_jsx from "react/jsx-runtime";
4
+ var __cjsExternals = { "react": __ext_react, "react-dom": __ext_react_dom, "react/jsx-runtime": __ext_react_jsx };
5
+ var require = function (id) {
6
+ var mod = __cjsExternals[id];
7
+ if (mod) return mod.default || mod;
8
+ throw new Error('Dynamic require of "' + id + '" is not supported');
9
+ };
10
+
11
+ import {
12
+ ReportFilterBar,
13
+ SearchBar,
14
+ headCellSx,
15
+ reportBodyCellSx,
16
+ sortLabelSx
17
+ } from "./chunk-MCD5FQNY.mjs";
18
+ import {
19
+ SDKPermissionGuard
20
+ } from "./chunk-ADM2JJCP.mjs";
21
+ import {
22
+ agentDetailReport_default
23
+ } from "./chunk-MD472UKG.mjs";
24
+ import {
25
+ PageHeader
26
+ } from "./chunk-KRXHK4AU.mjs";
27
+ import {
28
+ AppButton
29
+ } from "./chunk-LX6I32Y4.mjs";
30
+ import "./chunk-UTSRABCL.mjs";
31
+ import {
32
+ SDKProvider
33
+ } from "./chunk-4YF4IDV6.mjs";
34
+ import {
35
+ END_POINT,
36
+ SDK_PERMISSIONS,
37
+ axios_default
38
+ } from "./chunk-F7G2XFRU.mjs";
39
+ import {
40
+ __spreadProps,
41
+ __spreadValues
42
+ } from "./chunk-S4J35V4B.mjs";
43
+
44
+ // call-control-sdk/lib/pages/agentPerformanceReport/index.tsx
45
+ import { useState as useState2, useEffect, useCallback as useCallback2, useMemo, useRef } from "react";
46
+ import {
47
+ Box,
48
+ Paper,
49
+ Table,
50
+ TableBody,
51
+ TableCell,
52
+ TableContainer,
53
+ TableHead,
54
+ TableRow,
55
+ TableSortLabel,
56
+ TablePagination,
57
+ CircularProgress,
58
+ Alert,
59
+ Stack,
60
+ IconButton
61
+ } from "@mui/material";
62
+ import FileDownloadIcon from "@mui/icons-material/FileDownload";
63
+ import RefreshIcon from "@mui/icons-material/Refresh";
64
+ import VisibilityIcon from "@mui/icons-material/Visibility";
65
+ import dayjs from "dayjs";
66
+ import isoWeek from "dayjs/plugin/isoWeek";
67
+ import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
68
+ import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
69
+
70
+ // call-control-sdk/lib/pages/agentPerformanceReport/useAgentPerformanceReport.ts
71
+ import { useCallback, useState } from "react";
72
+ function fmtSecs(s) {
73
+ if (!s || s <= 0) return "00:00:00";
74
+ const h = Math.floor(s / 3600);
75
+ const m = Math.floor(s % 3600 / 60);
76
+ const sc = Math.floor(s % 60);
77
+ return [h, m, sc].map((x) => String(x).padStart(2, "0")).join(":");
78
+ }
79
+ function validateReportPayload(payload) {
80
+ if (!payload.startDate || !payload.startTime) return { isValid: false, error: "Start date/time required" };
81
+ if (!payload.endDate || !payload.endTime) return { isValid: false, error: "End date/time required" };
82
+ if (!payload.loginUsersOnly && !payload.agents) return { isValid: false, error: "Select at least one agent" };
83
+ return { isValid: true };
84
+ }
85
+ function mapAgentPerfRow(a) {
86
+ var _a;
87
+ return {
88
+ agentDetails: { agentId: a.agentId, fullName: a.fullName, process: a.processName, queueNames: a.queueNames },
89
+ calls: { totalCalls: a.totalCalls, answered: a.answeredCalls, missed: a.missedCalls },
90
+ inCalls: { total: a.inCalls },
91
+ outCalls: { total: a.outCalls },
92
+ average: { holdTime: fmtSecs(a.holdTimeSeconds), wrapUp: fmtSecs(a.wrapupSeconds), aht: fmtSecs(a.ahtSeconds), ringing: "00:00:00", dialing: "00:00:00" },
93
+ loginDetails: { loggedInDuration: fmtSecs(a.loginDurationSeconds), talkTime: fmtSecs(a.talkTimeSeconds), idleTime: fmtSecs(a.idleTimeSeconds) },
94
+ breaks: { shortBreak: fmtSecs(a.breakTimeSeconds), breakCount: a.breakCount, lunch: "00:00:00", tea: "00:00:00", training: "00:00:00", meeting: "00:00:00" },
95
+ loginStats: { firstLogin: a.firstLoginTime || "", noOfLogins: 0 },
96
+ adherence: { pct: (_a = a.adherencePct) != null ? _a : null }
97
+ };
98
+ }
99
+ async function getUserPerformanceReportPaged(payload) {
100
+ var _a, _b, _c, _d, _e, _f, _g, _h;
101
+ const params = {
102
+ start_date: payload.startDate,
103
+ end_date: payload.endDate,
104
+ agent_id: payload.agents,
105
+ queue_id: payload.queueIds && payload.queueIds.length > 0 ? payload.queueIds : void 0,
106
+ page: (_a = payload.page) != null ? _a : 1,
107
+ pageSize: (_b = payload.pageSize) != null ? _b : 10,
108
+ search: payload.search
109
+ };
110
+ const res = await axios_default.get(
111
+ `${END_POINT.AGENT_PERFORMANCE_REPORT}${buildQs(params)}`
112
+ );
113
+ const data = res.data;
114
+ const agentsPage = data == null ? void 0 : data.agents;
115
+ const rawRows = Array.isArray(agentsPage) ? agentsPage : Array.isArray(agentsPage == null ? void 0 : agentsPage.data) ? agentsPage.data : [];
116
+ const rows = rawRows.map(mapAgentPerfRow);
117
+ const total = (_h = (_g = (_e = (_c = agentsPage == null ? void 0 : agentsPage.total) != null ? _c : data == null ? void 0 : data.total) != null ? _e : (_d = data == null ? void 0 : data.pagination) == null ? void 0 : _d.total) != null ? _g : (_f = data == null ? void 0 : data.summary) == null ? void 0 : _f.agentsLoggedIn) != null ? _h : rows.length;
118
+ return { rows, total };
119
+ }
120
+ async function fetchQueues() {
121
+ var _a;
122
+ const res = await axios_default.get(END_POINT.MASTER_QUEUES);
123
+ if (Array.isArray(res.data)) return res.data;
124
+ if (Array.isArray((_a = res.data) == null ? void 0 : _a.data)) return res.data.data;
125
+ return [];
126
+ }
127
+ async function fetchProcesses() {
128
+ var _a;
129
+ const res = await axios_default.get(END_POINT.MASTER_PROCESS);
130
+ if (Array.isArray(res.data)) return res.data;
131
+ if (Array.isArray((_a = res.data) == null ? void 0 : _a.data)) return res.data.data;
132
+ return [];
133
+ }
134
+ function buildQs(params) {
135
+ const qs = new URLSearchParams();
136
+ if (params.start_date) qs.append("start_date", params.start_date);
137
+ if (params.end_date) qs.append("end_date", params.end_date);
138
+ if (params.agent_id) for (const id of params.agent_id) qs.append("agent_id", id);
139
+ if (params.queue_id) for (const id of params.queue_id) qs.append("queue_id", String(id));
140
+ if (params.process_id) for (const id of params.process_id) qs.append("process_id", String(id));
141
+ if (params.top_n) qs.append("top_n", String(params.top_n));
142
+ if (params.search) qs.append("search", params.search);
143
+ if (params.page) qs.append("page", String(params.page));
144
+ if (params.pageSize) qs.append("pageSize", String(params.pageSize));
145
+ const str = qs.toString();
146
+ return str ? `?${str}` : "";
147
+ }
148
+ async function exportAgentPerformanceToExcel(params) {
149
+ var _a;
150
+ const res = await axios_default.get(
151
+ `${END_POINT.AGENT_PERFORMANCE_REPORT_EXPORT_EXCEL}${buildQs(params)}`,
152
+ { responseType: "blob" }
153
+ );
154
+ const url = URL.createObjectURL(new Blob([res.data]));
155
+ const a = document.createElement("a");
156
+ a.href = url;
157
+ a.download = `agent-performance-${(_a = params.start_date) != null ? _a : "export"}.xlsx`;
158
+ a.click();
159
+ URL.revokeObjectURL(url);
160
+ }
161
+
162
+ // call-control-sdk/lib/pages/agentPerformanceReport/index.tsx
163
+ import { jsx, jsxs } from "react/jsx-runtime";
164
+ dayjs.extend(isoWeek);
165
+ var C = {
166
+ navy: "#0d2a56",
167
+ blue: "#1565c8",
168
+ green: "#0a9a62",
169
+ amber: "#c47c00",
170
+ red: "#cc2a2a",
171
+ purple: "#6b3fbf",
172
+ teal: "#0b7a8f",
173
+ bg: "transparent",
174
+ surface: "#fff",
175
+ s2: "#f7f9fc",
176
+ s3: "#eef2f7",
177
+ b1: "rgba(20,50,100,.07)",
178
+ b2: "rgba(20,50,100,.13)",
179
+ t1: "#0d1e35",
180
+ t2: "#364f6e",
181
+ t3: "#7a93b5",
182
+ t4: "#bccad9",
183
+ blt: "#e8f0fc",
184
+ glt: "#e4f6ef",
185
+ alt: "#fdf3e0",
186
+ rlt: "#fde8e8",
187
+ plt: "#f0eafa",
188
+ tlt: "#e3f4f7"
189
+ };
190
+ function parseDur(d) {
191
+ if (!d || d === "00:00:00") return 0;
192
+ const p = d.split(":").map(Number);
193
+ if (p.length === 3) return p[0] * 3600 + p[1] * 60 + p[2];
194
+ if (p.length === 2) return p[0] * 60 + p[1];
195
+ return 0;
196
+ }
197
+ function fmtDur(s) {
198
+ if (!s || s <= 0) return "00:00:00";
199
+ const h = Math.floor(s / 3600);
200
+ const m = Math.floor(s % 3600 / 60);
201
+ const sc = Math.floor(s % 60);
202
+ return [h, m, sc].map((x) => String(x).padStart(2, "0")).join(":");
203
+ }
204
+ function getVal(row, key) {
205
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
206
+ switch (key) {
207
+ case "id":
208
+ return ((_a = row.agentDetails) == null ? void 0 : _a.agentId) || "";
209
+ case "name":
210
+ return ((_b = row.agentDetails) == null ? void 0 : _b.fullName) || "";
211
+ case "process":
212
+ return ((_c = row.agentDetails) == null ? void 0 : _c.process) || "";
213
+ case "queue":
214
+ return ((_d = row.agentDetails) == null ? void 0 : _d.queueNames) || "";
215
+ case "total":
216
+ return (_f = (_e = row.calls) == null ? void 0 : _e.totalCalls) != null ? _f : 0;
217
+ case "ans":
218
+ return (_h = (_g = row.calls) == null ? void 0 : _g.answered) != null ? _h : 0;
219
+ case "miss":
220
+ return (_j = (_i = row.calls) == null ? void 0 : _i.missed) != null ? _j : 0;
221
+ case "inTotal":
222
+ return (_l = (_k = row.inCalls) == null ? void 0 : _k.total) != null ? _l : 0;
223
+ case "outTotal":
224
+ return (_n = (_m = row.outCalls) == null ? void 0 : _m.total) != null ? _n : 0;
225
+ case "aht":
226
+ return parseDur(((_o = row.average) == null ? void 0 : _o.aht) || "00:00:00");
227
+ case "loginDur":
228
+ return parseDur(((_p = row.loginDetails) == null ? void 0 : _p.loggedInDuration) || "00:00:00");
229
+ case "talk":
230
+ return parseDur(((_q = row.loginDetails) == null ? void 0 : _q.talkTime) || "00:00:00");
231
+ case "hold":
232
+ return parseDur(((_r = row.average) == null ? void 0 : _r.holdTime) || "00:00:00");
233
+ case "wrapup":
234
+ return parseDur(((_s = row.average) == null ? void 0 : _s.wrapUp) || "00:00:00");
235
+ case "breakTime":
236
+ return parseDur(((_t = row.breaks) == null ? void 0 : _t.lunch) || "00:00:00") + parseDur(((_u = row.breaks) == null ? void 0 : _u.tea) || "00:00:00") + parseDur(((_v = row.breaks) == null ? void 0 : _v.training) || "00:00:00") + parseDur(((_w = row.breaks) == null ? void 0 : _w.meeting) || "00:00:00") + parseDur(((_x = row.breaks) == null ? void 0 : _x.shortBreak) || "00:00:00");
237
+ case "idle":
238
+ return parseDur(((_y = row.loginDetails) == null ? void 0 : _y.idleTime) || "00:00:00");
239
+ case "adherence":
240
+ return (_A = (_z = row.adherence) == null ? void 0 : _z.pct) != null ? _A : null;
241
+ case "firstLogin":
242
+ return ((_B = row.loginStats) == null ? void 0 : _B.firstLogin) || "";
243
+ default:
244
+ return "";
245
+ }
246
+ }
247
+ var COLUMNS = [
248
+ { key: "id", label: "User ID", group: "Agent" },
249
+ { key: "name", label: "Full Name", group: "Agent" },
250
+ { key: "queue", label: "Queues", group: "Agent" },
251
+ { key: "total", label: "Total Calls", group: "Calls", align: "right" },
252
+ { key: "ans", label: "Answered", group: "Calls", align: "right" },
253
+ { key: "miss", label: "Missed", group: "Calls", align: "right" },
254
+ { key: "inTotal", label: "Inbound", group: "Calls", align: "right" },
255
+ { key: "outTotal", label: "Outbound", group: "Calls", align: "right" },
256
+ { key: "aht", label: "AHT", group: "Time", align: "right" },
257
+ { key: "loginDur", label: "Login Dur", group: "Time", align: "right" },
258
+ { key: "talk", label: "Talk Time", group: "Time", align: "right" },
259
+ { key: "hold", label: "Hold Time", group: "Time", align: "right" },
260
+ { key: "wrapup", label: "Wrapup Time", group: "Time", align: "right" },
261
+ { key: "breakTime", label: "Break Time", group: "Breaks", align: "right" },
262
+ { key: "idle", label: "Idle Time", group: "Time", align: "right" },
263
+ { key: "firstLogin", label: "First Login", group: "Login" },
264
+ { key: "adherence", label: "Adherence %", group: "Agent", align: "right" }
265
+ ];
266
+ function AgentPerformanceReportContent() {
267
+ const [startDate, setStartDate] = useState2(dayjs().startOf("day"));
268
+ const [endDate, setEndDate] = useState2(dayjs());
269
+ const [quickRange, setQuickRange] = useState2("today");
270
+ const [selectedUsers, setSelectedUsers] = useState2([]);
271
+ const [isAllUsersSelected, setIsAllUsersSelected] = useState2(false);
272
+ const [processes, setProcesses] = useState2([]);
273
+ const [process, setProcess] = useState2("");
274
+ const [search, setSearch] = useState2("");
275
+ const [loginUsersOnly] = useState2(true);
276
+ const [queues, setQueues] = useState2([]);
277
+ const [selectedQueues, setSelectedQueues] = useState2([]);
278
+ const [data, setData] = useState2([]);
279
+ const [loading, setLoading] = useState2(false);
280
+ const [error, setError] = useState2("");
281
+ const [selectedAgent, setSelectedAgent] = useState2(null);
282
+ const [orderBy, setOrderBy] = useState2("total");
283
+ const [order, setOrder] = useState2("desc");
284
+ const [page, setPage] = useState2(0);
285
+ const [rowsPerPage, setRowsPerPage] = useState2(10);
286
+ const [totalCount, setTotalCount] = useState2(-1);
287
+ const [visibleCols] = useState2(new Set(COLUMNS.map((c) => c.key)));
288
+ const [debouncedSearch, setDebouncedSearch] = useState2("");
289
+ const debounceRef = useRef(void 0);
290
+ useEffect(() => {
291
+ debounceRef.current = setTimeout(() => setDebouncedSearch(search.trim()), 400);
292
+ return () => clearTimeout(debounceRef.current);
293
+ }, [search]);
294
+ useEffect(() => {
295
+ fetchProcesses().then((p) => {
296
+ const mapped = p.map((x) => ({ label: x.name, value: x.name }));
297
+ setProcesses(mapped);
298
+ if (mapped.length) setProcess(mapped[0].value);
299
+ }).catch(() => {
300
+ });
301
+ fetchQueues().then((data2) => setQueues(data2 || [])).catch(() => {
302
+ });
303
+ }, []);
304
+ const handleQuickRangeChange = (range) => {
305
+ setQuickRange(range);
306
+ };
307
+ const handleRefresh = () => {
308
+ if (quickRange === "today" || quickRange === "week" || quickRange === "month") {
309
+ const now = dayjs();
310
+ let sd = now.startOf("day");
311
+ const ed = now;
312
+ if (quickRange === "week") sd = now.startOf("week").startOf("day");
313
+ else if (quickRange === "month") sd = now.startOf("month").startOf("day");
314
+ setStartDate(sd);
315
+ setEndDate(ed);
316
+ } else {
317
+ fetchReport(page);
318
+ }
319
+ };
320
+ const fetchReport = useCallback2(async (pageNum) => {
321
+ const fromDate = startDate;
322
+ const toDate = endDate;
323
+ if (!fromDate || !toDate) {
324
+ setError("Select date range");
325
+ return;
326
+ }
327
+ const payload = {
328
+ startDate: fromDate.format("YYYY-MM-DDTHH:mm:ss"),
329
+ endDate: toDate.format("YYYY-MM-DDTHH:mm:ss"),
330
+ startTime: fromDate.format("HH:mm:ss"),
331
+ endTime: toDate.format("HH:mm:ss"),
332
+ process,
333
+ agents: isAllUsersSelected ? [] : selectedUsers.map((u) => u.userId),
334
+ loginUsersOnly,
335
+ queueIds: selectedQueues.length > 0 && selectedQueues.length < queues.length ? selectedQueues.map((q) => q.id) : void 0,
336
+ search: debouncedSearch || void 0,
337
+ page: pageNum + 1,
338
+ pageSize: rowsPerPage
339
+ };
340
+ const valid = validateReportPayload(payload);
341
+ if (!valid.isValid) {
342
+ setError(valid.error || "Invalid");
343
+ return;
344
+ }
345
+ try {
346
+ setLoading(true);
347
+ setError("");
348
+ const { rows, total } = await getUserPerformanceReportPaged(payload);
349
+ setData(rows);
350
+ setTotalCount(typeof total === "number" ? total : rows.length);
351
+ } catch (err) {
352
+ setError((err == null ? void 0 : err.message) || "Failed to fetch report");
353
+ setData([]);
354
+ } finally {
355
+ setLoading(false);
356
+ }
357
+ }, [startDate, endDate, process, selectedUsers, isAllUsersSelected, selectedQueues, loginUsersOnly, debouncedSearch, rowsPerPage]);
358
+ useEffect(() => {
359
+ setPage(0);
360
+ fetchReport(0);
361
+ }, [fetchReport]);
362
+ const handlePageChange = useCallback2(
363
+ (_event, newPage) => {
364
+ setPage(newPage);
365
+ fetchReport(newPage);
366
+ },
367
+ [fetchReport]
368
+ );
369
+ const sorted = useMemo(() => {
370
+ return [...data].sort((a, b) => {
371
+ const av = getVal(a, orderBy);
372
+ const bv = getVal(b, orderBy);
373
+ if (typeof av === "number" && typeof bv === "number") return order === "asc" ? av - bv : bv - av;
374
+ return order === "asc" ? String(av).localeCompare(String(bv)) : String(bv).localeCompare(String(av));
375
+ });
376
+ }, [data, orderBy, order]);
377
+ const paged = sorted;
378
+ const handleSort = (key) => {
379
+ setOrder(orderBy === key && order === "asc" ? "desc" : "asc");
380
+ setOrderBy(key);
381
+ };
382
+ const handleExportExcel = async () => {
383
+ const fromDate = startDate;
384
+ const toDate = endDate;
385
+ if (!fromDate || !toDate) {
386
+ setError("Select date range");
387
+ return;
388
+ }
389
+ const params = {
390
+ start_date: fromDate.format("YYYY-MM-DDTHH:mm:ss"),
391
+ end_date: toDate.format("YYYY-MM-DDTHH:mm:ss"),
392
+ agent_id: !isAllUsersSelected && selectedUsers.length > 0 ? selectedUsers.map((u) => u.userId) : void 0,
393
+ queue_id: selectedQueues.length > 0 && selectedQueues.length < queues.length ? selectedQueues.map((q) => q.id) : void 0,
394
+ search: debouncedSearch || void 0
395
+ };
396
+ try {
397
+ await exportAgentPerformanceToExcel(params);
398
+ } catch (err) {
399
+ setError((err == null ? void 0 : err.message) || "Failed to export Excel");
400
+ }
401
+ };
402
+ const renderCellValue = (row, col) => {
403
+ const v = getVal(row, col.key);
404
+ const durKeys = ["aht", "loginDur", "talk", "hold", "wrapup", "breakTime", "idle"];
405
+ if (durKeys.includes(col.key)) return fmtDur(v);
406
+ if (col.key === "adherence") return v != null ? `${v}%` : "\u2014";
407
+ if (col.key === "firstLogin") return v ? dayjs(v).format("DD MMM YYYY hh:mm A") : "";
408
+ return v != null ? v : "";
409
+ };
410
+ const activeCols = COLUMNS.filter((c) => visibleCols.has(c.key));
411
+ if (selectedAgent) {
412
+ return /* @__PURE__ */ jsx(
413
+ agentDetailReport_default,
414
+ {
415
+ agentRow: selectedAgent,
416
+ onBack: () => setSelectedAgent(null),
417
+ initialStartDate: startDate,
418
+ initialEndDate: endDate,
419
+ initialQuickRange: quickRange,
420
+ from: "REPORTS_LIST"
421
+ }
422
+ );
423
+ }
424
+ return /* @__PURE__ */ jsx(LocalizationProvider, { dateAdapter: AdapterDayjs, children: /* @__PURE__ */ jsxs(Box, { sx: { background: C.bg, minHeight: "100vh" }, children: [
425
+ /* @__PURE__ */ jsx(
426
+ PageHeader,
427
+ {
428
+ title: " Performance Report",
429
+ actions: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, children: [
430
+ /* @__PURE__ */ jsx(
431
+ SearchBar,
432
+ {
433
+ value: search,
434
+ onChange: setSearch,
435
+ placeholder: "Search name, ID...",
436
+ width: 250
437
+ }
438
+ ),
439
+ /* @__PURE__ */ jsx(
440
+ SDKPermissionGuard,
441
+ {
442
+ permissions: [SDK_PERMISSIONS.REPORTS_AGENT_PERFORMANCE_EXPORT, SDK_PERMISSIONS.REPORTS_AGENT_PERFORMANCE_MANAGE],
443
+ showFallback: false,
444
+ children: /* @__PURE__ */ jsx(
445
+ AppButton,
446
+ {
447
+ startIcon: /* @__PURE__ */ jsx(FileDownloadIcon, { sx: { fontSize: "0.95rem !important" } }),
448
+ disabled: !data.length,
449
+ onClick: handleExportExcel,
450
+ sx: { height: 36 },
451
+ children: "Export Excel"
452
+ }
453
+ )
454
+ }
455
+ )
456
+ ] })
457
+ }
458
+ ),
459
+ /* @__PURE__ */ jsx(
460
+ ReportFilterBar,
461
+ {
462
+ startDate,
463
+ endDate,
464
+ onStartChange: setStartDate,
465
+ onEndChange: setEndDate,
466
+ quickRange,
467
+ onQuickRangeChange: handleQuickRangeChange,
468
+ showAgentSelect: true,
469
+ selectedAgents: selectedUsers,
470
+ onAgentsChange: setSelectedUsers,
471
+ setIsAllUsersSelected,
472
+ showQueueSelect: true,
473
+ queues,
474
+ selectedQueues,
475
+ onQueuesChange: setSelectedQueues,
476
+ showProcessSelect: true,
477
+ processes,
478
+ selectedProcess: process,
479
+ onProcessChange: setProcess,
480
+ extra: /* @__PURE__ */ jsx(
481
+ AppButton,
482
+ {
483
+ startIcon: /* @__PURE__ */ jsx(RefreshIcon, { sx: { fontSize: "0.9rem !important" } }),
484
+ disabled: loading,
485
+ onClick: handleRefresh,
486
+ sx: { height: 32 },
487
+ children: "Refresh"
488
+ }
489
+ )
490
+ }
491
+ ),
492
+ error && /* @__PURE__ */ jsx(Alert, { severity: "error", sx: { mx: 2.5, mt: 1.5 }, onClose: () => setError(""), children: error }),
493
+ /* @__PURE__ */ jsxs(Box, { sx: { py: 2, px: 1, overflow: "auto", position: "relative" }, children: [
494
+ loading && /* @__PURE__ */ jsx(Box, { sx: { position: "absolute", top: 0, left: 0, right: 0, bottom: 0, background: "rgba(240,244,248,0.7)", display: "flex", alignItems: "center", justifyContent: "center", zIndex: 10 }, children: /* @__PURE__ */ jsx(CircularProgress, {}) }),
495
+ /* @__PURE__ */ jsxs(Paper, { elevation: 0, sx: { borderRadius: "8px", border: "1px solid #e0e7ef", overflow: "hidden", mb: 2 }, children: [
496
+ /* @__PURE__ */ jsx(TableContainer, { children: /* @__PURE__ */ jsxs(Table, { size: "small", sx: {
497
+ minWidth: 1400,
498
+ "& .MuiTableCell-root": { fontSize: "0.75rem", borderBottom: "1px solid #eef1f6", py: 0.6, px: 1 }
499
+ }, children: [
500
+ /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
501
+ activeCols.map((col) => /* @__PURE__ */ jsx(TableCell, { align: col.align || "left", sx: headCellSx, children: /* @__PURE__ */ jsx(TableSortLabel, { active: orderBy === col.key, direction: orderBy === col.key ? order : "asc", onClick: () => handleSort(col.key), sx: sortLabelSx, children: col.label }) }, col.key)),
502
+ /* @__PURE__ */ jsx(TableCell, { sx: __spreadProps(__spreadValues({}, headCellSx), { width: 48 }), children: "Detail" })
503
+ ] }) }),
504
+ /* @__PURE__ */ jsxs(TableBody, { children: [
505
+ paged.map((row, idx) => /* @__PURE__ */ jsxs(TableRow, { hover: true, onClick: () => setSelectedAgent(row), sx: {
506
+ backgroundColor: "#fff",
507
+ "&:hover": { backgroundColor: "#f0f7f8" },
508
+ cursor: "pointer"
509
+ }, children: [
510
+ activeCols.map((col) => /* @__PURE__ */ jsx(TableCell, { align: col.align || "left", sx: reportBodyCellSx, children: renderCellValue(row, col) }, col.key)),
511
+ /* @__PURE__ */ jsx(TableCell, { sx: reportBodyCellSx, align: "center", children: /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: (e) => {
512
+ e.stopPropagation();
513
+ setSelectedAgent(row);
514
+ }, sx: { color: C.blue }, children: /* @__PURE__ */ jsx(VisibilityIcon, { sx: { fontSize: 16 } }) }) })
515
+ ] }, idx)),
516
+ paged.length === 0 && /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colSpan: activeCols.length + 1, sx: { textAlign: "center", py: 4, color: C.t3, fontSize: 13 }, children: "No data found" }) })
517
+ ] })
518
+ ] }) }),
519
+ /* @__PURE__ */ jsx(
520
+ TablePagination,
521
+ {
522
+ component: "div",
523
+ count: totalCount,
524
+ page,
525
+ onPageChange: handlePageChange,
526
+ rowsPerPage,
527
+ onRowsPerPageChange: (e) => {
528
+ setRowsPerPage(parseInt(e.target.value, 10));
529
+ setPage(0);
530
+ },
531
+ rowsPerPageOptions: [10, 15, 25, 50, 100],
532
+ sx: { borderTop: "1px solid #eef1f6", "& .MuiTablePagination-displayedRows": { fontSize: "0.73rem" }, "& .MuiTablePagination-selectLabel": { fontSize: "0.73rem" } }
533
+ }
534
+ )
535
+ ] })
536
+ ] })
537
+ ] }) });
538
+ }
539
+ var AgentPerformanceReport = () => /* @__PURE__ */ jsx(SDKProvider, { children: /* @__PURE__ */ jsx(AgentPerformanceReportContent, {}) });
540
+ var agentPerformanceReport_default = AgentPerformanceReport;
541
+ export {
542
+ agentPerformanceReport_default as default
543
+ };
544
+ //# sourceMappingURL=agentPerformanceReport-MU2FASNN.mjs.map