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