@consilioweb/payload-support 0.8.2 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/RichTextEditor/index.cjs +233 -0
- package/dist/components/RichTextEditor/index.js +232 -0
- package/dist/components/TicketConversation/components/CodeBlock.cjs +24 -7
- package/dist/components/TicketConversation/components/CodeBlock.js +23 -9
- package/dist/index.cjs +19 -1
- package/dist/index.js +19 -1
- package/dist/views/BillingView/client.cjs +260 -103
- package/dist/views/BillingView/client.js +259 -103
- package/dist/views/ChatView/client.cjs +184 -137
- package/dist/views/ChatView/client.js +180 -137
- package/dist/views/CrmView/client.cjs +270 -122
- package/dist/views/CrmView/client.js +266 -122
- package/dist/views/EmailTrackingView/client.cjs +80 -69
- package/dist/views/EmailTrackingView/client.js +80 -70
- package/dist/views/ImportConversationView/client.cjs +127 -94
- package/dist/views/ImportConversationView/client.js +123 -94
- package/dist/views/LogsView/client.cjs +56 -58
- package/dist/views/LogsView/client.js +52 -58
- package/dist/views/NewTicketView/client.cjs +39 -55
- package/dist/views/NewTicketView/client.js +38 -55
- package/dist/views/PendingEmailsView/client.cjs +399 -102
- package/dist/views/PendingEmailsView/client.js +396 -103
- package/dist/views/SupportDashboardView/client.cjs +276 -137
- package/dist/views/SupportDashboardView/client.js +275 -137
- package/dist/views/TicketDetailView/client.cjs +487 -204
- package/dist/views/TicketDetailView/client.js +486 -204
- package/dist/views/TicketInboxView/client.cjs +62 -65
- package/dist/views/TicketInboxView/client.js +62 -66
- package/dist/views/TicketingSettingsView/client.cjs +10 -8
- package/dist/views/TicketingSettingsView/client.js +10 -8
- package/dist/views/TimeDashboardView/client.cjs +70 -59
- package/dist/views/TimeDashboardView/client.js +69 -59
- package/package.json +7 -3
- package/src/components/RichTextEditor/index.tsx +261 -0
- package/src/components/TicketConversation/components/CodeBlock.tsx +53 -14
- package/src/plugin.ts +2 -0
- package/src/utils/emailTemplate.ts +37 -0
- package/src/views/BillingView/client.tsx +362 -69
- package/src/views/ChatView/client.tsx +225 -140
- package/src/views/CrmView/client.tsx +447 -189
- package/src/views/EmailTrackingView/client.tsx +111 -71
- package/src/views/ImportConversationView/client.tsx +255 -70
- package/src/views/LogsView/client.tsx +85 -50
- package/src/views/NewTicketView/client.tsx +37 -53
- package/src/views/PendingEmailsView/client.tsx +512 -92
- package/src/views/SupportDashboardView/client.tsx +294 -134
- package/src/views/TicketDetailView/client.tsx +486 -213
- package/src/views/TicketInboxView/client.tsx +52 -61
- package/src/views/TicketingSettingsView/client.tsx +10 -9
- 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: {
|
|
13
|
-
error: {
|
|
14
|
-
ignored: {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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", {
|
|
92
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
93
|
-
/* @__PURE__ */ jsxRuntime.
|
|
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", {
|
|
96
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
97
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
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", {
|
|
100
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
101
|
-
/* @__PURE__ */ jsxRuntime.
|
|
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", {
|
|
105
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
106
|
-
|
|
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)
|
|
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
|
-
|
|
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", {
|
|
115
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", {
|
|
116
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", {
|
|
117
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", {
|
|
118
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", {
|
|
119
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", {
|
|
120
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { style: {
|
|
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: {
|
|
125
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { style: {
|
|
126
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { style: {
|
|
127
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", {
|
|
128
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", {
|
|
129
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { style: {
|
|
130
|
-
/* @__PURE__ */ jsxRuntime.
|
|
131
|
-
log.processingTimeMs,
|
|
132
|
-
|
|
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", {
|
|
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", {
|
|
144
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", {
|
|
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", {
|
|
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 {
|
|
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: {
|
|
8
|
-
error: {
|
|
9
|
-
ignored: {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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", {
|
|
87
|
-
/* @__PURE__ */ jsx("div", {
|
|
88
|
-
/* @__PURE__ */
|
|
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", {
|
|
91
|
-
/* @__PURE__ */ jsx("div", {
|
|
92
|
-
/* @__PURE__ */ jsx("div", {
|
|
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", {
|
|
95
|
-
/* @__PURE__ */ jsx("div", {
|
|
96
|
-
/* @__PURE__ */
|
|
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", {
|
|
100
|
-
/* @__PURE__ */ jsx("div", {
|
|
101
|
-
|
|
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)
|
|
109
|
+
/* @__PURE__ */ jsx("input", { type: "text", className: s.searchInput, placeholder: t("emailTracking.searchPlaceholder"), value: search, onChange: (e) => setSearch(e.target.value) })
|
|
106
110
|
] }),
|
|
107
|
-
|
|
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", {
|
|
110
|
-
/* @__PURE__ */ jsx("th", {
|
|
111
|
-
/* @__PURE__ */ jsx("th", {
|
|
112
|
-
/* @__PURE__ */ jsx("th", {
|
|
113
|
-
/* @__PURE__ */ jsx("th", {
|
|
114
|
-
/* @__PURE__ */ jsx("th", {
|
|
115
|
-
/* @__PURE__ */ jsx("th", { style: {
|
|
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: {
|
|
120
|
-
/* @__PURE__ */ jsx("td", { style: {
|
|
121
|
-
/* @__PURE__ */ jsx("td", { style: {
|
|
122
|
-
/* @__PURE__ */ jsx("td", {
|
|
123
|
-
/* @__PURE__ */ jsx("td", {
|
|
124
|
-
/* @__PURE__ */ jsx("td", { style: {
|
|
125
|
-
/* @__PURE__ */
|
|
126
|
-
log.processingTimeMs,
|
|
127
|
-
|
|
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", {
|
|
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", {
|
|
139
|
-
/* @__PURE__ */ jsx("button", {
|
|
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", {
|
|
159
|
+
/* @__PURE__ */ jsx("button", { className: s.pageBtn, onClick: () => setPage((p) => p + 1), disabled: !hasMore, children: t("common.next") })
|
|
150
160
|
] })
|
|
151
161
|
] });
|
|
152
162
|
};
|