@consilioweb/payload-support 0.8.2 → 0.9.4

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 (50) hide show
  1. package/dist/components/RichTextEditor/index.cjs +233 -0
  2. package/dist/components/RichTextEditor/index.js +232 -0
  3. package/dist/components/TicketConversation/components/CodeBlock.cjs +24 -7
  4. package/dist/components/TicketConversation/components/CodeBlock.js +23 -9
  5. package/dist/index.cjs +19 -1
  6. package/dist/index.js +19 -1
  7. package/dist/views/BillingView/client.cjs +260 -103
  8. package/dist/views/BillingView/client.js +259 -103
  9. package/dist/views/ChatView/client.cjs +184 -137
  10. package/dist/views/ChatView/client.js +180 -137
  11. package/dist/views/CrmView/client.cjs +270 -122
  12. package/dist/views/CrmView/client.js +266 -122
  13. package/dist/views/EmailTrackingView/client.cjs +80 -69
  14. package/dist/views/EmailTrackingView/client.js +80 -70
  15. package/dist/views/ImportConversationView/client.cjs +127 -94
  16. package/dist/views/ImportConversationView/client.js +123 -94
  17. package/dist/views/LogsView/client.cjs +56 -58
  18. package/dist/views/LogsView/client.js +52 -58
  19. package/dist/views/NewTicketView/client.cjs +39 -55
  20. package/dist/views/NewTicketView/client.js +38 -55
  21. package/dist/views/PendingEmailsView/client.cjs +399 -102
  22. package/dist/views/PendingEmailsView/client.js +396 -103
  23. package/dist/views/SupportDashboardView/client.cjs +276 -137
  24. package/dist/views/SupportDashboardView/client.js +275 -137
  25. package/dist/views/TicketDetailView/client.cjs +487 -204
  26. package/dist/views/TicketDetailView/client.js +486 -204
  27. package/dist/views/TicketInboxView/client.cjs +62 -65
  28. package/dist/views/TicketInboxView/client.js +62 -66
  29. package/dist/views/TicketingSettingsView/client.cjs +10 -8
  30. package/dist/views/TicketingSettingsView/client.js +10 -8
  31. package/dist/views/TimeDashboardView/client.cjs +70 -59
  32. package/dist/views/TimeDashboardView/client.js +69 -59
  33. package/package.json +6 -2
  34. package/src/components/RichTextEditor/index.tsx +261 -0
  35. package/src/components/TicketConversation/components/CodeBlock.tsx +53 -14
  36. package/src/plugin.ts +2 -0
  37. package/src/utils/emailTemplate.ts +37 -0
  38. package/src/views/BillingView/client.tsx +362 -69
  39. package/src/views/ChatView/client.tsx +225 -140
  40. package/src/views/CrmView/client.tsx +447 -189
  41. package/src/views/EmailTrackingView/client.tsx +111 -71
  42. package/src/views/ImportConversationView/client.tsx +255 -70
  43. package/src/views/LogsView/client.tsx +85 -50
  44. package/src/views/NewTicketView/client.tsx +37 -53
  45. package/src/views/PendingEmailsView/client.tsx +512 -92
  46. package/src/views/SupportDashboardView/client.tsx +294 -134
  47. package/src/views/TicketDetailView/client.tsx +486 -213
  48. package/src/views/TicketInboxView/client.tsx +52 -61
  49. package/src/views/TicketingSettingsView/client.tsx +10 -9
  50. package/src/views/TimeDashboardView/client.tsx +184 -69
@@ -3,6 +3,7 @@ import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { useState, useCallback, useEffect, useMemo } from 'react';
4
4
  import Link from 'next/link';
5
5
  import { useTranslation } from '../../components/TicketConversation/hooks/useTranslation.js';
6
+ import styles from '../../styles/SupportDashboard.module.scss';
6
7
 
7
8
  function formatResponseTime(hours) {
8
9
  if (hours == null) return "--";
@@ -30,17 +31,80 @@ function computeTrend(current, previous) {
30
31
  if (pct === 0) return { pct: 0, dir: "neutral" };
31
32
  return { pct: Math.abs(pct), dir: pct > 0 ? "up" : "down" };
32
33
  }
33
- function StatCard({ label, value, trend, accentColor }) {
34
- return /* @__PURE__ */ jsxs("div", { style: { padding: "16px 20px", borderRadius: 10, border: "1px solid var(--theme-elevation-150)", background: "var(--theme-elevation-0)", borderLeft: `3px solid ${accentColor || "#2563eb"}` }, children: [
35
- /* @__PURE__ */ jsx("div", { style: { fontSize: 12, color: "var(--theme-elevation-500)", marginBottom: 4 }, children: label }),
36
- /* @__PURE__ */ jsx("div", { style: { fontSize: 24, fontWeight: 700, color: "var(--theme-text)" }, children: value }),
37
- trend && trend.dir !== "neutral" && /* @__PURE__ */ jsxs("div", { style: { fontSize: 11, color: trend.dir === "up" ? "#dc2626" : "#16a34a", marginTop: 4 }, children: [
38
- trend.dir === "up" ? "\u2191" : "\u2193",
39
- " ",
40
- trend.pct,
41
- "%"
34
+ function StatCard({ label, value, trend, accentColor, onClick }) {
35
+ const style = accentColor ? { "--stat-accent": accentColor } : void 0;
36
+ const Tag = onClick ? "button" : "div";
37
+ return /* @__PURE__ */ jsxs(
38
+ Tag,
39
+ {
40
+ className: styles.statCard,
41
+ style,
42
+ onClick,
43
+ type: onClick ? "button" : void 0,
44
+ children: [
45
+ /* @__PURE__ */ jsx("div", { className: styles.statLabel, children: label }),
46
+ /* @__PURE__ */ jsx("div", { className: styles.statValueRow, children: /* @__PURE__ */ jsx("span", { className: styles.statValue, children: value }) }),
47
+ trend && trend.dir !== "neutral" && /* @__PURE__ */ jsxs("div", { className: `${styles.statTrend} ${styles[trend.dir]}`, children: [
48
+ /* @__PURE__ */ jsx("span", { className: styles.trendArrow, children: trend.dir === "up" ? "\u2191" : "\u2193" }),
49
+ trend.pct,
50
+ "%"
51
+ ] }),
52
+ trend && trend.dir === "neutral" && /* @__PURE__ */ jsx("div", { className: `${styles.statTrend} ${styles.neutral}`, children: "\u2014 stable" })
53
+ ]
54
+ }
55
+ );
56
+ }
57
+ function VolumeChart({ data }) {
58
+ const max = Math.max(...data.map((d) => d.value), 1);
59
+ return /* @__PURE__ */ jsxs("div", { children: [
60
+ /* @__PURE__ */ jsx("div", { className: styles.volumeChart, children: data.map((d, i) => /* @__PURE__ */ jsx(
61
+ "div",
62
+ {
63
+ className: styles.volumeBar,
64
+ style: { height: `${Math.max(d.value / max * 100, 5)}%` },
65
+ title: `${d.label}: ${d.value}`
66
+ },
67
+ i
68
+ )) }),
69
+ /* @__PURE__ */ jsxs("div", { className: styles.volumeLabels, children: [
70
+ /* @__PURE__ */ jsx("span", { children: data[0]?.label }),
71
+ /* @__PURE__ */ jsx("span", { children: data[data.length - 1]?.label })
72
+ ] })
73
+ ] });
74
+ }
75
+ function CSATRing({ score, count }) {
76
+ const pct = score > 0 ? score / 5 * 100 : 0;
77
+ const radius = 42;
78
+ const circumference = 2 * Math.PI * radius;
79
+ const strokeDashoffset = circumference - pct / 100 * circumference;
80
+ const color = score >= 4 ? "#22c55e" : score >= 3 ? "#f59e0b" : score > 0 ? "#ef4444" : "#94a3b8";
81
+ return /* @__PURE__ */ jsxs("div", { className: styles.csatContainer, children: [
82
+ /* @__PURE__ */ jsxs("div", { className: styles.csatRing, children: [
83
+ /* @__PURE__ */ jsxs("svg", { width: "100", height: "100", viewBox: "0 0 100 100", children: [
84
+ /* @__PURE__ */ jsx("circle", { cx: "50", cy: "50", r: radius, fill: "none", stroke: "var(--theme-elevation-150, #e2e8f0)", strokeWidth: "6" }),
85
+ /* @__PURE__ */ jsx(
86
+ "circle",
87
+ {
88
+ cx: "50",
89
+ cy: "50",
90
+ r: radius,
91
+ fill: "none",
92
+ stroke: color,
93
+ strokeWidth: "6",
94
+ strokeLinecap: "round",
95
+ strokeDasharray: circumference,
96
+ strokeDashoffset,
97
+ transform: "rotate(-90 50 50)",
98
+ style: { transition: "stroke-dashoffset 600ms ease" }
99
+ }
100
+ )
101
+ ] }),
102
+ /* @__PURE__ */ jsx("div", { className: styles.csatValue, children: score > 0 ? score.toFixed(1) : "--" })
42
103
  ] }),
43
- trend && trend.dir === "neutral" && /* @__PURE__ */ jsx("div", { style: { fontSize: 11, color: "#6b7280", marginTop: 4 }, children: "-- stable" })
104
+ /* @__PURE__ */ jsxs("div", { className: styles.csatMeta, children: [
105
+ /* @__PURE__ */ jsx("div", { className: styles.csatLabel, children: score > 0 ? `${score.toFixed(1)} / 5` : "Pas de donn\xE9es" }),
106
+ /* @__PURE__ */ jsx("div", { className: styles.csatSub, children: count > 0 ? `${count} avis recueillis` : "Aucun avis" })
107
+ ] })
44
108
  ] });
45
109
  }
46
110
  function formatSlaTime(minutes) {
@@ -54,14 +118,15 @@ function formatSlaTime(minutes) {
54
118
  return remainH > 0 ? `${d}j ${remainH}h` : `${d}j`;
55
119
  }
56
120
  function SlaSection() {
57
- const { t } = useTranslation();
58
121
  const [sla, setSla] = useState(null);
59
122
  const [slaLoading, setSlaLoading] = useState(true);
60
123
  useEffect(() => {
61
124
  const fetchSla = async () => {
62
125
  try {
63
126
  const res = await fetch("/api/support/sla-check");
64
- if (res.ok) setSla(await res.json());
127
+ if (res.ok) {
128
+ setSla(await res.json());
129
+ }
65
130
  } catch {
66
131
  }
67
132
  setSlaLoading(false);
@@ -70,58 +135,96 @@ function SlaSection() {
70
135
  const interval = setInterval(fetchSla, 6e4);
71
136
  return () => clearInterval(interval);
72
137
  }, []);
73
- if (slaLoading) return /* @__PURE__ */ jsx("div", { style: { padding: 16, color: "#94a3b8", fontSize: 13 }, children: t("sla.loading") });
138
+ if (slaLoading) {
139
+ return /* @__PURE__ */ jsxs("div", { className: styles.slaSection, children: [
140
+ /* @__PURE__ */ jsx("h2", { className: styles.slaSectionTitle, children: "SLA" }),
141
+ /* @__PURE__ */ jsx("div", { className: styles.slaLoading, children: "Chargement..." })
142
+ ] });
143
+ }
74
144
  if (!sla) return null;
75
- return /* @__PURE__ */ jsxs("div", { style: { marginTop: 24 }, children: [
76
- /* @__PURE__ */ jsx("h2", { style: { fontSize: 16, fontWeight: 700, marginBottom: 12, color: "var(--theme-text)" }, children: t("sla.title") }),
77
- /* @__PURE__ */ jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 16 }, children: [
78
- /* @__PURE__ */ jsxs("div", { style: { padding: 16, borderRadius: 10, border: "1px solid #fecaca", background: "#fef2f2" }, children: [
79
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", marginBottom: 8 }, children: [
80
- /* @__PURE__ */ jsx("h3", { style: { fontSize: 14, fontWeight: 700, color: "#dc2626", margin: 0 }, children: t("sla.breached") }),
81
- /* @__PURE__ */ jsx("span", { style: { padding: "2px 8px", borderRadius: 10, background: "#fecaca", color: "#dc2626", fontSize: 12, fontWeight: 700 }, children: sla.breached.length })
82
- ] }),
83
- sla.breached.length === 0 ? /* @__PURE__ */ jsx("div", { style: { fontSize: 13, color: "#6b7280" }, children: t("sla.noBreached") }) : /* @__PURE__ */ jsx("ul", { style: { listStyle: "none", margin: 0, padding: 0 }, children: sla.breached.map((ticket) => {
84
- const overdueMin = Math.round((Date.now() - new Date(ticket.createdAt).getTime()) / 6e4);
85
- return /* @__PURE__ */ jsxs("li", { style: { padding: "6px 0", borderBottom: "1px solid #fecaca", cursor: "pointer", display: "flex", justifyContent: "space-between", alignItems: "center", fontSize: 13 }, onClick: () => {
86
- window.location.href = `/admin/support/ticket?id=${ticket.id}`;
87
- }, children: [
88
- /* @__PURE__ */ jsxs("div", { children: [
89
- /* @__PURE__ */ jsxs("span", { style: { fontWeight: 600 }, children: [
90
- "#",
91
- ticket.ticketNumber
92
- ] }),
93
- " ",
94
- /* @__PURE__ */ jsx("span", { style: { color: "#6b7280" }, children: ticket.subject })
145
+ const navigateToTicket = (id) => {
146
+ window.location.href = `/admin/support/ticket?id=${id}`;
147
+ };
148
+ return /* @__PURE__ */ jsxs("div", { className: styles.slaSection, children: [
149
+ /* @__PURE__ */ jsx("h2", { className: styles.slaSectionTitle, children: "SLA" }),
150
+ /* @__PURE__ */ jsxs("div", { className: styles.slaGrid, children: [
151
+ /* @__PURE__ */ jsxs("div", { className: `${styles.slaCard} ${styles.slaBreach}`, children: [
152
+ /* @__PURE__ */ jsxs("div", { className: styles.slaCardHeader, children: [
153
+ /* @__PURE__ */ jsxs("h3", { className: `${styles.slaCardTitle} ${styles.slaCardTitleBreach}`, children: [
154
+ /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
155
+ /* @__PURE__ */ jsx("path", { d: "M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" }),
156
+ /* @__PURE__ */ jsx("line", { x1: "12", y1: "9", x2: "12", y2: "13" }),
157
+ /* @__PURE__ */ jsx("line", { x1: "12", y1: "17", x2: "12.01", y2: "17" })
95
158
  ] }),
96
- /* @__PURE__ */ jsxs("span", { style: { color: "#dc2626", fontWeight: 600, fontSize: 12 }, children: [
97
- "+",
98
- formatSlaTime(overdueMin)
99
- ] })
100
- ] }, ticket.id);
159
+ "En breach"
160
+ ] }),
161
+ /* @__PURE__ */ jsx("span", { className: `${styles.slaCount} ${styles.slaCountBreach}`, children: sla.breached.length })
162
+ ] }),
163
+ sla.breached.length === 0 ? /* @__PURE__ */ jsx("div", { className: styles.slaEmpty, children: "Aucun ticket en breach" }) : /* @__PURE__ */ jsx("ul", { className: styles.slaList, children: sla.breached.map((ticket) => {
164
+ const now = /* @__PURE__ */ new Date();
165
+ const created = new Date(ticket.createdAt);
166
+ const overdueMin = Math.round((now.getTime() - created.getTime()) / 6e4);
167
+ return /* @__PURE__ */ jsxs(
168
+ "li",
169
+ {
170
+ className: styles.slaItem,
171
+ onClick: () => navigateToTicket(ticket.id),
172
+ children: [
173
+ /* @__PURE__ */ jsxs("div", { className: styles.slaItemLeft, children: [
174
+ /* @__PURE__ */ jsxs("span", { className: styles.slaItemNum, children: [
175
+ "#",
176
+ ticket.ticketNumber
177
+ ] }),
178
+ /* @__PURE__ */ jsx("span", { className: styles.slaItemSubject, children: ticket.subject })
179
+ ] }),
180
+ /* @__PURE__ */ jsxs("span", { className: `${styles.slaItemTime} ${styles.slaTimeBreach}`, children: [
181
+ "+",
182
+ formatSlaTime(overdueMin)
183
+ ] })
184
+ ]
185
+ },
186
+ ticket.id
187
+ );
101
188
  }) })
102
189
  ] }),
103
- /* @__PURE__ */ jsxs("div", { style: { padding: 16, borderRadius: 10, border: "1px solid #fde68a", background: "#fefce8" }, children: [
104
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", marginBottom: 8 }, children: [
105
- /* @__PURE__ */ jsx("h3", { style: { fontSize: 14, fontWeight: 700, color: "#d97706", margin: 0 }, children: t("sla.atRisk") }),
106
- /* @__PURE__ */ jsx("span", { style: { padding: "2px 8px", borderRadius: 10, background: "#fde68a", color: "#d97706", fontSize: 12, fontWeight: 700 }, children: sla.atRisk.length })
190
+ /* @__PURE__ */ jsxs("div", { className: `${styles.slaCard} ${styles.slaRisk}`, children: [
191
+ /* @__PURE__ */ jsxs("div", { className: styles.slaCardHeader, children: [
192
+ /* @__PURE__ */ jsxs("h3", { className: `${styles.slaCardTitle} ${styles.slaCardTitleRisk}`, children: [
193
+ /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
194
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
195
+ /* @__PURE__ */ jsx("polyline", { points: "12 6 12 12 16 14" })
196
+ ] }),
197
+ "\xC0 risque"
198
+ ] }),
199
+ /* @__PURE__ */ jsx("span", { className: `${styles.slaCount} ${styles.slaCountRisk}`, children: sla.atRisk.length })
107
200
  ] }),
108
- sla.atRisk.length === 0 ? /* @__PURE__ */ jsx("div", { style: { fontSize: 13, color: "#6b7280" }, children: t("sla.noAtRisk") }) : /* @__PURE__ */ jsx("ul", { style: { listStyle: "none", margin: 0, padding: 0 }, children: sla.atRisk.map((ticket) => {
109
- const elapsedMin = Math.round((Date.now() - new Date(ticket.createdAt).getTime()) / 6e4);
201
+ sla.atRisk.length === 0 ? /* @__PURE__ */ jsx("div", { className: styles.slaEmpty, children: "Aucun ticket \xE0 risque" }) : /* @__PURE__ */ jsx("ul", { className: styles.slaList, children: sla.atRisk.map((ticket) => {
202
+ const now = /* @__PURE__ */ new Date();
203
+ const created = new Date(ticket.createdAt);
204
+ const elapsedMin = Math.round((now.getTime() - created.getTime()) / 6e4);
110
205
  const estimatedTotalMin = Math.round(elapsedMin / 0.8);
111
206
  const remainingMin = Math.max(estimatedTotalMin - elapsedMin, 0);
112
- return /* @__PURE__ */ jsxs("li", { style: { padding: "6px 0", borderBottom: "1px solid #fde68a", cursor: "pointer", display: "flex", justifyContent: "space-between", alignItems: "center", fontSize: 13 }, onClick: () => {
113
- window.location.href = `/admin/support/ticket?id=${ticket.id}`;
114
- }, children: [
115
- /* @__PURE__ */ jsxs("div", { children: [
116
- /* @__PURE__ */ jsxs("span", { style: { fontWeight: 600 }, children: [
117
- "#",
118
- ticket.ticketNumber
119
- ] }),
120
- " ",
121
- /* @__PURE__ */ jsx("span", { style: { color: "#6b7280" }, children: ticket.subject })
122
- ] }),
123
- /* @__PURE__ */ jsx("span", { style: { color: "#d97706", fontWeight: 600, fontSize: 12 }, children: t("sla.remaining", { time: formatSlaTime(remainingMin) }) })
124
- ] }, ticket.id);
207
+ return /* @__PURE__ */ jsxs(
208
+ "li",
209
+ {
210
+ className: styles.slaItem,
211
+ onClick: () => navigateToTicket(ticket.id),
212
+ children: [
213
+ /* @__PURE__ */ jsxs("div", { className: styles.slaItemLeft, children: [
214
+ /* @__PURE__ */ jsxs("span", { className: styles.slaItemNum, children: [
215
+ "#",
216
+ ticket.ticketNumber
217
+ ] }),
218
+ /* @__PURE__ */ jsx("span", { className: styles.slaItemSubject, children: ticket.subject })
219
+ ] }),
220
+ /* @__PURE__ */ jsxs("span", { className: `${styles.slaItemTime} ${styles.slaTimeRisk}`, children: [
221
+ formatSlaTime(remainingMin),
222
+ " restant"
223
+ ] })
224
+ ]
225
+ },
226
+ ticket.id
227
+ );
125
228
  }) })
126
229
  ] })
127
230
  ] })
@@ -168,24 +271,34 @@ const SupportDashboardClient = () => {
168
271
  const volumeData = useMemo(() => {
169
272
  if (!stats) return [];
170
273
  const avg = stats.createdLast7Days;
171
- const days = [t("dashboard.weekDays.mon"), t("dashboard.weekDays.tue"), t("dashboard.weekDays.wed"), t("dashboard.weekDays.thu"), t("dashboard.weekDays.fri"), t("dashboard.weekDays.sat"), t("dashboard.weekDays.sun")];
274
+ const days = ["Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dim"];
172
275
  const base = Math.max(Math.floor(avg / 7), 0);
173
276
  return days.map((label, i) => ({
174
277
  label,
278
+ // Simple deterministic variation based on index
175
279
  value: Math.max(base + (i * 3 + 1) % 5 - 2, 0)
176
280
  }));
177
- }, [stats, t]);
281
+ }, [stats]);
178
282
  if (loading) {
179
- return /* @__PURE__ */ jsxs("div", { style: { padding: "20px 30px", maxWidth: 1100, margin: "0 auto" }, children: [
180
- /* @__PURE__ */ jsx("h1", { style: { fontSize: 24, fontWeight: 700 }, children: t("dashboard.title") }),
181
- /* @__PURE__ */ jsx("p", { style: { color: "#94a3b8" }, children: t("dashboard.loadingMetrics") }),
182
- /* @__PURE__ */ jsx("div", { style: { display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 16, marginTop: 20 }, children: [0, 1, 2, 3].map((i) => /* @__PURE__ */ jsx("div", { style: { height: 80, borderRadius: 10, background: "#f1f5f9" } }, i)) })
283
+ return /* @__PURE__ */ jsxs("div", { className: styles.page, children: [
284
+ /* @__PURE__ */ jsxs("div", { className: styles.header, children: [
285
+ /* @__PURE__ */ jsx("h1", { className: styles.title, children: t("dashboard.title") }),
286
+ /* @__PURE__ */ jsx("p", { className: styles.subtitle, children: t("dashboard.loadingMetrics") })
287
+ ] }),
288
+ /* @__PURE__ */ jsx("div", { className: styles.statsRow, children: [0, 1, 2, 3].map((i) => /* @__PURE__ */ jsx("div", { className: styles.skeletonCard }, i)) }),
289
+ /* @__PURE__ */ jsxs("div", { className: styles.middleGrid, children: [
290
+ /* @__PURE__ */ jsx("div", { className: styles.skeletonTable }),
291
+ /* @__PURE__ */ jsxs("div", { className: styles.rightColumn, children: [
292
+ /* @__PURE__ */ jsx("div", { className: styles.skeletonChart }),
293
+ /* @__PURE__ */ jsx("div", { className: styles.skeletonChart })
294
+ ] })
295
+ ] })
183
296
  ] });
184
297
  }
185
298
  if (!stats) {
186
- return /* @__PURE__ */ jsx("div", { style: { padding: "20px 30px", maxWidth: 1100, margin: "0 auto" }, children: /* @__PURE__ */ jsxs("div", { style: { padding: 40, textAlign: "center", color: "#dc2626" }, children: [
299
+ return /* @__PURE__ */ jsx("div", { className: styles.page, children: /* @__PURE__ */ jsxs("div", { className: styles.errorState, children: [
187
300
  /* @__PURE__ */ jsx("strong", { children: t("dashboard.loadError") }),
188
- /* @__PURE__ */ jsx("p", { children: sessionExpired ? t("common.sessionExpired") : t("dashboard.cannotLoadStats") })
301
+ sessionExpired ? t("common.sessionExpired") : t("dashboard.cannotLoadStats")
189
302
  ] }) });
190
303
  }
191
304
  const openCount = stats.byStatus.open || 0;
@@ -197,98 +310,123 @@ const SupportDashboardClient = () => {
197
310
  if (typeof ticket.client === "string") return ticket.client;
198
311
  return ticket.client.company || ticket.client.firstName || "--";
199
312
  };
200
- const statusDotColor = (status) => {
313
+ const getStatusDotClass = (status) => {
201
314
  switch (status) {
202
315
  case "open":
203
- return "#22c55e";
316
+ return styles.statusDotOpen;
204
317
  case "waiting_client":
205
- return "#eab308";
318
+ return styles.statusDotWaiting;
206
319
  case "resolved":
207
- return "#94a3b8";
320
+ return styles.statusDotResolved;
208
321
  default:
209
- return "#94a3b8";
322
+ return "";
210
323
  }
211
324
  };
212
- const maxVolume = Math.max(...volumeData.map((d) => d.value), 1);
213
- const csatScore = stats.satisfactionAvg;
214
- const csatPct = csatScore > 0 ? csatScore / 5 * 100 : 0;
215
- const csatRadius = 42;
216
- const csatCircumference = 2 * Math.PI * csatRadius;
217
- const csatStrokeDashoffset = csatCircumference - csatPct / 100 * csatCircumference;
218
- const csatColor = csatScore >= 4 ? "#22c55e" : csatScore >= 3 ? "#f59e0b" : csatScore > 0 ? "#ef4444" : "#94a3b8";
219
- return /* @__PURE__ */ jsxs("div", { style: { padding: "20px 30px", maxWidth: 1100, margin: "0 auto" }, children: [
220
- /* @__PURE__ */ jsxs("div", { style: { marginBottom: 20 }, children: [
221
- /* @__PURE__ */ jsx("h1", { style: { fontSize: 24, fontWeight: 700, margin: 0, color: "var(--theme-text)" }, children: t("dashboard.title") }),
222
- /* @__PURE__ */ jsx("p", { style: { color: "var(--theme-elevation-500)", margin: "4px 0 0", fontSize: 14 }, children: t("dashboard.subtitle") })
325
+ return /* @__PURE__ */ jsxs("div", { className: styles.page, children: [
326
+ /* @__PURE__ */ jsxs("div", { className: styles.header, children: [
327
+ /* @__PURE__ */ jsx("h1", { className: styles.title, children: t("dashboard.title") }),
328
+ /* @__PURE__ */ jsx("p", { className: styles.subtitle, children: t("dashboard.subtitle") })
223
329
  ] }),
224
- /* @__PURE__ */ jsxs("div", { style: { display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 16, marginBottom: 24 }, children: [
225
- /* @__PURE__ */ jsx(StatCard, { label: t("dashboard.openTickets"), value: String(openCount), trend: trendOpen, accentColor: "#3b82f6" }),
226
- /* @__PURE__ */ jsx(StatCard, { label: t("dashboard.waitingClient"), value: String(waitingCount), trend: waitingTrend, accentColor: "#f59e0b" }),
227
- /* @__PURE__ */ jsx(StatCard, { label: t("dashboard.responseTime"), value: formatResponseTime(stats.avgResponseTimeHours), accentColor: stats.avgResponseTimeHours != null && stats.avgResponseTimeHours > 24 ? "#ef4444" : "#22c55e" }),
228
- /* @__PURE__ */ jsx(StatCard, { label: t("dashboard.satisfaction"), value: stats.satisfactionAvg > 0 ? `${stats.satisfactionAvg}/5` : "--", accentColor: stats.satisfactionAvg >= 4 ? "#22c55e" : stats.satisfactionAvg >= 3 ? "#f59e0b" : "#94a3b8" })
330
+ /* @__PURE__ */ jsxs("div", { className: styles.statsRow, children: [
331
+ /* @__PURE__ */ jsx(
332
+ StatCard,
333
+ {
334
+ label: t("dashboard.openTickets"),
335
+ value: String(openCount),
336
+ trend: trendOpen,
337
+ accentColor: "#3b82f6"
338
+ }
339
+ ),
340
+ /* @__PURE__ */ jsx(
341
+ StatCard,
342
+ {
343
+ label: t("dashboard.waitingClient"),
344
+ value: String(waitingCount),
345
+ trend: waitingTrend,
346
+ accentColor: "#f59e0b"
347
+ }
348
+ ),
349
+ /* @__PURE__ */ jsx(
350
+ StatCard,
351
+ {
352
+ label: t("dashboard.responseTime"),
353
+ value: formatResponseTime(stats.avgResponseTimeHours),
354
+ accentColor: stats.avgResponseTimeHours != null && stats.avgResponseTimeHours > 24 ? "#ef4444" : "#22c55e"
355
+ }
356
+ ),
357
+ /* @__PURE__ */ jsx(
358
+ StatCard,
359
+ {
360
+ label: t("dashboard.satisfaction"),
361
+ value: stats.satisfactionAvg > 0 ? `${stats.satisfactionAvg}/5` : "--",
362
+ accentColor: stats.satisfactionAvg >= 4 ? "#22c55e" : stats.satisfactionAvg >= 3 ? "#f59e0b" : "#94a3b8"
363
+ }
364
+ )
229
365
  ] }),
230
- /* @__PURE__ */ jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 320px", gap: 20, marginBottom: 24 }, children: [
231
- /* @__PURE__ */ jsxs("div", { style: { padding: 16, borderRadius: 10, border: "1px solid var(--theme-elevation-150)" }, children: [
232
- /* @__PURE__ */ jsx("h2", { style: { fontSize: 15, fontWeight: 700, margin: "0 0 12px", color: "var(--theme-text)" }, children: t("dashboard.activeTickets") }),
233
- tickets.length === 0 ? /* @__PURE__ */ jsx("div", { style: { padding: 20, textAlign: "center", color: "#94a3b8" }, children: t("dashboard.noActiveTickets") }) : /* @__PURE__ */ jsxs("table", { style: { width: "100%", borderCollapse: "collapse", fontSize: 13 }, children: [
366
+ /* @__PURE__ */ jsxs("div", { className: styles.middleGrid, children: [
367
+ /* @__PURE__ */ jsxs("div", { className: styles.panel, children: [
368
+ /* @__PURE__ */ jsx("h2", { className: styles.panelTitle, children: t("dashboard.activeTickets") }),
369
+ tickets.length === 0 ? /* @__PURE__ */ jsx("div", { className: styles.emptyTable, children: t("dashboard.noActiveTickets") }) : /* @__PURE__ */ jsxs("table", { className: styles.ticketTable, children: [
234
370
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
235
- /* @__PURE__ */ jsx("th", { style: { textAlign: "left", padding: "6px 8px", borderBottom: "1px solid var(--theme-elevation-200)", fontSize: 11, color: "var(--theme-elevation-500)" }, children: t("dashboard.tableHeaders.status") }),
236
- /* @__PURE__ */ jsx("th", { style: { textAlign: "left", padding: "6px 8px", borderBottom: "1px solid var(--theme-elevation-200)", fontSize: 11, color: "var(--theme-elevation-500)" }, children: t("dashboard.tableHeaders.number") }),
237
- /* @__PURE__ */ jsx("th", { style: { textAlign: "left", padding: "6px 8px", borderBottom: "1px solid var(--theme-elevation-200)", fontSize: 11, color: "var(--theme-elevation-500)" }, children: t("dashboard.tableHeaders.subject") }),
238
- /* @__PURE__ */ jsx("th", { style: { textAlign: "left", padding: "6px 8px", borderBottom: "1px solid var(--theme-elevation-200)", fontSize: 11, color: "var(--theme-elevation-500)" }, children: t("dashboard.tableHeaders.client") }),
239
- /* @__PURE__ */ jsx("th", { style: { textAlign: "left", padding: "6px 8px", borderBottom: "1px solid var(--theme-elevation-200)", fontSize: 11, color: "var(--theme-elevation-500)" }, children: t("dashboard.tableHeaders.modified") })
371
+ /* @__PURE__ */ jsx("th", { children: t("dashboard.tableHeaders.status") }),
372
+ /* @__PURE__ */ jsx("th", { children: t("dashboard.tableHeaders.number") }),
373
+ /* @__PURE__ */ jsx("th", { children: t("dashboard.tableHeaders.subject") }),
374
+ /* @__PURE__ */ jsx("th", { children: t("dashboard.tableHeaders.client") }),
375
+ /* @__PURE__ */ jsx("th", { children: t("dashboard.tableHeaders.modified") }),
376
+ /* @__PURE__ */ jsx("th", {})
240
377
  ] }) }),
241
- /* @__PURE__ */ jsx("tbody", { children: tickets.map((tk) => /* @__PURE__ */ jsxs("tr", { style: { cursor: "pointer" }, onClick: () => {
242
- window.location.href = `/admin/support/ticket?id=${tk.id}`;
243
- }, children: [
244
- /* @__PURE__ */ jsx("td", { style: { padding: "8px" }, children: /* @__PURE__ */ jsx("span", { style: { width: 8, height: 8, borderRadius: "50%", display: "inline-block", backgroundColor: statusDotColor(tk.status) } }) }),
245
- /* @__PURE__ */ jsxs("td", { style: { padding: "8px", fontWeight: 600, fontSize: 12 }, children: [
246
- "#",
247
- tk.ticketNumber
248
- ] }),
249
- /* @__PURE__ */ jsx("td", { style: { padding: "8px", maxWidth: 250, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: tk.subject }),
250
- /* @__PURE__ */ jsx("td", { style: { padding: "8px", color: "var(--theme-elevation-500)", fontSize: 12 }, children: getClientName(tk) }),
251
- /* @__PURE__ */ jsx("td", { style: { padding: "8px", color: "var(--theme-elevation-400)", fontSize: 12 }, children: timeAgo(tk.updatedAt) })
252
- ] }, tk.id)) })
378
+ /* @__PURE__ */ jsx("tbody", { children: tickets.map((tk) => /* @__PURE__ */ jsxs(
379
+ "tr",
380
+ {
381
+ onClick: () => {
382
+ window.location.href = `/admin/support/ticket?id=${tk.id}`;
383
+ },
384
+ children: [
385
+ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx("span", { className: `${styles.statusDot} ${getStatusDotClass(tk.status)}` }) }),
386
+ /* @__PURE__ */ jsxs("td", { className: styles.ticketNum, children: [
387
+ "#",
388
+ tk.ticketNumber
389
+ ] }),
390
+ /* @__PURE__ */ jsx("td", { className: styles.ticketSubject, children: tk.subject }),
391
+ /* @__PURE__ */ jsx("td", { className: styles.ticketClient, children: getClientName(tk) }),
392
+ /* @__PURE__ */ jsx("td", { className: styles.ticketTime, children: timeAgo(tk.updatedAt) }),
393
+ /* @__PURE__ */ jsx("td", { className: styles.ticketArrow, children: "\u2192" })
394
+ ]
395
+ },
396
+ tk.id
397
+ )) })
253
398
  ] })
254
399
  ] }),
255
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 16 }, children: [
256
- /* @__PURE__ */ jsxs("div", { style: { padding: 16, borderRadius: 10, border: "1px solid var(--theme-elevation-150)" }, children: [
257
- /* @__PURE__ */ jsx("h2", { style: { fontSize: 15, fontWeight: 700, margin: "0 0 12px", color: "var(--theme-text)" }, children: t("dashboard.volume7days") }),
258
- /* @__PURE__ */ jsx("div", { style: { display: "flex", alignItems: "flex-end", gap: 4, height: 80 }, children: volumeData.map((d, i) => /* @__PURE__ */ jsx("div", { style: { flex: 1, background: "#3b82f6", borderRadius: "3px 3px 0 0", height: `${Math.max(d.value / maxVolume * 100, 5)}%` }, title: `${d.label}: ${d.value}` }, i)) }),
259
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", fontSize: 10, color: "var(--theme-elevation-400)", marginTop: 4 }, children: [
260
- /* @__PURE__ */ jsx("span", { children: volumeData[0]?.label }),
261
- /* @__PURE__ */ jsx("span", { children: volumeData[volumeData.length - 1]?.label })
262
- ] })
400
+ /* @__PURE__ */ jsxs("div", { className: styles.rightColumn, children: [
401
+ /* @__PURE__ */ jsxs("div", { className: styles.panel, children: [
402
+ /* @__PURE__ */ jsx("h2", { className: styles.panelTitle, children: t("dashboard.volume7days") }),
403
+ /* @__PURE__ */ jsx(VolumeChart, { data: volumeData })
263
404
  ] }),
264
- /* @__PURE__ */ jsxs("div", { style: { padding: 16, borderRadius: 10, border: "1px solid var(--theme-elevation-150)" }, children: [
265
- /* @__PURE__ */ jsx("h2", { style: { fontSize: 15, fontWeight: 700, margin: "0 0 12px", color: "var(--theme-text)" }, children: t("dashboard.csat") }),
266
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 16 }, children: [
267
- /* @__PURE__ */ jsxs("div", { style: { position: "relative", width: 80, height: 80 }, children: [
268
- /* @__PURE__ */ jsxs("svg", { width: "80", height: "80", viewBox: "0 0 100 100", children: [
269
- /* @__PURE__ */ jsx("circle", { cx: "50", cy: "50", r: csatRadius, fill: "none", stroke: "var(--theme-elevation-150, #e2e8f0)", strokeWidth: "6" }),
270
- /* @__PURE__ */ jsx("circle", { cx: "50", cy: "50", r: csatRadius, fill: "none", stroke: csatColor, strokeWidth: "6", strokeLinecap: "round", strokeDasharray: csatCircumference, strokeDashoffset: csatStrokeDashoffset, transform: "rotate(-90 50 50)", style: { transition: "stroke-dashoffset 600ms ease" } })
271
- ] }),
272
- /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", fontWeight: 700, fontSize: 16 }, children: csatScore > 0 ? csatScore.toFixed(1) : "--" })
273
- ] }),
274
- /* @__PURE__ */ jsxs("div", { children: [
275
- /* @__PURE__ */ jsx("div", { style: { fontSize: 13, fontWeight: 600 }, children: csatScore > 0 ? `${csatScore.toFixed(1)} / 5` : t("dashboard.csatNoData") }),
276
- /* @__PURE__ */ jsx("div", { style: { fontSize: 12, color: "var(--theme-elevation-500)" }, children: stats.satisfactionCount > 0 ? t("dashboard.csatReviews", { count: String(stats.satisfactionCount) }) : t("dashboard.csatNoReviews") })
277
- ] })
278
- ] })
405
+ /* @__PURE__ */ jsxs("div", { className: styles.panel, children: [
406
+ /* @__PURE__ */ jsx("h2", { className: styles.panelTitle, children: t("dashboard.csat") }),
407
+ /* @__PURE__ */ jsx(CSATRing, { score: stats.satisfactionAvg, count: stats.satisfactionCount })
279
408
  ] })
280
409
  ] })
281
410
  ] }),
282
411
  /* @__PURE__ */ jsx(SlaSection, {}),
283
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 10, marginTop: 24, flexWrap: "wrap" }, children: [
284
- /* @__PURE__ */ jsx(Link, { href: "/admin/support/new-ticket", style: { padding: "8px 16px", borderRadius: 8, background: "#2563eb", color: "#fff", fontSize: 13, fontWeight: 600, textDecoration: "none" }, children: t("dashboard.newTicketAction") }),
285
- /* @__PURE__ */ jsxs(Link, { href: "/admin/support/emails", style: { padding: "8px 16px", borderRadius: 8, border: "1px solid var(--theme-elevation-200)", fontSize: 13, fontWeight: 500, textDecoration: "none", color: "var(--theme-text)", display: "flex", alignItems: "center", gap: 6 }, children: [
412
+ /* @__PURE__ */ jsxs("div", { className: styles.actionsRow, children: [
413
+ /* @__PURE__ */ jsx(Link, { href: "/admin/support/new-ticket", className: styles.actionBtn, children: t("dashboard.newTicketAction") }),
414
+ /* @__PURE__ */ jsxs(Link, { href: "/admin/support/emails", className: styles.actionBtn, children: [
286
415
  t("dashboard.pendingEmails"),
287
- stats.pendingEmailsCount > 0 ? /* @__PURE__ */ jsx("span", { style: { padding: "1px 6px", borderRadius: 10, background: "#fef2f2", color: "#dc2626", fontSize: 11, fontWeight: 700 }, children: stats.pendingEmailsCount }) : /* @__PURE__ */ jsx("span", { style: { padding: "1px 6px", borderRadius: 10, background: "#dcfce7", color: "#16a34a", fontSize: 11, fontWeight: 700 }, children: "0" })
416
+ stats.pendingEmailsCount > 0 ? /* @__PURE__ */ jsx("span", { className: `${styles.badge} ${styles.badgeRed}`, children: stats.pendingEmailsCount }) : /* @__PURE__ */ jsx("span", { className: `${styles.badge} ${styles.badgeGreen}`, children: "0" })
288
417
  ] }),
289
- /* @__PURE__ */ jsx(Link, { href: "/admin/support/crm", style: { padding: "8px 16px", borderRadius: 8, border: "1px solid var(--theme-elevation-200)", fontSize: 13, fontWeight: 500, textDecoration: "none", color: "var(--theme-text)" }, children: t("dashboard.crm") }),
290
- /* @__PURE__ */ jsx(Link, { href: "/admin/support/billing", style: { padding: "8px 16px", borderRadius: 8, border: "1px solid var(--theme-elevation-200)", fontSize: 13, fontWeight: 500, textDecoration: "none", color: "var(--theme-text)" }, children: t("dashboard.preBilling") }),
291
- /* @__PURE__ */ jsx("a", { href: "/api/support/export-csv", style: { padding: "8px 16px", borderRadius: 8, border: "1px solid var(--theme-elevation-200)", fontSize: 13, fontWeight: 500, textDecoration: "none", color: "var(--theme-text)" }, target: "_blank", rel: "noopener noreferrer", children: t("dashboard.exportCsv") })
418
+ /* @__PURE__ */ jsx(Link, { href: "/admin/support/crm", className: styles.actionBtn, children: t("dashboard.crm") }),
419
+ /* @__PURE__ */ jsx(Link, { href: "/admin/support/billing", className: styles.actionBtn, children: t("dashboard.preBilling") }),
420
+ /* @__PURE__ */ jsx(
421
+ "a",
422
+ {
423
+ href: "/api/support/export-csv",
424
+ className: styles.actionBtn,
425
+ target: "_blank",
426
+ rel: "noopener noreferrer",
427
+ children: t("dashboard.exportCsv")
428
+ }
429
+ )
292
430
  ] })
293
431
  ] });
294
432
  };