@consilioweb/payload-support 0.8.1 → 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 (51) 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 -2
  6. package/dist/index.js +19 -2
  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/collections/ClientSummaries.ts +0 -1
  35. package/src/components/RichTextEditor/index.tsx +261 -0
  36. package/src/components/TicketConversation/components/CodeBlock.tsx +53 -14
  37. package/src/plugin.ts +2 -0
  38. package/src/utils/emailTemplate.ts +37 -0
  39. package/src/views/BillingView/client.tsx +362 -69
  40. package/src/views/ChatView/client.tsx +225 -140
  41. package/src/views/CrmView/client.tsx +447 -189
  42. package/src/views/EmailTrackingView/client.tsx +111 -71
  43. package/src/views/ImportConversationView/client.tsx +255 -70
  44. package/src/views/LogsView/client.tsx +85 -50
  45. package/src/views/NewTicketView/client.tsx +37 -53
  46. package/src/views/PendingEmailsView/client.tsx +512 -92
  47. package/src/views/SupportDashboardView/client.tsx +294 -134
  48. package/src/views/TicketDetailView/client.tsx +486 -213
  49. package/src/views/TicketInboxView/client.tsx +52 -61
  50. package/src/views/TicketingSettingsView/client.tsx +10 -9
  51. package/src/views/TimeDashboardView/client.tsx +184 -69
@@ -3,15 +3,17 @@
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
4
  var React = require('react');
5
5
  var useTranslation = require('../../components/TicketConversation/hooks/useTranslation');
6
+ var s = require('../../styles/EmailTracking.module.scss');
6
7
 
7
8
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
9
 
9
10
  var React__default = /*#__PURE__*/_interopDefault(React);
11
+ var s__default = /*#__PURE__*/_interopDefault(s);
10
12
 
11
13
  const STATUS_CFG = {
12
- success: { key: "emailTracking.status.success", bg: "#dcfce7", color: "#16a34a" },
13
- error: { key: "emailTracking.status.error", bg: "#fef2f2", color: "#dc2626" },
14
- ignored: { key: "emailTracking.status.ignored", bg: "#f3f4f6", color: "#6b7280" }
14
+ success: { label: "Succ\xE8s", bg: "#dcfce7", color: "#16a34a" },
15
+ error: { label: "Erreur", bg: "#fef2f2", color: "#dc2626" },
16
+ ignored: { label: "Ignor\xE9", bg: "#f3f4f6", color: "#6b7280" }
15
17
  };
16
18
  function fmtDate(d) {
17
19
  return new Date(d).toLocaleDateString("fr-FR", { day: "2-digit", month: "2-digit", year: "2-digit", hour: "2-digit", minute: "2-digit" });
@@ -28,12 +30,12 @@ const EmailTrackingClient = () => {
28
30
  const [page, setPage] = React.useState(1);
29
31
  const [hasMore, setHasMore] = React.useState(false);
30
32
  const [totalDocs, setTotalDocs] = React.useState(0);
33
+ const LIMIT = 30;
31
34
  const fetchStats = React.useCallback(async () => {
32
35
  try {
33
36
  const r = await fetch(`/api/support/email-stats?days=${dateRange}`);
34
37
  if (r.ok) setStats(await r.json());
35
- } catch (err) {
36
- console.warn("[support] fetchStats error:", err);
38
+ } catch {
37
39
  }
38
40
  }, [dateRange]);
39
41
  const fetchLogs = React.useCallback(async () => {
@@ -44,15 +46,14 @@ const EmailTrackingClient = () => {
44
46
  where.push(`where[or][0][recipientEmail][contains]=${encodeURIComponent(search)}`, `where[or][1][subject][contains]=${encodeURIComponent(search)}`);
45
47
  }
46
48
  try {
47
- const r = await fetch(`/api/email-logs?${where.join("&")}&sort=-createdAt&limit=30&page=${page}&depth=0`);
49
+ const r = await fetch(`/api/email-logs?${where.join("&")}&sort=-createdAt&limit=${LIMIT}&page=${page}&depth=0`);
48
50
  if (r.ok) {
49
51
  const d = await r.json();
50
52
  setLogs(d.docs);
51
53
  setHasMore(d.hasNextPage);
52
54
  setTotalDocs(d.totalDocs);
53
55
  }
54
- } catch (err) {
55
- console.warn("[support] fetchLogs error:", err);
56
+ } catch {
56
57
  }
57
58
  setLoading(false);
58
59
  }, [dateRange, tab, search, page]);
@@ -64,75 +65,85 @@ const EmailTrackingClient = () => {
64
65
  fetchStats();
65
66
  fetchLogs();
66
67
  }, [fetchStats, fetchLogs]);
67
- const S = {
68
- page: { padding: "20px 30px", maxWidth: 1100, margin: "0 auto" },
69
- statGrid: { display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 12, marginBottom: 20 },
70
- statCard: { padding: "12px 16px", borderRadius: 8, border: "1px solid var(--theme-elevation-150)" },
71
- statLabel: { fontSize: 11, color: "var(--theme-elevation-500)" },
72
- statValue: { fontSize: 22, fontWeight: 700, color: "var(--theme-text)" },
73
- filters: { display: "flex", gap: 12, alignItems: "center", marginBottom: 16, flexWrap: "wrap" },
74
- tab: { padding: "4px 10px", borderRadius: 6, border: "none", background: "none", cursor: "pointer", fontSize: 12, color: "var(--theme-elevation-500)" },
75
- tabActive: { background: "var(--theme-elevation-100)", fontWeight: 700, color: "var(--theme-text)" },
76
- dateBtn: { padding: "4px 8px", borderRadius: 4, border: "1px solid var(--theme-elevation-200)", fontSize: 11, cursor: "pointer", background: "var(--theme-elevation-0)", color: "var(--theme-text)" },
77
- dateBtnActive: { background: "#2563eb", color: "#fff", borderColor: "#2563eb" },
78
- table: { width: "100%", borderCollapse: "collapse", fontSize: 13 },
79
- th: { textAlign: "left", padding: "6px 8px", borderBottom: "1px solid var(--theme-elevation-200)", fontSize: 11, color: "var(--theme-elevation-500)" },
80
- td: { padding: "6px 8px", borderBottom: "1px solid var(--theme-elevation-100)" },
81
- badge: { padding: "2px 6px", borderRadius: 4, fontSize: 11, fontWeight: 600 },
82
- btn: { padding: "4px 10px", borderRadius: 6, border: "1px solid var(--theme-elevation-200)", fontSize: 11, cursor: "pointer", background: "var(--theme-elevation-0)", color: "var(--theme-text)" }
83
- };
84
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.page, children: [
85
- /* @__PURE__ */ jsxRuntime.jsx("h1", { style: { fontSize: 22, fontWeight: 700, marginBottom: 16, color: "var(--theme-text)" }, children: t("emailTracking.title") }),
86
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.statGrid, children: [
87
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.statCard, children: [
88
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: S.statLabel, children: t("emailTracking.stats.emailsSent") }),
89
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: S.statValue, children: stats?.total ?? "--" })
68
+ const tabsList = [
69
+ { key: "all", label: t("emailTracking.tabs.all"), count: stats?.total },
70
+ { key: "success", label: t("emailTracking.tabs.success"), count: stats?.success },
71
+ { key: "error", label: t("emailTracking.tabs.errors"), count: stats?.errors },
72
+ { key: "ignored", label: t("emailTracking.tabs.ignored"), count: stats?.ignored }
73
+ ];
74
+ if (loading && !stats) return /* @__PURE__ */ jsxRuntime.jsx("div", { className: s__default.default.loading, children: t("common.loading") });
75
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: s__default.default.page, children: [
76
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: s__default.default.header, children: /* @__PURE__ */ jsxRuntime.jsx("h1", { className: s__default.default.title, children: t("emailTracking.title") }) }),
77
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: s__default.default.statGrid, children: [
78
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: s__default.default.statCard, children: [
79
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: s__default.default.statLabel, children: t("emailTracking.stats.emailsSent") }),
80
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: s__default.default.statValue, children: stats?.total ?? "\u2014" })
90
81
  ] }),
91
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.statCard, children: [
92
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: S.statLabel, children: t("emailTracking.stats.successRate") }),
93
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: S.statValue, children: stats ? `${stats.successRate}%` : "--" })
82
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: s__default.default.statCard, children: [
83
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: s__default.default.statLabel, children: t("emailTracking.stats.successRate") }),
84
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: s__default.default.statValue, children: [
85
+ stats ? `${stats.successRate}` : "\u2014",
86
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: s__default.default.statUnit, children: "%" })
87
+ ] })
94
88
  ] }),
95
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.statCard, children: [
96
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: S.statLabel, children: t("emailTracking.stats.errors") }),
97
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: S.statValue, children: stats?.errors ?? "--" })
89
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: s__default.default.statCard, children: [
90
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: s__default.default.statLabel, children: t("emailTracking.stats.errors") }),
91
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: s__default.default.statValue, children: stats?.errors ?? "\u2014" })
98
92
  ] }),
99
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.statCard, children: [
100
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: S.statLabel, children: t("emailTracking.stats.avgTime") }),
101
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: S.statValue, children: stats ? `${stats.avgProcessingTime}ms` : "--" })
93
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: s__default.default.statCard, children: [
94
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: s__default.default.statLabel, children: t("emailTracking.stats.avgTime") }),
95
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: s__default.default.statValue, children: [
96
+ stats ? stats.avgProcessingTime : "\u2014",
97
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: s__default.default.statUnit, children: "ms" })
98
+ ] })
102
99
  ] })
103
100
  ] }),
104
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.filters, children: [
105
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", gap: 4 }, children: ["all", "success", "error", "ignored"].map((st) => /* @__PURE__ */ jsxRuntime.jsx("button", { style: { ...S.tab, ...tab === st ? S.tabActive : {} }, onClick: () => setTab(st), children: t(`emailTracking.tabs.${st === "error" ? "errors" : st}`) }, st)) }),
106
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", gap: 4 }, children: [7, 30, 90].map((v) => /* @__PURE__ */ jsxRuntime.jsxs("button", { style: { ...S.dateBtn, ...dateRange === v ? S.dateBtnActive : {} }, onClick: () => setDateRange(v), children: [
101
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: s__default.default.filters, children: [
102
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: s__default.default.tabs, children: tabsList.map((t2) => /* @__PURE__ */ jsxRuntime.jsxs("button", { className: `${s__default.default.tab} ${tab === t2.key ? s__default.default.tabActive : ""}`, onClick: () => setTab(t2.key), children: [
103
+ t2.label,
104
+ " ",
105
+ typeof t2.count === "number" && /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { marginLeft: 4, opacity: 0.6 }, children: [
106
+ "(",
107
+ t2.count,
108
+ ")"
109
+ ] })
110
+ ] }, t2.key)) }),
111
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: s__default.default.dateRangeGroup, children: [7, 30, 90].map((v) => /* @__PURE__ */ jsxRuntime.jsxs("button", { className: `${s__default.default.dateRangeBtn} ${dateRange === v ? s__default.default.dateRangeActive : ""}`, onClick: () => setDateRange(v), children: [
107
112
  v,
108
113
  "j"
109
114
  ] }, v)) }),
110
- /* @__PURE__ */ jsxRuntime.jsx("input", { type: "text", placeholder: t("emailTracking.searchPlaceholder"), value: search, onChange: (e) => setSearch(e.target.value), style: { padding: "6px 10px", borderRadius: 6, border: "1px solid var(--theme-elevation-200)", fontSize: 12, color: "var(--theme-text)", background: "var(--theme-elevation-0)" } })
115
+ /* @__PURE__ */ jsxRuntime.jsx("input", { type: "text", className: s__default.default.searchInput, placeholder: t("emailTracking.searchPlaceholder"), value: search, onChange: (e) => setSearch(e.target.value) })
111
116
  ] }),
112
- loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: 40, textAlign: "center", color: "#94a3b8" }, children: t("common.loading") }) : logs.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: 40, textAlign: "center", color: "#94a3b8" }, children: t("emailTracking.noLogs") }) : /* @__PURE__ */ jsxRuntime.jsxs("table", { style: S.table, children: [
117
+ logs.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: s__default.default.empty, children: t("emailTracking.noLogs") }) : /* @__PURE__ */ jsxRuntime.jsxs("table", { className: s__default.default.table, children: [
113
118
  /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
114
- /* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("emailTracking.tableHeaders.date") }),
115
- /* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("emailTracking.tableHeaders.recipient") }),
116
- /* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("emailTracking.tableHeaders.subject") }),
117
- /* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("emailTracking.tableHeaders.ticket") }),
118
- /* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("emailTracking.tableHeaders.status") }),
119
- /* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("emailTracking.tableHeaders.action") }),
120
- /* @__PURE__ */ jsxRuntime.jsx("th", { style: { ...S.th, textAlign: "right" }, children: t("emailTracking.tableHeaders.time") })
119
+ /* @__PURE__ */ jsxRuntime.jsx("th", { children: t("emailTracking.tableHeaders.date") }),
120
+ /* @__PURE__ */ jsxRuntime.jsx("th", { children: t("emailTracking.tableHeaders.recipient") }),
121
+ /* @__PURE__ */ jsxRuntime.jsx("th", { children: t("emailTracking.tableHeaders.subject") }),
122
+ /* @__PURE__ */ jsxRuntime.jsx("th", { children: t("emailTracking.tableHeaders.ticket") }),
123
+ /* @__PURE__ */ jsxRuntime.jsx("th", { children: t("emailTracking.tableHeaders.status") }),
124
+ /* @__PURE__ */ jsxRuntime.jsx("th", { children: t("emailTracking.tableHeaders.action") }),
125
+ /* @__PURE__ */ jsxRuntime.jsx("th", { style: { textAlign: "right" }, children: t("emailTracking.tableHeaders.time") })
121
126
  ] }) }),
122
127
  /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: logs.map((log) => /* @__PURE__ */ jsxRuntime.jsxs(React__default.default.Fragment, { children: [
123
- /* @__PURE__ */ jsxRuntime.jsxs("tr", { onClick: () => log.status === "error" && log.errorMessage ? setExpandedRow(expandedRow === log.id ? null : log.id) : null, style: { cursor: log.status === "error" ? "pointer" : "default" }, children: [
124
- /* @__PURE__ */ jsxRuntime.jsx("td", { style: { ...S.td, fontSize: 12, whiteSpace: "nowrap" }, children: fmtDate(log.createdAt) }),
125
- /* @__PURE__ */ jsxRuntime.jsx("td", { style: { ...S.td, maxWidth: 200, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: log.recipientEmail || "--" }),
126
- /* @__PURE__ */ jsxRuntime.jsx("td", { style: { ...S.td, maxWidth: 250, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: log.subject || "--" }),
127
- /* @__PURE__ */ jsxRuntime.jsx("td", { style: S.td, children: log.ticketNumber || "--" }),
128
- /* @__PURE__ */ jsxRuntime.jsx("td", { style: S.td, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: { ...S.badge, background: STATUS_CFG[log.status]?.bg, color: STATUS_CFG[log.status]?.color }, children: STATUS_CFG[log.status]?.key ? t(STATUS_CFG[log.status].key) : log.status }) }),
129
- /* @__PURE__ */ jsxRuntime.jsx("td", { style: { ...S.td, fontSize: 12 }, children: log.action || "--" }),
130
- /* @__PURE__ */ jsxRuntime.jsx("td", { style: { ...S.td, textAlign: "right" }, children: log.processingTimeMs != null ? /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { fontFamily: "monospace", fontSize: 12, color: log.processingTimeMs > 2e3 ? "#dc2626" : "#16a34a" }, children: [
131
- log.processingTimeMs,
132
- "ms"
133
- ] }) : "--" })
128
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { onClick: () => log.status === "error" && log.errorMessage ? setExpandedRow(expandedRow === log.id ? null : log.id) : null, style: { cursor: log.status === "error" && log.errorMessage ? "pointer" : "default" }, children: [
129
+ /* @__PURE__ */ jsxRuntime.jsx("td", { style: { fontSize: 12, whiteSpace: "nowrap" }, children: fmtDate(log.createdAt) }),
130
+ /* @__PURE__ */ jsxRuntime.jsx("td", { style: { maxWidth: 200, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, title: log.recipientEmail, children: log.recipientEmail || "\u2014" }),
131
+ /* @__PURE__ */ jsxRuntime.jsx("td", { style: { maxWidth: 250, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, title: log.subject, children: log.subject || "\u2014" }),
132
+ /* @__PURE__ */ jsxRuntime.jsx("td", { children: log.ticketNumber ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: s__default.default.ticketLink, children: log.ticketNumber }) : "\u2014" }),
133
+ /* @__PURE__ */ jsxRuntime.jsx("td", { children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: s__default.default.statusBadge, style: { background: STATUS_CFG[log.status]?.bg, color: STATUS_CFG[log.status]?.color }, children: STATUS_CFG[log.status]?.label || log.status }) }),
134
+ /* @__PURE__ */ jsxRuntime.jsx("td", { style: { fontSize: 12 }, children: log.action || "\u2014" }),
135
+ /* @__PURE__ */ jsxRuntime.jsxs("td", { style: { textAlign: "right" }, children: [
136
+ log.processingTimeMs != null ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: `${s__default.default.processingTime} ${log.processingTimeMs > 2e3 ? s__default.default.timeSlow : log.processingTimeMs > 500 ? s__default.default.timeMedium : s__default.default.timeFast}`, children: [
137
+ log.processingTimeMs,
138
+ "ms"
139
+ ] }) : "\u2014",
140
+ log.status === "error" && log.errorMessage && /* @__PURE__ */ jsxRuntime.jsx("button", { className: s__default.default.expandBtn, onClick: (e) => {
141
+ e.stopPropagation();
142
+ setExpandedRow(expandedRow === log.id ? null : log.id);
143
+ }, children: expandedRow === log.id ? "\u25B4" : "\u25BE" })
144
+ ] })
134
145
  ] }),
135
- expandedRow === log.id && log.errorMessage && /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: 7, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { padding: "8px 12px", background: "#fef2f2", borderRadius: 6, fontSize: 12, color: "#dc2626" }, children: [
146
+ expandedRow === log.id && log.errorMessage && /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: 7, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: s__default.default.errorDetail, children: [
136
147
  "Erreur",
137
148
  log.httpStatus ? ` (HTTP ${log.httpStatus})` : "",
138
149
  ": ",
@@ -140,18 +151,18 @@ const EmailTrackingClient = () => {
140
151
  ] }) }) })
141
152
  ] }, log.id)) })
142
153
  ] }),
143
- totalDocs > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "center", gap: 12, marginTop: 16, alignItems: "center" }, children: [
144
- /* @__PURE__ */ jsxRuntime.jsx("button", { style: S.btn, onClick: () => setPage((p) => Math.max(1, p - 1)), disabled: page <= 1, children: t("common.previous") }),
145
- /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { fontSize: 12, color: "var(--theme-elevation-500)" }, children: [
154
+ totalDocs > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: s__default.default.pagination, children: [
155
+ /* @__PURE__ */ jsxRuntime.jsx("button", { className: s__default.default.pageBtn, onClick: () => setPage((p) => Math.max(1, p - 1)), disabled: page <= 1, children: t("common.previous") }),
156
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { fontSize: 12, color: "var(--theme-elevation-500)", alignSelf: "center" }, children: [
146
157
  t("common.page"),
147
158
  " ",
148
159
  page,
149
- " -- ",
160
+ " \u2014 ",
150
161
  totalDocs,
151
162
  " ",
152
163
  t("common.results")
153
164
  ] }),
154
- /* @__PURE__ */ jsxRuntime.jsx("button", { style: S.btn, onClick: () => setPage((p) => p + 1), disabled: !hasMore, children: t("common.next") })
165
+ /* @__PURE__ */ jsxRuntime.jsx("button", { className: s__default.default.pageBtn, onClick: () => setPage((p) => p + 1), disabled: !hasMore, children: t("common.next") })
155
166
  ] })
156
167
  ] });
157
168
  };
@@ -1,12 +1,13 @@
1
1
  "use client";
2
- import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
3
  import React, { useState, useCallback, useEffect } from 'react';
4
4
  import { useTranslation } from '../../components/TicketConversation/hooks/useTranslation.js';
5
+ import s from '../../styles/EmailTracking.module.scss';
5
6
 
6
7
  const STATUS_CFG = {
7
- success: { key: "emailTracking.status.success", bg: "#dcfce7", color: "#16a34a" },
8
- error: { key: "emailTracking.status.error", bg: "#fef2f2", color: "#dc2626" },
9
- ignored: { key: "emailTracking.status.ignored", bg: "#f3f4f6", color: "#6b7280" }
8
+ success: { label: "Succ\xE8s", bg: "#dcfce7", color: "#16a34a" },
9
+ error: { label: "Erreur", bg: "#fef2f2", color: "#dc2626" },
10
+ ignored: { label: "Ignor\xE9", bg: "#f3f4f6", color: "#6b7280" }
10
11
  };
11
12
  function fmtDate(d) {
12
13
  return new Date(d).toLocaleDateString("fr-FR", { day: "2-digit", month: "2-digit", year: "2-digit", hour: "2-digit", minute: "2-digit" });
@@ -23,12 +24,12 @@ const EmailTrackingClient = () => {
23
24
  const [page, setPage] = useState(1);
24
25
  const [hasMore, setHasMore] = useState(false);
25
26
  const [totalDocs, setTotalDocs] = useState(0);
27
+ const LIMIT = 30;
26
28
  const fetchStats = useCallback(async () => {
27
29
  try {
28
30
  const r = await fetch(`/api/support/email-stats?days=${dateRange}`);
29
31
  if (r.ok) setStats(await r.json());
30
- } catch (err) {
31
- console.warn("[support] fetchStats error:", err);
32
+ } catch {
32
33
  }
33
34
  }, [dateRange]);
34
35
  const fetchLogs = useCallback(async () => {
@@ -39,15 +40,14 @@ const EmailTrackingClient = () => {
39
40
  where.push(`where[or][0][recipientEmail][contains]=${encodeURIComponent(search)}`, `where[or][1][subject][contains]=${encodeURIComponent(search)}`);
40
41
  }
41
42
  try {
42
- const r = await fetch(`/api/email-logs?${where.join("&")}&sort=-createdAt&limit=30&page=${page}&depth=0`);
43
+ const r = await fetch(`/api/email-logs?${where.join("&")}&sort=-createdAt&limit=${LIMIT}&page=${page}&depth=0`);
43
44
  if (r.ok) {
44
45
  const d = await r.json();
45
46
  setLogs(d.docs);
46
47
  setHasMore(d.hasNextPage);
47
48
  setTotalDocs(d.totalDocs);
48
49
  }
49
- } catch (err) {
50
- console.warn("[support] fetchLogs error:", err);
50
+ } catch {
51
51
  }
52
52
  setLoading(false);
53
53
  }, [dateRange, tab, search, page]);
@@ -59,75 +59,85 @@ const EmailTrackingClient = () => {
59
59
  fetchStats();
60
60
  fetchLogs();
61
61
  }, [fetchStats, fetchLogs]);
62
- const S = {
63
- page: { padding: "20px 30px", maxWidth: 1100, margin: "0 auto" },
64
- statGrid: { display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 12, marginBottom: 20 },
65
- statCard: { padding: "12px 16px", borderRadius: 8, border: "1px solid var(--theme-elevation-150)" },
66
- statLabel: { fontSize: 11, color: "var(--theme-elevation-500)" },
67
- statValue: { fontSize: 22, fontWeight: 700, color: "var(--theme-text)" },
68
- filters: { display: "flex", gap: 12, alignItems: "center", marginBottom: 16, flexWrap: "wrap" },
69
- tab: { padding: "4px 10px", borderRadius: 6, border: "none", background: "none", cursor: "pointer", fontSize: 12, color: "var(--theme-elevation-500)" },
70
- tabActive: { background: "var(--theme-elevation-100)", fontWeight: 700, color: "var(--theme-text)" },
71
- dateBtn: { padding: "4px 8px", borderRadius: 4, border: "1px solid var(--theme-elevation-200)", fontSize: 11, cursor: "pointer", background: "var(--theme-elevation-0)", color: "var(--theme-text)" },
72
- dateBtnActive: { background: "#2563eb", color: "#fff", borderColor: "#2563eb" },
73
- table: { width: "100%", borderCollapse: "collapse", fontSize: 13 },
74
- th: { textAlign: "left", padding: "6px 8px", borderBottom: "1px solid var(--theme-elevation-200)", fontSize: 11, color: "var(--theme-elevation-500)" },
75
- td: { padding: "6px 8px", borderBottom: "1px solid var(--theme-elevation-100)" },
76
- badge: { padding: "2px 6px", borderRadius: 4, fontSize: 11, fontWeight: 600 },
77
- btn: { padding: "4px 10px", borderRadius: 6, border: "1px solid var(--theme-elevation-200)", fontSize: 11, cursor: "pointer", background: "var(--theme-elevation-0)", color: "var(--theme-text)" }
78
- };
79
- return /* @__PURE__ */ jsxs("div", { style: S.page, children: [
80
- /* @__PURE__ */ jsx("h1", { style: { fontSize: 22, fontWeight: 700, marginBottom: 16, color: "var(--theme-text)" }, children: t("emailTracking.title") }),
81
- /* @__PURE__ */ jsxs("div", { style: S.statGrid, children: [
82
- /* @__PURE__ */ jsxs("div", { style: S.statCard, children: [
83
- /* @__PURE__ */ jsx("div", { style: S.statLabel, children: t("emailTracking.stats.emailsSent") }),
84
- /* @__PURE__ */ jsx("div", { style: S.statValue, children: stats?.total ?? "--" })
62
+ const tabsList = [
63
+ { key: "all", label: t("emailTracking.tabs.all"), count: stats?.total },
64
+ { key: "success", label: t("emailTracking.tabs.success"), count: stats?.success },
65
+ { key: "error", label: t("emailTracking.tabs.errors"), count: stats?.errors },
66
+ { key: "ignored", label: t("emailTracking.tabs.ignored"), count: stats?.ignored }
67
+ ];
68
+ if (loading && !stats) return /* @__PURE__ */ jsx("div", { className: s.loading, children: t("common.loading") });
69
+ return /* @__PURE__ */ jsxs("div", { className: s.page, children: [
70
+ /* @__PURE__ */ jsx("div", { className: s.header, children: /* @__PURE__ */ jsx("h1", { className: s.title, children: t("emailTracking.title") }) }),
71
+ /* @__PURE__ */ jsxs("div", { className: s.statGrid, children: [
72
+ /* @__PURE__ */ jsxs("div", { className: s.statCard, children: [
73
+ /* @__PURE__ */ jsx("div", { className: s.statLabel, children: t("emailTracking.stats.emailsSent") }),
74
+ /* @__PURE__ */ jsx("div", { className: s.statValue, children: stats?.total ?? "\u2014" })
85
75
  ] }),
86
- /* @__PURE__ */ jsxs("div", { style: S.statCard, children: [
87
- /* @__PURE__ */ jsx("div", { style: S.statLabel, children: t("emailTracking.stats.successRate") }),
88
- /* @__PURE__ */ jsx("div", { style: S.statValue, children: stats ? `${stats.successRate}%` : "--" })
76
+ /* @__PURE__ */ jsxs("div", { className: s.statCard, children: [
77
+ /* @__PURE__ */ jsx("div", { className: s.statLabel, children: t("emailTracking.stats.successRate") }),
78
+ /* @__PURE__ */ jsxs("div", { className: s.statValue, children: [
79
+ stats ? `${stats.successRate}` : "\u2014",
80
+ /* @__PURE__ */ jsx("span", { className: s.statUnit, children: "%" })
81
+ ] })
89
82
  ] }),
90
- /* @__PURE__ */ jsxs("div", { style: S.statCard, children: [
91
- /* @__PURE__ */ jsx("div", { style: S.statLabel, children: t("emailTracking.stats.errors") }),
92
- /* @__PURE__ */ jsx("div", { style: S.statValue, children: stats?.errors ?? "--" })
83
+ /* @__PURE__ */ jsxs("div", { className: s.statCard, children: [
84
+ /* @__PURE__ */ jsx("div", { className: s.statLabel, children: t("emailTracking.stats.errors") }),
85
+ /* @__PURE__ */ jsx("div", { className: s.statValue, children: stats?.errors ?? "\u2014" })
93
86
  ] }),
94
- /* @__PURE__ */ jsxs("div", { style: S.statCard, children: [
95
- /* @__PURE__ */ jsx("div", { style: S.statLabel, children: t("emailTracking.stats.avgTime") }),
96
- /* @__PURE__ */ jsx("div", { style: S.statValue, children: stats ? `${stats.avgProcessingTime}ms` : "--" })
87
+ /* @__PURE__ */ jsxs("div", { className: s.statCard, children: [
88
+ /* @__PURE__ */ jsx("div", { className: s.statLabel, children: t("emailTracking.stats.avgTime") }),
89
+ /* @__PURE__ */ jsxs("div", { className: s.statValue, children: [
90
+ stats ? stats.avgProcessingTime : "\u2014",
91
+ /* @__PURE__ */ jsx("span", { className: s.statUnit, children: "ms" })
92
+ ] })
97
93
  ] })
98
94
  ] }),
99
- /* @__PURE__ */ jsxs("div", { style: S.filters, children: [
100
- /* @__PURE__ */ jsx("div", { style: { display: "flex", gap: 4 }, children: ["all", "success", "error", "ignored"].map((st) => /* @__PURE__ */ jsx("button", { style: { ...S.tab, ...tab === st ? S.tabActive : {} }, onClick: () => setTab(st), children: t(`emailTracking.tabs.${st === "error" ? "errors" : st}`) }, st)) }),
101
- /* @__PURE__ */ jsx("div", { style: { display: "flex", gap: 4 }, children: [7, 30, 90].map((v) => /* @__PURE__ */ jsxs("button", { style: { ...S.dateBtn, ...dateRange === v ? S.dateBtnActive : {} }, onClick: () => setDateRange(v), children: [
95
+ /* @__PURE__ */ jsxs("div", { className: s.filters, children: [
96
+ /* @__PURE__ */ jsx("div", { className: s.tabs, children: tabsList.map((t2) => /* @__PURE__ */ jsxs("button", { className: `${s.tab} ${tab === t2.key ? s.tabActive : ""}`, onClick: () => setTab(t2.key), children: [
97
+ t2.label,
98
+ " ",
99
+ typeof t2.count === "number" && /* @__PURE__ */ jsxs("span", { style: { marginLeft: 4, opacity: 0.6 }, children: [
100
+ "(",
101
+ t2.count,
102
+ ")"
103
+ ] })
104
+ ] }, t2.key)) }),
105
+ /* @__PURE__ */ jsx("div", { className: s.dateRangeGroup, children: [7, 30, 90].map((v) => /* @__PURE__ */ jsxs("button", { className: `${s.dateRangeBtn} ${dateRange === v ? s.dateRangeActive : ""}`, onClick: () => setDateRange(v), children: [
102
106
  v,
103
107
  "j"
104
108
  ] }, v)) }),
105
- /* @__PURE__ */ jsx("input", { type: "text", placeholder: t("emailTracking.searchPlaceholder"), value: search, onChange: (e) => setSearch(e.target.value), style: { padding: "6px 10px", borderRadius: 6, border: "1px solid var(--theme-elevation-200)", fontSize: 12, color: "var(--theme-text)", background: "var(--theme-elevation-0)" } })
109
+ /* @__PURE__ */ jsx("input", { type: "text", className: s.searchInput, placeholder: t("emailTracking.searchPlaceholder"), value: search, onChange: (e) => setSearch(e.target.value) })
106
110
  ] }),
107
- loading ? /* @__PURE__ */ jsx("div", { style: { padding: 40, textAlign: "center", color: "#94a3b8" }, children: t("common.loading") }) : logs.length === 0 ? /* @__PURE__ */ jsx("div", { style: { padding: 40, textAlign: "center", color: "#94a3b8" }, children: t("emailTracking.noLogs") }) : /* @__PURE__ */ jsxs("table", { style: S.table, children: [
111
+ logs.length === 0 ? /* @__PURE__ */ jsx("div", { className: s.empty, children: t("emailTracking.noLogs") }) : /* @__PURE__ */ jsxs("table", { className: s.table, children: [
108
112
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
109
- /* @__PURE__ */ jsx("th", { style: S.th, children: t("emailTracking.tableHeaders.date") }),
110
- /* @__PURE__ */ jsx("th", { style: S.th, children: t("emailTracking.tableHeaders.recipient") }),
111
- /* @__PURE__ */ jsx("th", { style: S.th, children: t("emailTracking.tableHeaders.subject") }),
112
- /* @__PURE__ */ jsx("th", { style: S.th, children: t("emailTracking.tableHeaders.ticket") }),
113
- /* @__PURE__ */ jsx("th", { style: S.th, children: t("emailTracking.tableHeaders.status") }),
114
- /* @__PURE__ */ jsx("th", { style: S.th, children: t("emailTracking.tableHeaders.action") }),
115
- /* @__PURE__ */ jsx("th", { style: { ...S.th, textAlign: "right" }, children: t("emailTracking.tableHeaders.time") })
113
+ /* @__PURE__ */ jsx("th", { children: t("emailTracking.tableHeaders.date") }),
114
+ /* @__PURE__ */ jsx("th", { children: t("emailTracking.tableHeaders.recipient") }),
115
+ /* @__PURE__ */ jsx("th", { children: t("emailTracking.tableHeaders.subject") }),
116
+ /* @__PURE__ */ jsx("th", { children: t("emailTracking.tableHeaders.ticket") }),
117
+ /* @__PURE__ */ jsx("th", { children: t("emailTracking.tableHeaders.status") }),
118
+ /* @__PURE__ */ jsx("th", { children: t("emailTracking.tableHeaders.action") }),
119
+ /* @__PURE__ */ jsx("th", { style: { textAlign: "right" }, children: t("emailTracking.tableHeaders.time") })
116
120
  ] }) }),
117
121
  /* @__PURE__ */ jsx("tbody", { children: logs.map((log) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
118
- /* @__PURE__ */ jsxs("tr", { onClick: () => log.status === "error" && log.errorMessage ? setExpandedRow(expandedRow === log.id ? null : log.id) : null, style: { cursor: log.status === "error" ? "pointer" : "default" }, children: [
119
- /* @__PURE__ */ jsx("td", { style: { ...S.td, fontSize: 12, whiteSpace: "nowrap" }, children: fmtDate(log.createdAt) }),
120
- /* @__PURE__ */ jsx("td", { style: { ...S.td, maxWidth: 200, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: log.recipientEmail || "--" }),
121
- /* @__PURE__ */ jsx("td", { style: { ...S.td, maxWidth: 250, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: log.subject || "--" }),
122
- /* @__PURE__ */ jsx("td", { style: S.td, children: log.ticketNumber || "--" }),
123
- /* @__PURE__ */ jsx("td", { style: S.td, children: /* @__PURE__ */ jsx("span", { style: { ...S.badge, background: STATUS_CFG[log.status]?.bg, color: STATUS_CFG[log.status]?.color }, children: STATUS_CFG[log.status]?.key ? t(STATUS_CFG[log.status].key) : log.status }) }),
124
- /* @__PURE__ */ jsx("td", { style: { ...S.td, fontSize: 12 }, children: log.action || "--" }),
125
- /* @__PURE__ */ jsx("td", { style: { ...S.td, textAlign: "right" }, children: log.processingTimeMs != null ? /* @__PURE__ */ jsxs("span", { style: { fontFamily: "monospace", fontSize: 12, color: log.processingTimeMs > 2e3 ? "#dc2626" : "#16a34a" }, children: [
126
- log.processingTimeMs,
127
- "ms"
128
- ] }) : "--" })
122
+ /* @__PURE__ */ jsxs("tr", { onClick: () => log.status === "error" && log.errorMessage ? setExpandedRow(expandedRow === log.id ? null : log.id) : null, style: { cursor: log.status === "error" && log.errorMessage ? "pointer" : "default" }, children: [
123
+ /* @__PURE__ */ jsx("td", { style: { fontSize: 12, whiteSpace: "nowrap" }, children: fmtDate(log.createdAt) }),
124
+ /* @__PURE__ */ jsx("td", { style: { maxWidth: 200, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, title: log.recipientEmail, children: log.recipientEmail || "\u2014" }),
125
+ /* @__PURE__ */ jsx("td", { style: { maxWidth: 250, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, title: log.subject, children: log.subject || "\u2014" }),
126
+ /* @__PURE__ */ jsx("td", { children: log.ticketNumber ? /* @__PURE__ */ jsx("span", { className: s.ticketLink, children: log.ticketNumber }) : "\u2014" }),
127
+ /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx("span", { className: s.statusBadge, style: { background: STATUS_CFG[log.status]?.bg, color: STATUS_CFG[log.status]?.color }, children: STATUS_CFG[log.status]?.label || log.status }) }),
128
+ /* @__PURE__ */ jsx("td", { style: { fontSize: 12 }, children: log.action || "\u2014" }),
129
+ /* @__PURE__ */ jsxs("td", { style: { textAlign: "right" }, children: [
130
+ log.processingTimeMs != null ? /* @__PURE__ */ jsxs("span", { className: `${s.processingTime} ${log.processingTimeMs > 2e3 ? s.timeSlow : log.processingTimeMs > 500 ? s.timeMedium : s.timeFast}`, children: [
131
+ log.processingTimeMs,
132
+ "ms"
133
+ ] }) : "\u2014",
134
+ log.status === "error" && log.errorMessage && /* @__PURE__ */ jsx("button", { className: s.expandBtn, onClick: (e) => {
135
+ e.stopPropagation();
136
+ setExpandedRow(expandedRow === log.id ? null : log.id);
137
+ }, children: expandedRow === log.id ? "\u25B4" : "\u25BE" })
138
+ ] })
129
139
  ] }),
130
- expandedRow === log.id && log.errorMessage && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: 7, children: /* @__PURE__ */ jsxs("div", { style: { padding: "8px 12px", background: "#fef2f2", borderRadius: 6, fontSize: 12, color: "#dc2626" }, children: [
140
+ expandedRow === log.id && log.errorMessage && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: 7, children: /* @__PURE__ */ jsxs("div", { className: s.errorDetail, children: [
131
141
  "Erreur",
132
142
  log.httpStatus ? ` (HTTP ${log.httpStatus})` : "",
133
143
  ": ",
@@ -135,18 +145,18 @@ const EmailTrackingClient = () => {
135
145
  ] }) }) })
136
146
  ] }, log.id)) })
137
147
  ] }),
138
- totalDocs > 0 && /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "center", gap: 12, marginTop: 16, alignItems: "center" }, children: [
139
- /* @__PURE__ */ jsx("button", { style: S.btn, onClick: () => setPage((p) => Math.max(1, p - 1)), disabled: page <= 1, children: t("common.previous") }),
140
- /* @__PURE__ */ jsxs("span", { style: { fontSize: 12, color: "var(--theme-elevation-500)" }, children: [
148
+ totalDocs > 0 && /* @__PURE__ */ jsxs("div", { className: s.pagination, children: [
149
+ /* @__PURE__ */ jsx("button", { className: s.pageBtn, onClick: () => setPage((p) => Math.max(1, p - 1)), disabled: page <= 1, children: t("common.previous") }),
150
+ /* @__PURE__ */ jsxs("span", { style: { fontSize: 12, color: "var(--theme-elevation-500)", alignSelf: "center" }, children: [
141
151
  t("common.page"),
142
152
  " ",
143
153
  page,
144
- " -- ",
154
+ " \u2014 ",
145
155
  totalDocs,
146
156
  " ",
147
157
  t("common.results")
148
158
  ] }),
149
- /* @__PURE__ */ jsx("button", { style: S.btn, onClick: () => setPage((p) => p + 1), disabled: !hasMore, children: t("common.next") })
159
+ /* @__PURE__ */ jsx("button", { className: s.pageBtn, onClick: () => setPage((p) => p + 1), disabled: !hasMore, children: t("common.next") })
150
160
  ] })
151
161
  ] });
152
162
  };