@consilioweb/payload-support 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/TicketConversation/components/AISummaryPanel.cjs +77 -0
- package/dist/components/TicketConversation/components/AISummaryPanel.js +76 -0
- package/dist/components/TicketConversation/components/ActionPanels.cjs +121 -0
- package/dist/components/TicketConversation/components/ActionPanels.js +118 -0
- package/dist/components/TicketConversation/components/ActivityLog.cjs +24 -0
- package/dist/components/TicketConversation/components/ActivityLog.js +23 -0
- package/dist/components/TicketConversation/components/ClientBar.cjs +43 -0
- package/dist/components/TicketConversation/components/ClientBar.js +42 -0
- package/dist/components/TicketConversation/components/ClientHistory.cjs +138 -0
- package/dist/components/TicketConversation/components/ClientHistory.js +137 -0
- package/dist/components/TicketConversation/components/CodeBlock.cjs +154 -0
- package/dist/components/TicketConversation/components/CodeBlock.js +152 -0
- package/dist/components/TicketConversation/components/CodeBlockInserter.cjs +156 -0
- package/dist/components/TicketConversation/components/CodeBlockInserter.js +155 -0
- package/dist/components/TicketConversation/components/QuickActions.cjs +66 -0
- package/dist/components/TicketConversation/components/QuickActions.js +65 -0
- package/dist/components/TicketConversation/components/TicketHeader.cjs +93 -0
- package/dist/components/TicketConversation/components/TicketHeader.js +92 -0
- package/dist/components/TicketConversation/components/TimeTrackingPanel.cjs +134 -0
- package/dist/components/TicketConversation/components/TimeTrackingPanel.js +133 -0
- package/dist/components/TicketConversation/config.cjs +44 -0
- package/dist/components/TicketConversation/config.js +41 -0
- package/dist/components/TicketConversation/constants.cjs +100 -0
- package/dist/components/TicketConversation/constants.js +96 -0
- package/dist/components/TicketConversation/context.cjs +13 -0
- package/dist/components/TicketConversation/context.js +11 -0
- package/dist/components/TicketConversation/hooks/useAI.cjs +177 -0
- package/dist/components/TicketConversation/hooks/useAI.js +176 -0
- package/dist/components/TicketConversation/hooks/useMessageActions.cjs +136 -0
- package/dist/components/TicketConversation/hooks/useMessageActions.js +135 -0
- package/dist/components/TicketConversation/hooks/useReply.cjs +188 -0
- package/dist/components/TicketConversation/hooks/useReply.js +187 -0
- package/dist/components/TicketConversation/hooks/useTicketActions.cjs +231 -0
- package/dist/components/TicketConversation/hooks/useTicketActions.js +230 -0
- package/dist/components/TicketConversation/hooks/useTimeTracking.cjs +123 -0
- package/dist/components/TicketConversation/hooks/useTimeTracking.js +122 -0
- package/dist/components/TicketConversation/hooks/useTranslation.cjs +78 -0
- package/dist/components/TicketConversation/hooks/useTranslation.js +70 -0
- package/dist/components/TicketConversation/index.cjs +1128 -0
- package/dist/components/TicketConversation/index.js +1123 -0
- package/dist/components/TicketConversation/locales/en.json +878 -0
- package/dist/components/TicketConversation/locales/fr.json +878 -0
- package/dist/components/TicketConversation/types.cjs +2 -0
- package/dist/components/TicketConversation/types.js +2 -0
- package/dist/components/TicketConversation/utils.cjs +27 -0
- package/dist/components/TicketConversation/utils.js +25 -0
- package/dist/styles/BillingView.module.scss +311 -0
- package/dist/styles/ChatView.module.scss +438 -0
- package/dist/styles/CommandPalette.module.scss +160 -0
- package/dist/styles/CrmView.module.scss +554 -0
- package/dist/styles/EmailTracking.module.scss +238 -0
- package/dist/styles/ImportConversation.module.scss +267 -0
- package/dist/styles/Layout.module.scss +55 -0
- package/dist/styles/Logs.module.scss +164 -0
- package/dist/styles/NewTicket.module.scss +143 -0
- package/dist/styles/PendingEmails.module.scss +629 -0
- package/dist/styles/SupportDashboard.module.scss +649 -0
- package/dist/styles/TicketDetail.module.scss +1050 -0
- package/dist/styles/TicketInbox.module.scss +296 -0
- package/dist/styles/TicketingSettings.module.scss +358 -0
- package/dist/styles/TimeDashboard.module.scss +287 -0
- package/dist/styles/_tokens.scss +78 -0
- package/dist/{components/TicketConversation.css → styles/theme.css} +326 -13
- package/dist/views/BillingView/client.cjs +209 -0
- package/dist/views/BillingView/client.js +204 -0
- package/dist/views/BillingView/index.cjs +34 -0
- package/dist/views/BillingView/index.js +29 -0
- package/dist/views/ChatView/client.cjs +253 -0
- package/dist/views/ChatView/client.js +252 -0
- package/dist/views/ChatView/index.cjs +34 -0
- package/dist/views/ChatView/index.js +29 -0
- package/dist/views/CrmView/client.cjs +233 -0
- package/dist/views/CrmView/client.js +232 -0
- package/dist/views/CrmView/index.cjs +34 -0
- package/dist/views/CrmView/index.js +29 -0
- package/dist/views/EmailTrackingView/client.cjs +159 -0
- package/dist/views/EmailTrackingView/client.js +154 -0
- package/dist/views/EmailTrackingView/index.cjs +34 -0
- package/dist/views/EmailTrackingView/index.js +29 -0
- package/dist/views/ImportConversationView/client.cjs +205 -0
- package/dist/views/ImportConversationView/client.js +204 -0
- package/dist/views/ImportConversationView/index.cjs +34 -0
- package/dist/views/ImportConversationView/index.js +29 -0
- package/dist/views/LogsView/client.cjs +149 -0
- package/dist/views/LogsView/client.js +148 -0
- package/dist/views/LogsView/index.cjs +32 -0
- package/dist/views/LogsView/index.js +27 -0
- package/dist/views/NewTicketView/client.cjs +229 -0
- package/dist/views/NewTicketView/client.js +224 -0
- package/dist/views/NewTicketView/index.cjs +32 -0
- package/dist/views/NewTicketView/index.js +27 -0
- package/dist/views/PendingEmailsView/client.cjs +173 -0
- package/dist/views/PendingEmailsView/client.js +172 -0
- package/dist/views/PendingEmailsView/index.cjs +34 -0
- package/dist/views/PendingEmailsView/index.js +29 -0
- package/dist/views/SupportDashboardView/client.cjs +301 -0
- package/dist/views/SupportDashboardView/client.js +296 -0
- package/dist/views/SupportDashboardView/index.cjs +34 -0
- package/dist/views/SupportDashboardView/index.js +29 -0
- package/dist/views/TicketDetailView/client.cjs +850 -0
- package/dist/views/TicketDetailView/client.js +844 -0
- package/dist/views/TicketDetailView/index.cjs +34 -0
- package/dist/views/TicketDetailView/index.js +29 -0
- package/dist/views/TicketInboxView/client.cjs +299 -0
- package/dist/views/TicketInboxView/client.js +294 -0
- package/dist/views/TicketInboxView/index.cjs +32 -0
- package/dist/views/TicketInboxView/index.js +27 -0
- package/dist/{views.css → views/TicketingSettingsView/TicketingSettings.module.scss} +138 -66
- package/dist/views/TicketingSettingsView/client.cjs +733 -0
- package/dist/views/TicketingSettingsView/client.js +728 -0
- package/dist/views/TicketingSettingsView/index.cjs +34 -0
- package/dist/views/TicketingSettingsView/index.js +29 -0
- package/dist/views/TimeDashboardView/client.cjs +169 -0
- package/dist/views/TimeDashboardView/client.js +164 -0
- package/dist/views/TimeDashboardView/index.cjs +34 -0
- package/dist/views/TimeDashboardView/index.js +29 -0
- package/dist/views/shared/AdminViewHeader.cjs +68 -0
- package/dist/views/shared/AdminViewHeader.js +67 -0
- package/dist/views/shared/ErrorBoundary.cjs +55 -0
- package/dist/views/shared/ErrorBoundary.js +50 -0
- package/dist/views/shared/Skeleton.cjs +77 -0
- package/dist/views/shared/Skeleton.js +72 -0
- package/dist/views/shared/adminTokens.cjs +34 -0
- package/dist/views/shared/adminTokens.js +31 -0
- package/dist/views/shared/config.cjs +44 -0
- package/dist/views/shared/config.js +40 -0
- package/dist/views/shared/index.cjs +58 -0
- package/dist/views/shared/index.js +5 -0
- package/dist/views.cjs +77 -6175
- package/dist/views.d.cts +13 -30
- package/dist/views.d.ts +13 -30
- package/dist/views.js +13 -6165
- package/package.json +2 -2
- package/dist/components/TicketConversation.js +0 -3004
|
@@ -0,0 +1,233 @@
|
|
|
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 statusLabelKeys = { open: "ticket.status.open", waiting_client: "ticket.status.waiting_client", resolved: "ticket.status.resolved" };
|
|
8
|
+
const statusColors = { open: "#3b82f6", waiting_client: "#f59e0b", resolved: "#22c55e" };
|
|
9
|
+
function formatDuration(minutes) {
|
|
10
|
+
const h = Math.floor(minutes / 60);
|
|
11
|
+
const m = minutes % 60;
|
|
12
|
+
if (h === 0) return `${m}min`;
|
|
13
|
+
if (m === 0) return `${h}h`;
|
|
14
|
+
return `${h}h${m}m`;
|
|
15
|
+
}
|
|
16
|
+
function timeAgo(dateStr) {
|
|
17
|
+
const diff = Date.now() - new Date(dateStr).getTime();
|
|
18
|
+
const days = Math.floor(diff / 864e5);
|
|
19
|
+
if (days === 0) return "Aujourd'hui";
|
|
20
|
+
if (days === 1) return "Hier";
|
|
21
|
+
if (days < 30) return `Il y a ${days}j`;
|
|
22
|
+
return `Il y a ${Math.floor(days / 30)} mois`;
|
|
23
|
+
}
|
|
24
|
+
const CrmClient = () => {
|
|
25
|
+
const { t } = useTranslation.useTranslation();
|
|
26
|
+
const [clients, setClients] = react.useState([]);
|
|
27
|
+
const [loading, setLoading] = react.useState(true);
|
|
28
|
+
const [search, setSearch] = react.useState("");
|
|
29
|
+
const [selectedId, setSelectedId] = react.useState(null);
|
|
30
|
+
const [detail, setDetail] = react.useState(null);
|
|
31
|
+
const [detailLoading, setDetailLoading] = react.useState(false);
|
|
32
|
+
const [showMerge, setShowMerge] = react.useState(false);
|
|
33
|
+
const [mergeSearch, setMergeSearch] = react.useState("");
|
|
34
|
+
const [mergeResults, setMergeResults] = react.useState([]);
|
|
35
|
+
const [merging, setMerging] = react.useState(false);
|
|
36
|
+
const [mergeSuccess, setMergeSuccess] = react.useState("");
|
|
37
|
+
const fetchClients = react.useCallback(async () => {
|
|
38
|
+
try {
|
|
39
|
+
const params = new URLSearchParams({ limit: "100", sort: "company", depth: "0" });
|
|
40
|
+
if (search) params.set("where[company][like]", search);
|
|
41
|
+
const res = await fetch(`/api/support-clients?${params}`);
|
|
42
|
+
if (res.ok) {
|
|
43
|
+
const json = await res.json();
|
|
44
|
+
setClients(json.docs || []);
|
|
45
|
+
}
|
|
46
|
+
} catch {
|
|
47
|
+
}
|
|
48
|
+
setLoading(false);
|
|
49
|
+
}, [search]);
|
|
50
|
+
react.useEffect(() => {
|
|
51
|
+
const timeout = setTimeout(fetchClients, 300);
|
|
52
|
+
return () => clearTimeout(timeout);
|
|
53
|
+
}, [fetchClients]);
|
|
54
|
+
const fetchDetail = react.useCallback(async (clientId) => {
|
|
55
|
+
setDetailLoading(true);
|
|
56
|
+
try {
|
|
57
|
+
const [clientRes, ticketsRes, projectsRes, timeRes] = await Promise.all([
|
|
58
|
+
fetch(`/api/support-clients/${clientId}?depth=0`),
|
|
59
|
+
fetch(`/api/tickets?where[client][equals]=${clientId}&sort=-createdAt&limit=20&depth=0`),
|
|
60
|
+
fetch(`/api/projects?where[client][equals]=${clientId}&depth=0`),
|
|
61
|
+
fetch(`/api/time-entries?limit=0&depth=0`)
|
|
62
|
+
]);
|
|
63
|
+
const client = clientRes.ok ? await clientRes.json() : null;
|
|
64
|
+
const tickets = ticketsRes.ok ? (await ticketsRes.json()).docs || [] : [];
|
|
65
|
+
const projects = projectsRes.ok ? (await projectsRes.json()).docs || [] : [];
|
|
66
|
+
const ticketIds = tickets.map((t2) => t2.id);
|
|
67
|
+
let totalTimeMinutes = 0;
|
|
68
|
+
if (timeRes.ok) {
|
|
69
|
+
const timeData = await timeRes.json();
|
|
70
|
+
totalTimeMinutes = timeData.docs.filter((e) => ticketIds.includes(e.ticket)).reduce((sum, e) => sum + (e.duration || 0), 0);
|
|
71
|
+
}
|
|
72
|
+
const openTickets = tickets.filter((t2) => ["open", "waiting_client"].includes(t2.status)).length;
|
|
73
|
+
const resolvedTickets = tickets.filter((t2) => t2.status === "resolved").length;
|
|
74
|
+
setDetail({ client, tickets, projects, stats: { totalTickets: tickets.length, openTickets, resolvedTickets, totalTimeMinutes, lastActivity: tickets.length > 0 ? tickets[0].createdAt : null } });
|
|
75
|
+
} catch {
|
|
76
|
+
setDetail(null);
|
|
77
|
+
}
|
|
78
|
+
setDetailLoading(false);
|
|
79
|
+
}, []);
|
|
80
|
+
const selectClient = (id) => {
|
|
81
|
+
setSelectedId(id);
|
|
82
|
+
fetchDetail(id);
|
|
83
|
+
setShowMerge(false);
|
|
84
|
+
setMergeSuccess("");
|
|
85
|
+
};
|
|
86
|
+
react.useEffect(() => {
|
|
87
|
+
if (!mergeSearch || mergeSearch.length < 2) {
|
|
88
|
+
setMergeResults([]);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const timer = setTimeout(async () => {
|
|
92
|
+
try {
|
|
93
|
+
const res = await fetch(`/api/support-clients?where[or][0][company][like]=${encodeURIComponent(mergeSearch)}&where[or][1][email][like]=${encodeURIComponent(mergeSearch)}&limit=10&depth=0`);
|
|
94
|
+
if (res.ok) {
|
|
95
|
+
const json = await res.json();
|
|
96
|
+
setMergeResults((json.docs || []).filter((c) => c.id !== selectedId));
|
|
97
|
+
}
|
|
98
|
+
} catch {
|
|
99
|
+
}
|
|
100
|
+
}, 300);
|
|
101
|
+
return () => clearTimeout(timer);
|
|
102
|
+
}, [mergeSearch, selectedId]);
|
|
103
|
+
const handleMerge = async (targetId) => {
|
|
104
|
+
if (!selectedId || !detail) return;
|
|
105
|
+
if (!confirm(`Fusionner ce client dans un autre ? Cette action est irreversible.`)) return;
|
|
106
|
+
setMerging(true);
|
|
107
|
+
try {
|
|
108
|
+
const res = await fetch("/api/support/merge-clients", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ sourceId: selectedId, targetId }) });
|
|
109
|
+
if (res.ok) {
|
|
110
|
+
const data = await res.json();
|
|
111
|
+
setMergeSuccess(data.message);
|
|
112
|
+
setShowMerge(false);
|
|
113
|
+
setSelectedId(targetId);
|
|
114
|
+
fetchDetail(targetId);
|
|
115
|
+
fetchClients();
|
|
116
|
+
} else {
|
|
117
|
+
const err = await res.json().catch(() => ({ error: "Erreur inconnue" }));
|
|
118
|
+
alert(`Erreur : ${err.error}`);
|
|
119
|
+
}
|
|
120
|
+
} catch {
|
|
121
|
+
alert("Erreur reseau");
|
|
122
|
+
}
|
|
123
|
+
setMerging(false);
|
|
124
|
+
};
|
|
125
|
+
const S = {
|
|
126
|
+
page: { padding: "20px 30px", maxWidth: 1200, margin: "0 auto" },
|
|
127
|
+
grid: { display: "grid", gridTemplateColumns: "300px 1fr", gap: 20 },
|
|
128
|
+
sidebar: { borderRight: "1px solid var(--theme-elevation-200)", paddingRight: 16 },
|
|
129
|
+
searchInput: { width: "100%", padding: "8px 12px", borderRadius: 8, border: "1px solid var(--theme-elevation-200)", fontSize: 13, marginBottom: 12, color: "var(--theme-text)", background: "var(--theme-elevation-0)" },
|
|
130
|
+
clientItem: { padding: "10px 12px", borderRadius: 8, cursor: "pointer", marginBottom: 4, border: "1px solid transparent" },
|
|
131
|
+
clientItemActive: { background: "var(--theme-elevation-50)", borderColor: "var(--theme-elevation-200)" },
|
|
132
|
+
statsGrid: { display: "grid", gridTemplateColumns: "repeat(5, 1fr)", gap: 8, marginBottom: 16 },
|
|
133
|
+
statCard: { padding: "10px 12px", borderRadius: 8, border: "1px solid var(--theme-elevation-150)", textAlign: "center" },
|
|
134
|
+
table: { width: "100%", borderCollapse: "collapse", fontSize: 13 },
|
|
135
|
+
th: { textAlign: "left", padding: "6px 8px", borderBottom: "1px solid var(--theme-elevation-200)", fontSize: 11, color: "var(--theme-elevation-500)" },
|
|
136
|
+
td: { padding: "6px 8px", borderBottom: "1px solid var(--theme-elevation-100)" },
|
|
137
|
+
badge: { padding: "2px 6px", borderRadius: 4, fontSize: 10, fontWeight: 600 }
|
|
138
|
+
};
|
|
139
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.page, children: [
|
|
140
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: 20 }, children: [
|
|
141
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { style: { fontSize: 22, fontWeight: 700, margin: 0, color: "var(--theme-text)" }, children: t("crm.title") }),
|
|
142
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 13, color: "var(--theme-elevation-500)", marginTop: 4 }, children: t("crm.subtitle") })
|
|
143
|
+
] }),
|
|
144
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.grid, children: [
|
|
145
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.sidebar, children: [
|
|
146
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "text", placeholder: t("crm.searchPlaceholder"), value: search, onChange: (e) => setSearch(e.target.value), style: S.searchInput }),
|
|
147
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: 20, textAlign: "center", color: "#94a3b8" }, children: t("common.loading") }) : clients.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: 20, textAlign: "center", color: "#94a3b8" }, children: t("crm.noClientFound") }) : clients.map((c) => /* @__PURE__ */ jsxRuntime.jsxs("div", { onClick: () => selectClient(c.id), style: { ...S.clientItem, ...selectedId === c.id ? S.clientItemActive : {} }, children: [
|
|
148
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontWeight: 600, fontSize: 13 }, children: c.company }),
|
|
149
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { fontSize: 12, color: "var(--theme-elevation-500)" }, children: [
|
|
150
|
+
c.firstName,
|
|
151
|
+
" ",
|
|
152
|
+
c.lastName
|
|
153
|
+
] }),
|
|
154
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 11, color: "var(--theme-elevation-400)" }, children: c.email })
|
|
155
|
+
] }, c.id)) })
|
|
156
|
+
] }),
|
|
157
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: !selectedId ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: 60, textAlign: "center", color: "#94a3b8" }, children: t("crm.selectClient") }) : detailLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: 60, textAlign: "center", color: "#94a3b8" }, children: t("common.loading") }) : detail ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
158
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "space-between", marginBottom: 16 }, children: [
|
|
159
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
160
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: { fontSize: 20, fontWeight: 700, margin: 0 }, children: detail.client.company }),
|
|
161
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { fontSize: 13, color: "var(--theme-elevation-500)" }, children: [
|
|
162
|
+
detail.client.firstName,
|
|
163
|
+
" ",
|
|
164
|
+
detail.client.lastName
|
|
165
|
+
] }),
|
|
166
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { fontSize: 12, color: "var(--theme-elevation-400)" }, children: [
|
|
167
|
+
detail.client.email,
|
|
168
|
+
" ",
|
|
169
|
+
detail.client.phone && `-- ${detail.client.phone}`
|
|
170
|
+
] }),
|
|
171
|
+
detail.client.notes && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 12, color: "var(--theme-elevation-500)", marginTop: 4, fontStyle: "italic" }, children: detail.client.notes })
|
|
172
|
+
] }),
|
|
173
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: 8 }, children: [
|
|
174
|
+
/* @__PURE__ */ jsxRuntime.jsx("a", { href: `/admin/collections/support-clients/${detail.client.id}`, style: { padding: "6px 14px", borderRadius: 6, background: "#2563eb", color: "#fff", fontSize: 12, fontWeight: 600, textDecoration: "none" }, children: t("crm.editButton") }),
|
|
175
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { onClick: () => {
|
|
176
|
+
setShowMerge(!showMerge);
|
|
177
|
+
setMergeSearch("");
|
|
178
|
+
setMergeResults([]);
|
|
179
|
+
}, style: { padding: "6px 14px", borderRadius: 6, border: "1px solid #d97706", background: "none", color: "#d97706", fontSize: 12, fontWeight: 600, cursor: "pointer" }, children: t("crm.mergeButton") })
|
|
180
|
+
] })
|
|
181
|
+
] }),
|
|
182
|
+
mergeSuccess && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "8px 14px", borderRadius: 6, background: "#dcfce7", color: "#166534", fontSize: 13, marginBottom: 12 }, children: mergeSuccess }),
|
|
183
|
+
showMerge && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { padding: 16, borderRadius: 8, border: "1px solid #fde68a", background: "#fefce8", marginBottom: 16 }, children: [
|
|
184
|
+
/* @__PURE__ */ jsxRuntime.jsx("h4", { style: { margin: "0 0 8px", fontSize: 14 }, children: t("crm.mergeTitle") }),
|
|
185
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "text", value: mergeSearch, onChange: (e) => setMergeSearch(e.target.value), placeholder: t("crm.mergeSearchPlaceholder"), style: S.searchInput }),
|
|
186
|
+
mergeResults.map((c) => /* @__PURE__ */ jsxRuntime.jsxs("button", { onClick: () => handleMerge(c.id), disabled: merging, style: { display: "block", width: "100%", padding: "8px 12px", border: "1px solid var(--theme-elevation-200)", borderRadius: 6, background: "var(--theme-elevation-0)", cursor: "pointer", textAlign: "left", marginBottom: 4, fontSize: 13 }, children: [
|
|
187
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: c.company }),
|
|
188
|
+
" -- ",
|
|
189
|
+
c.firstName,
|
|
190
|
+
" ",
|
|
191
|
+
c.lastName,
|
|
192
|
+
" ",
|
|
193
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "var(--theme-elevation-400)", fontSize: 11 }, children: c.email })
|
|
194
|
+
] }, c.id))
|
|
195
|
+
] }),
|
|
196
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: S.statsGrid, children: [
|
|
197
|
+
{ label: t("crm.stats.totalTickets"), value: String(detail.stats.totalTickets) },
|
|
198
|
+
{ label: t("crm.stats.openTickets"), value: String(detail.stats.openTickets) },
|
|
199
|
+
{ label: t("crm.stats.resolvedTickets"), value: String(detail.stats.resolvedTickets) },
|
|
200
|
+
{ label: t("crm.stats.timeSpent"), value: formatDuration(detail.stats.totalTimeMinutes) },
|
|
201
|
+
{ label: t("crm.stats.lastActivity"), value: detail.stats.lastActivity ? timeAgo(detail.stats.lastActivity) : "-" }
|
|
202
|
+
].map((stat) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.statCard, children: [
|
|
203
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 11, color: "var(--theme-elevation-500)", marginBottom: 2 }, children: stat.label }),
|
|
204
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 18, fontWeight: 700, color: "var(--theme-text)" }, children: stat.value })
|
|
205
|
+
] }, stat.label)) }),
|
|
206
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { padding: 16, borderRadius: 10, border: "1px solid var(--theme-elevation-150)", marginBottom: 16 }, children: [
|
|
207
|
+
/* @__PURE__ */ jsxRuntime.jsxs("h3", { style: { fontSize: 14, fontWeight: 700, margin: "0 0 8px" }, children: [
|
|
208
|
+
t("crm.sections.tickets"),
|
|
209
|
+
" (",
|
|
210
|
+
detail.tickets.length,
|
|
211
|
+
")"
|
|
212
|
+
] }),
|
|
213
|
+
detail.tickets.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: "#94a3b8", fontSize: 13 }, children: t("crm.noTickets") }) : /* @__PURE__ */ jsxRuntime.jsxs("table", { style: S.table, children: [
|
|
214
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
215
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("crm.tableHeaders.number") }),
|
|
216
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("crm.tableHeaders.subject") }),
|
|
217
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("crm.tableHeaders.status") }),
|
|
218
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { style: S.th, children: t("crm.tableHeaders.date") })
|
|
219
|
+
] }) }),
|
|
220
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: detail.tickets.map((tk) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
221
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: S.td, children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: `/admin/support/ticket?id=${tk.id}`, style: { color: "#2563eb", fontWeight: 600, textDecoration: "none" }, children: tk.ticketNumber }) }),
|
|
222
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: S.td, children: tk.subject }),
|
|
223
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: S.td, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: { ...S.badge, background: `${statusColors[tk.status] || "#94a3b8"}20`, color: statusColors[tk.status] || "#94a3b8" }, children: statusLabelKeys[tk.status] ? t(statusLabelKeys[tk.status]) : tk.status }) }),
|
|
224
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { style: { ...S.td, fontSize: 12, color: "var(--theme-elevation-400)" }, children: timeAgo(tk.createdAt) })
|
|
225
|
+
] }, tk.id)) })
|
|
226
|
+
] })
|
|
227
|
+
] })
|
|
228
|
+
] }) : null })
|
|
229
|
+
] })
|
|
230
|
+
] });
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
exports.CrmClient = CrmClient;
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
4
|
+
import { useTranslation } from '../../components/TicketConversation/hooks/useTranslation';
|
|
5
|
+
|
|
6
|
+
const statusLabelKeys = { open: "ticket.status.open", waiting_client: "ticket.status.waiting_client", resolved: "ticket.status.resolved" };
|
|
7
|
+
const statusColors = { open: "#3b82f6", waiting_client: "#f59e0b", resolved: "#22c55e" };
|
|
8
|
+
function formatDuration(minutes) {
|
|
9
|
+
const h = Math.floor(minutes / 60);
|
|
10
|
+
const m = minutes % 60;
|
|
11
|
+
if (h === 0) return `${m}min`;
|
|
12
|
+
if (m === 0) return `${h}h`;
|
|
13
|
+
return `${h}h${m}m`;
|
|
14
|
+
}
|
|
15
|
+
function timeAgo(dateStr) {
|
|
16
|
+
const diff = Date.now() - new Date(dateStr).getTime();
|
|
17
|
+
const days = Math.floor(diff / 864e5);
|
|
18
|
+
if (days === 0) return "Aujourd'hui";
|
|
19
|
+
if (days === 1) return "Hier";
|
|
20
|
+
if (days < 30) return `Il y a ${days}j`;
|
|
21
|
+
return `Il y a ${Math.floor(days / 30)} mois`;
|
|
22
|
+
}
|
|
23
|
+
const CrmClient = () => {
|
|
24
|
+
const { t } = useTranslation();
|
|
25
|
+
const [clients, setClients] = useState([]);
|
|
26
|
+
const [loading, setLoading] = useState(true);
|
|
27
|
+
const [search, setSearch] = useState("");
|
|
28
|
+
const [selectedId, setSelectedId] = useState(null);
|
|
29
|
+
const [detail, setDetail] = useState(null);
|
|
30
|
+
const [detailLoading, setDetailLoading] = useState(false);
|
|
31
|
+
const [showMerge, setShowMerge] = useState(false);
|
|
32
|
+
const [mergeSearch, setMergeSearch] = useState("");
|
|
33
|
+
const [mergeResults, setMergeResults] = useState([]);
|
|
34
|
+
const [merging, setMerging] = useState(false);
|
|
35
|
+
const [mergeSuccess, setMergeSuccess] = useState("");
|
|
36
|
+
const fetchClients = useCallback(async () => {
|
|
37
|
+
try {
|
|
38
|
+
const params = new URLSearchParams({ limit: "100", sort: "company", depth: "0" });
|
|
39
|
+
if (search) params.set("where[company][like]", search);
|
|
40
|
+
const res = await fetch(`/api/support-clients?${params}`);
|
|
41
|
+
if (res.ok) {
|
|
42
|
+
const json = await res.json();
|
|
43
|
+
setClients(json.docs || []);
|
|
44
|
+
}
|
|
45
|
+
} catch {
|
|
46
|
+
}
|
|
47
|
+
setLoading(false);
|
|
48
|
+
}, [search]);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
const timeout = setTimeout(fetchClients, 300);
|
|
51
|
+
return () => clearTimeout(timeout);
|
|
52
|
+
}, [fetchClients]);
|
|
53
|
+
const fetchDetail = useCallback(async (clientId) => {
|
|
54
|
+
setDetailLoading(true);
|
|
55
|
+
try {
|
|
56
|
+
const [clientRes, ticketsRes, projectsRes, timeRes] = await Promise.all([
|
|
57
|
+
fetch(`/api/support-clients/${clientId}?depth=0`),
|
|
58
|
+
fetch(`/api/tickets?where[client][equals]=${clientId}&sort=-createdAt&limit=20&depth=0`),
|
|
59
|
+
fetch(`/api/projects?where[client][equals]=${clientId}&depth=0`),
|
|
60
|
+
fetch(`/api/time-entries?limit=0&depth=0`)
|
|
61
|
+
]);
|
|
62
|
+
const client = clientRes.ok ? await clientRes.json() : null;
|
|
63
|
+
const tickets = ticketsRes.ok ? (await ticketsRes.json()).docs || [] : [];
|
|
64
|
+
const projects = projectsRes.ok ? (await projectsRes.json()).docs || [] : [];
|
|
65
|
+
const ticketIds = tickets.map((t2) => t2.id);
|
|
66
|
+
let totalTimeMinutes = 0;
|
|
67
|
+
if (timeRes.ok) {
|
|
68
|
+
const timeData = await timeRes.json();
|
|
69
|
+
totalTimeMinutes = timeData.docs.filter((e) => ticketIds.includes(e.ticket)).reduce((sum, e) => sum + (e.duration || 0), 0);
|
|
70
|
+
}
|
|
71
|
+
const openTickets = tickets.filter((t2) => ["open", "waiting_client"].includes(t2.status)).length;
|
|
72
|
+
const resolvedTickets = tickets.filter((t2) => t2.status === "resolved").length;
|
|
73
|
+
setDetail({ client, tickets, projects, stats: { totalTickets: tickets.length, openTickets, resolvedTickets, totalTimeMinutes, lastActivity: tickets.length > 0 ? tickets[0].createdAt : null } });
|
|
74
|
+
} catch {
|
|
75
|
+
setDetail(null);
|
|
76
|
+
}
|
|
77
|
+
setDetailLoading(false);
|
|
78
|
+
}, []);
|
|
79
|
+
const selectClient = (id) => {
|
|
80
|
+
setSelectedId(id);
|
|
81
|
+
fetchDetail(id);
|
|
82
|
+
setShowMerge(false);
|
|
83
|
+
setMergeSuccess("");
|
|
84
|
+
};
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (!mergeSearch || mergeSearch.length < 2) {
|
|
87
|
+
setMergeResults([]);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const timer = setTimeout(async () => {
|
|
91
|
+
try {
|
|
92
|
+
const res = await fetch(`/api/support-clients?where[or][0][company][like]=${encodeURIComponent(mergeSearch)}&where[or][1][email][like]=${encodeURIComponent(mergeSearch)}&limit=10&depth=0`);
|
|
93
|
+
if (res.ok) {
|
|
94
|
+
const json = await res.json();
|
|
95
|
+
setMergeResults((json.docs || []).filter((c) => c.id !== selectedId));
|
|
96
|
+
}
|
|
97
|
+
} catch {
|
|
98
|
+
}
|
|
99
|
+
}, 300);
|
|
100
|
+
return () => clearTimeout(timer);
|
|
101
|
+
}, [mergeSearch, selectedId]);
|
|
102
|
+
const handleMerge = async (targetId) => {
|
|
103
|
+
if (!selectedId || !detail) return;
|
|
104
|
+
if (!confirm(`Fusionner ce client dans un autre ? Cette action est irreversible.`)) return;
|
|
105
|
+
setMerging(true);
|
|
106
|
+
try {
|
|
107
|
+
const res = await fetch("/api/support/merge-clients", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ sourceId: selectedId, targetId }) });
|
|
108
|
+
if (res.ok) {
|
|
109
|
+
const data = await res.json();
|
|
110
|
+
setMergeSuccess(data.message);
|
|
111
|
+
setShowMerge(false);
|
|
112
|
+
setSelectedId(targetId);
|
|
113
|
+
fetchDetail(targetId);
|
|
114
|
+
fetchClients();
|
|
115
|
+
} else {
|
|
116
|
+
const err = await res.json().catch(() => ({ error: "Erreur inconnue" }));
|
|
117
|
+
alert(`Erreur : ${err.error}`);
|
|
118
|
+
}
|
|
119
|
+
} catch {
|
|
120
|
+
alert("Erreur reseau");
|
|
121
|
+
}
|
|
122
|
+
setMerging(false);
|
|
123
|
+
};
|
|
124
|
+
const S = {
|
|
125
|
+
page: { padding: "20px 30px", maxWidth: 1200, margin: "0 auto" },
|
|
126
|
+
grid: { display: "grid", gridTemplateColumns: "300px 1fr", gap: 20 },
|
|
127
|
+
sidebar: { borderRight: "1px solid var(--theme-elevation-200)", paddingRight: 16 },
|
|
128
|
+
searchInput: { width: "100%", padding: "8px 12px", borderRadius: 8, border: "1px solid var(--theme-elevation-200)", fontSize: 13, marginBottom: 12, color: "var(--theme-text)", background: "var(--theme-elevation-0)" },
|
|
129
|
+
clientItem: { padding: "10px 12px", borderRadius: 8, cursor: "pointer", marginBottom: 4, border: "1px solid transparent" },
|
|
130
|
+
clientItemActive: { background: "var(--theme-elevation-50)", borderColor: "var(--theme-elevation-200)" },
|
|
131
|
+
statsGrid: { display: "grid", gridTemplateColumns: "repeat(5, 1fr)", gap: 8, marginBottom: 16 },
|
|
132
|
+
statCard: { padding: "10px 12px", borderRadius: 8, border: "1px solid var(--theme-elevation-150)", textAlign: "center" },
|
|
133
|
+
table: { width: "100%", borderCollapse: "collapse", fontSize: 13 },
|
|
134
|
+
th: { textAlign: "left", padding: "6px 8px", borderBottom: "1px solid var(--theme-elevation-200)", fontSize: 11, color: "var(--theme-elevation-500)" },
|
|
135
|
+
td: { padding: "6px 8px", borderBottom: "1px solid var(--theme-elevation-100)" },
|
|
136
|
+
badge: { padding: "2px 6px", borderRadius: 4, fontSize: 10, fontWeight: 600 }
|
|
137
|
+
};
|
|
138
|
+
return /* @__PURE__ */ jsxs("div", { style: S.page, children: [
|
|
139
|
+
/* @__PURE__ */ jsxs("div", { style: { marginBottom: 20 }, children: [
|
|
140
|
+
/* @__PURE__ */ jsx("h1", { style: { fontSize: 22, fontWeight: 700, margin: 0, color: "var(--theme-text)" }, children: t("crm.title") }),
|
|
141
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 13, color: "var(--theme-elevation-500)", marginTop: 4 }, children: t("crm.subtitle") })
|
|
142
|
+
] }),
|
|
143
|
+
/* @__PURE__ */ jsxs("div", { style: S.grid, children: [
|
|
144
|
+
/* @__PURE__ */ jsxs("div", { style: S.sidebar, children: [
|
|
145
|
+
/* @__PURE__ */ jsx("input", { type: "text", placeholder: t("crm.searchPlaceholder"), value: search, onChange: (e) => setSearch(e.target.value), style: S.searchInput }),
|
|
146
|
+
/* @__PURE__ */ jsx("div", { children: loading ? /* @__PURE__ */ jsx("div", { style: { padding: 20, textAlign: "center", color: "#94a3b8" }, children: t("common.loading") }) : clients.length === 0 ? /* @__PURE__ */ jsx("div", { style: { padding: 20, textAlign: "center", color: "#94a3b8" }, children: t("crm.noClientFound") }) : clients.map((c) => /* @__PURE__ */ jsxs("div", { onClick: () => selectClient(c.id), style: { ...S.clientItem, ...selectedId === c.id ? S.clientItemActive : {} }, children: [
|
|
147
|
+
/* @__PURE__ */ jsx("div", { style: { fontWeight: 600, fontSize: 13 }, children: c.company }),
|
|
148
|
+
/* @__PURE__ */ jsxs("div", { style: { fontSize: 12, color: "var(--theme-elevation-500)" }, children: [
|
|
149
|
+
c.firstName,
|
|
150
|
+
" ",
|
|
151
|
+
c.lastName
|
|
152
|
+
] }),
|
|
153
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 11, color: "var(--theme-elevation-400)" }, children: c.email })
|
|
154
|
+
] }, c.id)) })
|
|
155
|
+
] }),
|
|
156
|
+
/* @__PURE__ */ jsx("div", { children: !selectedId ? /* @__PURE__ */ jsx("div", { style: { padding: 60, textAlign: "center", color: "#94a3b8" }, children: t("crm.selectClient") }) : detailLoading ? /* @__PURE__ */ jsx("div", { style: { padding: 60, textAlign: "center", color: "#94a3b8" }, children: t("common.loading") }) : detail ? /* @__PURE__ */ jsxs("div", { children: [
|
|
157
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", marginBottom: 16 }, children: [
|
|
158
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
159
|
+
/* @__PURE__ */ jsx("h2", { style: { fontSize: 20, fontWeight: 700, margin: 0 }, children: detail.client.company }),
|
|
160
|
+
/* @__PURE__ */ jsxs("div", { style: { fontSize: 13, color: "var(--theme-elevation-500)" }, children: [
|
|
161
|
+
detail.client.firstName,
|
|
162
|
+
" ",
|
|
163
|
+
detail.client.lastName
|
|
164
|
+
] }),
|
|
165
|
+
/* @__PURE__ */ jsxs("div", { style: { fontSize: 12, color: "var(--theme-elevation-400)" }, children: [
|
|
166
|
+
detail.client.email,
|
|
167
|
+
" ",
|
|
168
|
+
detail.client.phone && `-- ${detail.client.phone}`
|
|
169
|
+
] }),
|
|
170
|
+
detail.client.notes && /* @__PURE__ */ jsx("div", { style: { fontSize: 12, color: "var(--theme-elevation-500)", marginTop: 4, fontStyle: "italic" }, children: detail.client.notes })
|
|
171
|
+
] }),
|
|
172
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 8 }, children: [
|
|
173
|
+
/* @__PURE__ */ jsx("a", { href: `/admin/collections/support-clients/${detail.client.id}`, style: { padding: "6px 14px", borderRadius: 6, background: "#2563eb", color: "#fff", fontSize: 12, fontWeight: 600, textDecoration: "none" }, children: t("crm.editButton") }),
|
|
174
|
+
/* @__PURE__ */ jsx("button", { onClick: () => {
|
|
175
|
+
setShowMerge(!showMerge);
|
|
176
|
+
setMergeSearch("");
|
|
177
|
+
setMergeResults([]);
|
|
178
|
+
}, style: { padding: "6px 14px", borderRadius: 6, border: "1px solid #d97706", background: "none", color: "#d97706", fontSize: 12, fontWeight: 600, cursor: "pointer" }, children: t("crm.mergeButton") })
|
|
179
|
+
] })
|
|
180
|
+
] }),
|
|
181
|
+
mergeSuccess && /* @__PURE__ */ jsx("div", { style: { padding: "8px 14px", borderRadius: 6, background: "#dcfce7", color: "#166534", fontSize: 13, marginBottom: 12 }, children: mergeSuccess }),
|
|
182
|
+
showMerge && /* @__PURE__ */ jsxs("div", { style: { padding: 16, borderRadius: 8, border: "1px solid #fde68a", background: "#fefce8", marginBottom: 16 }, children: [
|
|
183
|
+
/* @__PURE__ */ jsx("h4", { style: { margin: "0 0 8px", fontSize: 14 }, children: t("crm.mergeTitle") }),
|
|
184
|
+
/* @__PURE__ */ jsx("input", { type: "text", value: mergeSearch, onChange: (e) => setMergeSearch(e.target.value), placeholder: t("crm.mergeSearchPlaceholder"), style: S.searchInput }),
|
|
185
|
+
mergeResults.map((c) => /* @__PURE__ */ jsxs("button", { onClick: () => handleMerge(c.id), disabled: merging, style: { display: "block", width: "100%", padding: "8px 12px", border: "1px solid var(--theme-elevation-200)", borderRadius: 6, background: "var(--theme-elevation-0)", cursor: "pointer", textAlign: "left", marginBottom: 4, fontSize: 13 }, children: [
|
|
186
|
+
/* @__PURE__ */ jsx("strong", { children: c.company }),
|
|
187
|
+
" -- ",
|
|
188
|
+
c.firstName,
|
|
189
|
+
" ",
|
|
190
|
+
c.lastName,
|
|
191
|
+
" ",
|
|
192
|
+
/* @__PURE__ */ jsx("span", { style: { color: "var(--theme-elevation-400)", fontSize: 11 }, children: c.email })
|
|
193
|
+
] }, c.id))
|
|
194
|
+
] }),
|
|
195
|
+
/* @__PURE__ */ jsx("div", { style: S.statsGrid, children: [
|
|
196
|
+
{ label: t("crm.stats.totalTickets"), value: String(detail.stats.totalTickets) },
|
|
197
|
+
{ label: t("crm.stats.openTickets"), value: String(detail.stats.openTickets) },
|
|
198
|
+
{ label: t("crm.stats.resolvedTickets"), value: String(detail.stats.resolvedTickets) },
|
|
199
|
+
{ label: t("crm.stats.timeSpent"), value: formatDuration(detail.stats.totalTimeMinutes) },
|
|
200
|
+
{ label: t("crm.stats.lastActivity"), value: detail.stats.lastActivity ? timeAgo(detail.stats.lastActivity) : "-" }
|
|
201
|
+
].map((stat) => /* @__PURE__ */ jsxs("div", { style: S.statCard, children: [
|
|
202
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 11, color: "var(--theme-elevation-500)", marginBottom: 2 }, children: stat.label }),
|
|
203
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 18, fontWeight: 700, color: "var(--theme-text)" }, children: stat.value })
|
|
204
|
+
] }, stat.label)) }),
|
|
205
|
+
/* @__PURE__ */ jsxs("div", { style: { padding: 16, borderRadius: 10, border: "1px solid var(--theme-elevation-150)", marginBottom: 16 }, children: [
|
|
206
|
+
/* @__PURE__ */ jsxs("h3", { style: { fontSize: 14, fontWeight: 700, margin: "0 0 8px" }, children: [
|
|
207
|
+
t("crm.sections.tickets"),
|
|
208
|
+
" (",
|
|
209
|
+
detail.tickets.length,
|
|
210
|
+
")"
|
|
211
|
+
] }),
|
|
212
|
+
detail.tickets.length === 0 ? /* @__PURE__ */ jsx("div", { style: { color: "#94a3b8", fontSize: 13 }, children: t("crm.noTickets") }) : /* @__PURE__ */ jsxs("table", { style: S.table, children: [
|
|
213
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
214
|
+
/* @__PURE__ */ jsx("th", { style: S.th, children: t("crm.tableHeaders.number") }),
|
|
215
|
+
/* @__PURE__ */ jsx("th", { style: S.th, children: t("crm.tableHeaders.subject") }),
|
|
216
|
+
/* @__PURE__ */ jsx("th", { style: S.th, children: t("crm.tableHeaders.status") }),
|
|
217
|
+
/* @__PURE__ */ jsx("th", { style: S.th, children: t("crm.tableHeaders.date") })
|
|
218
|
+
] }) }),
|
|
219
|
+
/* @__PURE__ */ jsx("tbody", { children: detail.tickets.map((tk) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
220
|
+
/* @__PURE__ */ jsx("td", { style: S.td, children: /* @__PURE__ */ jsx("a", { href: `/admin/support/ticket?id=${tk.id}`, style: { color: "#2563eb", fontWeight: 600, textDecoration: "none" }, children: tk.ticketNumber }) }),
|
|
221
|
+
/* @__PURE__ */ jsx("td", { style: S.td, children: tk.subject }),
|
|
222
|
+
/* @__PURE__ */ jsx("td", { style: S.td, children: /* @__PURE__ */ jsx("span", { style: { ...S.badge, background: `${statusColors[tk.status] || "#94a3b8"}20`, color: statusColors[tk.status] || "#94a3b8" }, children: statusLabelKeys[tk.status] ? t(statusLabelKeys[tk.status]) : tk.status }) }),
|
|
223
|
+
/* @__PURE__ */ jsx("td", { style: { ...S.td, fontSize: 12, color: "var(--theme-elevation-400)" }, children: timeAgo(tk.createdAt) })
|
|
224
|
+
] }, tk.id)) })
|
|
225
|
+
] })
|
|
226
|
+
] })
|
|
227
|
+
] }) : null })
|
|
228
|
+
] })
|
|
229
|
+
] });
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export { CrmClient };
|
|
@@ -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 CrmView = ({ 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: "CrmView", children: /* @__PURE__ */ jsxRuntime.jsx(client.CrmClient, {}) })
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
var CrmView_default = CrmView;
|
|
32
|
+
|
|
33
|
+
exports.CrmView = CrmView;
|
|
34
|
+
exports.default = CrmView_default;
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { CrmClient } from './client';
|
|
6
|
+
|
|
7
|
+
const CrmView = ({ 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: "CrmView", children: /* @__PURE__ */ jsx(CrmClient, {}) })
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
var CrmView_default = CrmView;
|
|
28
|
+
|
|
29
|
+
export { CrmView, CrmView_default as default };
|