@consilioweb/payload-support 0.6.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{styles/theme.css → components/TicketConversation.css} +13 -326
- package/dist/components/TicketConversation.js +3004 -0
- package/dist/index.cjs +11 -11
- package/dist/index.js +11 -11
- package/dist/views/BillingView/client.cjs +209 -0
- package/dist/views/BillingView/index.cjs +34 -0
- package/dist/views/ChatView/client.cjs +253 -0
- package/dist/views/ChatView/index.cjs +34 -0
- package/dist/views/CrmView/client.cjs +233 -0
- package/dist/views/CrmView/index.cjs +34 -0
- package/dist/views/EmailTrackingView/client.cjs +159 -0
- package/dist/views/EmailTrackingView/index.cjs +34 -0
- package/dist/views/ImportConversationView/client.cjs +205 -0
- package/dist/views/ImportConversationView/index.cjs +34 -0
- package/dist/views/LogsView/client.cjs +149 -0
- package/dist/views/LogsView/index.cjs +32 -0
- package/dist/views/NewTicketView/client.cjs +229 -0
- package/dist/views/NewTicketView/index.cjs +32 -0
- package/dist/views/PendingEmailsView/client.cjs +173 -0
- package/dist/views/PendingEmailsView/index.cjs +34 -0
- package/dist/views/SupportDashboardView/client.cjs +301 -0
- package/dist/views/SupportDashboardView/index.cjs +34 -0
- package/dist/views/TicketDetailView/client.cjs +850 -0
- package/dist/views/TicketDetailView/index.cjs +34 -0
- package/dist/views/TicketInboxView/client.cjs +299 -0
- package/dist/views/TicketInboxView/index.cjs +32 -0
- package/dist/views/TicketingSettingsView/client.cjs +733 -0
- package/dist/views/TicketingSettingsView/index.cjs +34 -0
- package/dist/views/TimeDashboardView/client.cjs +169 -0
- package/dist/views/TimeDashboardView/index.cjs +34 -0
- package/dist/views/shared/AdminViewHeader.cjs +68 -0
- package/dist/views/shared/ErrorBoundary.cjs +55 -0
- package/dist/views/shared/Skeleton.cjs +77 -0
- package/dist/views/shared/adminTokens.cjs +34 -0
- package/dist/views/shared/adminTokens.js +0 -1
- package/dist/{components/TicketConversation/config.js → views/shared/config.cjs} +5 -2
- package/dist/views/shared/config.js +0 -1
- package/dist/views/shared/index.cjs +58 -0
- package/dist/views/shared/index.js +0 -1
- package/dist/views.cjs +86 -0
- package/dist/views.d.cts +13 -0
- package/dist/views.d.ts +13 -0
- package/dist/views.js +13 -0
- package/package.json +14 -7
- package/src/plugin.ts +11 -11
- package/src/views.ts +17 -0
- package/dist/components/TicketConversation/components/AISummaryPanel.js +0 -76
- package/dist/components/TicketConversation/components/ActionPanels.js +0 -118
- package/dist/components/TicketConversation/components/ActivityLog.js +0 -23
- package/dist/components/TicketConversation/components/ClientBar.js +0 -42
- package/dist/components/TicketConversation/components/ClientHistory.js +0 -137
- package/dist/components/TicketConversation/components/CodeBlock.js +0 -152
- package/dist/components/TicketConversation/components/CodeBlockInserter.js +0 -155
- package/dist/components/TicketConversation/components/QuickActions.js +0 -65
- package/dist/components/TicketConversation/components/TicketHeader.js +0 -92
- package/dist/components/TicketConversation/components/TimeTrackingPanel.js +0 -133
- package/dist/components/TicketConversation/constants.js +0 -96
- package/dist/components/TicketConversation/context.js +0 -11
- package/dist/components/TicketConversation/hooks/useAI.js +0 -176
- package/dist/components/TicketConversation/hooks/useMessageActions.js +0 -135
- package/dist/components/TicketConversation/hooks/useReply.js +0 -187
- package/dist/components/TicketConversation/hooks/useTicketActions.js +0 -230
- package/dist/components/TicketConversation/hooks/useTimeTracking.js +0 -122
- package/dist/components/TicketConversation/hooks/useTranslation.js +0 -70
- package/dist/components/TicketConversation/index.js +0 -1123
- package/dist/components/TicketConversation/locales/en.json +0 -878
- package/dist/components/TicketConversation/locales/fr.json +0 -878
- package/dist/components/TicketConversation/types.js +0 -2
- package/dist/components/TicketConversation/utils.js +0 -25
- package/dist/styles/BillingView.module.scss +0 -311
- package/dist/styles/ChatView.module.scss +0 -438
- package/dist/styles/CommandPalette.module.scss +0 -160
- package/dist/styles/CrmView.module.scss +0 -554
- package/dist/styles/EmailTracking.module.scss +0 -238
- package/dist/styles/ImportConversation.module.scss +0 -267
- package/dist/styles/Layout.module.scss +0 -55
- package/dist/styles/Logs.module.scss +0 -164
- package/dist/styles/NewTicket.module.scss +0 -143
- package/dist/styles/PendingEmails.module.scss +0 -629
- package/dist/styles/SupportDashboard.module.scss +0 -649
- package/dist/styles/TicketDetail.module.scss +0 -1050
- package/dist/styles/TicketInbox.module.scss +0 -296
- package/dist/styles/TicketingSettings.module.scss +0 -358
- package/dist/styles/TimeDashboard.module.scss +0 -287
- package/dist/styles/_tokens.scss +0 -78
|
@@ -0,0 +1,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 TicketDetailView = ({ 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: "TicketDetailView", children: /* @__PURE__ */ jsxRuntime.jsx(client.TicketDetailClient, {}) })
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
var TicketDetailView_default = TicketDetailView;
|
|
32
|
+
|
|
33
|
+
exports.TicketDetailView = TicketDetailView;
|
|
34
|
+
exports.default = TicketDetailView_default;
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var navigation = require('next/navigation');
|
|
6
|
+
var Link = require('next/link');
|
|
7
|
+
var useTranslation = require('../../components/TicketConversation/hooks/useTranslation');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var Link__default = /*#__PURE__*/_interopDefault(Link);
|
|
12
|
+
|
|
13
|
+
const STATUS_DOTS = {
|
|
14
|
+
open: "#22c55e",
|
|
15
|
+
waiting_client: "#eab308",
|
|
16
|
+
resolved: "#94a3b8"
|
|
17
|
+
};
|
|
18
|
+
const STATUS_LABEL_KEYS = {
|
|
19
|
+
open: "inbox.tabs.open",
|
|
20
|
+
waiting_client: "inbox.tabs.waiting",
|
|
21
|
+
resolved: "inbox.tabs.resolved"
|
|
22
|
+
};
|
|
23
|
+
const PRIORITY_COLORS = {
|
|
24
|
+
urgent: "#ef4444",
|
|
25
|
+
high: "#f97316",
|
|
26
|
+
normal: "transparent",
|
|
27
|
+
low: "transparent"
|
|
28
|
+
};
|
|
29
|
+
const CATEGORY_LABEL_KEYS = {
|
|
30
|
+
bug: "ticket.category.bug",
|
|
31
|
+
content: "ticket.category.content",
|
|
32
|
+
feature: "ticket.category.feature",
|
|
33
|
+
question: "ticket.category.question",
|
|
34
|
+
hosting: "ticket.category.hosting"
|
|
35
|
+
};
|
|
36
|
+
function relativeTime(dateStr) {
|
|
37
|
+
const diff = Date.now() - new Date(dateStr).getTime();
|
|
38
|
+
const mins = Math.floor(diff / 6e4);
|
|
39
|
+
if (mins < 1) return "maintenant";
|
|
40
|
+
if (mins < 60) return `${mins}m`;
|
|
41
|
+
const hours = Math.floor(mins / 60);
|
|
42
|
+
if (hours < 24) return `${hours}h`;
|
|
43
|
+
const days = Math.floor(hours / 24);
|
|
44
|
+
if (days < 7) return `${days}j`;
|
|
45
|
+
return new Date(dateStr).toLocaleDateString("fr-FR", { day: "numeric", month: "short" });
|
|
46
|
+
}
|
|
47
|
+
const TicketInboxClient = () => {
|
|
48
|
+
const { t } = useTranslation.useTranslation();
|
|
49
|
+
const searchParams = navigation.useSearchParams();
|
|
50
|
+
const [tickets, setTickets] = react.useState([]);
|
|
51
|
+
const [loading, setLoading] = react.useState(true);
|
|
52
|
+
const [tab, setTab] = react.useState(() => {
|
|
53
|
+
const urlTab = searchParams.get("tab");
|
|
54
|
+
if (urlTab && ["all", "open", "waiting_client", "resolved"].includes(urlTab)) return urlTab;
|
|
55
|
+
return "all";
|
|
56
|
+
});
|
|
57
|
+
const [search, setSearch] = react.useState("");
|
|
58
|
+
const [sort, setSort] = react.useState("-updatedAt");
|
|
59
|
+
const [counts, setCounts] = react.useState({ all: 0, open: 0, waiting: 0, resolved: 0 });
|
|
60
|
+
const [selectedIdx, setSelectedIdx] = react.useState(-1);
|
|
61
|
+
const [checkedIds, setCheckedIds] = react.useState(/* @__PURE__ */ new Set());
|
|
62
|
+
const [bulkAction, setBulkAction] = react.useState("");
|
|
63
|
+
const [bulkProcessing, setBulkProcessing] = react.useState(false);
|
|
64
|
+
const toggleCheck = (id) => {
|
|
65
|
+
setCheckedIds((prev) => {
|
|
66
|
+
const next = new Set(prev);
|
|
67
|
+
if (next.has(id)) next.delete(id);
|
|
68
|
+
else next.add(id);
|
|
69
|
+
return next;
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
const handleBulkAction = async (action) => {
|
|
73
|
+
if (checkedIds.size === 0) return;
|
|
74
|
+
setBulkProcessing(true);
|
|
75
|
+
try {
|
|
76
|
+
const res = await fetch("/api/support/bulk-action", {
|
|
77
|
+
method: "POST",
|
|
78
|
+
headers: { "Content-Type": "application/json" },
|
|
79
|
+
credentials: "include",
|
|
80
|
+
body: JSON.stringify({ ticketIds: Array.from(checkedIds), action })
|
|
81
|
+
});
|
|
82
|
+
if (res.ok) {
|
|
83
|
+
setCheckedIds(/* @__PURE__ */ new Set());
|
|
84
|
+
setBulkAction("");
|
|
85
|
+
fetchTickets();
|
|
86
|
+
}
|
|
87
|
+
} catch {
|
|
88
|
+
}
|
|
89
|
+
setBulkProcessing(false);
|
|
90
|
+
};
|
|
91
|
+
const fetchTickets = react.useCallback(async () => {
|
|
92
|
+
const params = [`limit=30`, `sort=${sort}`, `depth=1`, `select[id]=true`, `select[ticketNumber]=true`, `select[subject]=true`, `select[status]=true`, `select[priority]=true`, `select[category]=true`, `select[client]=true`, `select[updatedAt]=true`, `select[lastClientMessageAt]=true`, `select[lastAdminReadAt]=true`];
|
|
93
|
+
if (tab !== "all") params.push(`where[status][equals]=${tab}`);
|
|
94
|
+
if (search.trim()) {
|
|
95
|
+
params.push(`where[or][0][subject][contains]=${encodeURIComponent(search)}`);
|
|
96
|
+
params.push(`where[or][1][ticketNumber][contains]=${encodeURIComponent(search)}`);
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
const url = `/api/tickets?${params.join("&")}`;
|
|
100
|
+
const res = await fetch(url, { credentials: "include" });
|
|
101
|
+
if (res.ok) {
|
|
102
|
+
const d = await res.json();
|
|
103
|
+
setTickets(d.docs || []);
|
|
104
|
+
} else {
|
|
105
|
+
console.error("[inbox] Fetch failed:", res.status, await res.text().catch(() => ""));
|
|
106
|
+
}
|
|
107
|
+
} catch (err) {
|
|
108
|
+
console.error("[inbox] Fetch error:", err);
|
|
109
|
+
}
|
|
110
|
+
setLoading(false);
|
|
111
|
+
}, [tab, sort, search]);
|
|
112
|
+
react.useEffect(() => {
|
|
113
|
+
setLoading(true);
|
|
114
|
+
fetchTickets();
|
|
115
|
+
}, [fetchTickets]);
|
|
116
|
+
react.useEffect(() => {
|
|
117
|
+
const fetchCounts = async () => {
|
|
118
|
+
try {
|
|
119
|
+
const [all, openRes, waiting, resolved] = await Promise.all([
|
|
120
|
+
fetch("/api/tickets?limit=0&depth=0", { credentials: "include" }),
|
|
121
|
+
fetch("/api/tickets?limit=0&depth=0&where[status][equals]=open", { credentials: "include" }),
|
|
122
|
+
fetch("/api/tickets?limit=0&depth=0&where[status][equals]=waiting_client", { credentials: "include" }),
|
|
123
|
+
fetch("/api/tickets?limit=0&depth=0&where[status][equals]=resolved", { credentials: "include" })
|
|
124
|
+
]);
|
|
125
|
+
const [a, o, w, r] = await Promise.all([all.json(), openRes.json(), waiting.json(), resolved.json()]);
|
|
126
|
+
setCounts({ all: a.totalDocs || 0, open: o.totalDocs || 0, waiting: w.totalDocs || 0, resolved: r.totalDocs || 0 });
|
|
127
|
+
} catch {
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
fetchCounts();
|
|
131
|
+
}, []);
|
|
132
|
+
react.useEffect(() => {
|
|
133
|
+
const iv = setInterval(fetchTickets, 6e4);
|
|
134
|
+
return () => clearInterval(iv);
|
|
135
|
+
}, [fetchTickets]);
|
|
136
|
+
react.useEffect(() => {
|
|
137
|
+
const handleKey = (e) => {
|
|
138
|
+
if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) return;
|
|
139
|
+
if (e.key === "j" || e.key === "ArrowDown") {
|
|
140
|
+
e.preventDefault();
|
|
141
|
+
setSelectedIdx((p) => Math.min(p + 1, tickets.length - 1));
|
|
142
|
+
}
|
|
143
|
+
if (e.key === "k" || e.key === "ArrowUp") {
|
|
144
|
+
e.preventDefault();
|
|
145
|
+
setSelectedIdx((p) => Math.max(p - 1, 0));
|
|
146
|
+
}
|
|
147
|
+
if (e.key === "Enter" && selectedIdx >= 0 && tickets[selectedIdx]) {
|
|
148
|
+
window.location.href = `/admin/support/ticket?id=${tickets[selectedIdx].id}`;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
window.addEventListener("keydown", handleKey);
|
|
152
|
+
return () => window.removeEventListener("keydown", handleKey);
|
|
153
|
+
}, [tickets, selectedIdx]);
|
|
154
|
+
const tabs = [
|
|
155
|
+
{ key: "all", label: t("inbox.tabs.all"), count: counts.all },
|
|
156
|
+
{ key: "open", label: t("inbox.tabs.open"), count: counts.open },
|
|
157
|
+
{ key: "waiting_client", label: t("inbox.tabs.waiting"), count: counts.waiting },
|
|
158
|
+
{ key: "resolved", label: t("inbox.tabs.resolved"), count: counts.resolved }
|
|
159
|
+
];
|
|
160
|
+
const S = {
|
|
161
|
+
page: { padding: "20px 30px", maxWidth: 1100, margin: "0 auto" },
|
|
162
|
+
header: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 16 },
|
|
163
|
+
title: { fontSize: 24, fontWeight: 700, margin: 0, color: "var(--theme-text)" },
|
|
164
|
+
headerRight: { display: "flex", gap: 10, alignItems: "center" },
|
|
165
|
+
searchWrap: { position: "relative", display: "flex", alignItems: "center" },
|
|
166
|
+
searchInput: { padding: "6px 12px 6px 30px", borderRadius: 8, border: "1px solid var(--theme-elevation-200)", fontSize: 13, background: "var(--theme-elevation-0)", color: "var(--theme-text)", width: 200 },
|
|
167
|
+
newTicketBtn: { padding: "7px 14px", borderRadius: 8, background: "#2563eb", color: "#fff", fontSize: 13, fontWeight: 600, textDecoration: "none", whiteSpace: "nowrap" },
|
|
168
|
+
tabsRow: { display: "flex", gap: 4, marginBottom: 12, borderBottom: "1px solid var(--theme-elevation-200)", paddingBottom: 8 },
|
|
169
|
+
tab: { padding: "6px 12px", borderRadius: 6, border: "none", background: "none", cursor: "pointer", fontSize: 13, color: "var(--theme-elevation-500)", fontWeight: 500 },
|
|
170
|
+
tabActive: { background: "var(--theme-elevation-100)", color: "var(--theme-text)", fontWeight: 700 },
|
|
171
|
+
sortRow: { display: "flex", alignItems: "center", marginBottom: 12 },
|
|
172
|
+
sortSelect: { padding: "4px 10px", borderRadius: 6, border: "1px solid var(--theme-elevation-200)", fontSize: 12, background: "var(--theme-elevation-0)", color: "var(--theme-text)", cursor: "pointer" },
|
|
173
|
+
loading: { padding: 40, textAlign: "center", color: "#94a3b8" },
|
|
174
|
+
empty: { padding: 60, textAlign: "center", color: "#94a3b8" },
|
|
175
|
+
list: { display: "flex", flexDirection: "column", gap: 1 },
|
|
176
|
+
row: { display: "grid", gridTemplateColumns: "20px 10px 60px 70px 1fr 140px 80px 4px 50px 10px", gap: 8, alignItems: "center", padding: "10px 12px", borderRadius: 8, textDecoration: "none", color: "var(--theme-text)", fontSize: 13, cursor: "pointer", transition: "background 100ms", background: "var(--theme-elevation-0)" },
|
|
177
|
+
statusDot: { width: 8, height: 8, borderRadius: "50%" },
|
|
178
|
+
priorityBar: { width: 4, height: 20, borderRadius: 2 },
|
|
179
|
+
unreadDot: { width: 8, height: 8, borderRadius: "50%", background: "#2563eb" },
|
|
180
|
+
keyboardHints: { display: "flex", gap: 12, marginTop: 16, fontSize: 11, color: "var(--theme-elevation-400)" }
|
|
181
|
+
};
|
|
182
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.page, children: [
|
|
183
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.header, children: [
|
|
184
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { style: S.title, children: t("inbox.title") }),
|
|
185
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.headerRight, children: [
|
|
186
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: S.searchWrap, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
187
|
+
"input",
|
|
188
|
+
{
|
|
189
|
+
type: "text",
|
|
190
|
+
style: S.searchInput,
|
|
191
|
+
placeholder: t("inbox.searchPlaceholder"),
|
|
192
|
+
value: search,
|
|
193
|
+
onChange: (e) => setSearch(e.target.value)
|
|
194
|
+
}
|
|
195
|
+
) }),
|
|
196
|
+
/* @__PURE__ */ jsxRuntime.jsx(Link__default.default, { href: "/admin/support/new-ticket", style: S.newTicketBtn, children: t("inbox.newTicketBtn") })
|
|
197
|
+
] })
|
|
198
|
+
] }),
|
|
199
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: S.tabsRow, children: tabs.map((tb) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
200
|
+
"button",
|
|
201
|
+
{
|
|
202
|
+
style: { ...S.tab, ...tab === tb.key ? S.tabActive : {} },
|
|
203
|
+
onClick: () => {
|
|
204
|
+
setTab(tb.key);
|
|
205
|
+
setSelectedIdx(-1);
|
|
206
|
+
},
|
|
207
|
+
children: [
|
|
208
|
+
tb.label,
|
|
209
|
+
" ",
|
|
210
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { opacity: 0.6 }, children: [
|
|
211
|
+
"(",
|
|
212
|
+
tb.count,
|
|
213
|
+
")"
|
|
214
|
+
] })
|
|
215
|
+
]
|
|
216
|
+
},
|
|
217
|
+
tb.key
|
|
218
|
+
)) }),
|
|
219
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: S.sortRow, children: checkedIds.size > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: 8, alignItems: "center", flex: 1 }, children: [
|
|
220
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 13, fontWeight: 600, color: "var(--theme-text)" }, children: checkedIds.size > 1 ? t("inbox.selectedPlural", { count: String(checkedIds.size) }) : t("inbox.selected", { count: String(checkedIds.size) }) }),
|
|
221
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { style: S.sortSelect, onClick: () => handleBulkAction("close"), disabled: bulkProcessing, children: t("inbox.closeAction") }),
|
|
222
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { style: S.sortSelect, onClick: () => handleBulkAction("reopen"), disabled: bulkProcessing, children: t("inbox.reopenAction") }),
|
|
223
|
+
/* @__PURE__ */ jsxRuntime.jsxs("select", { style: S.sortSelect, value: bulkAction, onChange: (e) => {
|
|
224
|
+
if (e.target.value) handleBulkAction(e.target.value);
|
|
225
|
+
setBulkAction("");
|
|
226
|
+
}, children: [
|
|
227
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: t("inbox.moreActions") }),
|
|
228
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "set_priority", children: t("inbox.changePriority") }),
|
|
229
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "delete", children: t("inbox.deleteAction") })
|
|
230
|
+
] }),
|
|
231
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { style: { ...S.sortSelect, marginLeft: "auto" }, onClick: () => setCheckedIds(/* @__PURE__ */ new Set()), children: t("inbox.deselect") })
|
|
232
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("select", { style: S.sortSelect, value: sort, onChange: (e) => setSort(e.target.value), children: [
|
|
233
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "-updatedAt", children: t("inbox.sort.newest") }),
|
|
234
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "updatedAt", children: t("inbox.sort.oldest") }),
|
|
235
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "-createdAt", children: t("inbox.sort.created") }),
|
|
236
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "priority", children: t("inbox.sort.priority") })
|
|
237
|
+
] }) }),
|
|
238
|
+
loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: S.loading, children: t("common.loading") }) : tickets.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: S.empty, children: t("inbox.empty") }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: S.list, children: tickets.map((tk, idx) => {
|
|
239
|
+
const clientObj = typeof tk.client === "object" ? tk.client : null;
|
|
240
|
+
const clientName = clientObj ? `${clientObj.firstName || ""} ${clientObj.lastName || ""}`.trim() : "";
|
|
241
|
+
const clientCompany = clientObj?.company || "";
|
|
242
|
+
const displayClient = clientName ? `${clientName}${clientCompany ? `, ${clientCompany}` : ""}` : "--";
|
|
243
|
+
const isUnread = tk.lastClientMessageAt && (!tk.lastAdminReadAt || new Date(tk.lastClientMessageAt) > new Date(tk.lastAdminReadAt));
|
|
244
|
+
const priorityColor = PRIORITY_COLORS[tk.priority] || "transparent";
|
|
245
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
246
|
+
"a",
|
|
247
|
+
{
|
|
248
|
+
href: `/admin/support/ticket?id=${tk.id}`,
|
|
249
|
+
style: { ...S.row, ...idx === selectedIdx ? { background: "var(--theme-elevation-100)" } : {} },
|
|
250
|
+
onClick: (e) => {
|
|
251
|
+
e.preventDefault();
|
|
252
|
+
window.location.href = `/admin/support/ticket?id=${tk.id}`;
|
|
253
|
+
},
|
|
254
|
+
children: [
|
|
255
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
256
|
+
"input",
|
|
257
|
+
{
|
|
258
|
+
type: "checkbox",
|
|
259
|
+
checked: checkedIds.has(tk.id),
|
|
260
|
+
onClick: (e) => e.stopPropagation(),
|
|
261
|
+
onChange: () => toggleCheck(tk.id),
|
|
262
|
+
style: { width: 14, height: 14, cursor: "pointer", accentColor: "#2563eb" }
|
|
263
|
+
}
|
|
264
|
+
),
|
|
265
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...S.statusDot, backgroundColor: STATUS_DOTS[tk.status] || "#94a3b8" } }),
|
|
266
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 11, color: "var(--theme-elevation-500)" }, children: STATUS_LABEL_KEYS[tk.status] ? t(STATUS_LABEL_KEYS[tk.status]) : tk.status }),
|
|
267
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 600, fontSize: 12, color: "var(--theme-elevation-400)" }, children: tk.ticketNumber }),
|
|
268
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 500 }, children: tk.subject }),
|
|
269
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 12, color: "var(--theme-elevation-500)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: displayClient }),
|
|
270
|
+
tk.category ? /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { fontSize: 11, color: "var(--theme-elevation-400)" }, children: [
|
|
271
|
+
"[",
|
|
272
|
+
CATEGORY_LABEL_KEYS[tk.category] ? t(CATEGORY_LABEL_KEYS[tk.category]) : tk.category,
|
|
273
|
+
"]"
|
|
274
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("span", {}),
|
|
275
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...S.priorityBar, backgroundColor: priorityColor } }),
|
|
276
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 11, color: "var(--theme-elevation-400)", textAlign: "right" }, children: relativeTime(tk.updatedAt) }),
|
|
277
|
+
isUnread ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: S.unreadDot }) : /* @__PURE__ */ jsxRuntime.jsx("span", {})
|
|
278
|
+
]
|
|
279
|
+
},
|
|
280
|
+
tk.id
|
|
281
|
+
);
|
|
282
|
+
}) }),
|
|
283
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.keyboardHints, children: [
|
|
284
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
285
|
+
/* @__PURE__ */ jsxRuntime.jsx("kbd", { children: "\u2191" }),
|
|
286
|
+
/* @__PURE__ */ jsxRuntime.jsx("kbd", { children: "\u2193" }),
|
|
287
|
+
" ",
|
|
288
|
+
t("inbox.keyboardNavigate")
|
|
289
|
+
] }),
|
|
290
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
291
|
+
/* @__PURE__ */ jsxRuntime.jsx("kbd", { children: "\u21B5" }),
|
|
292
|
+
" ",
|
|
293
|
+
t("inbox.keyboardOpen")
|
|
294
|
+
] })
|
|
295
|
+
] })
|
|
296
|
+
] });
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
exports.TicketInboxClient = TicketInboxClient;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var templates = require('@payloadcms/next/templates');
|
|
7
|
+
var navigation = require('next/navigation');
|
|
8
|
+
var ErrorBoundary = require('../shared/ErrorBoundary');
|
|
9
|
+
var client = require('./client');
|
|
10
|
+
|
|
11
|
+
const TicketInboxView = ({ initPageResult }) => {
|
|
12
|
+
const { req, visibleEntities } = initPageResult;
|
|
13
|
+
if (!req.user) navigation.redirect("/admin/login");
|
|
14
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
15
|
+
templates.DefaultTemplate,
|
|
16
|
+
{
|
|
17
|
+
i18n: req.i18n,
|
|
18
|
+
locale: initPageResult.locale,
|
|
19
|
+
params: {},
|
|
20
|
+
payload: req.payload,
|
|
21
|
+
permissions: initPageResult.permissions,
|
|
22
|
+
searchParams: {},
|
|
23
|
+
user: req.user,
|
|
24
|
+
visibleEntities,
|
|
25
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary.AdminErrorBoundary, { viewName: "TicketInboxView", children: /* @__PURE__ */ jsxRuntime.jsx(client.TicketInboxClient, {}) })
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
var TicketInboxView_default = TicketInboxView;
|
|
30
|
+
|
|
31
|
+
exports.TicketInboxView = TicketInboxView;
|
|
32
|
+
exports.default = TicketInboxView_default;
|