@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
package/dist/index.cjs
CHANGED
|
@@ -7693,25 +7693,25 @@ function supportPlugin(config) {
|
|
|
7693
7693
|
if (features.pendingEmails) supportCollections.push(createPendingEmailsCollection(slugs));
|
|
7694
7694
|
const existingViews = incomingConfig.admin?.components?.views || {};
|
|
7695
7695
|
const supportViews = {
|
|
7696
|
-
"support-inbox": viewConfig(`${viewsBase}
|
|
7697
|
-
"support-dashboard": viewConfig(`${viewsBase}
|
|
7698
|
-
"support-ticket": viewConfig(`${viewsBase}
|
|
7699
|
-
"support-new-ticket": viewConfig(`${viewsBase}
|
|
7700
|
-
"support-settings": viewConfig(`${viewsBase}
|
|
7701
|
-
"support-logs": viewConfig(`${viewsBase}
|
|
7702
|
-
"support-crm": viewConfig(`${viewsBase}
|
|
7696
|
+
"support-inbox": viewConfig(`${viewsBase}#TicketInboxView`, `${bp}/inbox`),
|
|
7697
|
+
"support-dashboard": viewConfig(`${viewsBase}#SupportDashboardView`, `${bp}/dashboard`),
|
|
7698
|
+
"support-ticket": viewConfig(`${viewsBase}#TicketDetailView`, `${bp}/ticket`),
|
|
7699
|
+
"support-new-ticket": viewConfig(`${viewsBase}#NewTicketView`, `${bp}/new-ticket`),
|
|
7700
|
+
"support-settings": viewConfig(`${viewsBase}#TicketingSettingsView`, `${bp}/settings`),
|
|
7701
|
+
"support-logs": viewConfig(`${viewsBase}#LogsView`, `${bp}/logs`),
|
|
7702
|
+
"support-crm": viewConfig(`${viewsBase}#CrmView`, `${bp}/crm`)
|
|
7703
7703
|
};
|
|
7704
7704
|
if (features.chat) {
|
|
7705
|
-
supportViews["support-chat"] = viewConfig(`${viewsBase}
|
|
7705
|
+
supportViews["support-chat"] = viewConfig(`${viewsBase}#ChatView`, `${bp}/chat`);
|
|
7706
7706
|
}
|
|
7707
7707
|
if (features.pendingEmails) {
|
|
7708
|
-
supportViews["support-emails"] = viewConfig(`${viewsBase}
|
|
7708
|
+
supportViews["support-emails"] = viewConfig(`${viewsBase}#PendingEmailsView`, `${bp}/emails`);
|
|
7709
7709
|
}
|
|
7710
7710
|
if (features.emailTracking) {
|
|
7711
|
-
supportViews["support-tracking"] = viewConfig(`${viewsBase}
|
|
7711
|
+
supportViews["support-tracking"] = viewConfig(`${viewsBase}#EmailTrackingView`, `${bp}/tracking`);
|
|
7712
7712
|
}
|
|
7713
7713
|
if (features.timeTracking) {
|
|
7714
|
-
supportViews["support-time"] = viewConfig(`${viewsBase}
|
|
7714
|
+
supportViews["support-time"] = viewConfig(`${viewsBase}#TimeDashboardView`, `${bp}/time`);
|
|
7715
7715
|
}
|
|
7716
7716
|
const existingEndpoints = incomingConfig.endpoints || [];
|
|
7717
7717
|
const supportEndpoints = createSupportEndpoints(slugs, {
|
package/dist/index.js
CHANGED
|
@@ -7687,25 +7687,25 @@ function supportPlugin(config) {
|
|
|
7687
7687
|
if (features.pendingEmails) supportCollections.push(createPendingEmailsCollection(slugs));
|
|
7688
7688
|
const existingViews = incomingConfig.admin?.components?.views || {};
|
|
7689
7689
|
const supportViews = {
|
|
7690
|
-
"support-inbox": viewConfig(`${viewsBase}
|
|
7691
|
-
"support-dashboard": viewConfig(`${viewsBase}
|
|
7692
|
-
"support-ticket": viewConfig(`${viewsBase}
|
|
7693
|
-
"support-new-ticket": viewConfig(`${viewsBase}
|
|
7694
|
-
"support-settings": viewConfig(`${viewsBase}
|
|
7695
|
-
"support-logs": viewConfig(`${viewsBase}
|
|
7696
|
-
"support-crm": viewConfig(`${viewsBase}
|
|
7690
|
+
"support-inbox": viewConfig(`${viewsBase}#TicketInboxView`, `${bp}/inbox`),
|
|
7691
|
+
"support-dashboard": viewConfig(`${viewsBase}#SupportDashboardView`, `${bp}/dashboard`),
|
|
7692
|
+
"support-ticket": viewConfig(`${viewsBase}#TicketDetailView`, `${bp}/ticket`),
|
|
7693
|
+
"support-new-ticket": viewConfig(`${viewsBase}#NewTicketView`, `${bp}/new-ticket`),
|
|
7694
|
+
"support-settings": viewConfig(`${viewsBase}#TicketingSettingsView`, `${bp}/settings`),
|
|
7695
|
+
"support-logs": viewConfig(`${viewsBase}#LogsView`, `${bp}/logs`),
|
|
7696
|
+
"support-crm": viewConfig(`${viewsBase}#CrmView`, `${bp}/crm`)
|
|
7697
7697
|
};
|
|
7698
7698
|
if (features.chat) {
|
|
7699
|
-
supportViews["support-chat"] = viewConfig(`${viewsBase}
|
|
7699
|
+
supportViews["support-chat"] = viewConfig(`${viewsBase}#ChatView`, `${bp}/chat`);
|
|
7700
7700
|
}
|
|
7701
7701
|
if (features.pendingEmails) {
|
|
7702
|
-
supportViews["support-emails"] = viewConfig(`${viewsBase}
|
|
7702
|
+
supportViews["support-emails"] = viewConfig(`${viewsBase}#PendingEmailsView`, `${bp}/emails`);
|
|
7703
7703
|
}
|
|
7704
7704
|
if (features.emailTracking) {
|
|
7705
|
-
supportViews["support-tracking"] = viewConfig(`${viewsBase}
|
|
7705
|
+
supportViews["support-tracking"] = viewConfig(`${viewsBase}#EmailTrackingView`, `${bp}/tracking`);
|
|
7706
7706
|
}
|
|
7707
7707
|
if (features.timeTracking) {
|
|
7708
|
-
supportViews["support-time"] = viewConfig(`${viewsBase}
|
|
7708
|
+
supportViews["support-time"] = viewConfig(`${viewsBase}#TimeDashboardView`, `${bp}/time`);
|
|
7709
7709
|
}
|
|
7710
7710
|
const existingEndpoints = incomingConfig.endpoints || [];
|
|
7711
7711
|
const supportEndpoints = createSupportEndpoints(slugs, {
|
|
@@ -0,0 +1,209 @@
|
|
|
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 _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
10
|
+
|
|
11
|
+
function formatDuration(minutes) {
|
|
12
|
+
const h = Math.floor(minutes / 60);
|
|
13
|
+
const m = minutes % 60;
|
|
14
|
+
if (h === 0) return `${m}min`;
|
|
15
|
+
if (m === 0) return `${h}h`;
|
|
16
|
+
return `${h}h ${m}min`;
|
|
17
|
+
}
|
|
18
|
+
function formatAmount(minutes, rate) {
|
|
19
|
+
return (minutes / 60 * rate).toFixed(2);
|
|
20
|
+
}
|
|
21
|
+
function getMonthRange(offset) {
|
|
22
|
+
const now = /* @__PURE__ */ new Date();
|
|
23
|
+
const start = new Date(now.getFullYear(), now.getMonth() + offset, 1);
|
|
24
|
+
const end = new Date(now.getFullYear(), now.getMonth() + offset + 1, 0);
|
|
25
|
+
return { from: start.toISOString().split("T")[0], to: end.toISOString().split("T")[0] };
|
|
26
|
+
}
|
|
27
|
+
function getQuarterRange(offset) {
|
|
28
|
+
const now = /* @__PURE__ */ new Date();
|
|
29
|
+
const q = Math.floor(now.getMonth() / 3) + offset;
|
|
30
|
+
const start = new Date(now.getFullYear(), q * 3, 1);
|
|
31
|
+
const end = new Date(now.getFullYear(), q * 3 + 3, 0);
|
|
32
|
+
return { from: start.toISOString().split("T")[0], to: end.toISOString().split("T")[0] };
|
|
33
|
+
}
|
|
34
|
+
const BillingClient = () => {
|
|
35
|
+
const { t } = useTranslation.useTranslation();
|
|
36
|
+
const [from, setFrom] = React.useState(() => getMonthRange(0).from);
|
|
37
|
+
const [to, setTo] = React.useState(() => getMonthRange(0).to);
|
|
38
|
+
const [projectId, setProjectId] = React.useState("");
|
|
39
|
+
const [rate, setRate] = React.useState(60);
|
|
40
|
+
const [data, setData] = React.useState(null);
|
|
41
|
+
const [loading, setLoading] = React.useState(false);
|
|
42
|
+
const [projects, setProjects] = React.useState([]);
|
|
43
|
+
const [projectsLoaded, setProjectsLoaded] = React.useState(false);
|
|
44
|
+
const [copied, setCopied] = React.useState(false);
|
|
45
|
+
const loadProjects = React.useCallback(async () => {
|
|
46
|
+
if (projectsLoaded) return;
|
|
47
|
+
try {
|
|
48
|
+
const res = await fetch("/api/projects?limit=100&depth=0&sort=name");
|
|
49
|
+
if (res.ok) {
|
|
50
|
+
const json = await res.json();
|
|
51
|
+
setProjects(json.docs?.map((p) => ({ id: p.id, name: p.name })) || []);
|
|
52
|
+
}
|
|
53
|
+
} catch (err) {
|
|
54
|
+
console.warn("[support] loadProjects error:", err);
|
|
55
|
+
}
|
|
56
|
+
setProjectsLoaded(true);
|
|
57
|
+
}, [projectsLoaded]);
|
|
58
|
+
React__default.default.useEffect(() => {
|
|
59
|
+
loadProjects();
|
|
60
|
+
}, [loadProjects]);
|
|
61
|
+
const fetchBilling = React.useCallback(async () => {
|
|
62
|
+
setLoading(true);
|
|
63
|
+
try {
|
|
64
|
+
const params = new URLSearchParams({ from, to });
|
|
65
|
+
if (projectId) params.set("projectId", projectId);
|
|
66
|
+
const res = await fetch(`/api/support/billing?${params}`);
|
|
67
|
+
if (res.ok) setData(await res.json());
|
|
68
|
+
} catch (err) {
|
|
69
|
+
console.warn("[support] fetchBilling error:", err);
|
|
70
|
+
}
|
|
71
|
+
setLoading(false);
|
|
72
|
+
}, [from, to, projectId]);
|
|
73
|
+
const setPeriod = (range) => {
|
|
74
|
+
setFrom(range.from);
|
|
75
|
+
setTo(range.to);
|
|
76
|
+
};
|
|
77
|
+
const copyRecap = React.useCallback(() => {
|
|
78
|
+
if (!data) return;
|
|
79
|
+
const lines = [`PRE-FACTURATION -- Du ${from} au ${to}`, `Taux horaire : ${rate} EUR/h`, "=".repeat(50)];
|
|
80
|
+
for (const group of data.groups) {
|
|
81
|
+
lines.push("", `PROJET : ${group.project?.name || "Sans projet"}`);
|
|
82
|
+
if (group.client?.company) lines.push(`Client : ${group.client.company}`);
|
|
83
|
+
for (const ticket of group.tickets) {
|
|
84
|
+
lines.push(` ${ticket.ticketNumber} -- ${ticket.subject}`);
|
|
85
|
+
for (const entry of ticket.entries) lines.push(` ${entry.date} | ${formatDuration(entry.duration)} | ${entry.description || "-"}`);
|
|
86
|
+
lines.push(` Sous-total : ${formatDuration(ticket.totalMinutes)} = ${formatAmount(ticket.totalMinutes, rate)} EUR`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
lines.push("", "=".repeat(50), `TOTAL : ${formatDuration(data.grandTotalMinutes)} = ${formatAmount(data.grandTotalMinutes, rate)} EUR`);
|
|
90
|
+
navigator.clipboard.writeText(lines.join("\n"));
|
|
91
|
+
setCopied(true);
|
|
92
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
93
|
+
}, [data, from, to, rate]);
|
|
94
|
+
const S = {
|
|
95
|
+
page: { padding: "20px 30px", maxWidth: 1100, margin: "0 auto" },
|
|
96
|
+
filters: { marginBottom: 20 },
|
|
97
|
+
quickPeriod: { display: "flex", gap: 6, marginBottom: 8 },
|
|
98
|
+
btn: { padding: "6px 12px", borderRadius: 6, border: "1px solid var(--theme-elevation-200)", fontSize: 12, cursor: "pointer", background: "var(--theme-elevation-0)", color: "var(--theme-text)" },
|
|
99
|
+
btnPrimary: { padding: "6px 12px", borderRadius: 6, border: "none", fontSize: 12, cursor: "pointer", background: "#2563eb", color: "#fff", fontWeight: 600 },
|
|
100
|
+
filterRow: { display: "flex", gap: 12, alignItems: "flex-end", flexWrap: "wrap" },
|
|
101
|
+
fieldGroup: { display: "flex", flexDirection: "column", gap: 4 },
|
|
102
|
+
label: { fontSize: 11, fontWeight: 600, color: "var(--theme-elevation-500)" },
|
|
103
|
+
input: { padding: "6px 10px", borderRadius: 6, border: "1px solid var(--theme-elevation-200)", fontSize: 12, color: "var(--theme-text)", background: "var(--theme-elevation-0)" },
|
|
104
|
+
select: { padding: "6px 10px", borderRadius: 6, border: "1px solid var(--theme-elevation-200)", fontSize: 12, color: "var(--theme-text)", background: "var(--theme-elevation-0)" },
|
|
105
|
+
groupCard: { marginBottom: 16, borderRadius: 10, border: "1px solid var(--theme-elevation-150)", overflow: "hidden" },
|
|
106
|
+
groupHeader: { display: "flex", justifyContent: "space-between", padding: "12px 16px", background: "var(--theme-elevation-50)", borderBottom: "1px solid var(--theme-elevation-150)" },
|
|
107
|
+
table: { width: "100%", borderCollapse: "collapse", fontSize: 12 },
|
|
108
|
+
th: { textAlign: "left", padding: "6px 8px", borderBottom: "1px solid var(--theme-elevation-200)", fontSize: 11, color: "var(--theme-elevation-500)" },
|
|
109
|
+
td: { padding: "6px 8px", borderBottom: "1px solid var(--theme-elevation-100)" },
|
|
110
|
+
grandTotal: { padding: 16, borderRadius: 10, border: "2px solid #2563eb", display: "flex", justifyContent: "space-between", alignItems: "center", marginTop: 16 }
|
|
111
|
+
};
|
|
112
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.page, children: [
|
|
113
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: 16 }, children: [
|
|
114
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { style: { fontSize: 22, fontWeight: 700, margin: 0 }, children: t("billing.title") }),
|
|
115
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { fontSize: 13, color: "var(--theme-elevation-500)", margin: "4px 0 0" }, children: t("billing.subtitle") })
|
|
116
|
+
] }),
|
|
117
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.filters, children: [
|
|
118
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.quickPeriod, children: [
|
|
119
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { style: S.btnPrimary, onClick: () => setPeriod(getMonthRange(0)), children: t("billing.filters.thisMonth") }),
|
|
120
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { style: S.btn, onClick: () => setPeriod(getMonthRange(-1)), children: t("billing.filters.lastMonth") }),
|
|
121
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { style: S.btn, onClick: () => setPeriod(getQuarterRange(0)), children: t("billing.filters.thisQuarter") })
|
|
122
|
+
] }),
|
|
123
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.filterRow, children: [
|
|
124
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.fieldGroup, children: [
|
|
125
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: S.label, children: t("billing.filters.from") }),
|
|
126
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "date", value: from, onChange: (e) => setFrom(e.target.value), style: S.input })
|
|
127
|
+
] }),
|
|
128
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.fieldGroup, children: [
|
|
129
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: S.label, children: t("billing.filters.to") }),
|
|
130
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "date", value: to, onChange: (e) => setTo(e.target.value), style: S.input })
|
|
131
|
+
] }),
|
|
132
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.fieldGroup, children: [
|
|
133
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: S.label, children: t("billing.filters.project") }),
|
|
134
|
+
/* @__PURE__ */ jsxRuntime.jsxs("select", { value: projectId, onChange: (e) => setProjectId(e.target.value), style: S.select, children: [
|
|
135
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: t("common.all") }),
|
|
136
|
+
projects.map((p) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: p.id, children: p.name }, p.id))
|
|
137
|
+
] })
|
|
138
|
+
] }),
|
|
139
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.fieldGroup, children: [
|
|
140
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: S.label, children: t("billing.filters.hourlyRate") }),
|
|
141
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: 4, alignItems: "center" }, children: [
|
|
142
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "number", value: rate, onChange: (e) => setRate(Number(e.target.value)), style: { ...S.input, width: 70 }, min: 0 }),
|
|
143
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 11 }, children: t("billing.filters.rateUnit") })
|
|
144
|
+
] })
|
|
145
|
+
] }),
|
|
146
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { style: S.btnPrimary, onClick: fetchBilling, disabled: loading, children: loading ? t("billing.filters.loading") : t("billing.filters.load") })
|
|
147
|
+
] })
|
|
148
|
+
] }),
|
|
149
|
+
data && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: data.groups.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: 40, textAlign: "center", color: "#94a3b8" }, children: t("billing.empty") }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
150
|
+
data.groups.map((group, gi) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.groupCard, children: [
|
|
151
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.groupHeader, children: [
|
|
152
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
153
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 700 }, children: group.project?.name || "Sans projet" }),
|
|
154
|
+
group.client?.company && /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { color: "var(--theme-elevation-500)" }, children: [
|
|
155
|
+
" -- ",
|
|
156
|
+
group.client.company
|
|
157
|
+
] })
|
|
158
|
+
] }),
|
|
159
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { textAlign: "right" }, children: [
|
|
160
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontWeight: 700 }, children: formatDuration(group.totalMinutes) }),
|
|
161
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { fontSize: 12, color: "#2563eb", fontWeight: 600 }, children: [
|
|
162
|
+
formatAmount(group.totalMinutes, rate),
|
|
163
|
+
" EUR"
|
|
164
|
+
] })
|
|
165
|
+
] })
|
|
166
|
+
] }),
|
|
167
|
+
/* @__PURE__ */ jsxRuntime.jsxs("table", { style: S.table, children: [
|
|
168
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
169
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("billing.table.ticketNumber") }),
|
|
170
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("billing.table.subject") }),
|
|
171
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("billing.table.date") }),
|
|
172
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("billing.table.duration") }),
|
|
173
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("billing.table.description") }),
|
|
174
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: { ...S.th, textAlign: "right" }, children: t("billing.table.amount") })
|
|
175
|
+
] }) }),
|
|
176
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: group.tickets.map((ticket) => ticket.entries.map((entry, ei) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
177
|
+
ei === 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
178
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: { ...S.td, fontWeight: 600 }, rowSpan: ticket.entries.length, children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: `/admin/support/ticket?id=${ticket.id}`, style: { color: "#2563eb", textDecoration: "none" }, children: ticket.ticketNumber }) }),
|
|
179
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: S.td, rowSpan: ticket.entries.length, children: ticket.subject })
|
|
180
|
+
] }),
|
|
181
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: S.td, children: entry.date }),
|
|
182
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: S.td, children: formatDuration(entry.duration) }),
|
|
183
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: S.td, children: entry.description || "-" }),
|
|
184
|
+
/* @__PURE__ */ jsxRuntime.jsxs("td", { style: { ...S.td, textAlign: "right", fontWeight: 600 }, children: [
|
|
185
|
+
formatAmount(entry.duration, rate),
|
|
186
|
+
" EUR"
|
|
187
|
+
] })
|
|
188
|
+
] }, `${ticket.id}-${ei}`))) })
|
|
189
|
+
] })
|
|
190
|
+
] }, gi)),
|
|
191
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.grandTotal, children: [
|
|
192
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
193
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 12, color: "var(--theme-elevation-500)" }, children: t("billing.totals.billableTicketsPlural", { count: String(data.groups.reduce((s2, g) => s2 + g.tickets.length, 0)) }) }),
|
|
194
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { fontSize: 18, fontWeight: 700 }, children: [
|
|
195
|
+
t("billing.totals.total"),
|
|
196
|
+
" : ",
|
|
197
|
+
formatDuration(data.grandTotalMinutes),
|
|
198
|
+
" = ",
|
|
199
|
+
formatAmount(data.grandTotalMinutes, rate),
|
|
200
|
+
" EUR"
|
|
201
|
+
] })
|
|
202
|
+
] }),
|
|
203
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { style: S.btnPrimary, onClick: copyRecap, children: copied ? t("billing.totals.copiedRecap") : t("billing.totals.copyRecap") })
|
|
204
|
+
] })
|
|
205
|
+
] }) })
|
|
206
|
+
] });
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
exports.BillingClient = BillingClient;
|
|
@@ -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 BillingView = ({ 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: "BillingView", children: /* @__PURE__ */ jsxRuntime.jsx(client.BillingClient, {}) })
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
var BillingView_default = BillingView;
|
|
32
|
+
|
|
33
|
+
exports.BillingView = BillingView;
|
|
34
|
+
exports.default = BillingView_default;
|
|
@@ -0,0 +1,253 @@
|
|
|
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
|
+
const ChatViewClient = () => {
|
|
8
|
+
const { t } = useTranslation.useTranslation();
|
|
9
|
+
const [sessions, setSessions] = react.useState({ active: [], closed: [] });
|
|
10
|
+
const [selectedSession, setSelectedSession] = react.useState(null);
|
|
11
|
+
const [messages, setMessages] = react.useState([]);
|
|
12
|
+
const [input, setInput] = react.useState("");
|
|
13
|
+
const [sending, setSending] = react.useState(false);
|
|
14
|
+
const [showClosed, setShowClosed] = react.useState(false);
|
|
15
|
+
const [loading, setLoading] = react.useState(true);
|
|
16
|
+
const [cannedResponses, setCannedResponses] = react.useState([]);
|
|
17
|
+
const messagesEndRef = react.useRef(null);
|
|
18
|
+
const lastFetchRef = react.useRef(null);
|
|
19
|
+
const [sessionExpired, setSessionExpired] = react.useState(false);
|
|
20
|
+
const sessionsESRef = react.useRef(null);
|
|
21
|
+
const messagesESRef = react.useRef(null);
|
|
22
|
+
const fetchSessions = react.useCallback(async () => {
|
|
23
|
+
try {
|
|
24
|
+
const res = await fetch("/api/support/admin-chat");
|
|
25
|
+
if (res.status === 401 || res.status === 403) {
|
|
26
|
+
setSessionExpired(true);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (res.ok) {
|
|
30
|
+
const data = await res.json();
|
|
31
|
+
setSessions({ active: data.active || [], closed: data.closed || [] });
|
|
32
|
+
}
|
|
33
|
+
} catch {
|
|
34
|
+
}
|
|
35
|
+
setLoading(false);
|
|
36
|
+
}, []);
|
|
37
|
+
react.useEffect(() => {
|
|
38
|
+
if (sessionExpired) return;
|
|
39
|
+
fetchSessions();
|
|
40
|
+
if (typeof EventSource !== "undefined") {
|
|
41
|
+
const es = new EventSource("/api/support/admin-chat-stream");
|
|
42
|
+
sessionsESRef.current = es;
|
|
43
|
+
es.onmessage = (event) => {
|
|
44
|
+
try {
|
|
45
|
+
const parsed = JSON.parse(event.data);
|
|
46
|
+
if (parsed.type === "sessions" && parsed.data) {
|
|
47
|
+
setSessions({ active: parsed.data.active || [], closed: parsed.data.closed || [] });
|
|
48
|
+
setLoading(false);
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
es.onerror = () => {
|
|
54
|
+
es.close();
|
|
55
|
+
sessionsESRef.current = null;
|
|
56
|
+
const iv2 = setInterval(fetchSessions, 5e3);
|
|
57
|
+
return () => clearInterval(iv2);
|
|
58
|
+
};
|
|
59
|
+
return () => {
|
|
60
|
+
es.close();
|
|
61
|
+
sessionsESRef.current = null;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const iv = setInterval(fetchSessions, 5e3);
|
|
65
|
+
return () => clearInterval(iv);
|
|
66
|
+
}, [fetchSessions, sessionExpired]);
|
|
67
|
+
react.useEffect(() => {
|
|
68
|
+
fetch("/api/canned-responses?sort=sortOrder&limit=50&depth=0", { credentials: "include" }).then((res) => res.ok ? res.json() : null).then((data) => {
|
|
69
|
+
if (data?.docs) setCannedResponses(data.docs);
|
|
70
|
+
}).catch(() => {
|
|
71
|
+
});
|
|
72
|
+
}, []);
|
|
73
|
+
react.useEffect(() => {
|
|
74
|
+
if (!selectedSession) return;
|
|
75
|
+
const fetchMessages = async () => {
|
|
76
|
+
try {
|
|
77
|
+
const after = lastFetchRef.current || "";
|
|
78
|
+
const url = `/api/support/admin-chat?session=${selectedSession}${after ? `&after=${after}` : ""}`;
|
|
79
|
+
const res = await fetch(url);
|
|
80
|
+
if (res.ok) {
|
|
81
|
+
const data = await res.json();
|
|
82
|
+
if (!lastFetchRef.current) {
|
|
83
|
+
setMessages(data.messages || []);
|
|
84
|
+
} else if (data.messages?.length > 0) {
|
|
85
|
+
setMessages((prev) => {
|
|
86
|
+
const ids = new Set(prev.map((m) => m.id));
|
|
87
|
+
const newMsgs = data.messages.filter((m) => !ids.has(m.id));
|
|
88
|
+
return newMsgs.length > 0 ? [...prev, ...newMsgs] : prev;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (data.messages?.length > 0) {
|
|
92
|
+
lastFetchRef.current = data.messages[data.messages.length - 1].createdAt;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} catch {
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
lastFetchRef.current = null;
|
|
99
|
+
fetchMessages();
|
|
100
|
+
if (typeof EventSource !== "undefined") {
|
|
101
|
+
const es = new EventSource(`/api/support/admin-chat-stream?session=${selectedSession}`);
|
|
102
|
+
messagesESRef.current = es;
|
|
103
|
+
es.onmessage = (event) => {
|
|
104
|
+
try {
|
|
105
|
+
const parsed = JSON.parse(event.data);
|
|
106
|
+
if (parsed.type === "messages" && parsed.data?.length > 0) {
|
|
107
|
+
setMessages((prev) => {
|
|
108
|
+
const ids = new Set(prev.map((m) => m.id));
|
|
109
|
+
const newMsgs = parsed.data.filter((m) => !ids.has(m.id));
|
|
110
|
+
return newMsgs.length > 0 ? [...prev, ...newMsgs] : prev;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
} catch {
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
es.onerror = () => {
|
|
117
|
+
es.close();
|
|
118
|
+
messagesESRef.current = null;
|
|
119
|
+
const iv2 = setInterval(fetchMessages, 3e3);
|
|
120
|
+
fetchMessages._fallbackIv = iv2;
|
|
121
|
+
};
|
|
122
|
+
return () => {
|
|
123
|
+
es.close();
|
|
124
|
+
messagesESRef.current = null;
|
|
125
|
+
if (fetchMessages._fallbackIv) clearInterval(fetchMessages._fallbackIv);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const iv = setInterval(fetchMessages, 3e3);
|
|
129
|
+
return () => clearInterval(iv);
|
|
130
|
+
}, [selectedSession]);
|
|
131
|
+
react.useEffect(() => {
|
|
132
|
+
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
133
|
+
}, [messages]);
|
|
134
|
+
const sendMessage = async (e) => {
|
|
135
|
+
e.preventDefault();
|
|
136
|
+
if (!input.trim() || !selectedSession || sending) return;
|
|
137
|
+
setSending(true);
|
|
138
|
+
try {
|
|
139
|
+
const res = await fetch("/api/support/admin-chat", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ action: "send", session: selectedSession, message: input.trim() }) });
|
|
140
|
+
if (res.ok) {
|
|
141
|
+
const data = await res.json();
|
|
142
|
+
setMessages((prev) => [...prev, data.message]);
|
|
143
|
+
lastFetchRef.current = data.message.createdAt;
|
|
144
|
+
setInput("");
|
|
145
|
+
}
|
|
146
|
+
} catch {
|
|
147
|
+
}
|
|
148
|
+
setSending(false);
|
|
149
|
+
};
|
|
150
|
+
const closeSession = async () => {
|
|
151
|
+
if (!selectedSession) return;
|
|
152
|
+
try {
|
|
153
|
+
await fetch("/api/support/admin-chat", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ action: "close", session: selectedSession }) });
|
|
154
|
+
setSelectedSession(null);
|
|
155
|
+
fetchSessions();
|
|
156
|
+
} catch {
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const getClientName = (client) => {
|
|
160
|
+
if (typeof client === "number") return `Client #${client}`;
|
|
161
|
+
const parts = [client.firstName, client.lastName].filter(Boolean);
|
|
162
|
+
if (parts.length > 0) return parts.join(" ");
|
|
163
|
+
return client.email || `Client #${client.id}`;
|
|
164
|
+
};
|
|
165
|
+
const displayedSessions = showClosed ? sessions.closed : sessions.active;
|
|
166
|
+
const S = {
|
|
167
|
+
page: { padding: "20px 30px", maxWidth: 1200, margin: "0 auto" },
|
|
168
|
+
container: { display: "grid", gridTemplateColumns: "320px 1fr", gap: 16, minHeight: "calc(100vh - 300px)" },
|
|
169
|
+
sidebar: { borderRight: "1px solid var(--theme-elevation-200)" },
|
|
170
|
+
sessionItem: { display: "block", width: "100%", padding: "10px 14px", border: "none", background: "none", cursor: "pointer", textAlign: "left", borderBottom: "1px solid var(--theme-elevation-100)", fontSize: 13 },
|
|
171
|
+
sessionActive: { background: "var(--theme-elevation-50)" },
|
|
172
|
+
chatPanel: { display: "flex", flexDirection: "column" },
|
|
173
|
+
messagesArea: { flex: 1, overflowY: "auto", padding: "12px 0" },
|
|
174
|
+
bubble: { maxWidth: "70%", padding: "8px 12px", borderRadius: 10, marginBottom: 8, fontSize: 14 },
|
|
175
|
+
bubbleAgent: { background: "#dbeafe", color: "#1e3a5f", marginLeft: "auto" },
|
|
176
|
+
bubbleClient: { background: "var(--theme-elevation-100)", color: "var(--theme-text)" },
|
|
177
|
+
bubbleSystem: { margin: "4px auto", padding: "4px 12px", fontSize: 11, color: "#6b7280", textAlign: "center" },
|
|
178
|
+
composer: { borderTop: "1px solid var(--theme-elevation-200)", padding: "8px 0" },
|
|
179
|
+
composerInput: { flex: 1, padding: "8px 12px", borderRadius: 8, border: "1px solid var(--theme-elevation-200)", fontSize: 13, background: "var(--theme-elevation-0)", color: "var(--theme-text)" },
|
|
180
|
+
sendBtn: { padding: "8px 16px", borderRadius: 8, background: "#2563eb", color: "#fff", border: "none", fontWeight: 600, cursor: "pointer", fontSize: 13 },
|
|
181
|
+
tabsRow: { display: "flex", gap: 4, padding: "8px 14px", borderBottom: "1px solid var(--theme-elevation-200)" },
|
|
182
|
+
tab: { padding: "4px 10px", borderRadius: 6, border: "none", background: "none", cursor: "pointer", fontSize: 12, color: "var(--theme-elevation-500)" },
|
|
183
|
+
tabActive: { background: "var(--theme-elevation-100)", fontWeight: 700, color: "var(--theme-text)" }
|
|
184
|
+
};
|
|
185
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.page, children: [
|
|
186
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: 16 }, children: [
|
|
187
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { style: { fontSize: 22, fontWeight: 700, margin: 0, color: "var(--theme-text)" }, children: t("chat.title") }),
|
|
188
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { color: "var(--theme-elevation-500)", fontSize: 13, margin: "4px 0 0" }, children: sessions.active.length !== 1 ? t("chat.sessionCountPlural", { count: String(sessions.active.length) }) : t("chat.sessionCount", { count: String(sessions.active.length) }) })
|
|
189
|
+
] }),
|
|
190
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.container, children: [
|
|
191
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.sidebar, children: [
|
|
192
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.tabsRow, children: [
|
|
193
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { onClick: () => setShowClosed(false), style: { ...S.tab, ...!showClosed ? S.tabActive : {} }, children: [
|
|
194
|
+
t("chat.tabs.active"),
|
|
195
|
+
" (",
|
|
196
|
+
sessions.active.length,
|
|
197
|
+
")"
|
|
198
|
+
] }),
|
|
199
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { onClick: () => setShowClosed(true), style: { ...S.tab, ...showClosed ? S.tabActive : {} }, children: [
|
|
200
|
+
t("chat.tabs.closed"),
|
|
201
|
+
" (",
|
|
202
|
+
sessions.closed.length,
|
|
203
|
+
")"
|
|
204
|
+
] })
|
|
205
|
+
] }),
|
|
206
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: 20, textAlign: "center", color: "#94a3b8" }, children: t("common.loading") }) : displayedSessions.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: 20, textAlign: "center", color: "#94a3b8" }, children: showClosed ? t("chat.noSessionClosed") : t("chat.noSessionActive") }) : displayedSessions.map((s2) => /* @__PURE__ */ jsxRuntime.jsxs("button", { onClick: () => setSelectedSession(s2.session), style: { ...S.sessionItem, ...selectedSession === s2.session ? S.sessionActive : {} }, children: [
|
|
207
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "space-between" }, children: [
|
|
208
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 600 }, children: getClientName(s2.client) }),
|
|
209
|
+
s2.unreadCount > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { padding: "1px 6px", borderRadius: 10, background: "#dc2626", color: "#fff", fontSize: 10, fontWeight: 700 }, children: s2.unreadCount })
|
|
210
|
+
] }),
|
|
211
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 12, color: "var(--theme-elevation-500)", marginTop: 2, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: s2.lastMessage }),
|
|
212
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { fontSize: 11, color: "var(--theme-elevation-400)", marginTop: 2 }, children: [
|
|
213
|
+
new Date(s2.lastMessageAt).toLocaleString("fr-FR", { day: "2-digit", month: "2-digit", hour: "2-digit", minute: "2-digit" }),
|
|
214
|
+
" -- ",
|
|
215
|
+
s2.messageCount,
|
|
216
|
+
" ",
|
|
217
|
+
t("chat.msg")
|
|
218
|
+
] })
|
|
219
|
+
] }, s2.session)) })
|
|
220
|
+
] }),
|
|
221
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: S.chatPanel, children: !selectedSession ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1, display: "flex", alignItems: "center", justifyContent: "center", color: "#94a3b8", fontSize: 14 }, children: t("chat.selectSession") }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
222
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", padding: "8px 14px", borderBottom: "1px solid var(--theme-elevation-200)" }, children: [
|
|
223
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontFamily: "monospace", fontSize: 12, color: "var(--theme-elevation-500)" }, children: selectedSession }),
|
|
224
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { onClick: closeSession, style: { padding: "4px 12px", borderRadius: 6, border: "1px solid #dc2626", background: "none", color: "#dc2626", fontSize: 12, cursor: "pointer" }, children: t("chat.closeChat") })
|
|
225
|
+
] }),
|
|
226
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.messagesArea, children: [
|
|
227
|
+
messages.map((msg) => /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", flexDirection: msg.senderType === "agent" ? "row-reverse" : "row", padding: "2px 14px" }, children: msg.senderType === "system" ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: S.bubbleSystem, children: msg.message }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...S.bubble, ...msg.senderType === "agent" ? S.bubbleAgent : S.bubbleClient }, children: [
|
|
228
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 11, fontWeight: 600, marginBottom: 2 }, children: msg.senderType === "agent" ? t("chat.you") : t("chat.clientLabel") }),
|
|
229
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: msg.message }),
|
|
230
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 10, color: msg.senderType === "agent" ? "#1e40af" : "var(--theme-elevation-400)", marginTop: 2 }, children: new Date(msg.createdAt).toLocaleTimeString("fr-FR", { hour: "2-digit", minute: "2-digit" }) })
|
|
231
|
+
] }) }, msg.id)),
|
|
232
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: messagesEndRef })
|
|
233
|
+
] }),
|
|
234
|
+
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: sendMessage, style: S.composer, children: [
|
|
235
|
+
cannedResponses.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("select", { onChange: (e) => {
|
|
236
|
+
const cr = cannedResponses.find((c) => String(c.id) === e.target.value);
|
|
237
|
+
if (cr) setInput(cr.body);
|
|
238
|
+
e.target.value = "";
|
|
239
|
+
}, style: { padding: "4px 8px", borderRadius: 6, border: "1px solid var(--theme-elevation-200)", fontSize: 11, marginBottom: 6, color: "var(--theme-text)", background: "var(--theme-elevation-0)" }, children: [
|
|
240
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: t("chat.quickReply") }),
|
|
241
|
+
cannedResponses.map((cr) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: String(cr.id), children: cr.title }, cr.id))
|
|
242
|
+
] }),
|
|
243
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: 8 }, children: [
|
|
244
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "text", value: input, onChange: (e) => setInput(e.target.value), placeholder: t("chat.inputPlaceholder"), maxLength: 2e3, style: S.composerInput, autoFocus: true }),
|
|
245
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", disabled: !input.trim() || sending, style: S.sendBtn, children: t("chat.sendButton") })
|
|
246
|
+
] })
|
|
247
|
+
] })
|
|
248
|
+
] }) })
|
|
249
|
+
] })
|
|
250
|
+
] });
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
exports.ChatViewClient = ChatViewClient;
|
|
@@ -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 ChatView = ({ 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: "ChatView", children: /* @__PURE__ */ jsxRuntime.jsx(client.ChatViewClient, {}) })
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
var ChatView_default = ChatView;
|
|
32
|
+
|
|
33
|
+
exports.ChatView = ChatView;
|
|
34
|
+
exports.default = ChatView_default;
|