@burdenoff/microfe-support 2026.625.2 → 2026.626.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.
- package/dist/support/components/ui.js +2 -2
- package/dist/support/pages/AnalyticsPage.js +144 -113
- package/dist/support/pages/AnalyticsPage.js.map +1 -1
- package/dist/support/pages/ArticleDetailAdminPage.js +150 -113
- package/dist/support/pages/ArticleDetailAdminPage.js.map +1 -1
- package/dist/support/pages/ArticleDetailUserPage.js +90 -83
- package/dist/support/pages/ArticleDetailUserPage.js.map +1 -1
- package/dist/support/pages/ContactInquiriesPage.js +48 -44
- package/dist/support/pages/ContactInquiriesPage.js.map +1 -1
- package/dist/support/pages/ContactInquiryDetailPage.js +225 -205
- package/dist/support/pages/ContactInquiryDetailPage.js.map +1 -1
- package/dist/support/pages/CreateArticlePage.js +50 -46
- package/dist/support/pages/CreateArticlePage.js.map +1 -1
- package/dist/support/pages/CreateTicketPage.js +122 -116
- package/dist/support/pages/CreateTicketPage.js.map +1 -1
- package/dist/support/pages/EditArticlePage.js +76 -80
- package/dist/support/pages/EditArticlePage.js.map +1 -1
- package/dist/support/pages/JobApplicationDetailPage.js +292 -269
- package/dist/support/pages/JobApplicationDetailPage.js.map +1 -1
- package/dist/support/pages/JobApplicationsPage.js +50 -46
- package/dist/support/pages/JobApplicationsPage.js.map +1 -1
- package/dist/support/pages/KnowledgeBaseAdminPage.js +84 -81
- package/dist/support/pages/KnowledgeBaseAdminPage.js.map +1 -1
- package/dist/support/pages/KnowledgeBaseUserPage.js +76 -75
- package/dist/support/pages/KnowledgeBaseUserPage.js.map +1 -1
- package/dist/support/pages/SettingsPage.js +215 -182
- package/dist/support/pages/SettingsPage.js.map +1 -1
- package/dist/support/pages/TicketDetailAdminPage.js +158 -128
- package/dist/support/pages/TicketDetailAdminPage.js.map +1 -1
- package/dist/support/pages/TicketDetailUserPage.js +174 -141
- package/dist/support/pages/TicketDetailUserPage.js.map +1 -1
- package/dist/support/pages/TicketListPage.js +171 -170
- package/dist/support/pages/TicketListPage.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Badge as e, Button as t, CTAOverflowMenu as n, EmphasisPanel as r, GlassCard as i, Input as a } from "@burdenoff/fe-libs/ui";
|
|
2
|
-
export { e as Badge, t as Button, n as CTAOverflowMenu, r as EmphasisPanel, i as GlassCard, a as Input };
|
|
1
|
+
import { Badge as e, Button as t, CTAOverflowMenu as n, EmphasisPanel as r, GlassCard as i, Input as a, NextSteps as o, PagePurpose as s } from "@burdenoff/fe-libs/ui";
|
|
2
|
+
export { e as Badge, t as Button, n as CTAOverflowMenu, r as EmphasisPanel, i as GlassCard, a as Input, o as NextSteps, s as PagePurpose };
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { Button as e, EmphasisPanel as t } from "../components/ui.js";
|
|
2
|
-
import { EmptyState as
|
|
3
|
-
import { tWithFallback as
|
|
4
|
-
import { useAnalyticsOperations as
|
|
5
|
-
import { MetricCard as
|
|
6
|
-
import { TrendChart as
|
|
7
|
-
import { PriorityBreakdown as
|
|
8
|
-
import { CategoryBreakdown as
|
|
9
|
-
import { SLAReport as
|
|
10
|
-
import { TopAgents as
|
|
11
|
-
import { SatisfactionDistribution as
|
|
12
|
-
import { BarChart3 as
|
|
13
|
-
import { jsx as
|
|
14
|
-
import { useI18n as
|
|
1
|
+
import { Button as e, EmphasisPanel as t, NextSteps as n, PagePurpose as r } from "../components/ui.js";
|
|
2
|
+
import { EmptyState as i, LoadingState as a, PageLayout as o } from "../components/PageLayout.js";
|
|
3
|
+
import { tWithFallback as s } from "../utils/i18n.js";
|
|
4
|
+
import { useAnalyticsOperations as c } from "../hooks/useAnalyticsOperations.js";
|
|
5
|
+
import { MetricCard as l } from "../components/analytics/MetricCard.js";
|
|
6
|
+
import { TrendChart as u } from "../components/analytics/TrendChart.js";
|
|
7
|
+
import { PriorityBreakdown as d } from "../components/analytics/PriorityBreakdown.js";
|
|
8
|
+
import { CategoryBreakdown as f } from "../components/analytics/CategoryBreakdown.js";
|
|
9
|
+
import { SLAReport as p } from "../components/analytics/SLAReport.js";
|
|
10
|
+
import { TopAgents as m } from "../components/analytics/TopAgents.js";
|
|
11
|
+
import { SatisfactionDistribution as h } from "../components/analytics/SatisfactionDistribution.js";
|
|
12
|
+
import { BarChart3 as g, Calendar as _, CheckCircle as v, Clock as y, Download as b, ShieldAlert as x, ThumbsUp as S, TrendingUp as C } from "lucide-react";
|
|
13
|
+
import { jsx as w, jsxs as T } from "react/jsx-runtime";
|
|
14
|
+
import { useI18n as E } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
15
15
|
//#region src/support/pages/AnalyticsPage.tsx
|
|
16
|
-
function
|
|
16
|
+
function D(e) {
|
|
17
17
|
if (!e) return !1;
|
|
18
18
|
let t = String(e).toLowerCase();
|
|
19
19
|
return t.includes("forbidden") || t.includes("not authorized") || t.includes("permission denied") || t.includes("admin");
|
|
20
20
|
}
|
|
21
|
-
var
|
|
21
|
+
var O = [
|
|
22
22
|
{
|
|
23
23
|
value: "LAST_7_DAYS",
|
|
24
24
|
label: "Last 7 Days"
|
|
@@ -36,72 +36,72 @@ var E = [
|
|
|
36
36
|
label: "Last Year"
|
|
37
37
|
}
|
|
38
38
|
];
|
|
39
|
-
function
|
|
40
|
-
let { t:
|
|
41
|
-
if (
|
|
42
|
-
title:
|
|
43
|
-
subtitle:
|
|
44
|
-
icon: /* @__PURE__ */
|
|
45
|
-
children: /* @__PURE__ */
|
|
46
|
-
icon: /* @__PURE__ */
|
|
47
|
-
title:
|
|
48
|
-
description:
|
|
39
|
+
function k() {
|
|
40
|
+
let { t: k } = E(), A = (e, t) => s(k, e, t), { analytics: j, trends: M, slaReport: N, satisfaction: P, agentLeaderboard: F, period: I, analyticsLoading: L, trendsLoading: R, updatePeriod: z, exportReport: B, analyticsError: V, slaReportError: H, satisfactionError: U } = c();
|
|
41
|
+
if (D(V) || D(H) || D(U)) return /* @__PURE__ */ w(o, {
|
|
42
|
+
title: A("support.analytics.title", "Support Analytics"),
|
|
43
|
+
subtitle: A("support.analytics.subtitle", "View support performance metrics"),
|
|
44
|
+
icon: /* @__PURE__ */ w(g, { size: 24 }),
|
|
45
|
+
children: /* @__PURE__ */ w(i, {
|
|
46
|
+
icon: /* @__PURE__ */ w(x, { size: 48 }),
|
|
47
|
+
title: A("support.analytics.adminRequired.title", "Admin Access Required"),
|
|
48
|
+
description: A("support.analytics.adminRequired.description", "You need administrator privileges to view support analytics. Please contact your workspace admin for access.")
|
|
49
49
|
})
|
|
50
50
|
});
|
|
51
|
-
if (
|
|
52
|
-
title:
|
|
53
|
-
subtitle:
|
|
54
|
-
icon: /* @__PURE__ */
|
|
55
|
-
children: /* @__PURE__ */
|
|
51
|
+
if (L || R) return /* @__PURE__ */ w(o, {
|
|
52
|
+
title: A("support.analytics.title", "Support Analytics"),
|
|
53
|
+
subtitle: A("support.analytics.loadingSubtitle", "Loading analytics data..."),
|
|
54
|
+
icon: /* @__PURE__ */ w(g, { size: 24 }),
|
|
55
|
+
children: /* @__PURE__ */ w(a, { message: A("support.analytics.loading", "Loading analytics...") })
|
|
56
56
|
});
|
|
57
|
-
if (!
|
|
58
|
-
title:
|
|
59
|
-
subtitle:
|
|
60
|
-
icon: /* @__PURE__ */
|
|
61
|
-
children: /* @__PURE__ */
|
|
57
|
+
if (!j || j.stats.totalTickets === 0) return /* @__PURE__ */ w(o, {
|
|
58
|
+
title: A("support.analytics.title", "Support Analytics"),
|
|
59
|
+
subtitle: A("support.analytics.subtitle", "View support performance metrics"),
|
|
60
|
+
icon: /* @__PURE__ */ w(g, { size: 24 }),
|
|
61
|
+
children: /* @__PURE__ */ w(i, {
|
|
62
62
|
illustration: "empty-data",
|
|
63
|
-
title:
|
|
64
|
-
description:
|
|
63
|
+
title: A("support.analytics.noData.title", "No analytics data available"),
|
|
64
|
+
description: A("support.analytics.noData.description", "Analytics data will appear once there's ticket activity to report.")
|
|
65
65
|
})
|
|
66
66
|
});
|
|
67
|
-
let
|
|
68
|
-
startDate:
|
|
69
|
-
endDate:
|
|
70
|
-
label:
|
|
71
|
-
},
|
|
72
|
-
total:
|
|
73
|
-
open:
|
|
74
|
-
resolved:
|
|
75
|
-
avgResponseTimeHours:
|
|
76
|
-
avgResolutionTimeHours:
|
|
77
|
-
byPriority:
|
|
78
|
-
},
|
|
79
|
-
period:
|
|
80
|
-
totalTickets:
|
|
81
|
-
firstResponseCompliance:
|
|
82
|
-
resolutionCompliance:
|
|
83
|
-
avgFirstResponseTime:
|
|
84
|
-
avgResolutionTime:
|
|
85
|
-
breachedTickets:
|
|
86
|
-
byPriority: (
|
|
67
|
+
let W = O.find((e) => e.value === I)?.label || "Custom", G = {
|
|
68
|
+
startDate: N?.startDate ?? P?.startDate ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
69
|
+
endDate: N?.endDate ?? P?.endDate ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
70
|
+
label: W
|
|
71
|
+
}, K = {
|
|
72
|
+
total: j.stats.totalTickets,
|
|
73
|
+
open: j.stats.openTickets,
|
|
74
|
+
resolved: j.stats.resolvedTickets,
|
|
75
|
+
avgResponseTimeHours: j.stats.averageFirstResponseTimeHours || 0,
|
|
76
|
+
avgResolutionTimeHours: j.stats.averageResolutionTimeHours || 0,
|
|
77
|
+
byPriority: j.priorityBreakdown
|
|
78
|
+
}, q = {
|
|
79
|
+
period: G,
|
|
80
|
+
totalTickets: N?.totalTickets ?? j.stats.totalTickets,
|
|
81
|
+
firstResponseCompliance: N?.firstResponseCompliance ?? j.stats.slaComplianceRate ?? 0,
|
|
82
|
+
resolutionCompliance: N?.resolutionCompliance ?? j.stats.slaComplianceRate ?? 0,
|
|
83
|
+
avgFirstResponseTime: N?.averageFirstResponseMinutes || 0,
|
|
84
|
+
avgResolutionTime: N?.averageResolutionMinutes || 0,
|
|
85
|
+
breachedTickets: N?.totalBreaches ?? 0,
|
|
86
|
+
byPriority: (N?.byPriority ?? []).map((e) => ({
|
|
87
87
|
priority: e.priority,
|
|
88
88
|
tickets: e.totalTickets,
|
|
89
89
|
compliance: e.resolutionCompliance
|
|
90
90
|
}))
|
|
91
|
-
},
|
|
92
|
-
period:
|
|
93
|
-
totalResponses:
|
|
94
|
-
averageRating:
|
|
95
|
-
csat:
|
|
96
|
-
nps:
|
|
91
|
+
}, J = P?.ratingDistribution ?? [], Y = {
|
|
92
|
+
period: G,
|
|
93
|
+
totalResponses: P?.totalResponses ?? 0,
|
|
94
|
+
averageRating: P?.averageRating || 0,
|
|
95
|
+
csat: P?.csatScore || 0,
|
|
96
|
+
nps: P?.npsScore || 0,
|
|
97
97
|
ratings: {
|
|
98
|
-
rating1:
|
|
99
|
-
rating2:
|
|
100
|
-
rating3:
|
|
101
|
-
rating4:
|
|
102
|
-
rating5:
|
|
98
|
+
rating1: J.find((e) => e.rating === 1)?.count || 0,
|
|
99
|
+
rating2: J.find((e) => e.rating === 2)?.count || 0,
|
|
100
|
+
rating3: J.find((e) => e.rating === 3)?.count || 0,
|
|
101
|
+
rating4: J.find((e) => e.rating === 4)?.count || 0,
|
|
102
|
+
rating5: J.find((e) => e.rating === 5)?.count || 0
|
|
103
103
|
}
|
|
104
|
-
},
|
|
104
|
+
}, X = (F?.agents ?? []).map((e) => ({
|
|
105
105
|
rank: e.rank,
|
|
106
106
|
ticketsResolved: e.ticketsResolved,
|
|
107
107
|
avgRating: e.averageRating || 0,
|
|
@@ -113,93 +113,124 @@ function D() {
|
|
|
113
113
|
email: e.agent.userId
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
})),
|
|
116
|
+
})), Z = (M.length > 0 ? M : j.ticketTrends).map((e) => ({
|
|
117
117
|
timestamp: e.date,
|
|
118
118
|
value: e.count,
|
|
119
119
|
label: e.groupBy
|
|
120
120
|
}));
|
|
121
|
-
return /* @__PURE__ */
|
|
121
|
+
return /* @__PURE__ */ w(o, {
|
|
122
122
|
title: "Support Analytics",
|
|
123
|
-
subtitle:
|
|
124
|
-
icon: /* @__PURE__ */
|
|
125
|
-
headerActions: /* @__PURE__ */
|
|
123
|
+
subtitle: W,
|
|
124
|
+
icon: /* @__PURE__ */ w(g, { size: 24 }),
|
|
125
|
+
headerActions: /* @__PURE__ */ T("div", {
|
|
126
126
|
className: "flex items-center gap-3",
|
|
127
|
-
children: [/* @__PURE__ */
|
|
127
|
+
children: [/* @__PURE__ */ T("div", {
|
|
128
128
|
className: "flex items-center gap-2",
|
|
129
|
-
children: [/* @__PURE__ */
|
|
129
|
+
children: [/* @__PURE__ */ w(_, {
|
|
130
130
|
size: 20,
|
|
131
131
|
className: "text-text-secondary"
|
|
132
|
-
}), /* @__PURE__ */
|
|
133
|
-
value:
|
|
134
|
-
onChange: (e) =>
|
|
132
|
+
}), /* @__PURE__ */ w("select", {
|
|
133
|
+
value: I,
|
|
134
|
+
onChange: (e) => z(e.target.value),
|
|
135
135
|
className: "px-3 py-2 rounded-lg border border-border-subtle bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary",
|
|
136
|
-
children:
|
|
136
|
+
children: O.map((e) => /* @__PURE__ */ w("option", {
|
|
137
137
|
value: e.value,
|
|
138
138
|
children: e.label
|
|
139
139
|
}, e.value))
|
|
140
140
|
})]
|
|
141
|
-
}), /* @__PURE__ */
|
|
142
|
-
onClick: () =>
|
|
143
|
-
children: [/* @__PURE__ */
|
|
141
|
+
}), /* @__PURE__ */ T(e, {
|
|
142
|
+
onClick: () => B("PDF"),
|
|
143
|
+
children: [/* @__PURE__ */ w(b, { size: 18 }), A("support.analytics.export", "Export")]
|
|
144
144
|
})]
|
|
145
145
|
}),
|
|
146
|
-
children: /* @__PURE__ */
|
|
146
|
+
children: /* @__PURE__ */ T("div", {
|
|
147
147
|
className: "space-y-6",
|
|
148
148
|
children: [
|
|
149
|
-
/* @__PURE__ */
|
|
149
|
+
/* @__PURE__ */ w(r, { children: "Measure how your support operation is performing. Track ticket volume, first-response and resolution times, SLA compliance and customer satisfaction so you can spot bottlenecks, balance agent workload, and prove the impact of your team. Adjust the period to compare trends over time." }),
|
|
150
|
+
/* @__PURE__ */ w(n, {
|
|
151
|
+
storageKey: "support-analytics",
|
|
152
|
+
title: "Make the most of your data",
|
|
153
|
+
steps: [
|
|
154
|
+
{
|
|
155
|
+
id: "period",
|
|
156
|
+
label: "Switch the reporting period",
|
|
157
|
+
description: "Compare the last 7, 30, 90 days or a full year to spot trends.",
|
|
158
|
+
onClick: () => z("LAST_90_DAYS")
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
id: "export",
|
|
162
|
+
label: "Export a PDF report",
|
|
163
|
+
description: "Share performance with stakeholders in one click.",
|
|
164
|
+
onClick: () => B("PDF")
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
id: "sla",
|
|
168
|
+
label: "Review SLA compliance",
|
|
169
|
+
description: "Scroll to the SLA report to see where commitments slipped.",
|
|
170
|
+
onClick: () => document.querySelector("[data-tour=\"support-analytics-sla\"]")?.scrollIntoView({
|
|
171
|
+
behavior: "smooth",
|
|
172
|
+
block: "start"
|
|
173
|
+
})
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
}),
|
|
177
|
+
/* @__PURE__ */ w(t, {
|
|
150
178
|
className: "p-4 sm:p-5",
|
|
151
|
-
children: /* @__PURE__ */
|
|
179
|
+
children: /* @__PURE__ */ T("div", {
|
|
152
180
|
className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",
|
|
153
181
|
children: [
|
|
154
|
-
/* @__PURE__ */
|
|
182
|
+
/* @__PURE__ */ w(l, {
|
|
155
183
|
title: "Total Tickets",
|
|
156
|
-
value:
|
|
157
|
-
icon:
|
|
184
|
+
value: K.total.toString(),
|
|
185
|
+
icon: C,
|
|
158
186
|
iconColor: "text-primary",
|
|
159
|
-
subtitle: `${
|
|
187
|
+
subtitle: `${K.open} open, ${K.resolved} resolved`
|
|
160
188
|
}),
|
|
161
|
-
/* @__PURE__ */
|
|
189
|
+
/* @__PURE__ */ w(l, {
|
|
162
190
|
title: "Avg Response Time",
|
|
163
|
-
value: `${
|
|
164
|
-
icon:
|
|
191
|
+
value: `${K.avgResponseTimeHours.toFixed(1)}h`,
|
|
192
|
+
icon: y,
|
|
165
193
|
iconColor: "text-accent",
|
|
166
|
-
subtitle: `Resolution: ${
|
|
194
|
+
subtitle: `Resolution: ${K.avgResolutionTimeHours.toFixed(1)}h`
|
|
167
195
|
}),
|
|
168
|
-
/* @__PURE__ */
|
|
196
|
+
/* @__PURE__ */ w(l, {
|
|
169
197
|
title: "SLA Compliance",
|
|
170
|
-
value: `${
|
|
171
|
-
icon:
|
|
172
|
-
iconColor:
|
|
173
|
-
subtitle: `${
|
|
198
|
+
value: `${q.firstResponseCompliance.toFixed(1)}%`,
|
|
199
|
+
icon: v,
|
|
200
|
+
iconColor: q.firstResponseCompliance >= 90 ? "text-success" : "text-warning",
|
|
201
|
+
subtitle: `${q.breachedTickets} breached`
|
|
174
202
|
}),
|
|
175
|
-
/* @__PURE__ */
|
|
203
|
+
/* @__PURE__ */ w(l, {
|
|
176
204
|
title: "Satisfaction",
|
|
177
|
-
value:
|
|
178
|
-
icon:
|
|
205
|
+
value: Y.averageRating.toFixed(1),
|
|
206
|
+
icon: S,
|
|
179
207
|
iconColor: "text-success",
|
|
180
|
-
subtitle: `CSAT: ${
|
|
208
|
+
subtitle: `CSAT: ${Y.csat.toFixed(0)}%, NPS: ${Y.nps.toFixed(0)}`
|
|
181
209
|
})
|
|
182
210
|
]
|
|
183
211
|
})
|
|
184
212
|
}),
|
|
185
|
-
/* @__PURE__ */
|
|
186
|
-
trends:
|
|
187
|
-
period:
|
|
213
|
+
/* @__PURE__ */ w(u, {
|
|
214
|
+
trends: Z,
|
|
215
|
+
period: Y.period
|
|
188
216
|
}),
|
|
189
|
-
/* @__PURE__ */
|
|
217
|
+
/* @__PURE__ */ T("div", {
|
|
190
218
|
className: "grid grid-cols-1 lg:grid-cols-2 gap-6",
|
|
191
|
-
children: [/* @__PURE__ */
|
|
219
|
+
children: [/* @__PURE__ */ w(d, { data: K.byPriority }), /* @__PURE__ */ w(f, { data: j.categoryBreakdown })]
|
|
220
|
+
}),
|
|
221
|
+
/* @__PURE__ */ w("div", {
|
|
222
|
+
"data-tour": "support-analytics-sla",
|
|
223
|
+
children: /* @__PURE__ */ w(p, { report: q })
|
|
192
224
|
}),
|
|
193
|
-
/* @__PURE__ */
|
|
194
|
-
/* @__PURE__ */ C("div", {
|
|
225
|
+
/* @__PURE__ */ T("div", {
|
|
195
226
|
className: "grid grid-cols-1 lg:grid-cols-2 gap-6",
|
|
196
|
-
children: [/* @__PURE__ */
|
|
227
|
+
children: [/* @__PURE__ */ w(h, { metrics: Y }), /* @__PURE__ */ w(m, { agents: X })]
|
|
197
228
|
})
|
|
198
229
|
]
|
|
199
230
|
})
|
|
200
231
|
});
|
|
201
232
|
}
|
|
202
233
|
//#endregion
|
|
203
|
-
export {
|
|
234
|
+
export { k as AnalyticsPage };
|
|
204
235
|
|
|
205
236
|
//# sourceMappingURL=AnalyticsPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsPage.js","names":[],"sources":["../../../src/support/pages/AnalyticsPage.tsx"],"sourcesContent":["import {\n BarChart3,\n TrendingUp,\n Clock,\n CheckCircle,\n Calendar,\n Download,\n ThumbsUp,\n ShieldAlert,\n} from 'lucide-react';\nimport { Button, EmphasisPanel } from '../components/ui';\nimport { useAnalyticsOperations, type TimePeriod } from '../hooks/useAnalyticsOperations';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { tWithFallback } from '../utils/i18n';\nimport { MetricCard } from '../components/analytics/MetricCard';\nimport { TrendChart } from '../components/analytics/TrendChart';\nimport { PriorityBreakdown } from '../components/analytics/PriorityBreakdown';\nimport { CategoryBreakdown } from '../components/analytics/CategoryBreakdown';\nimport { SLAReport } from '../components/analytics/SLAReport';\nimport { TopAgents } from '../components/analytics/TopAgents';\nimport { SatisfactionDistribution } from '../components/analytics/SatisfactionDistribution';\nimport { PageLayout, LoadingState, EmptyState } from '../components/PageLayout';\n\n// Helper to check if error is a permission/authorization error\nfunction isPermissionError(error: unknown): boolean {\n if (!error) return false;\n const errorMessage = String(error).toLowerCase();\n return (\n errorMessage.includes('forbidden') ||\n errorMessage.includes('not authorized') ||\n errorMessage.includes('permission denied') ||\n errorMessage.includes('admin')\n );\n}\n\nconst periodOptions: { value: TimePeriod; label: string }[] = [\n { value: 'LAST_7_DAYS' as TimePeriod, label: 'Last 7 Days' },\n { value: 'LAST_30_DAYS' as TimePeriod, label: 'Last 30 Days' },\n { value: 'LAST_90_DAYS' as TimePeriod, label: 'Last 90 Days' },\n { value: 'LAST_YEAR' as TimePeriod, label: 'Last Year' },\n];\n\nexport function AnalyticsPage() {\n const { t } = useI18n();\n const tr = (key: string, fallback: string) => tWithFallback(t, key, fallback);\n const {\n analytics,\n trends,\n slaReport,\n satisfaction,\n agentLeaderboard,\n period,\n analyticsLoading,\n trendsLoading,\n updatePeriod,\n exportReport,\n analyticsError,\n slaReportError,\n satisfactionError,\n } = useAnalyticsOperations();\n\n // Check for permission errors across all analytics queries\n const hasPermissionError =\n isPermissionError(analyticsError) ||\n isPermissionError(slaReportError) ||\n isPermissionError(satisfactionError);\n\n if (hasPermissionError) {\n return (\n <PageLayout\n title={tr('support.analytics.title', 'Support Analytics')}\n subtitle={tr('support.analytics.subtitle', 'View support performance metrics')}\n icon={<BarChart3 size={24} />}\n >\n <EmptyState\n icon={<ShieldAlert size={48} />}\n title={tr('support.analytics.adminRequired.title', 'Admin Access Required')}\n description={tr(\n 'support.analytics.adminRequired.description',\n 'You need administrator privileges to view support analytics. Please contact your workspace admin for access.'\n )}\n />\n </PageLayout>\n );\n }\n\n if (analyticsLoading || trendsLoading) {\n return (\n <PageLayout\n title={tr('support.analytics.title', 'Support Analytics')}\n subtitle={tr('support.analytics.loadingSubtitle', 'Loading analytics data...')}\n icon={<BarChart3 size={24} />}\n >\n <LoadingState message={tr('support.analytics.loading', 'Loading analytics...')} />\n </PageLayout>\n );\n }\n\n if (!analytics || analytics.stats.totalTickets === 0) {\n return (\n <PageLayout\n title={tr('support.analytics.title', 'Support Analytics')}\n subtitle={tr('support.analytics.subtitle', 'View support performance metrics')}\n icon={<BarChart3 size={24} />}\n >\n <EmptyState\n illustration=\"empty-data\"\n title={tr('support.analytics.noData.title', 'No analytics data available')}\n description={tr(\n 'support.analytics.noData.description',\n \"Analytics data will appear once there's ticket activity to report.\"\n )}\n />\n </PageLayout>\n );\n }\n\n const periodLabel = periodOptions.find((option) => option.value === period)?.label || 'Custom';\n const periodRange = {\n startDate: slaReport?.startDate ?? satisfaction?.startDate ?? new Date().toISOString(),\n endDate: slaReport?.endDate ?? satisfaction?.endDate ?? new Date().toISOString(),\n label: periodLabel,\n };\n const ticketStats = {\n total: analytics.stats.totalTickets,\n open: analytics.stats.openTickets,\n resolved: analytics.stats.resolvedTickets,\n avgResponseTimeHours: analytics.stats.averageFirstResponseTimeHours || 0,\n avgResolutionTimeHours: analytics.stats.averageResolutionTimeHours || 0,\n byPriority: analytics.priorityBreakdown,\n };\n const transformedSlaReport = {\n period: periodRange,\n totalTickets: slaReport?.totalTickets ?? analytics.stats.totalTickets,\n firstResponseCompliance:\n slaReport?.firstResponseCompliance ?? analytics.stats.slaComplianceRate ?? 0,\n resolutionCompliance: slaReport?.resolutionCompliance ?? analytics.stats.slaComplianceRate ?? 0,\n avgFirstResponseTime: slaReport?.averageFirstResponseMinutes || 0,\n avgResolutionTime: slaReport?.averageResolutionMinutes || 0,\n breachedTickets: slaReport?.totalBreaches ?? 0,\n byPriority: (slaReport?.byPriority ?? []).map(\n (item: { priority: string; totalTickets: number; resolutionCompliance: number }) => ({\n priority: item.priority,\n tickets: item.totalTickets,\n compliance: item.resolutionCompliance,\n })\n ),\n };\n const ratingDistribution = satisfaction?.ratingDistribution ?? [];\n const satisfactionMetrics = {\n period: periodRange,\n totalResponses: satisfaction?.totalResponses ?? 0,\n averageRating: satisfaction?.averageRating || 0,\n csat: satisfaction?.csatScore || 0,\n nps: satisfaction?.npsScore || 0,\n ratings: {\n rating1:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 1)\n ?.count || 0,\n rating2:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 2)\n ?.count || 0,\n rating3:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 3)\n ?.count || 0,\n rating4:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 4)\n ?.count || 0,\n rating5:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 5)\n ?.count || 0,\n },\n };\n const topAgents = (agentLeaderboard?.agents ?? []).map(\n (item: {\n rank: number;\n ticketsResolved: number;\n averageRating?: number | null;\n agent: { id: string; userId: string };\n }) => ({\n rank: item.rank,\n ticketsResolved: item.ticketsResolved,\n avgRating: item.averageRating || 0,\n agent: {\n id: item.agent.id,\n user: {\n id: item.agent.userId,\n name: item.agent.userId,\n email: item.agent.userId,\n },\n },\n })\n );\n const trendSource = trends.length > 0 ? trends : analytics.ticketTrends;\n const trendChartData = trendSource.map(\n (trend: { date: string; count: number; groupBy: string }) => ({\n timestamp: trend.date,\n value: trend.count,\n label: trend.groupBy,\n })\n );\n\n return (\n <PageLayout\n title=\"Support Analytics\"\n subtitle={periodLabel}\n icon={<BarChart3 size={24} />}\n headerActions={\n <div className=\"flex items-center gap-3\">\n {/* Period Selector */}\n <div className=\"flex items-center gap-2\">\n <Calendar size={20} className=\"text-text-secondary\" />\n <select\n value={period}\n onChange={(e) => updatePeriod(e.target.value as TimePeriod)}\n className=\"px-3 py-2 rounded-lg border border-border-subtle bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary\"\n >\n {periodOptions.map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n </div>\n\n {/* Export Button */}\n <Button onClick={() => exportReport('PDF')}>\n <Download size={18} />\n {tr('support.analytics.export', 'Export')}\n </Button>\n </div>\n }\n >\n <div className=\"space-y-6\">\n {/* Key Metrics — the single emphasis zone of the analytics page */}\n <EmphasisPanel className=\"p-4 sm:p-5\">\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4\">\n <MetricCard\n title=\"Total Tickets\"\n value={ticketStats.total.toString()}\n icon={TrendingUp}\n iconColor=\"text-primary\"\n subtitle={`${ticketStats.open} open, ${ticketStats.resolved} resolved`}\n />\n <MetricCard\n title=\"Avg Response Time\"\n value={`${ticketStats.avgResponseTimeHours.toFixed(1)}h`}\n icon={Clock}\n iconColor=\"text-accent\"\n subtitle={`Resolution: ${ticketStats.avgResolutionTimeHours.toFixed(1)}h`}\n />\n <MetricCard\n title=\"SLA Compliance\"\n value={`${transformedSlaReport.firstResponseCompliance.toFixed(1)}%`}\n icon={CheckCircle}\n iconColor={\n transformedSlaReport.firstResponseCompliance >= 90 ? 'text-success' : 'text-warning'\n }\n subtitle={`${transformedSlaReport.breachedTickets} breached`}\n />\n <MetricCard\n title=\"Satisfaction\"\n value={satisfactionMetrics.averageRating.toFixed(1)}\n icon={ThumbsUp}\n iconColor=\"text-success\"\n subtitle={`CSAT: ${satisfactionMetrics.csat.toFixed(0)}%, NPS: ${satisfactionMetrics.nps.toFixed(0)}`}\n />\n </div>\n </EmphasisPanel>\n\n {/* Ticket Trends Chart */}\n <TrendChart trends={trendChartData} period={satisfactionMetrics.period} />\n\n {/* Breakdowns Row */}\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-6\">\n <PriorityBreakdown data={ticketStats.byPriority} />\n <CategoryBreakdown data={analytics.categoryBreakdown} />\n </div>\n\n {/* SLA Report */}\n <SLAReport report={transformedSlaReport} />\n\n {/* Bottom Row */}\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-6\">\n <SatisfactionDistribution metrics={satisfactionMetrics} />\n <TopAgents agents={topAgents} />\n </div>\n </div>\n </PageLayout>\n );\n}\n"],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
+
{"version":3,"file":"AnalyticsPage.js","names":[],"sources":["../../../src/support/pages/AnalyticsPage.tsx"],"sourcesContent":["import {\n BarChart3,\n TrendingUp,\n Clock,\n CheckCircle,\n Calendar,\n Download,\n ThumbsUp,\n ShieldAlert,\n} from 'lucide-react';\nimport { Button, EmphasisPanel, PagePurpose, NextSteps } from '../components/ui';\nimport { useAnalyticsOperations, type TimePeriod } from '../hooks/useAnalyticsOperations';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { tWithFallback } from '../utils/i18n';\nimport { MetricCard } from '../components/analytics/MetricCard';\nimport { TrendChart } from '../components/analytics/TrendChart';\nimport { PriorityBreakdown } from '../components/analytics/PriorityBreakdown';\nimport { CategoryBreakdown } from '../components/analytics/CategoryBreakdown';\nimport { SLAReport } from '../components/analytics/SLAReport';\nimport { TopAgents } from '../components/analytics/TopAgents';\nimport { SatisfactionDistribution } from '../components/analytics/SatisfactionDistribution';\nimport { PageLayout, LoadingState, EmptyState } from '../components/PageLayout';\n\n// Helper to check if error is a permission/authorization error\nfunction isPermissionError(error: unknown): boolean {\n if (!error) return false;\n const errorMessage = String(error).toLowerCase();\n return (\n errorMessage.includes('forbidden') ||\n errorMessage.includes('not authorized') ||\n errorMessage.includes('permission denied') ||\n errorMessage.includes('admin')\n );\n}\n\nconst periodOptions: { value: TimePeriod; label: string }[] = [\n { value: 'LAST_7_DAYS' as TimePeriod, label: 'Last 7 Days' },\n { value: 'LAST_30_DAYS' as TimePeriod, label: 'Last 30 Days' },\n { value: 'LAST_90_DAYS' as TimePeriod, label: 'Last 90 Days' },\n { value: 'LAST_YEAR' as TimePeriod, label: 'Last Year' },\n];\n\nexport function AnalyticsPage() {\n const { t } = useI18n();\n const tr = (key: string, fallback: string) => tWithFallback(t, key, fallback);\n const {\n analytics,\n trends,\n slaReport,\n satisfaction,\n agentLeaderboard,\n period,\n analyticsLoading,\n trendsLoading,\n updatePeriod,\n exportReport,\n analyticsError,\n slaReportError,\n satisfactionError,\n } = useAnalyticsOperations();\n\n // Check for permission errors across all analytics queries\n const hasPermissionError =\n isPermissionError(analyticsError) ||\n isPermissionError(slaReportError) ||\n isPermissionError(satisfactionError);\n\n if (hasPermissionError) {\n return (\n <PageLayout\n title={tr('support.analytics.title', 'Support Analytics')}\n subtitle={tr('support.analytics.subtitle', 'View support performance metrics')}\n icon={<BarChart3 size={24} />}\n >\n <EmptyState\n icon={<ShieldAlert size={48} />}\n title={tr('support.analytics.adminRequired.title', 'Admin Access Required')}\n description={tr(\n 'support.analytics.adminRequired.description',\n 'You need administrator privileges to view support analytics. Please contact your workspace admin for access.'\n )}\n />\n </PageLayout>\n );\n }\n\n if (analyticsLoading || trendsLoading) {\n return (\n <PageLayout\n title={tr('support.analytics.title', 'Support Analytics')}\n subtitle={tr('support.analytics.loadingSubtitle', 'Loading analytics data...')}\n icon={<BarChart3 size={24} />}\n >\n <LoadingState message={tr('support.analytics.loading', 'Loading analytics...')} />\n </PageLayout>\n );\n }\n\n if (!analytics || analytics.stats.totalTickets === 0) {\n return (\n <PageLayout\n title={tr('support.analytics.title', 'Support Analytics')}\n subtitle={tr('support.analytics.subtitle', 'View support performance metrics')}\n icon={<BarChart3 size={24} />}\n >\n <EmptyState\n illustration=\"empty-data\"\n title={tr('support.analytics.noData.title', 'No analytics data available')}\n description={tr(\n 'support.analytics.noData.description',\n \"Analytics data will appear once there's ticket activity to report.\"\n )}\n />\n </PageLayout>\n );\n }\n\n const periodLabel = periodOptions.find((option) => option.value === period)?.label || 'Custom';\n const periodRange = {\n startDate: slaReport?.startDate ?? satisfaction?.startDate ?? new Date().toISOString(),\n endDate: slaReport?.endDate ?? satisfaction?.endDate ?? new Date().toISOString(),\n label: periodLabel,\n };\n const ticketStats = {\n total: analytics.stats.totalTickets,\n open: analytics.stats.openTickets,\n resolved: analytics.stats.resolvedTickets,\n avgResponseTimeHours: analytics.stats.averageFirstResponseTimeHours || 0,\n avgResolutionTimeHours: analytics.stats.averageResolutionTimeHours || 0,\n byPriority: analytics.priorityBreakdown,\n };\n const transformedSlaReport = {\n period: periodRange,\n totalTickets: slaReport?.totalTickets ?? analytics.stats.totalTickets,\n firstResponseCompliance:\n slaReport?.firstResponseCompliance ?? analytics.stats.slaComplianceRate ?? 0,\n resolutionCompliance: slaReport?.resolutionCompliance ?? analytics.stats.slaComplianceRate ?? 0,\n avgFirstResponseTime: slaReport?.averageFirstResponseMinutes || 0,\n avgResolutionTime: slaReport?.averageResolutionMinutes || 0,\n breachedTickets: slaReport?.totalBreaches ?? 0,\n byPriority: (slaReport?.byPriority ?? []).map(\n (item: { priority: string; totalTickets: number; resolutionCompliance: number }) => ({\n priority: item.priority,\n tickets: item.totalTickets,\n compliance: item.resolutionCompliance,\n })\n ),\n };\n const ratingDistribution = satisfaction?.ratingDistribution ?? [];\n const satisfactionMetrics = {\n period: periodRange,\n totalResponses: satisfaction?.totalResponses ?? 0,\n averageRating: satisfaction?.averageRating || 0,\n csat: satisfaction?.csatScore || 0,\n nps: satisfaction?.npsScore || 0,\n ratings: {\n rating1:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 1)\n ?.count || 0,\n rating2:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 2)\n ?.count || 0,\n rating3:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 3)\n ?.count || 0,\n rating4:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 4)\n ?.count || 0,\n rating5:\n ratingDistribution.find((item: { rating: number; count: number }) => item.rating === 5)\n ?.count || 0,\n },\n };\n const topAgents = (agentLeaderboard?.agents ?? []).map(\n (item: {\n rank: number;\n ticketsResolved: number;\n averageRating?: number | null;\n agent: { id: string; userId: string };\n }) => ({\n rank: item.rank,\n ticketsResolved: item.ticketsResolved,\n avgRating: item.averageRating || 0,\n agent: {\n id: item.agent.id,\n user: {\n id: item.agent.userId,\n name: item.agent.userId,\n email: item.agent.userId,\n },\n },\n })\n );\n const trendSource = trends.length > 0 ? trends : analytics.ticketTrends;\n const trendChartData = trendSource.map(\n (trend: { date: string; count: number; groupBy: string }) => ({\n timestamp: trend.date,\n value: trend.count,\n label: trend.groupBy,\n })\n );\n\n return (\n <PageLayout\n title=\"Support Analytics\"\n subtitle={periodLabel}\n icon={<BarChart3 size={24} />}\n headerActions={\n <div className=\"flex items-center gap-3\">\n {/* Period Selector */}\n <div className=\"flex items-center gap-2\">\n <Calendar size={20} className=\"text-text-secondary\" />\n <select\n value={period}\n onChange={(e) => updatePeriod(e.target.value as TimePeriod)}\n className=\"px-3 py-2 rounded-lg border border-border-subtle bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary\"\n >\n {periodOptions.map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n </div>\n\n {/* Export Button */}\n <Button onClick={() => exportReport('PDF')}>\n <Download size={18} />\n {tr('support.analytics.export', 'Export')}\n </Button>\n </div>\n }\n >\n <div className=\"space-y-6\">\n <PagePurpose>\n Measure how your support operation is performing. Track ticket volume, first-response and\n resolution times, SLA compliance and customer satisfaction so you can spot bottlenecks,\n balance agent workload, and prove the impact of your team. Adjust the period to compare\n trends over time.\n </PagePurpose>\n\n <NextSteps\n storageKey=\"support-analytics\"\n title=\"Make the most of your data\"\n steps={[\n {\n id: 'period',\n label: 'Switch the reporting period',\n description: 'Compare the last 7, 30, 90 days or a full year to spot trends.',\n onClick: () => updatePeriod('LAST_90_DAYS' as TimePeriod),\n },\n {\n id: 'export',\n label: 'Export a PDF report',\n description: 'Share performance with stakeholders in one click.',\n onClick: () => exportReport('PDF'),\n },\n {\n id: 'sla',\n label: 'Review SLA compliance',\n description: 'Scroll to the SLA report to see where commitments slipped.',\n onClick: () =>\n document\n .querySelector('[data-tour=\"support-analytics-sla\"]')\n ?.scrollIntoView({ behavior: 'smooth', block: 'start' }),\n },\n ]}\n />\n\n {/* Key Metrics — the single emphasis zone of the analytics page */}\n <EmphasisPanel className=\"p-4 sm:p-5\">\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4\">\n <MetricCard\n title=\"Total Tickets\"\n value={ticketStats.total.toString()}\n icon={TrendingUp}\n iconColor=\"text-primary\"\n subtitle={`${ticketStats.open} open, ${ticketStats.resolved} resolved`}\n />\n <MetricCard\n title=\"Avg Response Time\"\n value={`${ticketStats.avgResponseTimeHours.toFixed(1)}h`}\n icon={Clock}\n iconColor=\"text-accent\"\n subtitle={`Resolution: ${ticketStats.avgResolutionTimeHours.toFixed(1)}h`}\n />\n <MetricCard\n title=\"SLA Compliance\"\n value={`${transformedSlaReport.firstResponseCompliance.toFixed(1)}%`}\n icon={CheckCircle}\n iconColor={\n transformedSlaReport.firstResponseCompliance >= 90 ? 'text-success' : 'text-warning'\n }\n subtitle={`${transformedSlaReport.breachedTickets} breached`}\n />\n <MetricCard\n title=\"Satisfaction\"\n value={satisfactionMetrics.averageRating.toFixed(1)}\n icon={ThumbsUp}\n iconColor=\"text-success\"\n subtitle={`CSAT: ${satisfactionMetrics.csat.toFixed(0)}%, NPS: ${satisfactionMetrics.nps.toFixed(0)}`}\n />\n </div>\n </EmphasisPanel>\n\n {/* Ticket Trends Chart */}\n <TrendChart trends={trendChartData} period={satisfactionMetrics.period} />\n\n {/* Breakdowns Row */}\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-6\">\n <PriorityBreakdown data={ticketStats.byPriority} />\n <CategoryBreakdown data={analytics.categoryBreakdown} />\n </div>\n\n {/* SLA Report */}\n <div data-tour=\"support-analytics-sla\">\n <SLAReport report={transformedSlaReport} />\n </div>\n\n {/* Bottom Row */}\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-6\">\n <SatisfactionDistribution metrics={satisfactionMetrics} />\n <TopAgents agents={topAgents} />\n </div>\n </div>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,SAAS,EAAkB,GAAyB;AAClD,KAAI,CAAC,EAAO,QAAO;CACnB,IAAM,IAAe,OAAO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