@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,229 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var Link = require('next/link');
|
|
6
|
+
var navigation = require('next/navigation');
|
|
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 CATEGORY_KEYS = [
|
|
14
|
+
{ value: "", key: "ticket.category.select" },
|
|
15
|
+
{ value: "bug", key: "ticket.category.bugFull" },
|
|
16
|
+
{ value: "content", key: "ticket.category.contentFull" },
|
|
17
|
+
{ value: "feature", key: "ticket.category.featureFull" },
|
|
18
|
+
{ value: "question", key: "ticket.category.questionFull" },
|
|
19
|
+
{ value: "hosting", key: "ticket.category.hostingFull" }
|
|
20
|
+
];
|
|
21
|
+
const PRIORITY_KEYS = [
|
|
22
|
+
{ value: "low", key: "ticket.priority.low" },
|
|
23
|
+
{ value: "normal", key: "ticket.priority.normal" },
|
|
24
|
+
{ value: "high", key: "ticket.priority.high" },
|
|
25
|
+
{ value: "urgent", key: "ticket.priority.urgent" }
|
|
26
|
+
];
|
|
27
|
+
const NewTicketClient = () => {
|
|
28
|
+
const { t } = useTranslation.useTranslation();
|
|
29
|
+
const router = navigation.useRouter();
|
|
30
|
+
const [subject, setSubject] = react.useState("");
|
|
31
|
+
const [description, setDescription] = react.useState("");
|
|
32
|
+
const [category, setCategory] = react.useState("");
|
|
33
|
+
const [priority, setPriority] = react.useState("normal");
|
|
34
|
+
const [clientSearch, setClientSearch] = react.useState("");
|
|
35
|
+
const [clientId, setClientId] = react.useState(null);
|
|
36
|
+
const [clientResults, setClientResults] = react.useState([]);
|
|
37
|
+
const [selectedClient, setSelectedClient] = react.useState(null);
|
|
38
|
+
const [projectId, setProjectId] = react.useState(null);
|
|
39
|
+
const [projects, setProjects] = react.useState([]);
|
|
40
|
+
const [submitting, setSubmitting] = react.useState(false);
|
|
41
|
+
const [error, setError] = react.useState("");
|
|
42
|
+
react.useEffect(() => {
|
|
43
|
+
if (clientSearch.length < 2) {
|
|
44
|
+
setClientResults([]);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const timer = setTimeout(async () => {
|
|
48
|
+
try {
|
|
49
|
+
const res = await fetch(`/api/support-clients?where[or][0][email][contains]=${encodeURIComponent(clientSearch)}&where[or][1][firstName][contains]=${encodeURIComponent(clientSearch)}&where[or][2][company][contains]=${encodeURIComponent(clientSearch)}&limit=8&depth=0`, { credentials: "include" });
|
|
50
|
+
if (res.ok) {
|
|
51
|
+
const d = await res.json();
|
|
52
|
+
setClientResults(d.docs || []);
|
|
53
|
+
}
|
|
54
|
+
} catch (err) {
|
|
55
|
+
console.warn("[support] client search error:", err);
|
|
56
|
+
}
|
|
57
|
+
}, 300);
|
|
58
|
+
return () => clearTimeout(timer);
|
|
59
|
+
}, [clientSearch]);
|
|
60
|
+
react.useEffect(() => {
|
|
61
|
+
fetch("/api/projects?where[status][equals]=active&limit=50&depth=0", { credentials: "include" }).then((r) => r.json()).then((d) => setProjects(d.docs || [])).catch(() => {
|
|
62
|
+
});
|
|
63
|
+
}, []);
|
|
64
|
+
const handleSubmit = async (e) => {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
setError("");
|
|
67
|
+
if (!subject.trim()) {
|
|
68
|
+
setError(t("newTicket.errors.subjectRequired"));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (!clientId) {
|
|
72
|
+
setError(t("newTicket.errors.clientRequired"));
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
setSubmitting(true);
|
|
76
|
+
try {
|
|
77
|
+
const res = await fetch("/api/tickets", {
|
|
78
|
+
method: "POST",
|
|
79
|
+
headers: { "Content-Type": "application/json" },
|
|
80
|
+
credentials: "include",
|
|
81
|
+
body: JSON.stringify({
|
|
82
|
+
subject: subject.trim(),
|
|
83
|
+
client: clientId,
|
|
84
|
+
category: category || void 0,
|
|
85
|
+
priority,
|
|
86
|
+
project: projectId || void 0,
|
|
87
|
+
source: "admin",
|
|
88
|
+
status: "open"
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
if (!res.ok) {
|
|
92
|
+
const d = await res.json().catch(() => ({}));
|
|
93
|
+
setError(d.errors?.[0]?.message || t("newTicket.errors.creationError"));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const ticket = await res.json();
|
|
97
|
+
if (description.trim()) {
|
|
98
|
+
await fetch("/api/ticket-messages", {
|
|
99
|
+
method: "POST",
|
|
100
|
+
headers: { "Content-Type": "application/json" },
|
|
101
|
+
credentials: "include",
|
|
102
|
+
body: JSON.stringify({
|
|
103
|
+
ticket: ticket.doc.id,
|
|
104
|
+
body: description.trim(),
|
|
105
|
+
authorType: "admin",
|
|
106
|
+
isInternal: false
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
router.push(`/admin/support/ticket?id=${ticket.doc.id}`);
|
|
111
|
+
} catch {
|
|
112
|
+
setError(t("newTicket.errors.networkError"));
|
|
113
|
+
} finally {
|
|
114
|
+
setSubmitting(false);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const S = {
|
|
118
|
+
page: { padding: "20px 30px", maxWidth: 720, margin: "0 auto" },
|
|
119
|
+
header: { marginBottom: 24 },
|
|
120
|
+
backLink: { fontSize: 13, color: "#2563eb", textDecoration: "none" },
|
|
121
|
+
title: { fontSize: 24, fontWeight: 700, margin: "8px 0 4px", color: "var(--theme-text)" },
|
|
122
|
+
subtitle: { fontSize: 14, color: "var(--theme-elevation-500)" },
|
|
123
|
+
error: { padding: "10px 14px", borderRadius: 8, background: "#fef2f2", color: "#dc2626", fontSize: 13, marginBottom: 16, border: "1px solid #fecaca" },
|
|
124
|
+
fieldGroup: { marginBottom: 16 },
|
|
125
|
+
label: { display: "block", fontSize: 13, fontWeight: 600, marginBottom: 6, color: "var(--theme-text)" },
|
|
126
|
+
required: { color: "#dc2626" },
|
|
127
|
+
input: { width: "100%", padding: "8px 12px", borderRadius: 8, border: "1px solid var(--theme-elevation-200)", fontSize: 13, color: "var(--theme-text)", background: "var(--theme-elevation-0)" },
|
|
128
|
+
select: { width: "100%", padding: "8px 12px", borderRadius: 8, border: "1px solid var(--theme-elevation-200)", fontSize: 13, color: "var(--theme-text)", background: "var(--theme-elevation-0)" },
|
|
129
|
+
textarea: { width: "100%", padding: "8px 12px", borderRadius: 8, border: "1px solid var(--theme-elevation-200)", fontSize: 13, color: "var(--theme-text)", background: "var(--theme-elevation-0)", minHeight: 120, fontFamily: "inherit", resize: "vertical" },
|
|
130
|
+
row3: { display: "grid", gridTemplateColumns: "1fr 1fr 1fr", gap: 12, marginBottom: 16 },
|
|
131
|
+
submitBtn: { padding: "10px 20px", borderRadius: 8, background: "#2563eb", color: "#fff", fontSize: 14, fontWeight: 600, border: "none", cursor: "pointer" },
|
|
132
|
+
searchResults: { position: "absolute", top: "100%", left: 0, right: 0, background: "var(--theme-elevation-0)", border: "1px solid var(--theme-elevation-200)", borderRadius: 8, boxShadow: "0 4px 12px rgba(0,0,0,0.1)", zIndex: 50, maxHeight: 200, overflowY: "auto" },
|
|
133
|
+
searchItem: { padding: "8px 12px", cursor: "pointer", fontSize: 13, borderBottom: "1px solid var(--theme-elevation-100)" }
|
|
134
|
+
};
|
|
135
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.page, children: [
|
|
136
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.header, children: [
|
|
137
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Link__default.default, { href: "/admin/support/inbox", style: S.backLink, children: [
|
|
138
|
+
"\u2190 ",
|
|
139
|
+
t("newTicket.backToInbox")
|
|
140
|
+
] }),
|
|
141
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { style: S.title, children: t("newTicket.title") }),
|
|
142
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: S.subtitle, children: t("newTicket.subtitle") })
|
|
143
|
+
] }),
|
|
144
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: S.error, children: error }),
|
|
145
|
+
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
|
|
146
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.fieldGroup, children: [
|
|
147
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: S.label, children: [
|
|
148
|
+
t("newTicket.clientLabel"),
|
|
149
|
+
" ",
|
|
150
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: S.required, children: "*" })
|
|
151
|
+
] }),
|
|
152
|
+
selectedClient ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 10, padding: "8px 14px", borderRadius: 10, border: "1px solid var(--theme-elevation-200)", background: "var(--theme-elevation-50)" }, children: [
|
|
153
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { fontWeight: 600, fontSize: 13, color: "var(--theme-text)" }, children: [
|
|
154
|
+
selectedClient.firstName,
|
|
155
|
+
" ",
|
|
156
|
+
selectedClient.lastName,
|
|
157
|
+
" -- ",
|
|
158
|
+
selectedClient.company
|
|
159
|
+
] }),
|
|
160
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 12, color: "var(--theme-elevation-500)" }, children: selectedClient.email }),
|
|
161
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => {
|
|
162
|
+
setSelectedClient(null);
|
|
163
|
+
setClientId(null);
|
|
164
|
+
setClientSearch("");
|
|
165
|
+
}, style: { marginLeft: "auto", background: "none", border: "none", cursor: "pointer", color: "var(--theme-elevation-400)", fontSize: 16 }, children: "\xD7" })
|
|
166
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "relative" }, children: [
|
|
167
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
168
|
+
"input",
|
|
169
|
+
{
|
|
170
|
+
type: "text",
|
|
171
|
+
style: S.input,
|
|
172
|
+
placeholder: t("newTicket.clientSearchPlaceholder"),
|
|
173
|
+
value: clientSearch,
|
|
174
|
+
onChange: (e) => setClientSearch(e.target.value)
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
clientResults.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { style: S.searchResults, children: clientResults.map((c) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.searchItem, onClick: () => {
|
|
178
|
+
setSelectedClient(c);
|
|
179
|
+
setClientId(c.id);
|
|
180
|
+
setClientSearch("");
|
|
181
|
+
setClientResults([]);
|
|
182
|
+
}, children: [
|
|
183
|
+
/* @__PURE__ */ jsxRuntime.jsxs("strong", { children: [
|
|
184
|
+
c.firstName,
|
|
185
|
+
" ",
|
|
186
|
+
c.lastName
|
|
187
|
+
] }),
|
|
188
|
+
" -- ",
|
|
189
|
+
c.company,
|
|
190
|
+
" ",
|
|
191
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "var(--theme-elevation-400)", fontSize: 12 }, children: c.email })
|
|
192
|
+
] }, c.id)) })
|
|
193
|
+
] })
|
|
194
|
+
] }),
|
|
195
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.fieldGroup, children: [
|
|
196
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: S.label, children: [
|
|
197
|
+
t("newTicket.subjectLabel"),
|
|
198
|
+
" ",
|
|
199
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: S.required, children: "*" })
|
|
200
|
+
] }),
|
|
201
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "text", style: S.input, placeholder: t("newTicket.subjectPlaceholder"), value: subject, onChange: (e) => setSubject(e.target.value) })
|
|
202
|
+
] }),
|
|
203
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.row3, children: [
|
|
204
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.fieldGroup, children: [
|
|
205
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: S.label, children: t("newTicket.categoryLabel") }),
|
|
206
|
+
/* @__PURE__ */ jsxRuntime.jsx("select", { style: S.select, value: category, onChange: (e) => setCategory(e.target.value), children: CATEGORY_KEYS.map((c) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: c.value, children: t(c.key) }, c.value)) })
|
|
207
|
+
] }),
|
|
208
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.fieldGroup, children: [
|
|
209
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: S.label, children: t("newTicket.priorityLabel") }),
|
|
210
|
+
/* @__PURE__ */ jsxRuntime.jsx("select", { style: S.select, value: priority, onChange: (e) => setPriority(e.target.value), children: PRIORITY_KEYS.map((p) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: p.value, children: t(p.key) }, p.value)) })
|
|
211
|
+
] }),
|
|
212
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.fieldGroup, children: [
|
|
213
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: S.label, children: t("newTicket.projectLabel") }),
|
|
214
|
+
/* @__PURE__ */ jsxRuntime.jsxs("select", { style: S.select, value: projectId || "", onChange: (e) => setProjectId(e.target.value ? Number(e.target.value) : null), children: [
|
|
215
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: t("ticket.noProject") }),
|
|
216
|
+
projects.map((p) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: p.id, children: p.name }, p.id))
|
|
217
|
+
] })
|
|
218
|
+
] })
|
|
219
|
+
] }),
|
|
220
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: S.fieldGroup, children: [
|
|
221
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: S.label, children: t("newTicket.descriptionLabel") }),
|
|
222
|
+
/* @__PURE__ */ jsxRuntime.jsx("textarea", { style: S.textarea, placeholder: t("newTicket.descriptionPlaceholder"), value: description, onChange: (e) => setDescription(e.target.value) })
|
|
223
|
+
] }),
|
|
224
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", style: S.submitBtn, disabled: submitting, children: submitting ? t("newTicket.submitting") : t("newTicket.submitButton") })
|
|
225
|
+
] })
|
|
226
|
+
] });
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
exports.NewTicketClient = NewTicketClient;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
import Link from 'next/link';
|
|
5
|
+
import { useRouter } from 'next/navigation';
|
|
6
|
+
import { useTranslation } from '../../components/TicketConversation/hooks/useTranslation';
|
|
7
|
+
|
|
8
|
+
const CATEGORY_KEYS = [
|
|
9
|
+
{ value: "", key: "ticket.category.select" },
|
|
10
|
+
{ value: "bug", key: "ticket.category.bugFull" },
|
|
11
|
+
{ value: "content", key: "ticket.category.contentFull" },
|
|
12
|
+
{ value: "feature", key: "ticket.category.featureFull" },
|
|
13
|
+
{ value: "question", key: "ticket.category.questionFull" },
|
|
14
|
+
{ value: "hosting", key: "ticket.category.hostingFull" }
|
|
15
|
+
];
|
|
16
|
+
const PRIORITY_KEYS = [
|
|
17
|
+
{ value: "low", key: "ticket.priority.low" },
|
|
18
|
+
{ value: "normal", key: "ticket.priority.normal" },
|
|
19
|
+
{ value: "high", key: "ticket.priority.high" },
|
|
20
|
+
{ value: "urgent", key: "ticket.priority.urgent" }
|
|
21
|
+
];
|
|
22
|
+
const NewTicketClient = () => {
|
|
23
|
+
const { t } = useTranslation();
|
|
24
|
+
const router = useRouter();
|
|
25
|
+
const [subject, setSubject] = useState("");
|
|
26
|
+
const [description, setDescription] = useState("");
|
|
27
|
+
const [category, setCategory] = useState("");
|
|
28
|
+
const [priority, setPriority] = useState("normal");
|
|
29
|
+
const [clientSearch, setClientSearch] = useState("");
|
|
30
|
+
const [clientId, setClientId] = useState(null);
|
|
31
|
+
const [clientResults, setClientResults] = useState([]);
|
|
32
|
+
const [selectedClient, setSelectedClient] = useState(null);
|
|
33
|
+
const [projectId, setProjectId] = useState(null);
|
|
34
|
+
const [projects, setProjects] = useState([]);
|
|
35
|
+
const [submitting, setSubmitting] = useState(false);
|
|
36
|
+
const [error, setError] = useState("");
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (clientSearch.length < 2) {
|
|
39
|
+
setClientResults([]);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const timer = setTimeout(async () => {
|
|
43
|
+
try {
|
|
44
|
+
const res = await fetch(`/api/support-clients?where[or][0][email][contains]=${encodeURIComponent(clientSearch)}&where[or][1][firstName][contains]=${encodeURIComponent(clientSearch)}&where[or][2][company][contains]=${encodeURIComponent(clientSearch)}&limit=8&depth=0`, { credentials: "include" });
|
|
45
|
+
if (res.ok) {
|
|
46
|
+
const d = await res.json();
|
|
47
|
+
setClientResults(d.docs || []);
|
|
48
|
+
}
|
|
49
|
+
} catch (err) {
|
|
50
|
+
console.warn("[support] client search error:", err);
|
|
51
|
+
}
|
|
52
|
+
}, 300);
|
|
53
|
+
return () => clearTimeout(timer);
|
|
54
|
+
}, [clientSearch]);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
fetch("/api/projects?where[status][equals]=active&limit=50&depth=0", { credentials: "include" }).then((r) => r.json()).then((d) => setProjects(d.docs || [])).catch(() => {
|
|
57
|
+
});
|
|
58
|
+
}, []);
|
|
59
|
+
const handleSubmit = async (e) => {
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
setError("");
|
|
62
|
+
if (!subject.trim()) {
|
|
63
|
+
setError(t("newTicket.errors.subjectRequired"));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (!clientId) {
|
|
67
|
+
setError(t("newTicket.errors.clientRequired"));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
setSubmitting(true);
|
|
71
|
+
try {
|
|
72
|
+
const res = await fetch("/api/tickets", {
|
|
73
|
+
method: "POST",
|
|
74
|
+
headers: { "Content-Type": "application/json" },
|
|
75
|
+
credentials: "include",
|
|
76
|
+
body: JSON.stringify({
|
|
77
|
+
subject: subject.trim(),
|
|
78
|
+
client: clientId,
|
|
79
|
+
category: category || void 0,
|
|
80
|
+
priority,
|
|
81
|
+
project: projectId || void 0,
|
|
82
|
+
source: "admin",
|
|
83
|
+
status: "open"
|
|
84
|
+
})
|
|
85
|
+
});
|
|
86
|
+
if (!res.ok) {
|
|
87
|
+
const d = await res.json().catch(() => ({}));
|
|
88
|
+
setError(d.errors?.[0]?.message || t("newTicket.errors.creationError"));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const ticket = await res.json();
|
|
92
|
+
if (description.trim()) {
|
|
93
|
+
await fetch("/api/ticket-messages", {
|
|
94
|
+
method: "POST",
|
|
95
|
+
headers: { "Content-Type": "application/json" },
|
|
96
|
+
credentials: "include",
|
|
97
|
+
body: JSON.stringify({
|
|
98
|
+
ticket: ticket.doc.id,
|
|
99
|
+
body: description.trim(),
|
|
100
|
+
authorType: "admin",
|
|
101
|
+
isInternal: false
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
router.push(`/admin/support/ticket?id=${ticket.doc.id}`);
|
|
106
|
+
} catch {
|
|
107
|
+
setError(t("newTicket.errors.networkError"));
|
|
108
|
+
} finally {
|
|
109
|
+
setSubmitting(false);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const S = {
|
|
113
|
+
page: { padding: "20px 30px", maxWidth: 720, margin: "0 auto" },
|
|
114
|
+
header: { marginBottom: 24 },
|
|
115
|
+
backLink: { fontSize: 13, color: "#2563eb", textDecoration: "none" },
|
|
116
|
+
title: { fontSize: 24, fontWeight: 700, margin: "8px 0 4px", color: "var(--theme-text)" },
|
|
117
|
+
subtitle: { fontSize: 14, color: "var(--theme-elevation-500)" },
|
|
118
|
+
error: { padding: "10px 14px", borderRadius: 8, background: "#fef2f2", color: "#dc2626", fontSize: 13, marginBottom: 16, border: "1px solid #fecaca" },
|
|
119
|
+
fieldGroup: { marginBottom: 16 },
|
|
120
|
+
label: { display: "block", fontSize: 13, fontWeight: 600, marginBottom: 6, color: "var(--theme-text)" },
|
|
121
|
+
required: { color: "#dc2626" },
|
|
122
|
+
input: { width: "100%", padding: "8px 12px", borderRadius: 8, border: "1px solid var(--theme-elevation-200)", fontSize: 13, color: "var(--theme-text)", background: "var(--theme-elevation-0)" },
|
|
123
|
+
select: { width: "100%", padding: "8px 12px", borderRadius: 8, border: "1px solid var(--theme-elevation-200)", fontSize: 13, color: "var(--theme-text)", background: "var(--theme-elevation-0)" },
|
|
124
|
+
textarea: { width: "100%", padding: "8px 12px", borderRadius: 8, border: "1px solid var(--theme-elevation-200)", fontSize: 13, color: "var(--theme-text)", background: "var(--theme-elevation-0)", minHeight: 120, fontFamily: "inherit", resize: "vertical" },
|
|
125
|
+
row3: { display: "grid", gridTemplateColumns: "1fr 1fr 1fr", gap: 12, marginBottom: 16 },
|
|
126
|
+
submitBtn: { padding: "10px 20px", borderRadius: 8, background: "#2563eb", color: "#fff", fontSize: 14, fontWeight: 600, border: "none", cursor: "pointer" },
|
|
127
|
+
searchResults: { position: "absolute", top: "100%", left: 0, right: 0, background: "var(--theme-elevation-0)", border: "1px solid var(--theme-elevation-200)", borderRadius: 8, boxShadow: "0 4px 12px rgba(0,0,0,0.1)", zIndex: 50, maxHeight: 200, overflowY: "auto" },
|
|
128
|
+
searchItem: { padding: "8px 12px", cursor: "pointer", fontSize: 13, borderBottom: "1px solid var(--theme-elevation-100)" }
|
|
129
|
+
};
|
|
130
|
+
return /* @__PURE__ */ jsxs("div", { style: S.page, children: [
|
|
131
|
+
/* @__PURE__ */ jsxs("div", { style: S.header, children: [
|
|
132
|
+
/* @__PURE__ */ jsxs(Link, { href: "/admin/support/inbox", style: S.backLink, children: [
|
|
133
|
+
"\u2190 ",
|
|
134
|
+
t("newTicket.backToInbox")
|
|
135
|
+
] }),
|
|
136
|
+
/* @__PURE__ */ jsx("h1", { style: S.title, children: t("newTicket.title") }),
|
|
137
|
+
/* @__PURE__ */ jsx("p", { style: S.subtitle, children: t("newTicket.subtitle") })
|
|
138
|
+
] }),
|
|
139
|
+
error && /* @__PURE__ */ jsx("div", { style: S.error, children: error }),
|
|
140
|
+
/* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
|
|
141
|
+
/* @__PURE__ */ jsxs("div", { style: S.fieldGroup, children: [
|
|
142
|
+
/* @__PURE__ */ jsxs("label", { style: S.label, children: [
|
|
143
|
+
t("newTicket.clientLabel"),
|
|
144
|
+
" ",
|
|
145
|
+
/* @__PURE__ */ jsx("span", { style: S.required, children: "*" })
|
|
146
|
+
] }),
|
|
147
|
+
selectedClient ? /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 10, padding: "8px 14px", borderRadius: 10, border: "1px solid var(--theme-elevation-200)", background: "var(--theme-elevation-50)" }, children: [
|
|
148
|
+
/* @__PURE__ */ jsxs("span", { style: { fontWeight: 600, fontSize: 13, color: "var(--theme-text)" }, children: [
|
|
149
|
+
selectedClient.firstName,
|
|
150
|
+
" ",
|
|
151
|
+
selectedClient.lastName,
|
|
152
|
+
" -- ",
|
|
153
|
+
selectedClient.company
|
|
154
|
+
] }),
|
|
155
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 12, color: "var(--theme-elevation-500)" }, children: selectedClient.email }),
|
|
156
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => {
|
|
157
|
+
setSelectedClient(null);
|
|
158
|
+
setClientId(null);
|
|
159
|
+
setClientSearch("");
|
|
160
|
+
}, style: { marginLeft: "auto", background: "none", border: "none", cursor: "pointer", color: "var(--theme-elevation-400)", fontSize: 16 }, children: "\xD7" })
|
|
161
|
+
] }) : /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
|
|
162
|
+
/* @__PURE__ */ jsx(
|
|
163
|
+
"input",
|
|
164
|
+
{
|
|
165
|
+
type: "text",
|
|
166
|
+
style: S.input,
|
|
167
|
+
placeholder: t("newTicket.clientSearchPlaceholder"),
|
|
168
|
+
value: clientSearch,
|
|
169
|
+
onChange: (e) => setClientSearch(e.target.value)
|
|
170
|
+
}
|
|
171
|
+
),
|
|
172
|
+
clientResults.length > 0 && /* @__PURE__ */ jsx("div", { style: S.searchResults, children: clientResults.map((c) => /* @__PURE__ */ jsxs("div", { style: S.searchItem, onClick: () => {
|
|
173
|
+
setSelectedClient(c);
|
|
174
|
+
setClientId(c.id);
|
|
175
|
+
setClientSearch("");
|
|
176
|
+
setClientResults([]);
|
|
177
|
+
}, children: [
|
|
178
|
+
/* @__PURE__ */ jsxs("strong", { children: [
|
|
179
|
+
c.firstName,
|
|
180
|
+
" ",
|
|
181
|
+
c.lastName
|
|
182
|
+
] }),
|
|
183
|
+
" -- ",
|
|
184
|
+
c.company,
|
|
185
|
+
" ",
|
|
186
|
+
/* @__PURE__ */ jsx("span", { style: { color: "var(--theme-elevation-400)", fontSize: 12 }, children: c.email })
|
|
187
|
+
] }, c.id)) })
|
|
188
|
+
] })
|
|
189
|
+
] }),
|
|
190
|
+
/* @__PURE__ */ jsxs("div", { style: S.fieldGroup, children: [
|
|
191
|
+
/* @__PURE__ */ jsxs("label", { style: S.label, children: [
|
|
192
|
+
t("newTicket.subjectLabel"),
|
|
193
|
+
" ",
|
|
194
|
+
/* @__PURE__ */ jsx("span", { style: S.required, children: "*" })
|
|
195
|
+
] }),
|
|
196
|
+
/* @__PURE__ */ jsx("input", { type: "text", style: S.input, placeholder: t("newTicket.subjectPlaceholder"), value: subject, onChange: (e) => setSubject(e.target.value) })
|
|
197
|
+
] }),
|
|
198
|
+
/* @__PURE__ */ jsxs("div", { style: S.row3, children: [
|
|
199
|
+
/* @__PURE__ */ jsxs("div", { style: S.fieldGroup, children: [
|
|
200
|
+
/* @__PURE__ */ jsx("label", { style: S.label, children: t("newTicket.categoryLabel") }),
|
|
201
|
+
/* @__PURE__ */ jsx("select", { style: S.select, value: category, onChange: (e) => setCategory(e.target.value), children: CATEGORY_KEYS.map((c) => /* @__PURE__ */ jsx("option", { value: c.value, children: t(c.key) }, c.value)) })
|
|
202
|
+
] }),
|
|
203
|
+
/* @__PURE__ */ jsxs("div", { style: S.fieldGroup, children: [
|
|
204
|
+
/* @__PURE__ */ jsx("label", { style: S.label, children: t("newTicket.priorityLabel") }),
|
|
205
|
+
/* @__PURE__ */ jsx("select", { style: S.select, value: priority, onChange: (e) => setPriority(e.target.value), children: PRIORITY_KEYS.map((p) => /* @__PURE__ */ jsx("option", { value: p.value, children: t(p.key) }, p.value)) })
|
|
206
|
+
] }),
|
|
207
|
+
/* @__PURE__ */ jsxs("div", { style: S.fieldGroup, children: [
|
|
208
|
+
/* @__PURE__ */ jsx("label", { style: S.label, children: t("newTicket.projectLabel") }),
|
|
209
|
+
/* @__PURE__ */ jsxs("select", { style: S.select, value: projectId || "", onChange: (e) => setProjectId(e.target.value ? Number(e.target.value) : null), children: [
|
|
210
|
+
/* @__PURE__ */ jsx("option", { value: "", children: t("ticket.noProject") }),
|
|
211
|
+
projects.map((p) => /* @__PURE__ */ jsx("option", { value: p.id, children: p.name }, p.id))
|
|
212
|
+
] })
|
|
213
|
+
] })
|
|
214
|
+
] }),
|
|
215
|
+
/* @__PURE__ */ jsxs("div", { style: S.fieldGroup, children: [
|
|
216
|
+
/* @__PURE__ */ jsx("label", { style: S.label, children: t("newTicket.descriptionLabel") }),
|
|
217
|
+
/* @__PURE__ */ jsx("textarea", { style: S.textarea, placeholder: t("newTicket.descriptionPlaceholder"), value: description, onChange: (e) => setDescription(e.target.value) })
|
|
218
|
+
] }),
|
|
219
|
+
/* @__PURE__ */ jsx("button", { type: "submit", style: S.submitBtn, disabled: submitting, children: submitting ? t("newTicket.submitting") : t("newTicket.submitButton") })
|
|
220
|
+
] })
|
|
221
|
+
] });
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export { NewTicketClient };
|
|
@@ -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 NewTicketView = ({ 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: "NewTicketView", children: /* @__PURE__ */ jsxRuntime.jsx(client.NewTicketClient, {}) })
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
var NewTicketView_default = NewTicketView;
|
|
30
|
+
|
|
31
|
+
exports.NewTicketView = NewTicketView;
|
|
32
|
+
exports.default = NewTicketView_default;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { NewTicketClient } from './client';
|
|
6
|
+
|
|
7
|
+
const NewTicketView = ({ initPageResult }) => {
|
|
8
|
+
const { req, visibleEntities } = initPageResult;
|
|
9
|
+
if (!req.user) redirect("/admin/login");
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
11
|
+
DefaultTemplate,
|
|
12
|
+
{
|
|
13
|
+
i18n: req.i18n,
|
|
14
|
+
locale: initPageResult.locale,
|
|
15
|
+
params: {},
|
|
16
|
+
payload: req.payload,
|
|
17
|
+
permissions: initPageResult.permissions,
|
|
18
|
+
searchParams: {},
|
|
19
|
+
user: req.user,
|
|
20
|
+
visibleEntities,
|
|
21
|
+
children: /* @__PURE__ */ jsx(AdminErrorBoundary, { viewName: "NewTicketView", children: /* @__PURE__ */ jsx(NewTicketClient, {}) })
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
var NewTicketView_default = NewTicketView;
|
|
26
|
+
|
|
27
|
+
export { NewTicketView, NewTicketView_default as default };
|