@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.
Files changed (34) hide show
  1. package/dist/support/components/ui.js +2 -2
  2. package/dist/support/pages/AnalyticsPage.js +144 -113
  3. package/dist/support/pages/AnalyticsPage.js.map +1 -1
  4. package/dist/support/pages/ArticleDetailAdminPage.js +150 -113
  5. package/dist/support/pages/ArticleDetailAdminPage.js.map +1 -1
  6. package/dist/support/pages/ArticleDetailUserPage.js +90 -83
  7. package/dist/support/pages/ArticleDetailUserPage.js.map +1 -1
  8. package/dist/support/pages/ContactInquiriesPage.js +48 -44
  9. package/dist/support/pages/ContactInquiriesPage.js.map +1 -1
  10. package/dist/support/pages/ContactInquiryDetailPage.js +225 -205
  11. package/dist/support/pages/ContactInquiryDetailPage.js.map +1 -1
  12. package/dist/support/pages/CreateArticlePage.js +50 -46
  13. package/dist/support/pages/CreateArticlePage.js.map +1 -1
  14. package/dist/support/pages/CreateTicketPage.js +122 -116
  15. package/dist/support/pages/CreateTicketPage.js.map +1 -1
  16. package/dist/support/pages/EditArticlePage.js +76 -80
  17. package/dist/support/pages/EditArticlePage.js.map +1 -1
  18. package/dist/support/pages/JobApplicationDetailPage.js +292 -269
  19. package/dist/support/pages/JobApplicationDetailPage.js.map +1 -1
  20. package/dist/support/pages/JobApplicationsPage.js +50 -46
  21. package/dist/support/pages/JobApplicationsPage.js.map +1 -1
  22. package/dist/support/pages/KnowledgeBaseAdminPage.js +84 -81
  23. package/dist/support/pages/KnowledgeBaseAdminPage.js.map +1 -1
  24. package/dist/support/pages/KnowledgeBaseUserPage.js +76 -75
  25. package/dist/support/pages/KnowledgeBaseUserPage.js.map +1 -1
  26. package/dist/support/pages/SettingsPage.js +215 -182
  27. package/dist/support/pages/SettingsPage.js.map +1 -1
  28. package/dist/support/pages/TicketDetailAdminPage.js +158 -128
  29. package/dist/support/pages/TicketDetailAdminPage.js.map +1 -1
  30. package/dist/support/pages/TicketDetailUserPage.js +174 -141
  31. package/dist/support/pages/TicketDetailUserPage.js.map +1 -1
  32. package/dist/support/pages/TicketListPage.js +171 -170
  33. package/dist/support/pages/TicketListPage.js.map +1 -1
  34. 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 n, LoadingState as r, PageLayout as i } from "../components/PageLayout.js";
3
- import { tWithFallback as a } from "../utils/i18n.js";
4
- import { useAnalyticsOperations as o } from "../hooks/useAnalyticsOperations.js";
5
- import { MetricCard as s } from "../components/analytics/MetricCard.js";
6
- import { TrendChart as c } from "../components/analytics/TrendChart.js";
7
- import { PriorityBreakdown as l } from "../components/analytics/PriorityBreakdown.js";
8
- import { CategoryBreakdown as u } from "../components/analytics/CategoryBreakdown.js";
9
- import { SLAReport as d } from "../components/analytics/SLAReport.js";
10
- import { TopAgents as f } from "../components/analytics/TopAgents.js";
11
- import { SatisfactionDistribution as p } from "../components/analytics/SatisfactionDistribution.js";
12
- import { BarChart3 as m, Calendar as h, CheckCircle as g, Clock as _, Download as v, ShieldAlert as y, ThumbsUp as b, TrendingUp as x } from "lucide-react";
13
- import { jsx as S, jsxs as C } from "react/jsx-runtime";
14
- import { useI18n as w } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
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 T(e) {
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 E = [
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 D() {
40
- let { t: D } = w(), O = (e, t) => a(D, e, t), { analytics: k, trends: A, slaReport: j, satisfaction: M, agentLeaderboard: N, period: P, analyticsLoading: F, trendsLoading: I, updatePeriod: L, exportReport: R, analyticsError: z, slaReportError: B, satisfactionError: V } = o();
41
- if (T(z) || T(B) || T(V)) return /* @__PURE__ */ S(i, {
42
- title: O("support.analytics.title", "Support Analytics"),
43
- subtitle: O("support.analytics.subtitle", "View support performance metrics"),
44
- icon: /* @__PURE__ */ S(m, { size: 24 }),
45
- children: /* @__PURE__ */ S(n, {
46
- icon: /* @__PURE__ */ S(y, { size: 48 }),
47
- title: O("support.analytics.adminRequired.title", "Admin Access Required"),
48
- description: O("support.analytics.adminRequired.description", "You need administrator privileges to view support analytics. Please contact your workspace admin for access.")
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 (F || I) return /* @__PURE__ */ S(i, {
52
- title: O("support.analytics.title", "Support Analytics"),
53
- subtitle: O("support.analytics.loadingSubtitle", "Loading analytics data..."),
54
- icon: /* @__PURE__ */ S(m, { size: 24 }),
55
- children: /* @__PURE__ */ S(r, { message: O("support.analytics.loading", "Loading analytics...") })
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 (!k || k.stats.totalTickets === 0) return /* @__PURE__ */ S(i, {
58
- title: O("support.analytics.title", "Support Analytics"),
59
- subtitle: O("support.analytics.subtitle", "View support performance metrics"),
60
- icon: /* @__PURE__ */ S(m, { size: 24 }),
61
- children: /* @__PURE__ */ S(n, {
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: O("support.analytics.noData.title", "No analytics data available"),
64
- description: O("support.analytics.noData.description", "Analytics data will appear once there's ticket activity to report.")
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 H = E.find((e) => e.value === P)?.label || "Custom", U = {
68
- startDate: j?.startDate ?? M?.startDate ?? (/* @__PURE__ */ new Date()).toISOString(),
69
- endDate: j?.endDate ?? M?.endDate ?? (/* @__PURE__ */ new Date()).toISOString(),
70
- label: H
71
- }, W = {
72
- total: k.stats.totalTickets,
73
- open: k.stats.openTickets,
74
- resolved: k.stats.resolvedTickets,
75
- avgResponseTimeHours: k.stats.averageFirstResponseTimeHours || 0,
76
- avgResolutionTimeHours: k.stats.averageResolutionTimeHours || 0,
77
- byPriority: k.priorityBreakdown
78
- }, G = {
79
- period: U,
80
- totalTickets: j?.totalTickets ?? k.stats.totalTickets,
81
- firstResponseCompliance: j?.firstResponseCompliance ?? k.stats.slaComplianceRate ?? 0,
82
- resolutionCompliance: j?.resolutionCompliance ?? k.stats.slaComplianceRate ?? 0,
83
- avgFirstResponseTime: j?.averageFirstResponseMinutes || 0,
84
- avgResolutionTime: j?.averageResolutionMinutes || 0,
85
- breachedTickets: j?.totalBreaches ?? 0,
86
- byPriority: (j?.byPriority ?? []).map((e) => ({
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
- }, K = M?.ratingDistribution ?? [], q = {
92
- period: U,
93
- totalResponses: M?.totalResponses ?? 0,
94
- averageRating: M?.averageRating || 0,
95
- csat: M?.csatScore || 0,
96
- nps: M?.npsScore || 0,
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: K.find((e) => e.rating === 1)?.count || 0,
99
- rating2: K.find((e) => e.rating === 2)?.count || 0,
100
- rating3: K.find((e) => e.rating === 3)?.count || 0,
101
- rating4: K.find((e) => e.rating === 4)?.count || 0,
102
- rating5: K.find((e) => e.rating === 5)?.count || 0
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
- }, J = (N?.agents ?? []).map((e) => ({
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
- })), Y = (A.length > 0 ? A : k.ticketTrends).map((e) => ({
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__ */ S(i, {
121
+ return /* @__PURE__ */ w(o, {
122
122
  title: "Support Analytics",
123
- subtitle: H,
124
- icon: /* @__PURE__ */ S(m, { size: 24 }),
125
- headerActions: /* @__PURE__ */ C("div", {
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__ */ C("div", {
127
+ children: [/* @__PURE__ */ T("div", {
128
128
  className: "flex items-center gap-2",
129
- children: [/* @__PURE__ */ S(h, {
129
+ children: [/* @__PURE__ */ w(_, {
130
130
  size: 20,
131
131
  className: "text-text-secondary"
132
- }), /* @__PURE__ */ S("select", {
133
- value: P,
134
- onChange: (e) => L(e.target.value),
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: E.map((e) => /* @__PURE__ */ S("option", {
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__ */ C(e, {
142
- onClick: () => R("PDF"),
143
- children: [/* @__PURE__ */ S(v, { size: 18 }), O("support.analytics.export", "Export")]
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__ */ C("div", {
146
+ children: /* @__PURE__ */ T("div", {
147
147
  className: "space-y-6",
148
148
  children: [
149
- /* @__PURE__ */ S(t, {
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__ */ C("div", {
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__ */ S(s, {
182
+ /* @__PURE__ */ w(l, {
155
183
  title: "Total Tickets",
156
- value: W.total.toString(),
157
- icon: x,
184
+ value: K.total.toString(),
185
+ icon: C,
158
186
  iconColor: "text-primary",
159
- subtitle: `${W.open} open, ${W.resolved} resolved`
187
+ subtitle: `${K.open} open, ${K.resolved} resolved`
160
188
  }),
161
- /* @__PURE__ */ S(s, {
189
+ /* @__PURE__ */ w(l, {
162
190
  title: "Avg Response Time",
163
- value: `${W.avgResponseTimeHours.toFixed(1)}h`,
164
- icon: _,
191
+ value: `${K.avgResponseTimeHours.toFixed(1)}h`,
192
+ icon: y,
165
193
  iconColor: "text-accent",
166
- subtitle: `Resolution: ${W.avgResolutionTimeHours.toFixed(1)}h`
194
+ subtitle: `Resolution: ${K.avgResolutionTimeHours.toFixed(1)}h`
167
195
  }),
168
- /* @__PURE__ */ S(s, {
196
+ /* @__PURE__ */ w(l, {
169
197
  title: "SLA Compliance",
170
- value: `${G.firstResponseCompliance.toFixed(1)}%`,
171
- icon: g,
172
- iconColor: G.firstResponseCompliance >= 90 ? "text-success" : "text-warning",
173
- subtitle: `${G.breachedTickets} breached`
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__ */ S(s, {
203
+ /* @__PURE__ */ w(l, {
176
204
  title: "Satisfaction",
177
- value: q.averageRating.toFixed(1),
178
- icon: b,
205
+ value: Y.averageRating.toFixed(1),
206
+ icon: S,
179
207
  iconColor: "text-success",
180
- subtitle: `CSAT: ${q.csat.toFixed(0)}%, NPS: ${q.nps.toFixed(0)}`
208
+ subtitle: `CSAT: ${Y.csat.toFixed(0)}%, NPS: ${Y.nps.toFixed(0)}`
181
209
  })
182
210
  ]
183
211
  })
184
212
  }),
185
- /* @__PURE__ */ S(c, {
186
- trends: Y,
187
- period: q.period
213
+ /* @__PURE__ */ w(u, {
214
+ trends: Z,
215
+ period: Y.period
188
216
  }),
189
- /* @__PURE__ */ C("div", {
217
+ /* @__PURE__ */ T("div", {
190
218
  className: "grid grid-cols-1 lg:grid-cols-2 gap-6",
191
- children: [/* @__PURE__ */ S(l, { data: W.byPriority }), /* @__PURE__ */ S(u, { data: k.categoryBreakdown })]
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__ */ S(d, { report: G }),
194
- /* @__PURE__ */ C("div", {
225
+ /* @__PURE__ */ T("div", {
195
226
  className: "grid grid-cols-1 lg:grid-cols-2 gap-6",
196
- children: [/* @__PURE__ */ S(p, { metrics: q }), /* @__PURE__ */ S(f, { agents: J })]
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 { D as AnalyticsPage };
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"],"mappings":";;;;;;;;;;;;;;;AAwBA,SAAS,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/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,EAAM,CAAC,aAAa;AAChD,QACE,EAAa,SAAS,YA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