@consilioweb/payload-support 0.6.0 → 0.6.2
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/{styles/theme.css → components/TicketConversation.css} +13 -326
- package/dist/components/TicketConversation.js +3004 -0
- package/dist/index.cjs +11 -11
- package/dist/index.js +11 -11
- package/dist/views/BillingView/client.cjs +209 -0
- package/dist/views/BillingView/index.cjs +34 -0
- package/dist/views/ChatView/client.cjs +253 -0
- package/dist/views/ChatView/index.cjs +34 -0
- package/dist/views/CrmView/client.cjs +233 -0
- package/dist/views/CrmView/index.cjs +34 -0
- package/dist/views/EmailTrackingView/client.cjs +159 -0
- package/dist/views/EmailTrackingView/index.cjs +34 -0
- package/dist/views/ImportConversationView/client.cjs +205 -0
- package/dist/views/ImportConversationView/index.cjs +34 -0
- package/dist/views/LogsView/client.cjs +149 -0
- package/dist/views/LogsView/index.cjs +32 -0
- package/dist/views/NewTicketView/client.cjs +229 -0
- package/dist/views/NewTicketView/index.cjs +32 -0
- package/dist/views/PendingEmailsView/client.cjs +173 -0
- package/dist/views/PendingEmailsView/index.cjs +34 -0
- package/dist/views/SupportDashboardView/client.cjs +301 -0
- package/dist/views/SupportDashboardView/index.cjs +34 -0
- package/dist/views/TicketDetailView/client.cjs +850 -0
- package/dist/views/TicketDetailView/index.cjs +34 -0
- package/dist/views/TicketInboxView/client.cjs +299 -0
- package/dist/views/TicketInboxView/index.cjs +32 -0
- package/dist/views/TicketingSettingsView/client.cjs +733 -0
- package/dist/views/TicketingSettingsView/index.cjs +34 -0
- package/dist/views/TimeDashboardView/client.cjs +169 -0
- package/dist/views/TimeDashboardView/index.cjs +34 -0
- package/dist/views/shared/AdminViewHeader.cjs +68 -0
- package/dist/views/shared/ErrorBoundary.cjs +55 -0
- package/dist/views/shared/Skeleton.cjs +77 -0
- package/dist/views/shared/adminTokens.cjs +34 -0
- package/dist/views/shared/adminTokens.js +0 -1
- package/dist/{components/TicketConversation/config.js → views/shared/config.cjs} +5 -2
- package/dist/views/shared/config.js +0 -1
- package/dist/views/shared/index.cjs +58 -0
- package/dist/views/shared/index.js +0 -1
- package/dist/views.cjs +86 -0
- package/dist/views.d.cts +13 -0
- package/dist/views.d.ts +13 -0
- package/dist/views.js +13 -0
- package/package.json +14 -7
- package/src/plugin.ts +11 -11
- package/src/views.ts +17 -0
- package/dist/components/TicketConversation/components/AISummaryPanel.js +0 -76
- package/dist/components/TicketConversation/components/ActionPanels.js +0 -118
- package/dist/components/TicketConversation/components/ActivityLog.js +0 -23
- package/dist/components/TicketConversation/components/ClientBar.js +0 -42
- package/dist/components/TicketConversation/components/ClientHistory.js +0 -137
- package/dist/components/TicketConversation/components/CodeBlock.js +0 -152
- package/dist/components/TicketConversation/components/CodeBlockInserter.js +0 -155
- package/dist/components/TicketConversation/components/QuickActions.js +0 -65
- package/dist/components/TicketConversation/components/TicketHeader.js +0 -92
- package/dist/components/TicketConversation/components/TimeTrackingPanel.js +0 -133
- package/dist/components/TicketConversation/constants.js +0 -96
- package/dist/components/TicketConversation/context.js +0 -11
- package/dist/components/TicketConversation/hooks/useAI.js +0 -176
- package/dist/components/TicketConversation/hooks/useMessageActions.js +0 -135
- package/dist/components/TicketConversation/hooks/useReply.js +0 -187
- package/dist/components/TicketConversation/hooks/useTicketActions.js +0 -230
- package/dist/components/TicketConversation/hooks/useTimeTracking.js +0 -122
- package/dist/components/TicketConversation/hooks/useTranslation.js +0 -70
- package/dist/components/TicketConversation/index.js +0 -1123
- package/dist/components/TicketConversation/locales/en.json +0 -878
- package/dist/components/TicketConversation/locales/fr.json +0 -878
- package/dist/components/TicketConversation/types.js +0 -2
- package/dist/components/TicketConversation/utils.js +0 -25
- package/dist/styles/BillingView.module.scss +0 -311
- package/dist/styles/ChatView.module.scss +0 -438
- package/dist/styles/CommandPalette.module.scss +0 -160
- package/dist/styles/CrmView.module.scss +0 -554
- package/dist/styles/EmailTracking.module.scss +0 -238
- package/dist/styles/ImportConversation.module.scss +0 -267
- package/dist/styles/Layout.module.scss +0 -55
- package/dist/styles/Logs.module.scss +0 -164
- package/dist/styles/NewTicket.module.scss +0 -143
- package/dist/styles/PendingEmails.module.scss +0 -629
- package/dist/styles/SupportDashboard.module.scss +0 -649
- package/dist/styles/TicketDetail.module.scss +0 -1050
- package/dist/styles/TicketInbox.module.scss +0 -296
- package/dist/styles/TicketingSettings.module.scss +0 -358
- package/dist/styles/TimeDashboard.module.scss +0 -287
- package/dist/styles/_tokens.scss +0 -78
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var useTranslation = require('../../components/TicketConversation/hooks/useTranslation');
|
|
6
|
+
|
|
7
|
+
function ImportConversationClient() {
|
|
8
|
+
const { t } = useTranslation.useTranslation();
|
|
9
|
+
const [markdown, setMarkdown] = react.useState("");
|
|
10
|
+
const [fileName, setFileName] = react.useState("");
|
|
11
|
+
const [isDragOver, setIsDragOver] = react.useState(false);
|
|
12
|
+
const [preview, setPreview] = react.useState(null);
|
|
13
|
+
const [result, setResult] = react.useState(null);
|
|
14
|
+
const [error, setError] = react.useState("");
|
|
15
|
+
const [loading, setLoading] = react.useState(false);
|
|
16
|
+
const fileRef = react.useRef(null);
|
|
17
|
+
const handleFile = react.useCallback((file) => {
|
|
18
|
+
if (!file.name.endsWith(".md") && !file.name.endsWith(".txt")) {
|
|
19
|
+
setError(t("import.formatError"));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (file.size > 512e3) {
|
|
23
|
+
setError(t("import.sizeError"));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
setError("");
|
|
27
|
+
setFileName(file.name);
|
|
28
|
+
setResult(null);
|
|
29
|
+
setPreview(null);
|
|
30
|
+
const reader = new FileReader();
|
|
31
|
+
reader.onload = (e) => {
|
|
32
|
+
setMarkdown(e.target?.result);
|
|
33
|
+
};
|
|
34
|
+
reader.readAsText(file);
|
|
35
|
+
}, []);
|
|
36
|
+
const onDrop = react.useCallback((e) => {
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
setIsDragOver(false);
|
|
39
|
+
const file = e.dataTransfer.files[0];
|
|
40
|
+
if (file) handleFile(file);
|
|
41
|
+
}, [handleFile]);
|
|
42
|
+
const onFileChange = react.useCallback((e) => {
|
|
43
|
+
const file = e.target.files?.[0];
|
|
44
|
+
if (file) handleFile(file);
|
|
45
|
+
}, [handleFile]);
|
|
46
|
+
const doPreview = react.useCallback(async () => {
|
|
47
|
+
if (!markdown) return;
|
|
48
|
+
setLoading(true);
|
|
49
|
+
setError("");
|
|
50
|
+
setPreview(null);
|
|
51
|
+
try {
|
|
52
|
+
const res = await fetch("/api/support/import-conversation", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ markdown, previewOnly: true }) });
|
|
53
|
+
const data = await res.json();
|
|
54
|
+
if (!res.ok) {
|
|
55
|
+
setError(data.error || "Erreur");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
;
|
|
59
|
+
setPreview(data);
|
|
60
|
+
} catch {
|
|
61
|
+
setError("Erreur reseau");
|
|
62
|
+
} finally {
|
|
63
|
+
setLoading(false);
|
|
64
|
+
}
|
|
65
|
+
}, [markdown]);
|
|
66
|
+
const doImport = react.useCallback(async () => {
|
|
67
|
+
if (!markdown) return;
|
|
68
|
+
setLoading(true);
|
|
69
|
+
setError("");
|
|
70
|
+
try {
|
|
71
|
+
const res = await fetch("/api/support/import-conversation", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ markdown }) });
|
|
72
|
+
const data = await res.json();
|
|
73
|
+
if (!res.ok) {
|
|
74
|
+
setError(data.error || "Erreur");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
;
|
|
78
|
+
setResult(data);
|
|
79
|
+
setPreview(null);
|
|
80
|
+
} catch {
|
|
81
|
+
setError("Erreur reseau");
|
|
82
|
+
} finally {
|
|
83
|
+
setLoading(false);
|
|
84
|
+
}
|
|
85
|
+
}, [markdown]);
|
|
86
|
+
const reset = react.useCallback(() => {
|
|
87
|
+
setMarkdown("");
|
|
88
|
+
setFileName("");
|
|
89
|
+
setPreview(null);
|
|
90
|
+
setResult(null);
|
|
91
|
+
setError("");
|
|
92
|
+
if (fileRef.current) fileRef.current.value = "";
|
|
93
|
+
}, []);
|
|
94
|
+
const S = {
|
|
95
|
+
page: { padding: "20px 30px", maxWidth: 720, margin: "0 auto" },
|
|
96
|
+
dropzone: { border: "2px dashed var(--theme-elevation-300)", borderRadius: 12, padding: 40, textAlign: "center", cursor: "pointer", transition: "all 150ms" },
|
|
97
|
+
dropzoneDragOver: { border: "2px dashed #2563eb", borderRadius: 12, padding: 40, textAlign: "center", cursor: "pointer", background: "#eff6ff" },
|
|
98
|
+
dropzoneHasFile: { border: "2px solid #22c55e", borderRadius: 12, padding: 40, textAlign: "center", cursor: "pointer", background: "#f0fdf4" },
|
|
99
|
+
btn: { padding: "8px 16px", borderRadius: 8, border: "1px solid var(--theme-elevation-200)", fontSize: 13, cursor: "pointer", background: "var(--theme-elevation-0)", color: "var(--theme-text)", fontWeight: 600 },
|
|
100
|
+
btnPrimary: { padding: "8px 16px", borderRadius: 8, border: "none", fontSize: 13, cursor: "pointer", background: "#2563eb", color: "#fff", fontWeight: 600 },
|
|
101
|
+
btnGreen: { padding: "8px 16px", borderRadius: 8, border: "none", fontSize: 13, cursor: "pointer", background: "#16a34a", color: "#fff", fontWeight: 600 },
|
|
102
|
+
btnAmber: { padding: "8px 16px", borderRadius: 8, border: "none", fontSize: 13, cursor: "pointer", background: "#d97706", color: "#fff", fontWeight: 600 },
|
|
103
|
+
section: { padding: 16, borderRadius: 10, border: "1px solid var(--theme-elevation-150)", marginBottom: 12 },
|
|
104
|
+
infoRow: { display: "flex", justifyContent: "space-between", padding: "4px 0", fontSize: 13 },
|
|
105
|
+
infoLabel: { color: "var(--theme-elevation-500)" },
|
|
106
|
+
infoValue: { fontWeight: 600, color: "var(--theme-text)" },
|
|
107
|
+
msgAdmin: { padding: "8px 12px", borderRadius: 8, background: "#dbeafe", marginBottom: 6 },
|
|
108
|
+
msgClient: { padding: "8px 12px", borderRadius: 8, background: "var(--theme-elevation-50)", marginBottom: 6 },
|
|
109
|
+
resultSuccess: { padding: 20, borderRadius: 10, border: "2px solid #22c55e", background: "#f0fdf4" },
|
|
110
|
+
resultError: { padding: 16, borderRadius: 10, border: "1px solid #fecaca", background: "#fef2f2", color: "#dc2626", marginBottom: 12 }
|
|
111
|
+
};
|
|
112
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.page, children: [
|
|
113
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 20 }, children: [
|
|
114
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { style: { fontSize: 22, fontWeight: 700, margin: 0 }, children: t("import.title") }),
|
|
115
|
+
result && /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: reset, style: S.btnPrimary, children: t("import.newImport") })
|
|
116
|
+
] }),
|
|
117
|
+
!result && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: isDragOver ? S.dropzoneDragOver : markdown ? S.dropzoneHasFile : S.dropzone, onDragOver: (e) => {
|
|
118
|
+
e.preventDefault();
|
|
119
|
+
setIsDragOver(true);
|
|
120
|
+
}, onDragLeave: () => setIsDragOver(false), onDrop, onClick: () => fileRef.current?.click(), children: [
|
|
121
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 24, marginBottom: 8 }, children: "\u2191" }),
|
|
122
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { fontSize: 14, color: "var(--theme-text)" }, children: markdown ? t("import.dropzoneLoaded") : t("import.dropzoneText") }),
|
|
123
|
+
!markdown && /* @__PURE__ */ jsxRuntime.jsx("p", { style: { fontSize: 12, color: "var(--theme-elevation-400)", marginTop: 8 }, children: t("import.acceptedFormats") }),
|
|
124
|
+
fileName && /* @__PURE__ */ jsxRuntime.jsx("p", { style: { fontSize: 12, fontWeight: 600, marginTop: 8 }, children: fileName }),
|
|
125
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { ref: fileRef, type: "file", accept: ".md,.txt", onChange: onFileChange, style: { display: "none" } })
|
|
126
|
+
] }),
|
|
127
|
+
error && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.resultError, children: [
|
|
128
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: t("common.error") }),
|
|
129
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: "4px 0 0" }, children: error })
|
|
130
|
+
] }),
|
|
131
|
+
markdown && !preview && !result && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", justifyContent: "center", marginTop: 16 }, children: /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: doPreview, disabled: loading, style: S.btnAmber, children: loading ? t("import.analyzing") : t("import.preview") }) }),
|
|
132
|
+
preview && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
133
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.section, children: [
|
|
134
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontWeight: 700, marginBottom: 8 }, children: t("import.client") }),
|
|
135
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.infoRow, children: [
|
|
136
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: S.infoLabel, children: t("import.name") }),
|
|
137
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: S.infoValue, children: preview.client.name })
|
|
138
|
+
] }),
|
|
139
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.infoRow, children: [
|
|
140
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: S.infoLabel, children: t("import.email") }),
|
|
141
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: S.infoValue, children: preview.client.email })
|
|
142
|
+
] }),
|
|
143
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.infoRow, children: [
|
|
144
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: S.infoLabel, children: t("import.company") }),
|
|
145
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: S.infoValue, children: preview.client.company })
|
|
146
|
+
] }),
|
|
147
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.infoRow, children: [
|
|
148
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: S.infoLabel, children: t("import.parsing") }),
|
|
149
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: S.infoValue, children: preview.parseMethod === "structured" ? t("import.parsingRegex") : t("import.parsingAi") })
|
|
150
|
+
] })
|
|
151
|
+
] }),
|
|
152
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.section, children: [
|
|
153
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { fontWeight: 700, marginBottom: 8, display: "flex", justifyContent: "space-between" }, children: [
|
|
154
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: preview.subject }),
|
|
155
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { color: "var(--theme-elevation-500)", fontSize: 12 }, children: [
|
|
156
|
+
preview.messageCount,
|
|
157
|
+
" ",
|
|
158
|
+
t("import.messages")
|
|
159
|
+
] })
|
|
160
|
+
] }),
|
|
161
|
+
preview.messages.map((msg, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: msg.from === "admin" ? S.msgAdmin : S.msgClient, children: [
|
|
162
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "space-between", fontSize: 12, marginBottom: 4 }, children: [
|
|
163
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { fontWeight: 600 }, children: [
|
|
164
|
+
msg.from === "admin" ? ">> " : "<< ",
|
|
165
|
+
msg.name
|
|
166
|
+
] }),
|
|
167
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "var(--theme-elevation-400)" }, children: msg.date })
|
|
168
|
+
] }),
|
|
169
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 13 }, children: msg.preview })
|
|
170
|
+
] }, i))
|
|
171
|
+
] }),
|
|
172
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: 8, justifyContent: "flex-end", marginTop: 12 }, children: [
|
|
173
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { onClick: () => setPreview(null), style: S.btn, children: t("common.cancel") }),
|
|
174
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { onClick: doImport, disabled: loading, style: S.btnGreen, children: loading ? t("import.importing") : t("import.importButton", { count: String(preview.messageCount) }) })
|
|
175
|
+
] })
|
|
176
|
+
] }),
|
|
177
|
+
result && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.resultSuccess, children: [
|
|
178
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontWeight: 700, fontSize: 16, marginBottom: 12, color: "#166534" }, children: t("import.resultTitle") }),
|
|
179
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.infoRow, children: [
|
|
180
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: S.infoLabel, children: t("import.resultTicket") }),
|
|
181
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: S.infoValue, children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: `/admin/support/ticket?id=${result.ticketId}`, style: { color: "#2563eb" }, children: result.ticketNumber }) })
|
|
182
|
+
] }),
|
|
183
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.infoRow, children: [
|
|
184
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: S.infoLabel, children: t("import.resultClient") }),
|
|
185
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: S.infoValue, children: [
|
|
186
|
+
result.clientName,
|
|
187
|
+
" (",
|
|
188
|
+
result.clientEmail,
|
|
189
|
+
")",
|
|
190
|
+
result.isNewClient && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { marginLeft: 8, padding: "1px 6px", borderRadius: 4, background: "#dbeafe", color: "#1e40af", fontSize: 10 }, children: t("import.resultNew") })
|
|
191
|
+
] })
|
|
192
|
+
] }),
|
|
193
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.infoRow, children: [
|
|
194
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: S.infoLabel, children: t("import.resultCompany") }),
|
|
195
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: S.infoValue, children: result.clientCompany })
|
|
196
|
+
] }),
|
|
197
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.infoRow, children: [
|
|
198
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: S.infoLabel, children: t("import.resultMessages") }),
|
|
199
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: S.infoValue, children: t("import.resultImported", { count: String(result.messagesImported) }) })
|
|
200
|
+
] })
|
|
201
|
+
] })
|
|
202
|
+
] });
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
exports.ImportConversationClient = ImportConversationClient;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var templates = require('@payloadcms/next/templates');
|
|
7
|
+
var navigation = require('next/navigation');
|
|
8
|
+
var ErrorBoundary = require('../shared/ErrorBoundary');
|
|
9
|
+
var client = require('./client');
|
|
10
|
+
|
|
11
|
+
const ImportConversationView = ({ initPageResult }) => {
|
|
12
|
+
const { req, visibleEntities } = initPageResult;
|
|
13
|
+
if (!req.user) {
|
|
14
|
+
navigation.redirect("/admin/login");
|
|
15
|
+
}
|
|
16
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
17
|
+
templates.DefaultTemplate,
|
|
18
|
+
{
|
|
19
|
+
i18n: req.i18n,
|
|
20
|
+
locale: initPageResult.locale,
|
|
21
|
+
params: {},
|
|
22
|
+
payload: req.payload,
|
|
23
|
+
permissions: initPageResult.permissions,
|
|
24
|
+
searchParams: {},
|
|
25
|
+
user: req.user,
|
|
26
|
+
visibleEntities,
|
|
27
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary.AdminErrorBoundary, { viewName: "ImportConversationView", children: /* @__PURE__ */ jsxRuntime.jsx(client.ImportConversationClient, {}) })
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
var ImportConversationView_default = ImportConversationView;
|
|
32
|
+
|
|
33
|
+
exports.ImportConversationView = ImportConversationView;
|
|
34
|
+
exports.default = ImportConversationView_default;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var navigation = require('next/navigation');
|
|
6
|
+
var useTranslation = require('../../components/TicketConversation/hooks/useTranslation');
|
|
7
|
+
|
|
8
|
+
function fmtDate(d) {
|
|
9
|
+
return new Date(d).toLocaleDateString("fr-FR", { day: "2-digit", month: "2-digit", year: "2-digit", hour: "2-digit", minute: "2-digit" });
|
|
10
|
+
}
|
|
11
|
+
const LogsClient = () => {
|
|
12
|
+
const { t } = useTranslation.useTranslation();
|
|
13
|
+
const searchParams = navigation.useSearchParams();
|
|
14
|
+
const [logType, setLogType] = react.useState(() => {
|
|
15
|
+
const t2 = searchParams.get("type");
|
|
16
|
+
return t2 === "auth" ? "auth" : "email";
|
|
17
|
+
});
|
|
18
|
+
const [logs, setLogs] = react.useState([]);
|
|
19
|
+
const [loading, setLoading] = react.useState(true);
|
|
20
|
+
const [page, setPage] = react.useState(1);
|
|
21
|
+
const [hasMore, setHasMore] = react.useState(false);
|
|
22
|
+
const [totalDocs, setTotalDocs] = react.useState(0);
|
|
23
|
+
const [purgeResult, setPurgeResult] = react.useState(null);
|
|
24
|
+
const collection = logType === "email" ? "email-logs" : "auth-logs";
|
|
25
|
+
const fetchLogs = react.useCallback(async () => {
|
|
26
|
+
try {
|
|
27
|
+
const res = await fetch(`/api/${collection}?sort=-createdAt&limit=30&page=${page}&depth=0`, { credentials: "include" });
|
|
28
|
+
if (res.ok) {
|
|
29
|
+
const d = await res.json();
|
|
30
|
+
setLogs(d.docs || []);
|
|
31
|
+
setHasMore(d.hasNextPage);
|
|
32
|
+
setTotalDocs(d.totalDocs);
|
|
33
|
+
}
|
|
34
|
+
} catch {
|
|
35
|
+
}
|
|
36
|
+
setLoading(false);
|
|
37
|
+
}, [collection, page]);
|
|
38
|
+
react.useEffect(() => {
|
|
39
|
+
setLoading(true);
|
|
40
|
+
setPage(1);
|
|
41
|
+
}, [logType]);
|
|
42
|
+
react.useEffect(() => {
|
|
43
|
+
fetchLogs();
|
|
44
|
+
}, [fetchLogs]);
|
|
45
|
+
const handlePurge = async (days) => {
|
|
46
|
+
const label = days === 0 ? "TOUS les logs" : `les logs de plus de ${days} jours`;
|
|
47
|
+
if (!window.confirm(`Supprimer ${label} (${collection}) ? Cette action est irreversible.`)) return;
|
|
48
|
+
try {
|
|
49
|
+
const res = await fetch(`/api/support/purge-logs?collection=${collection}&days=${days}`, { method: "DELETE", credentials: "include" });
|
|
50
|
+
if (res.ok) {
|
|
51
|
+
const d = await res.json();
|
|
52
|
+
setPurgeResult(`${d.purged} log(s) supprime(s)`);
|
|
53
|
+
setTimeout(() => setPurgeResult(null), 5e3);
|
|
54
|
+
fetchLogs();
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const S = {
|
|
60
|
+
page: { padding: "20px 30px", maxWidth: 1100, margin: "0 auto" },
|
|
61
|
+
header: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 16 },
|
|
62
|
+
title: { fontSize: 22, fontWeight: 700, margin: 0, color: "var(--theme-text)" },
|
|
63
|
+
tabsRow: { display: "flex", gap: 4, marginBottom: 12 },
|
|
64
|
+
tab: { padding: "6px 12px", borderRadius: 6, border: "none", background: "none", cursor: "pointer", fontSize: 13, color: "var(--theme-elevation-500)", fontWeight: 500 },
|
|
65
|
+
tabActive: { background: "var(--theme-elevation-100)", color: "var(--theme-text)", fontWeight: 700 },
|
|
66
|
+
purgeBtn: { padding: "4px 10px", borderRadius: 6, border: "1px solid var(--theme-elevation-200)", fontSize: 11, background: "var(--theme-elevation-0)", cursor: "pointer", color: "var(--theme-text)" },
|
|
67
|
+
table: { width: "100%", borderCollapse: "collapse", fontSize: 13 },
|
|
68
|
+
th: { textAlign: "left", padding: "8px", borderBottom: "1px solid var(--theme-elevation-200)", fontSize: 11, color: "var(--theme-elevation-500)" },
|
|
69
|
+
td: { padding: "8px", borderBottom: "1px solid var(--theme-elevation-100)" },
|
|
70
|
+
badge: { padding: "2px 8px", borderRadius: 4, fontSize: 11, fontWeight: 600 },
|
|
71
|
+
mono: { fontFamily: "monospace", fontSize: 12 }
|
|
72
|
+
};
|
|
73
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.page, children: [
|
|
74
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.header, children: [
|
|
75
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { style: S.title, children: logType === "email" ? t("logs.title") : t("logs.titleAuth") }),
|
|
76
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: 6 }, children: [
|
|
77
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { style: S.purgeBtn, onClick: () => handlePurge(7), children: t("logs.purge7") }),
|
|
78
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { style: S.purgeBtn, onClick: () => handlePurge(30), children: t("logs.purge30") }),
|
|
79
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { style: { ...S.purgeBtn, color: "#dc2626", borderColor: "#dc2626" }, onClick: () => handlePurge(0), children: t("logs.purgeAll") })
|
|
80
|
+
] })
|
|
81
|
+
] }),
|
|
82
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.tabsRow, children: [
|
|
83
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { style: { ...S.tab, ...logType === "email" ? S.tabActive : {} }, onClick: () => setLogType("email"), children: [
|
|
84
|
+
t("logs.tabs.email"),
|
|
85
|
+
" (",
|
|
86
|
+
logType === "email" ? totalDocs : "...",
|
|
87
|
+
")"
|
|
88
|
+
] }),
|
|
89
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { style: { ...S.tab, ...logType === "auth" ? S.tabActive : {} }, onClick: () => setLogType("auth"), children: [
|
|
90
|
+
t("logs.tabs.auth"),
|
|
91
|
+
" (",
|
|
92
|
+
logType === "auth" ? totalDocs : "...",
|
|
93
|
+
")"
|
|
94
|
+
] })
|
|
95
|
+
] }),
|
|
96
|
+
purgeResult && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "8px 14px", borderRadius: 6, background: "#dcfce7", color: "#166534", fontSize: 13, marginBottom: 12 }, children: purgeResult }),
|
|
97
|
+
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("logs.noLogs") }) : logType === "email" ? /* @__PURE__ */ jsxRuntime.jsxs("table", { style: S.table, children: [
|
|
98
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
99
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("logs.tableHeaders.date") }),
|
|
100
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("logs.tableHeaders.status") }),
|
|
101
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("logs.tableHeaders.recipient") }),
|
|
102
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("logs.tableHeaders.subject") }),
|
|
103
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("logs.tableHeaders.action") }),
|
|
104
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { ...S.th, textAlign: "right" }, children: t("logs.tableHeaders.time") })
|
|
105
|
+
] }) }),
|
|
106
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: logs.map((log) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
107
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: { ...S.td, ...S.mono }, children: fmtDate(log.createdAt) }),
|
|
108
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: S.td, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: { ...S.badge, background: log.status === "success" ? "#dcfce7" : log.status === "error" ? "#fef2f2" : "#f3f4f6", color: log.status === "success" ? "#16a34a" : log.status === "error" ? "#dc2626" : "#6b7280" }, children: log.status === "success" ? t("logs.statusSuccess") : log.status === "error" ? t("logs.statusError") : t("logs.statusIgnored") }) }),
|
|
109
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: { ...S.td, maxWidth: 200, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, title: log.recipientEmail, children: log.recipientEmail || "--" }),
|
|
110
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: { ...S.td, maxWidth: 200, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, title: log.subject, children: log.subject || "--" }),
|
|
111
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: { ...S.td, fontSize: 12, color: "var(--theme-elevation-500)" }, children: log.action || "--" }),
|
|
112
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: { ...S.td, textAlign: "right" }, children: log.processingTimeMs != null ? /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { ...S.mono, color: log.processingTimeMs > 2e3 ? "#dc2626" : "#16a34a" }, children: [
|
|
113
|
+
log.processingTimeMs,
|
|
114
|
+
"ms"
|
|
115
|
+
] }) : "--" })
|
|
116
|
+
] }, log.id)) })
|
|
117
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("table", { style: S.table, children: [
|
|
118
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
119
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("logs.tableHeaders.date") }),
|
|
120
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("logs.tableHeaders.status") }),
|
|
121
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("logs.tableHeaders.email") }),
|
|
122
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("logs.tableHeaders.ip") }),
|
|
123
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("logs.tableHeaders.userAgent") })
|
|
124
|
+
] }) }),
|
|
125
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: logs.map((log) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
126
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: { ...S.td, ...S.mono }, children: fmtDate(log.createdAt) }),
|
|
127
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: S.td, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: { ...S.badge, background: log.success ? "#dcfce7" : "#fef2f2", color: log.success ? "#16a34a" : "#dc2626" }, children: log.success ? t("logs.statusSuccess") : t("logs.statusFailed") }) }),
|
|
128
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: { ...S.td, ...S.mono }, children: log.email || "--" }),
|
|
129
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: { ...S.td, ...S.mono }, children: log.ip || "--" }),
|
|
130
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: { ...S.td, fontSize: 11, maxWidth: 200, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: log.userAgent || "--" })
|
|
131
|
+
] }, log.id)) })
|
|
132
|
+
] }),
|
|
133
|
+
totalDocs > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "center", gap: 12, marginTop: 16, alignItems: "center" }, children: [
|
|
134
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { style: S.purgeBtn, onClick: () => setPage((p) => Math.max(1, p - 1)), disabled: page <= 1, children: t("common.previous") }),
|
|
135
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { fontSize: 12, color: "var(--theme-elevation-500)" }, children: [
|
|
136
|
+
t("common.page"),
|
|
137
|
+
" ",
|
|
138
|
+
page,
|
|
139
|
+
" -- ",
|
|
140
|
+
totalDocs,
|
|
141
|
+
" ",
|
|
142
|
+
t("common.results")
|
|
143
|
+
] }),
|
|
144
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { style: S.purgeBtn, onClick: () => setPage((p) => p + 1), disabled: !hasMore, children: t("common.next") })
|
|
145
|
+
] })
|
|
146
|
+
] });
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
exports.LogsClient = LogsClient;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var templates = require('@payloadcms/next/templates');
|
|
7
|
+
var navigation = require('next/navigation');
|
|
8
|
+
var ErrorBoundary = require('../shared/ErrorBoundary');
|
|
9
|
+
var client = require('./client');
|
|
10
|
+
|
|
11
|
+
const LogsView = ({ initPageResult }) => {
|
|
12
|
+
const { req, visibleEntities } = initPageResult;
|
|
13
|
+
if (!req.user) navigation.redirect("/admin/login");
|
|
14
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
15
|
+
templates.DefaultTemplate,
|
|
16
|
+
{
|
|
17
|
+
i18n: req.i18n,
|
|
18
|
+
locale: initPageResult.locale,
|
|
19
|
+
params: {},
|
|
20
|
+
payload: req.payload,
|
|
21
|
+
permissions: initPageResult.permissions,
|
|
22
|
+
searchParams: {},
|
|
23
|
+
user: req.user,
|
|
24
|
+
visibleEntities,
|
|
25
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary.AdminErrorBoundary, { viewName: "LogsView", children: /* @__PURE__ */ jsxRuntime.jsx(client.LogsClient, {}) })
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
var LogsView_default = LogsView;
|
|
30
|
+
|
|
31
|
+
exports.LogsView = LogsView;
|
|
32
|
+
exports.default = LogsView_default;
|