@consilioweb/payload-support 0.5.2 → 0.6.0

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.
Files changed (85) hide show
  1. package/dist/components/TicketConversation/components/AISummaryPanel.js +76 -0
  2. package/dist/components/TicketConversation/components/ActionPanels.js +118 -0
  3. package/dist/components/TicketConversation/components/ActivityLog.js +23 -0
  4. package/dist/components/TicketConversation/components/ClientBar.js +42 -0
  5. package/dist/components/TicketConversation/components/ClientHistory.js +137 -0
  6. package/dist/components/TicketConversation/components/CodeBlock.js +152 -0
  7. package/dist/components/TicketConversation/components/CodeBlockInserter.js +155 -0
  8. package/dist/components/TicketConversation/components/QuickActions.js +65 -0
  9. package/dist/components/TicketConversation/components/TicketHeader.js +92 -0
  10. package/dist/components/TicketConversation/components/TimeTrackingPanel.js +133 -0
  11. package/dist/components/TicketConversation/config.js +41 -0
  12. package/dist/components/TicketConversation/constants.js +96 -0
  13. package/dist/components/TicketConversation/context.js +11 -0
  14. package/dist/components/TicketConversation/hooks/useAI.js +176 -0
  15. package/dist/components/TicketConversation/hooks/useMessageActions.js +135 -0
  16. package/dist/components/TicketConversation/hooks/useReply.js +187 -0
  17. package/dist/components/TicketConversation/hooks/useTicketActions.js +230 -0
  18. package/dist/components/TicketConversation/hooks/useTimeTracking.js +122 -0
  19. package/dist/components/TicketConversation/hooks/useTranslation.js +70 -0
  20. package/dist/components/TicketConversation/index.js +1123 -0
  21. package/dist/components/TicketConversation/locales/en.json +878 -0
  22. package/dist/components/TicketConversation/locales/fr.json +878 -0
  23. package/dist/components/TicketConversation/types.js +2 -0
  24. package/dist/components/TicketConversation/utils.js +25 -0
  25. package/dist/index.cjs +2 -2
  26. package/dist/index.js +2 -2
  27. package/dist/styles/BillingView.module.scss +311 -0
  28. package/dist/styles/ChatView.module.scss +438 -0
  29. package/dist/styles/CommandPalette.module.scss +160 -0
  30. package/dist/styles/CrmView.module.scss +554 -0
  31. package/dist/styles/EmailTracking.module.scss +238 -0
  32. package/dist/styles/ImportConversation.module.scss +267 -0
  33. package/dist/styles/Layout.module.scss +55 -0
  34. package/dist/styles/Logs.module.scss +164 -0
  35. package/dist/styles/NewTicket.module.scss +143 -0
  36. package/dist/styles/PendingEmails.module.scss +629 -0
  37. package/dist/styles/SupportDashboard.module.scss +649 -0
  38. package/dist/styles/TicketDetail.module.scss +1050 -0
  39. package/dist/styles/TicketInbox.module.scss +296 -0
  40. package/dist/styles/TicketingSettings.module.scss +358 -0
  41. package/dist/styles/TimeDashboard.module.scss +287 -0
  42. package/dist/styles/_tokens.scss +78 -0
  43. package/dist/styles/theme.css +633 -0
  44. package/dist/views/BillingView/client.js +204 -0
  45. package/dist/views/BillingView/index.js +29 -0
  46. package/dist/views/ChatView/client.js +252 -0
  47. package/dist/views/ChatView/index.js +29 -0
  48. package/dist/views/CrmView/client.js +232 -0
  49. package/dist/views/CrmView/index.js +29 -0
  50. package/dist/views/EmailTrackingView/client.js +154 -0
  51. package/dist/views/EmailTrackingView/index.js +29 -0
  52. package/dist/views/ImportConversationView/client.js +204 -0
  53. package/dist/views/ImportConversationView/index.js +29 -0
  54. package/dist/views/LogsView/client.js +148 -0
  55. package/dist/views/LogsView/index.js +27 -0
  56. package/dist/views/NewTicketView/client.js +224 -0
  57. package/dist/views/NewTicketView/index.js +27 -0
  58. package/dist/views/PendingEmailsView/client.js +172 -0
  59. package/dist/views/PendingEmailsView/index.js +29 -0
  60. package/dist/views/SupportDashboardView/client.js +296 -0
  61. package/dist/views/SupportDashboardView/index.js +29 -0
  62. package/dist/views/TicketDetailView/client.js +844 -0
  63. package/dist/views/TicketDetailView/index.js +29 -0
  64. package/dist/views/TicketInboxView/client.js +294 -0
  65. package/dist/views/TicketInboxView/index.js +27 -0
  66. package/dist/{views.css → views/TicketingSettingsView/TicketingSettings.module.scss} +138 -66
  67. package/dist/views/TicketingSettingsView/client.js +728 -0
  68. package/dist/views/TicketingSettingsView/index.js +29 -0
  69. package/dist/views/TimeDashboardView/client.js +164 -0
  70. package/dist/views/TimeDashboardView/index.js +29 -0
  71. package/dist/views/shared/AdminViewHeader.js +67 -0
  72. package/dist/views/shared/ErrorBoundary.js +50 -0
  73. package/dist/views/shared/Skeleton.js +72 -0
  74. package/dist/views/shared/adminTokens.js +32 -0
  75. package/dist/views/shared/config.js +41 -0
  76. package/dist/views/shared/index.js +6 -0
  77. package/package.json +8 -12
  78. package/src/collections/Tickets.ts +1 -1
  79. package/src/components/TicketConversation/index.tsx +21 -2
  80. package/src/plugin.ts +3 -2
  81. package/dist/views.cjs +0 -6172
  82. package/dist/views.d.cts +0 -30
  83. package/dist/views.d.ts +0 -30
  84. package/dist/views.js +0 -6153
  85. package/src/views.ts +0 -16
@@ -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 { TicketingSettingsClient } from './client';
6
+
7
+ const TicketingSettingsView = ({ 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: "TicketingSettingsView", children: /* @__PURE__ */ jsx(TicketingSettingsClient, {}) })
24
+ }
25
+ );
26
+ };
27
+ var TicketingSettingsView_default = TicketingSettingsView;
28
+
29
+ export { TicketingSettingsView, TicketingSettingsView_default as default };
@@ -0,0 +1,164 @@
1
+ "use client";
2
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
3
+ import React, { useState, useCallback, useEffect } from 'react';
4
+ import { useTranslation } from '../../components/TicketConversation/hooks/useTranslation';
5
+
6
+ function formatDuration(minutes) {
7
+ const h = Math.floor(minutes / 60);
8
+ const m = minutes % 60;
9
+ if (h === 0) return `${m}min`;
10
+ if (m === 0) return `${h}h`;
11
+ return `${h}h${m}m`;
12
+ }
13
+ function getWeekNumber(d) {
14
+ const oneJan = new Date(d.getFullYear(), 0, 1);
15
+ return Math.ceil(((d.getTime() - oneJan.getTime()) / 864e5 + oneJan.getDay() + 1) / 7);
16
+ }
17
+ function getMonthRange(offset) {
18
+ const now = /* @__PURE__ */ new Date();
19
+ const start = new Date(now.getFullYear(), now.getMonth() + offset, 1);
20
+ const end = new Date(now.getFullYear(), now.getMonth() + offset + 1, 0);
21
+ return { from: start.toISOString().split("T")[0], to: end.toISOString().split("T")[0] };
22
+ }
23
+ const MONTHS_FR = ["Jan", "Fev", "Mar", "Avr", "Mai", "Jun", "Jul", "Aou", "Sep", "Oct", "Nov", "Dec"];
24
+ const TimeDashboardClient = () => {
25
+ const { t } = useTranslation();
26
+ const [entries, setEntries] = useState([]);
27
+ const [loading, setLoading] = useState(true);
28
+ const [from, setFrom] = useState(() => getMonthRange(0).from);
29
+ const [to, setTo] = useState(() => getMonthRange(0).to);
30
+ const [groupBy, setGroupBy] = useState("day");
31
+ const fetchEntries = useCallback(async () => {
32
+ setLoading(true);
33
+ try {
34
+ const params = new URLSearchParams({ limit: "500", depth: "2", sort: "-date" });
35
+ if (from) params.set("where[date][greater_than_equal]", from);
36
+ if (to) params.set("where[date][less_than_equal]", to);
37
+ const res = await fetch(`/api/time-entries?${params}`);
38
+ if (res.ok) {
39
+ const json = await res.json();
40
+ setEntries(json.docs || []);
41
+ }
42
+ } catch {
43
+ }
44
+ setLoading(false);
45
+ }, [from, to]);
46
+ useEffect(() => {
47
+ fetchEntries();
48
+ }, [fetchEntries]);
49
+ const totalMinutes = entries.reduce((sum, e) => sum + (e.duration || 0), 0);
50
+ const grouped = React.useMemo(() => {
51
+ const map = /* @__PURE__ */ new Map();
52
+ for (const entry of entries) {
53
+ let key;
54
+ if (groupBy === "day") {
55
+ key = entry.date ? entry.date.split("T")[0] : "Sans date";
56
+ } else if (groupBy === "week") {
57
+ const d = new Date(entry.date);
58
+ key = `Semaine ${getWeekNumber(d)} (${MONTHS_FR[d.getMonth()]} ${d.getFullYear()})`;
59
+ } else {
60
+ const ticket = typeof entry.ticket === "object" ? entry.ticket : null;
61
+ const project = ticket && typeof ticket.project === "object" ? ticket.project : null;
62
+ key = project?.name || "Sans projet";
63
+ }
64
+ if (!map.has(key)) map.set(key, []);
65
+ map.get(key).push(entry);
66
+ }
67
+ return Array.from(map.entries()).map(([label, items]) => ({ label, entries: items, totalMinutes: items.reduce((sum, e) => sum + (e.duration || 0), 0) }));
68
+ }, [entries, groupBy]);
69
+ const dailyChart = React.useMemo(() => {
70
+ const dayMap = /* @__PURE__ */ new Map();
71
+ for (const entry of entries) {
72
+ const day = entry.date ? entry.date.split("T")[0] : null;
73
+ if (day) dayMap.set(day, (dayMap.get(day) || 0) + (entry.duration || 0));
74
+ }
75
+ return Array.from(dayMap.entries()).sort(([a], [b]) => a.localeCompare(b)).slice(-30).map(([day, mins]) => ({ day, minutes: mins }));
76
+ }, [entries]);
77
+ const maxDailyMinutes = Math.max(...dailyChart.map((d) => d.minutes), 1);
78
+ const setPeriod = (range) => {
79
+ setFrom(range.from);
80
+ setTo(range.to);
81
+ };
82
+ const S = {
83
+ page: { padding: "20px 30px", maxWidth: 1100, margin: "0 auto" },
84
+ 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)" },
85
+ btnPrimary: { padding: "6px 12px", borderRadius: 6, border: "none", fontSize: 12, cursor: "pointer", background: "#2563eb", color: "#fff", fontWeight: 600 },
86
+ kpis: { display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 12, marginBottom: 20 },
87
+ kpiCard: { padding: "16px 20px", borderRadius: 10, border: "1px solid var(--theme-elevation-150)" },
88
+ groupCard: { marginBottom: 12, borderRadius: 10, border: "1px solid var(--theme-elevation-150)", overflow: "hidden" },
89
+ groupHeader: { display: "flex", justifyContent: "space-between", padding: "10px 16px", background: "var(--theme-elevation-50)", borderBottom: "1px solid var(--theme-elevation-150)" },
90
+ table: { width: "100%", borderCollapse: "collapse", fontSize: 12 },
91
+ td: { padding: "6px 8px", borderBottom: "1px solid var(--theme-elevation-100)" }
92
+ };
93
+ return /* @__PURE__ */ jsxs("div", { style: S.page, children: [
94
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 16 }, children: [
95
+ /* @__PURE__ */ jsxs("div", { children: [
96
+ /* @__PURE__ */ jsx("h1", { style: { fontSize: 22, fontWeight: 700, margin: 0 }, children: t("timeDashboard.title") }),
97
+ /* @__PURE__ */ jsx("p", { style: { fontSize: 13, color: "var(--theme-elevation-500)", margin: "4px 0 0" }, children: t("timeDashboard.subtitle") })
98
+ ] }),
99
+ /* @__PURE__ */ jsx("a", { href: "/admin/collections/time-entries/create", style: { ...S.btnPrimary, textDecoration: "none", display: "inline-block" }, children: t("timeDashboard.newEntry") })
100
+ ] }),
101
+ /* @__PURE__ */ jsxs("div", { style: { marginBottom: 16 }, children: [
102
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 6, marginBottom: 8 }, children: [
103
+ /* @__PURE__ */ jsx("button", { style: S.btnPrimary, onClick: () => setPeriod(getMonthRange(0)), children: t("timeDashboard.filters.thisMonth") }),
104
+ /* @__PURE__ */ jsx("button", { style: S.btn, onClick: () => setPeriod(getMonthRange(-1)), children: t("timeDashboard.filters.lastMonth") }),
105
+ /* @__PURE__ */ jsx("button", { style: S.btn, onClick: () => setPeriod(getMonthRange(-2)), children: t("timeDashboard.filters.twoMonthsAgo") })
106
+ ] }),
107
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 12, alignItems: "flex-end" }, children: [
108
+ /* @__PURE__ */ jsxs("div", { children: [
109
+ /* @__PURE__ */ jsx("label", { style: { fontSize: 11, fontWeight: 600, display: "block", marginBottom: 4, color: "var(--theme-elevation-500)" }, children: t("timeDashboard.filters.from") }),
110
+ /* @__PURE__ */ jsx("input", { type: "date", value: from, onChange: (e) => setFrom(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)" } })
111
+ ] }),
112
+ /* @__PURE__ */ jsxs("div", { children: [
113
+ /* @__PURE__ */ jsx("label", { style: { fontSize: 11, fontWeight: 600, display: "block", marginBottom: 4, color: "var(--theme-elevation-500)" }, children: t("timeDashboard.filters.to") }),
114
+ /* @__PURE__ */ jsx("input", { type: "date", value: to, onChange: (e) => setTo(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)" } })
115
+ ] }),
116
+ /* @__PURE__ */ jsxs("div", { children: [
117
+ /* @__PURE__ */ jsx("label", { style: { fontSize: 11, fontWeight: 600, display: "block", marginBottom: 4, color: "var(--theme-elevation-500)" }, children: t("timeDashboard.filters.groupBy") }),
118
+ /* @__PURE__ */ jsxs("select", { value: groupBy, onChange: (e) => setGroupBy(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)" }, children: [
119
+ /* @__PURE__ */ jsx("option", { value: "day", children: t("timeDashboard.filters.day") }),
120
+ /* @__PURE__ */ jsx("option", { value: "week", children: t("timeDashboard.filters.week") }),
121
+ /* @__PURE__ */ jsx("option", { value: "project", children: t("timeDashboard.filters.project") })
122
+ ] })
123
+ ] })
124
+ ] })
125
+ ] }),
126
+ loading ? /* @__PURE__ */ jsx("div", { style: { padding: 40, textAlign: "center", color: "#94a3b8" }, children: t("common.loading") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
127
+ /* @__PURE__ */ jsxs("div", { style: S.kpis, children: [
128
+ /* @__PURE__ */ jsxs("div", { style: S.kpiCard, children: [
129
+ /* @__PURE__ */ jsx("div", { style: { fontSize: 11, color: "var(--theme-elevation-500)" }, children: t("timeDashboard.kpis.totalTime") }),
130
+ /* @__PURE__ */ jsx("div", { style: { fontSize: 24, fontWeight: 700, color: "#2563eb" }, children: formatDuration(totalMinutes) })
131
+ ] }),
132
+ /* @__PURE__ */ jsxs("div", { style: S.kpiCard, children: [
133
+ /* @__PURE__ */ jsx("div", { style: { fontSize: 11, color: "var(--theme-elevation-500)" }, children: t("timeDashboard.kpis.entries") }),
134
+ /* @__PURE__ */ jsx("div", { style: { fontSize: 24, fontWeight: 700, color: "#d97706" }, children: entries.length })
135
+ ] }),
136
+ /* @__PURE__ */ jsxs("div", { style: S.kpiCard, children: [
137
+ /* @__PURE__ */ jsx("div", { style: { fontSize: 11, color: "var(--theme-elevation-500)" }, children: t("timeDashboard.kpis.dailyAverage") }),
138
+ /* @__PURE__ */ jsx("div", { style: { fontSize: 24, fontWeight: 700, color: "#ea580c" }, children: dailyChart.length > 0 ? formatDuration(Math.round(totalMinutes / dailyChart.length)) : "-" })
139
+ ] })
140
+ ] }),
141
+ dailyChart.length > 0 && /* @__PURE__ */ jsxs("div", { style: { padding: 16, borderRadius: 10, border: "1px solid var(--theme-elevation-150)", marginBottom: 20 }, children: [
142
+ /* @__PURE__ */ jsx("div", { style: { fontSize: 13, fontWeight: 700, marginBottom: 8 }, children: t("timeDashboard.chart.title") }),
143
+ /* @__PURE__ */ jsx("div", { style: { display: "flex", alignItems: "flex-end", gap: 3, height: 80 }, children: dailyChart.map((d) => /* @__PURE__ */ jsx("div", { style: { flex: 1, background: "#3b82f6", borderRadius: "3px 3px 0 0", height: `${Math.max(d.minutes / maxDailyMinutes * 100, 4)}%` }, title: `${d.day}: ${formatDuration(d.minutes)}` }, d.day)) })
144
+ ] }),
145
+ grouped.length === 0 ? /* @__PURE__ */ jsx("div", { style: { padding: 40, textAlign: "center", color: "#94a3b8" }, children: t("timeDashboard.empty") }) : grouped.map((group) => /* @__PURE__ */ jsxs("div", { style: S.groupCard, children: [
146
+ /* @__PURE__ */ jsxs("div", { style: S.groupHeader, children: [
147
+ /* @__PURE__ */ jsx("span", { style: { fontWeight: 700 }, children: group.label }),
148
+ /* @__PURE__ */ jsx("span", { style: { fontWeight: 700, color: "#2563eb" }, children: formatDuration(group.totalMinutes) })
149
+ ] }),
150
+ /* @__PURE__ */ jsx("table", { style: S.table, children: /* @__PURE__ */ jsx("tbody", { children: group.entries.map((entry) => {
151
+ const ticket = typeof entry.ticket === "object" ? entry.ticket : null;
152
+ return /* @__PURE__ */ jsxs("tr", { children: [
153
+ /* @__PURE__ */ jsx("td", { style: S.td, children: ticket ? /* @__PURE__ */ jsx("a", { href: `/admin/collections/tickets/${ticket.id}`, style: { color: "#2563eb", textDecoration: "none", fontWeight: 600 }, children: ticket.ticketNumber || `#${ticket.id}` }) : "-" }),
154
+ /* @__PURE__ */ jsx("td", { style: S.td, children: ticket?.subject || "" }),
155
+ /* @__PURE__ */ jsx("td", { style: { ...S.td, color: "var(--theme-elevation-500)" }, children: entry.description || "-" }),
156
+ /* @__PURE__ */ jsx("td", { style: { ...S.td, textAlign: "right", fontWeight: 600 }, children: formatDuration(entry.duration) })
157
+ ] }, entry.id);
158
+ }) }) })
159
+ ] }, group.label))
160
+ ] })
161
+ ] });
162
+ };
163
+
164
+ export { TimeDashboardClient };
@@ -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 { TimeDashboardClient } from './client';
6
+
7
+ const TimeDashboardView = ({ 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: "TimeDashboardView", children: /* @__PURE__ */ jsx(TimeDashboardClient, {}) })
24
+ }
25
+ );
26
+ };
27
+ var TimeDashboardView_default = TimeDashboardView;
28
+
29
+ export { TimeDashboardView, TimeDashboardView_default as default };
@@ -0,0 +1,67 @@
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { V } from './adminTokens';
4
+
5
+ const AdminViewHeader = ({
6
+ icon,
7
+ title,
8
+ subtitle,
9
+ breadcrumb,
10
+ actions
11
+ }) => {
12
+ return /* @__PURE__ */ jsxs(
13
+ "div",
14
+ {
15
+ style: {
16
+ display: "flex",
17
+ justifyContent: "space-between",
18
+ alignItems: "flex-start",
19
+ marginBottom: 20
20
+ },
21
+ children: [
22
+ /* @__PURE__ */ jsxs("div", { children: [
23
+ breadcrumb && /* @__PURE__ */ jsx("div", { style: { marginBottom: 6 }, children: /* @__PURE__ */ jsxs(
24
+ "a",
25
+ {
26
+ href: breadcrumb.href,
27
+ style: {
28
+ fontSize: 12,
29
+ fontWeight: 700,
30
+ color: V.cyan,
31
+ textDecoration: "none",
32
+ textTransform: "uppercase"
33
+ },
34
+ children: [
35
+ "\u2190 ",
36
+ breadcrumb.label
37
+ ]
38
+ }
39
+ ) }),
40
+ /* @__PURE__ */ jsxs(
41
+ "h1",
42
+ {
43
+ style: {
44
+ fontSize: 28,
45
+ fontWeight: 600,
46
+ letterSpacing: 0,
47
+ margin: 0,
48
+ color: V.text,
49
+ display: "flex",
50
+ alignItems: "center",
51
+ gap: 10
52
+ },
53
+ children: [
54
+ /* @__PURE__ */ jsx("span", { style: { color: V.cyan, display: "flex", alignItems: "center" }, children: icon }),
55
+ title
56
+ ]
57
+ }
58
+ ),
59
+ subtitle && /* @__PURE__ */ jsx("p", { style: { color: V.textSecondary, margin: "4px 0 0", fontSize: 14 }, children: subtitle })
60
+ ] }),
61
+ actions && /* @__PURE__ */ jsx("div", { style: { display: "flex", gap: 8 }, children: actions })
62
+ ]
63
+ }
64
+ );
65
+ };
66
+
67
+ export { AdminViewHeader };
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import React from 'react';
4
+
5
+ class AdminErrorBoundary extends React.Component {
6
+ constructor(props) {
7
+ super(props);
8
+ this.state = { hasError: false, error: null };
9
+ }
10
+ static getDerivedStateFromError(error) {
11
+ return { hasError: true, error };
12
+ }
13
+ componentDidCatch(error, errorInfo) {
14
+ console.error(`[${this.props.viewName || "AdminView"}] Error:`, error, errorInfo);
15
+ }
16
+ render() {
17
+ if (this.state.hasError) {
18
+ if (this.props.fallback) {
19
+ return this.props.fallback;
20
+ }
21
+ return /* @__PURE__ */ jsxs("div", { style: {
22
+ padding: "40px",
23
+ textAlign: "center",
24
+ color: "#dc2626"
25
+ }, children: [
26
+ /* @__PURE__ */ jsx("h2", { style: { marginBottom: "16px", fontSize: "18px" }, children: "Une erreur est survenue" }),
27
+ /* @__PURE__ */ jsx("p", { style: { marginBottom: "24px", color: "#6b7280", fontSize: "14px" }, children: this.state.error?.message || "Erreur inattendue" }),
28
+ /* @__PURE__ */ jsx(
29
+ "button",
30
+ {
31
+ onClick: () => this.setState({ hasError: false, error: null }),
32
+ style: {
33
+ padding: "8px 20px",
34
+ backgroundColor: "#2563eb",
35
+ color: "#fff",
36
+ border: "none",
37
+ borderRadius: "6px",
38
+ cursor: "pointer",
39
+ fontSize: "14px"
40
+ },
41
+ children: "Reessayer"
42
+ }
43
+ )
44
+ ] });
45
+ }
46
+ return this.props.children;
47
+ }
48
+ }
49
+
50
+ export { AdminErrorBoundary };
@@ -0,0 +1,72 @@
1
+ "use client";
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { useEffect } from 'react';
4
+
5
+ const styleId = "skeleton-shimmer-style";
6
+ function injectSkeletonStyles() {
7
+ if (typeof document === "undefined") return;
8
+ if (document.getElementById(styleId)) return;
9
+ const style = document.createElement("style");
10
+ style.id = styleId;
11
+ style.textContent = `
12
+ @keyframes skeleton-shimmer {
13
+ 0% { background-position: 200% 0; }
14
+ 100% { background-position: -200% 0; }
15
+ }
16
+ `;
17
+ document.head.appendChild(style);
18
+ }
19
+ function Skeleton({ width = "100%", height = "20px", borderRadius = "4px", style }) {
20
+ useEffect(() => {
21
+ injectSkeletonStyles();
22
+ }, []);
23
+ return /* @__PURE__ */ jsx(
24
+ "div",
25
+ {
26
+ style: {
27
+ width,
28
+ height,
29
+ borderRadius,
30
+ background: "linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%)",
31
+ backgroundSize: "200% 100%",
32
+ animation: "skeleton-shimmer 1.5s infinite",
33
+ ...style
34
+ }
35
+ }
36
+ );
37
+ }
38
+ function SkeletonText({ lines = 3, width = "100%" }) {
39
+ return /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: "8px", width }, children: Array.from({ length: lines }).map((_, i) => /* @__PURE__ */ jsx(Skeleton, { height: "16px", width: i === lines - 1 ? "60%" : "100%" }, i)) });
40
+ }
41
+ function SkeletonCard({ height = "200px" }) {
42
+ return /* @__PURE__ */ jsxs("div", { style: {
43
+ border: "1px solid #e5e7eb",
44
+ borderRadius: "8px",
45
+ padding: "20px",
46
+ display: "flex",
47
+ flexDirection: "column",
48
+ gap: "12px",
49
+ minHeight: height
50
+ }, children: [
51
+ /* @__PURE__ */ jsx(Skeleton, { height: "24px", width: "40%" }),
52
+ /* @__PURE__ */ jsx(SkeletonText, { lines: 3 }),
53
+ /* @__PURE__ */ jsx(Skeleton, { height: "32px", width: "120px", borderRadius: "6px" })
54
+ ] });
55
+ }
56
+ function SkeletonTable({ rows = 5, columns = 4 }) {
57
+ return /* @__PURE__ */ jsxs("div", { style: { width: "100%" }, children: [
58
+ /* @__PURE__ */ jsx("div", { style: { display: "flex", gap: "16px", padding: "12px 0", borderBottom: "2px solid #e5e7eb" }, children: Array.from({ length: columns }).map((_, i) => /* @__PURE__ */ jsx(Skeleton, { height: "16px", width: `${100 / columns}%` }, i)) }),
59
+ Array.from({ length: rows }).map((_, rowIdx) => /* @__PURE__ */ jsx("div", { style: { display: "flex", gap: "16px", padding: "12px 0", borderBottom: "1px solid #f3f4f6" }, children: Array.from({ length: columns }).map((_2, colIdx) => /* @__PURE__ */ jsx(Skeleton, { height: "14px", width: `${100 / columns}%` }, colIdx)) }, rowIdx))
60
+ ] });
61
+ }
62
+ function SkeletonDashboard() {
63
+ return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "24px", padding: "20px 0" }, children: [
64
+ /* @__PURE__ */ jsx("div", { style: { display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(200px, 1fr))", gap: "16px" }, children: Array.from({ length: 4 }).map((_, i) => /* @__PURE__ */ jsxs("div", { style: { padding: "20px", border: "1px solid #e5e7eb", borderRadius: "8px" }, children: [
65
+ /* @__PURE__ */ jsx(Skeleton, { height: "14px", width: "60%", style: { marginBottom: "8px" } }),
66
+ /* @__PURE__ */ jsx(Skeleton, { height: "32px", width: "40%" })
67
+ ] }, i)) }),
68
+ /* @__PURE__ */ jsx(SkeletonTable, { rows: 5, columns: 4 })
69
+ ] });
70
+ }
71
+
72
+ export { Skeleton, SkeletonCard, SkeletonDashboard, SkeletonTable, SkeletonText };
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ const V = {
3
+ text: "var(--theme-text)",
4
+ textSecondary: "var(--theme-elevation-500)",
5
+ bg: "var(--theme-elevation-50)",
6
+ bgCard: "var(--theme-elevation-100)",
7
+ border: "var(--theme-elevation-300)",
8
+ // Professional palette
9
+ blue: "#2563eb",
10
+ amber: "#d97706",
11
+ orange: "#ea580c",
12
+ green: "#16a34a",
13
+ red: "#dc2626",
14
+ // Legacy aliases (backward compat for views not yet updated)
15
+ cyan: "#2563eb",
16
+ yellow: "#d97706"
17
+ };
18
+ const btnStyle = (bg, opts) => ({
19
+ padding: opts?.small ? "6px 12px" : "8px 14px",
20
+ borderRadius: 6,
21
+ border: `1px solid var(--theme-elevation-300)`,
22
+ backgroundColor: bg,
23
+ color: "#fff",
24
+ fontWeight: 600,
25
+ fontSize: opts?.small ? 12 : 13,
26
+ cursor: opts?.disabled ? "not-allowed" : "pointer",
27
+ opacity: opts?.disabled ? 0.5 : 1,
28
+ textDecoration: "none",
29
+ whiteSpace: "nowrap"
30
+ });
31
+
32
+ export { V, btnStyle };
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ const DEFAULT_FEATURES = {
3
+ timeTracking: true,
4
+ ai: true,
5
+ satisfaction: true,
6
+ chat: true,
7
+ emailTracking: true,
8
+ canned: true,
9
+ merge: true,
10
+ snooze: true,
11
+ externalMessages: true,
12
+ clientHistory: true,
13
+ activityLog: true,
14
+ splitTicket: true,
15
+ scheduledReplies: true,
16
+ autoClose: true,
17
+ autoCloseDays: 7,
18
+ roundRobin: false
19
+ };
20
+ const STORAGE_KEY = "ticketing_features";
21
+ function getFeatures() {
22
+ if (typeof window === "undefined") return DEFAULT_FEATURES;
23
+ try {
24
+ const stored = localStorage.getItem(STORAGE_KEY);
25
+ if (stored) {
26
+ const parsed = JSON.parse(stored);
27
+ return { ...DEFAULT_FEATURES, ...parsed };
28
+ }
29
+ } catch {
30
+ }
31
+ return DEFAULT_FEATURES;
32
+ }
33
+ function saveFeatures(features) {
34
+ if (typeof window === "undefined") return;
35
+ try {
36
+ localStorage.setItem(STORAGE_KEY, JSON.stringify(features));
37
+ } catch {
38
+ }
39
+ }
40
+
41
+ export { DEFAULT_FEATURES, getFeatures, saveFeatures };
@@ -0,0 +1,6 @@
1
+ "use client";
2
+ export { AdminErrorBoundary } from './ErrorBoundary';
3
+ export { V, btnStyle } from './adminTokens';
4
+ export { AdminViewHeader } from './AdminViewHeader';
5
+ export { Skeleton, SkeletonCard, SkeletonDashboard, SkeletonTable, SkeletonText } from './Skeleton';
6
+ export { DEFAULT_FEATURES, getFeatures, saveFeatures } from './config';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@consilioweb/payload-support",
3
- "version": "0.5.2",
3
+ "version": "0.6.0",
4
4
  "description": "Payload CMS plugin — professional support & ticketing system with AI, SLA, time tracking, live chat, and more",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -27,18 +27,14 @@
27
27
  "default": "./dist/client.cjs"
28
28
  }
29
29
  },
30
- "./views": {
31
- "import": {
32
- "types": "./dist/views.d.ts",
33
- "default": "./dist/views.js"
34
- },
35
- "require": {
36
- "types": "./dist/views.d.cts",
37
- "default": "./dist/views.cjs"
38
- }
30
+ "./views/*": {
31
+ "types": "./dist/views/*/index.d.ts",
32
+ "default": "./dist/views/*/index.js"
39
33
  },
40
- "./src/views/*": "./src/views/*/index.tsx",
41
- "./src/components/*": "./src/components/*/index.tsx"
34
+ "./components/*": {
35
+ "types": "./dist/components/*/index.d.ts",
36
+ "default": "./dist/components/*/index.js"
37
+ }
42
38
  },
43
39
  "files": [
44
40
  "dist",
@@ -440,7 +440,7 @@ export function createTicketsCollection(slugs: CollectionSlugs, options?: {
440
440
  type: 'ui',
441
441
  admin: {
442
442
  components: {
443
- Field: options?.conversationComponent || '@consilioweb/payload-support/src/components/TicketConversation',
443
+ Field: options?.conversationComponent || '@consilioweb/payload-support/components/TicketConversation',
444
444
  },
445
445
  },
446
446
  })
@@ -1,7 +1,26 @@
1
1
  'use client'
2
2
 
3
3
  import React, { useState, useEffect, useCallback, useRef } from 'react'
4
- import { useDocumentInfo } from '@payloadcms/ui'
4
+
5
+ // Replacement for @payloadcms/ui's useDocumentInfo — avoids importing
6
+ // @payloadcms/ui (which has chunk splits that break webpack resolution
7
+ // when this bundle is consumed from node_modules).
8
+ // Extracts the document id from the admin URL pattern:
9
+ // /admin/collections/:slug/:id or /admin/globals/:slug
10
+ function useDocumentIdFromUrl(): { id: string | number | undefined } {
11
+ const [id, setId] = useState<string | number | undefined>(undefined)
12
+ useEffect(() => {
13
+ const match = window.location.pathname.match(
14
+ /\/admin\/collections\/[^/]+\/([^/?#]+)/
15
+ )
16
+ if (match && match[1] !== 'create') {
17
+ const raw = match[1]
18
+ const num = Number(raw)
19
+ setId(Number.isFinite(num) && String(num) === raw ? num : raw)
20
+ }
21
+ }, [])
22
+ return { id }
23
+ }
5
24
  import type { Message, TimeEntry, ClientInfo, CannedResponse, ActivityEntry, SatisfactionSurvey } from './types'
6
25
  import type { RichTextEditorHandle } from './context'
7
26
  import { C, s } from './constants'
@@ -64,7 +83,7 @@ const layoutStyles = {
64
83
  }
65
84
 
66
85
  const TicketConversation: React.FC = () => {
67
- const { id } = useDocumentInfo()
86
+ const { id } = useDocumentIdFromUrl()
68
87
  const [features] = useState<TicketingFeatures>(() => getFeatures())
69
88
  const [messages, setMessages] = useState<Message[]>([])
70
89
  const [timeEntries, setTimeEntries] = useState<TimeEntry[]>([])
package/src/plugin.ts CHANGED
@@ -54,8 +54,9 @@ export function supportPlugin(config?: SupportPluginConfig): Plugin {
54
54
  }
55
55
 
56
56
  const bp = config?.basePath || '/support'
57
- // Views are referenced by source path so Next.js can resolve server/client boundaries
58
- const viewsBase = '@consilioweb/payload-support/src/views'
57
+ // Use compiled subpath exports (one file per view) avoids webpack
58
+ // issues with bundled 'use client' files from node_modules.
59
+ const viewsBase = '@consilioweb/payload-support/views'
59
60
  const slugs = resolveSlugs({
60
61
  ...config?.collectionSlugs,
61
62
  users: config?.userCollectionSlug || 'users',