@adatechnology/conversations-ui 0.1.0-rc.5 → 0.1.0-rc.7
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/chunk-TGTBMMFC.js +1707 -0
- package/dist/index.d.ts +209 -22
- package/dist/index.js +243 -590
- package/dist/preview/index.d.ts +153 -9
- package/dist/preview/index.js +520 -38
- package/dist/{types-C2Yexi8A.d.ts → types-B5C1DLu1.d.ts} +70 -2
- package/package.json +2 -2
- package/src/Avatar.tsx +13 -2
- package/src/ConversationHeader.tsx +18 -0
- package/src/ConversationListItem.tsx +18 -2
- package/src/DocumentsLibrary.tsx +322 -0
- package/src/EmojiPicker.tsx +69 -55
- package/src/FileIcon.test.ts +46 -1
- package/src/FileIcon.tsx +76 -10
- package/src/InteractiveMessage.tsx +126 -0
- package/src/Lightbox.tsx +18 -3
- package/src/MessageBubble.tsx +31 -4
- package/src/MessageComposer.tsx +36 -5
- package/src/WhatsAppMessageEditor.tsx +28 -4
- package/src/emojiCatalog.test.ts +35 -0
- package/src/emojiCatalog.ts +189 -0
- package/src/index.ts +25 -12
- package/src/lib/createMediaUrlResolver.ts +33 -0
- package/src/preview/AudioRecorderButton.tsx +117 -0
- package/src/preview/ConversationPreview.tsx +184 -15
- package/src/preview/MediaTypesPreview.tsx +87 -0
- package/src/preview/audioRecorderFormat.test.ts +67 -0
- package/src/preview/conversationPreviewFailures.test.ts +64 -0
- package/src/preview/createMockConversationsApi.ts +62 -8
- package/src/preview/createPreviewWebhookClient.ts +28 -1
- package/src/preview/index.ts +16 -2
- package/src/preview/mediaTypeOf.test.ts +15 -0
- package/src/preview/mockDocumentsSearch.test.ts +57 -0
- package/src/preview/previewFileSamples.test.ts +151 -0
- package/src/preview/previewFileSamples.ts +74 -0
- package/src/preview/previewFixtures.ts +140 -8
- package/src/preview/previewMediaSource.test.ts +62 -0
- package/src/preview/previewMediaSource.ts +91 -0
- package/src/providers/types.ts +17 -0
- package/src/settings/WhatsAppCreateTemplateForm.tsx +3 -1
- package/src/types.ts +38 -1
- package/dist/chunk-YWITIIHD.js +0 -728
package/dist/index.js
CHANGED
|
@@ -4,23 +4,46 @@ import {
|
|
|
4
4
|
} from "./chunk-NV2RZ5KT.js";
|
|
5
5
|
import {
|
|
6
6
|
AudioPlayer,
|
|
7
|
+
ConversationDocumentsPanel,
|
|
7
8
|
ConversationLocalesProvider,
|
|
8
9
|
ConversationWallpaper,
|
|
10
|
+
ConversationsProvider,
|
|
11
|
+
DEFAULT_ACCEPTED_FILE_TYPES,
|
|
12
|
+
DEFAULT_CONVERSATION_DOCUMENTS_LABELS,
|
|
13
|
+
DEFAULT_DOCUMENTS_LIBRARY_LABELS,
|
|
14
|
+
DEFAULT_EMOJI_PICKER_LABELS,
|
|
15
|
+
DEFAULT_INTERACTIVE_MESSAGE_LABELS,
|
|
16
|
+
DEFAULT_LIGHTBOX_LABELS,
|
|
17
|
+
DEFAULT_MESSAGE_COMPOSER_LABELS,
|
|
18
|
+
DOCUMENT_SOURCE_FILTER,
|
|
9
19
|
DateDivider,
|
|
20
|
+
DocumentsLibrary,
|
|
21
|
+
EMOJI_CATEGORIES,
|
|
10
22
|
EmojiPicker,
|
|
11
23
|
FileIcon,
|
|
24
|
+
InteractiveMessage,
|
|
12
25
|
Lightbox,
|
|
13
26
|
MediaRenderer,
|
|
14
27
|
MessageBubble,
|
|
15
28
|
MessageComposer,
|
|
16
29
|
StatusTicks,
|
|
17
30
|
cn,
|
|
31
|
+
conversationsOf,
|
|
32
|
+
createMediaUrlResolver,
|
|
18
33
|
formatDateTime,
|
|
19
34
|
formatFileSize,
|
|
35
|
+
formatPhone,
|
|
20
36
|
formatTimestamp,
|
|
21
37
|
isSameDay,
|
|
22
|
-
|
|
23
|
-
|
|
38
|
+
phoneCountryFlag,
|
|
39
|
+
phoneInitials,
|
|
40
|
+
searchEmojis,
|
|
41
|
+
totalOf,
|
|
42
|
+
useAsyncResource,
|
|
43
|
+
useConversationDocuments,
|
|
44
|
+
useConversationLocales,
|
|
45
|
+
useConversations
|
|
46
|
+
} from "./chunk-TGTBMMFC.js";
|
|
24
47
|
import {
|
|
25
48
|
htmlToWA,
|
|
26
49
|
parseWhatsAppFormatting,
|
|
@@ -32,6 +55,15 @@ import {
|
|
|
32
55
|
import { useRef } from "react";
|
|
33
56
|
import { Bold, Italic, Strikethrough } from "lucide-react";
|
|
34
57
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
58
|
+
var DEFAULT_WHATSAPP_MESSAGE_EDITOR_LABELS = {
|
|
59
|
+
bold: "Negrito",
|
|
60
|
+
boldHint: "Negrito (*texto*)",
|
|
61
|
+
italic: "It\xE1lico",
|
|
62
|
+
italicHint: "It\xE1lico (_texto_)",
|
|
63
|
+
strikethrough: "Tachado",
|
|
64
|
+
strikethroughHint: "Tachado (~texto~)",
|
|
65
|
+
insertPlaceholder: (token) => `Inserir ${token}`
|
|
66
|
+
};
|
|
35
67
|
var INLINE_TOKEN = /(\*[^*\n]+\*|_[^_\n]+_|~[^~\n]+~|`[^`\n]+`|\{[a-zA-Z_]+\})/g;
|
|
36
68
|
function renderLine(line, lineKey) {
|
|
37
69
|
const nodes = [];
|
|
@@ -67,8 +99,10 @@ function WhatsAppMessageEditor({
|
|
|
67
99
|
placeholders = [],
|
|
68
100
|
rows = 4,
|
|
69
101
|
previewLabel = "Pr\xE9via (como aparece no WhatsApp)",
|
|
70
|
-
emptyPreviewText = "Sua mensagem aparecer\xE1 aqui\u2026"
|
|
102
|
+
emptyPreviewText = "Sua mensagem aparecer\xE1 aqui\u2026",
|
|
103
|
+
labels
|
|
71
104
|
}) {
|
|
105
|
+
const editorLabels = { ...DEFAULT_WHATSAPP_MESSAGE_EDITOR_LABELS, ...labels };
|
|
72
106
|
const textareaRef = useRef(null);
|
|
73
107
|
function wrapSelection(marker) {
|
|
74
108
|
const textarea = textareaRef.current;
|
|
@@ -99,9 +133,9 @@ function WhatsAppMessageEditor({
|
|
|
99
133
|
const toolbarButtonClass = "inline-flex items-center justify-center h-8 w-8 rounded-lg border border-gray-200 dark:border-gray-600 text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors";
|
|
100
134
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
101
135
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1.5 mb-2", children: [
|
|
102
|
-
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => wrapSelection("*"), className: toolbarButtonClass, title:
|
|
103
|
-
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => wrapSelection("_"), className: toolbarButtonClass, title:
|
|
104
|
-
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => wrapSelection("~"), className: toolbarButtonClass, title:
|
|
136
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => wrapSelection("*"), className: toolbarButtonClass, title: editorLabels.boldHint, "aria-label": editorLabels.bold, children: /* @__PURE__ */ jsx(Bold, { size: 15 }) }),
|
|
137
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => wrapSelection("_"), className: toolbarButtonClass, title: editorLabels.italicHint, "aria-label": editorLabels.italic, children: /* @__PURE__ */ jsx(Italic, { size: 15 }) }),
|
|
138
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => wrapSelection("~"), className: toolbarButtonClass, title: editorLabels.strikethroughHint, "aria-label": editorLabels.strikethrough, children: /* @__PURE__ */ jsx(Strikethrough, { size: 15 }) }),
|
|
105
139
|
placeholders.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
106
140
|
/* @__PURE__ */ jsx("span", { className: "mx-1 h-5 w-px bg-gray-200 dark:bg-gray-600" }),
|
|
107
141
|
placeholders.map((token) => /* @__PURE__ */ jsx(
|
|
@@ -110,7 +144,7 @@ function WhatsAppMessageEditor({
|
|
|
110
144
|
type: "button",
|
|
111
145
|
onClick: () => insertAtCursor(token),
|
|
112
146
|
className: "inline-flex items-center h-8 px-2 rounded-lg border border-gray-200 dark:border-gray-600 text-xs text-blue-600 dark:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/40 transition-colors",
|
|
113
|
-
title:
|
|
147
|
+
title: editorLabels.insertPlaceholder(token),
|
|
114
148
|
children: token
|
|
115
149
|
},
|
|
116
150
|
token
|
|
@@ -270,6 +304,9 @@ function SimpleEmojiPicker({ onSelect, label = "Emojis", pickerWidth = "280px",
|
|
|
270
304
|
|
|
271
305
|
// src/Avatar.tsx
|
|
272
306
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
307
|
+
var DEFAULT_AVATAR_LABELS = {
|
|
308
|
+
unnamedContact: "Contato sem nome"
|
|
309
|
+
};
|
|
273
310
|
var sizeClasses = {
|
|
274
311
|
sm: "w-6 h-6 text-xs",
|
|
275
312
|
md: "w-8 h-8 text-sm",
|
|
@@ -295,8 +332,9 @@ function getBgColor(name) {
|
|
|
295
332
|
const hash = name.charCodeAt(0) + (name.charCodeAt(name.length - 1) || 0);
|
|
296
333
|
return bgColors[hash % bgColors.length];
|
|
297
334
|
}
|
|
298
|
-
function Avatar({ name, avatarUrl, size = "md", className = "" }) {
|
|
335
|
+
function Avatar({ name, avatarUrl, size = "md", className = "", labels }) {
|
|
299
336
|
const sizeClass = sizeClasses[size];
|
|
337
|
+
const unnamedContactLabel = labels?.unnamedContact ?? DEFAULT_AVATAR_LABELS.unnamedContact;
|
|
300
338
|
if (avatarUrl) {
|
|
301
339
|
return /* @__PURE__ */ jsx3(
|
|
302
340
|
"img",
|
|
@@ -314,7 +352,7 @@ function Avatar({ name, avatarUrl, size = "md", className = "" }) {
|
|
|
314
352
|
{
|
|
315
353
|
className: `${sizeClass} ${bgColor} rounded-full flex items-center justify-center text-white flex-shrink-0 ${className}`,
|
|
316
354
|
role: "img",
|
|
317
|
-
"aria-label":
|
|
355
|
+
"aria-label": unnamedContactLabel,
|
|
318
356
|
children: /* @__PURE__ */ jsx3("svg", { viewBox: "0 0 24 24", fill: "currentColor", className: "h-[60%] w-[60%]", "aria-hidden": true, children: /* @__PURE__ */ jsx3("path", { d: "M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10Zm0 2c-4.42 0-8 2.24-8 5v1h16v-1c0-2.76-3.58-5-8-5Z" }) })
|
|
319
357
|
}
|
|
320
358
|
);
|
|
@@ -332,51 +370,6 @@ function Avatar({ name, avatarUrl, size = "md", className = "" }) {
|
|
|
332
370
|
// src/ConversationListItem.tsx
|
|
333
371
|
import { useMemo } from "react";
|
|
334
372
|
|
|
335
|
-
// src/lib/phone.ts
|
|
336
|
-
function formatPhone(number) {
|
|
337
|
-
const digits = number.replace(/\D/g, "");
|
|
338
|
-
if (digits.length === 13) {
|
|
339
|
-
return `+${digits.slice(0, 2)} (${digits.slice(2, 4)}) ${digits.slice(4, 9)}-${digits.slice(9, 13)}`;
|
|
340
|
-
}
|
|
341
|
-
if (digits.length === 12) {
|
|
342
|
-
return `+${digits.slice(0, 2)} (${digits.slice(2, 4)}) ${digits.slice(4, 8)}-${digits.slice(8, 12)}`;
|
|
343
|
-
}
|
|
344
|
-
if (digits.length === 11) {
|
|
345
|
-
return `(${digits.slice(0, 2)}) ${digits.slice(2, 7)}-${digits.slice(7, 11)}`;
|
|
346
|
-
}
|
|
347
|
-
if (digits.length === 10) {
|
|
348
|
-
return `(${digits.slice(0, 2)}) ${digits.slice(2, 6)}-${digits.slice(6, 10)}`;
|
|
349
|
-
}
|
|
350
|
-
return number;
|
|
351
|
-
}
|
|
352
|
-
var COUNTRY_FLAG_BY_DIAL_CODE = {
|
|
353
|
-
"55": "\u{1F1E7}\u{1F1F7}",
|
|
354
|
-
"351": "\u{1F1F5}\u{1F1F9}",
|
|
355
|
-
"34": "\u{1F1EA}\u{1F1F8}",
|
|
356
|
-
"54": "\u{1F1E6}\u{1F1F7}",
|
|
357
|
-
"56": "\u{1F1E8}\u{1F1F1}",
|
|
358
|
-
"57": "\u{1F1E8}\u{1F1F4}",
|
|
359
|
-
"52": "\u{1F1F2}\u{1F1FD}",
|
|
360
|
-
"598": "\u{1F1FA}\u{1F1FE}",
|
|
361
|
-
"595": "\u{1F1F5}\u{1F1FE}",
|
|
362
|
-
"44": "\u{1F1EC}\u{1F1E7}",
|
|
363
|
-
"49": "\u{1F1E9}\u{1F1EA}",
|
|
364
|
-
"39": "\u{1F1EE}\u{1F1F9}",
|
|
365
|
-
"33": "\u{1F1EB}\u{1F1F7}"
|
|
366
|
-
};
|
|
367
|
-
function phoneCountryFlag(number) {
|
|
368
|
-
const digits = number.replace(/\D/g, "");
|
|
369
|
-
for (const length of [3, 2, 1]) {
|
|
370
|
-
const flag = COUNTRY_FLAG_BY_DIAL_CODE[digits.slice(0, length)];
|
|
371
|
-
if (flag) return flag;
|
|
372
|
-
}
|
|
373
|
-
return "";
|
|
374
|
-
}
|
|
375
|
-
function phoneInitials(number) {
|
|
376
|
-
const digits = number.replace(/\D/g, "");
|
|
377
|
-
return digits.slice(-2);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
373
|
// src/conversationChannel.ts
|
|
381
374
|
var CONVERSATION_CHANNEL = {
|
|
382
375
|
WHATSAPP: "whatsapp",
|
|
@@ -458,6 +451,10 @@ function contactFlag(params) {
|
|
|
458
451
|
|
|
459
452
|
// src/ConversationListItem.tsx
|
|
460
453
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
454
|
+
var DEFAULT_CONVERSATION_LIST_ITEM_LABELS = {
|
|
455
|
+
expiredWindow: "Janela expirada",
|
|
456
|
+
warningWindow: "Janela pr\xF3xima do fim"
|
|
457
|
+
};
|
|
461
458
|
function formatRelativeTime(dateStr) {
|
|
462
459
|
try {
|
|
463
460
|
const date = new Date(dateStr);
|
|
@@ -518,8 +515,11 @@ var ConversationListItem = ({
|
|
|
518
515
|
onClick,
|
|
519
516
|
onSelect,
|
|
520
517
|
showDivider = true,
|
|
521
|
-
highlightActive = true
|
|
518
|
+
highlightActive = true,
|
|
519
|
+
labels
|
|
522
520
|
}) => {
|
|
521
|
+
const expiredWindowLabel = labels?.expiredWindow ?? DEFAULT_CONVERSATION_LIST_ITEM_LABELS.expiredWindow;
|
|
522
|
+
const warningWindowLabel = labels?.warningWindow ?? DEFAULT_CONVERSATION_LIST_ITEM_LABELS.warningWindow;
|
|
523
523
|
const isActive = active || selected;
|
|
524
524
|
const windowStatus = useMemo(() => getWindowStatus(conversation.lastInboundAt), [conversation.lastInboundAt]);
|
|
525
525
|
const preview = useMemo(() => lastMessagePreview(conversation), [conversation.lastContent]);
|
|
@@ -551,8 +551,8 @@ var ConversationListItem = ({
|
|
|
551
551
|
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-1.5 min-w-0", children: [
|
|
552
552
|
!conversation.clientName && flag ? /* @__PURE__ */ jsx4("span", { "aria-hidden": true, children: flag }) : null,
|
|
553
553
|
/* @__PURE__ */ jsx4("span", { className: "text-[16px] text-[#111b21] truncate", children: name }),
|
|
554
|
-
windowStatus && windowStatus.label === "expired" && /* @__PURE__ */ jsx4("span", { className: "w-2 h-2 rounded-full bg-red-500 flex-shrink-0", title:
|
|
555
|
-
windowStatus && windowStatus.label === "warning" && /* @__PURE__ */ jsx4("span", { className: "w-2 h-2 rounded-full bg-orange-500 flex-shrink-0", title:
|
|
554
|
+
windowStatus && windowStatus.label === "expired" && /* @__PURE__ */ jsx4("span", { className: "w-2 h-2 rounded-full bg-red-500 flex-shrink-0", title: expiredWindowLabel }),
|
|
555
|
+
windowStatus && windowStatus.label === "warning" && /* @__PURE__ */ jsx4("span", { className: "w-2 h-2 rounded-full bg-orange-500 flex-shrink-0", title: warningWindowLabel })
|
|
556
556
|
] }),
|
|
557
557
|
timestamp && /* @__PURE__ */ jsx4("span", { className: "text-xs text-[#667781] flex-shrink-0", children: timestamp })
|
|
558
558
|
] }),
|
|
@@ -934,6 +934,7 @@ function ConversationHeader({
|
|
|
934
934
|
onDownload,
|
|
935
935
|
onOpenDocuments,
|
|
936
936
|
documentsOpen = false,
|
|
937
|
+
extraUtilities,
|
|
937
938
|
onBack,
|
|
938
939
|
labels: labelsOverride,
|
|
939
940
|
className,
|
|
@@ -948,7 +949,8 @@ function ConversationHeader({
|
|
|
948
949
|
const [menuOpen, setMenuOpen] = useState4(false);
|
|
949
950
|
const utilities = [
|
|
950
951
|
onOpenDocuments ? { key: "documents", icon: "\u{1F4C4}", label: labels.documents, run: onOpenDocuments, active: documentsOpen } : void 0,
|
|
951
|
-
onDownload ? { key: "download", icon: "\u2B07\uFE0F", label: labels.download, run: onDownload, active: false } : void 0
|
|
952
|
+
onDownload ? { key: "download", icon: "\u2B07\uFE0F", label: labels.download, run: onDownload, active: false } : void 0,
|
|
953
|
+
...(extraUtilities ?? []).map((utility) => ({ ...utility, active: utility.active ?? false }))
|
|
952
954
|
].filter(
|
|
953
955
|
(utility) => Boolean(utility)
|
|
954
956
|
);
|
|
@@ -1148,371 +1150,6 @@ function isWindowBlocking(window2) {
|
|
|
1148
1150
|
return window2 === CONVERSATION_WINDOW.EXPIRED;
|
|
1149
1151
|
}
|
|
1150
1152
|
|
|
1151
|
-
// src/ConversationDocumentsPanel.tsx
|
|
1152
|
-
import { useState as useState8 } from "react";
|
|
1153
|
-
import { ArrowUpDown, Bot, Download, Eye, Users } from "lucide-react";
|
|
1154
|
-
|
|
1155
|
-
// src/providers/ConversationsProvider.tsx
|
|
1156
|
-
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
1157
|
-
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1158
|
-
var ConversationsContext = createContext2(null);
|
|
1159
|
-
function ConversationsProvider({
|
|
1160
|
-
api,
|
|
1161
|
-
sse,
|
|
1162
|
-
children
|
|
1163
|
-
}) {
|
|
1164
|
-
return /* @__PURE__ */ jsx14(ConversationsContext.Provider, { value: { api, sse }, children });
|
|
1165
|
-
}
|
|
1166
|
-
function useConversations() {
|
|
1167
|
-
return useContext2(ConversationsContext);
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
// src/hooks/useAsyncResource.ts
|
|
1171
|
-
import { useCallback as useCallback3, useEffect as useEffect4, useRef as useRef3, useState as useState7 } from "react";
|
|
1172
|
-
function useAsyncResource(fetcher, deps) {
|
|
1173
|
-
const [data, setData] = useState7(void 0);
|
|
1174
|
-
const [loading, setLoading] = useState7(false);
|
|
1175
|
-
const [error, setError] = useState7(void 0);
|
|
1176
|
-
const requestIdRef = useRef3(0);
|
|
1177
|
-
const load = useCallback3(async () => {
|
|
1178
|
-
const requestId = ++requestIdRef.current;
|
|
1179
|
-
setLoading(true);
|
|
1180
|
-
setError(void 0);
|
|
1181
|
-
try {
|
|
1182
|
-
const result = await fetcher();
|
|
1183
|
-
if (requestId === requestIdRef.current) setData(result);
|
|
1184
|
-
} catch (err) {
|
|
1185
|
-
if (requestId === requestIdRef.current) setError(err instanceof Error ? err : new Error(String(err)));
|
|
1186
|
-
} finally {
|
|
1187
|
-
if (requestId === requestIdRef.current) setLoading(false);
|
|
1188
|
-
}
|
|
1189
|
-
}, deps);
|
|
1190
|
-
useEffect4(() => {
|
|
1191
|
-
load();
|
|
1192
|
-
}, [load]);
|
|
1193
|
-
return { data, loading, error, refetch: load };
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
// src/lib/paginated.ts
|
|
1197
|
-
function conversationsOf(result) {
|
|
1198
|
-
return Array.isArray(result) ? result : result.conversations;
|
|
1199
|
-
}
|
|
1200
|
-
function documentsOf(result) {
|
|
1201
|
-
return Array.isArray(result) ? result : result.documents;
|
|
1202
|
-
}
|
|
1203
|
-
function totalOf(result) {
|
|
1204
|
-
return Array.isArray(result) ? result.length : result.total;
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
// src/hooks/useConversationDocuments.ts
|
|
1208
|
-
function useConversationDocuments(conversationId, params) {
|
|
1209
|
-
const context = useConversations();
|
|
1210
|
-
if (!context) {
|
|
1211
|
-
throw new Error("useConversationDocuments requires an ancestor <ConversationsProvider>");
|
|
1212
|
-
}
|
|
1213
|
-
const { api } = context;
|
|
1214
|
-
const { data, loading, error, refetch } = useAsyncResource(
|
|
1215
|
-
() => conversationId ? api.getDocuments(conversationId, params) : Promise.resolve([]),
|
|
1216
|
-
[conversationId, params?.search, params?.page, params?.limit, params?.source, params?.sortDirection]
|
|
1217
|
-
);
|
|
1218
|
-
if (data === void 0) {
|
|
1219
|
-
return { documents: [], total: 0, loading, error, refetch };
|
|
1220
|
-
}
|
|
1221
|
-
return { documents: documentsOf(data), total: totalOf(data), loading, error, refetch };
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
// src/ConversationDocumentsPanel.tsx
|
|
1225
|
-
import { jsx as jsx15, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1226
|
-
var DOCUMENT_SOURCE_FILTER = {
|
|
1227
|
-
ALL: "all",
|
|
1228
|
-
CUSTOMER: "customer",
|
|
1229
|
-
TEAM: "team"
|
|
1230
|
-
};
|
|
1231
|
-
var TEAM_SOURCES = /* @__PURE__ */ new Set(["agent", "bot"]);
|
|
1232
|
-
var DEFAULT_CONVERSATION_DOCUMENTS_LABELS = {
|
|
1233
|
-
toggle: "\u{1F4CE} Arquivos",
|
|
1234
|
-
title: "Arquivos da conversa",
|
|
1235
|
-
noResults: "Nenhum arquivo encontrado para os filtros aplicados",
|
|
1236
|
-
view: "Visualizar",
|
|
1237
|
-
sourceFilterAll: "Todas as origens",
|
|
1238
|
-
sourceFilterCustomer: "Cliente",
|
|
1239
|
-
sourceFilterTeam: "Equipe",
|
|
1240
|
-
sortMostRecent: "Mais recentes",
|
|
1241
|
-
sortOldest: "Mais antigos",
|
|
1242
|
-
clearFilters: "Limpar filtros",
|
|
1243
|
-
selectAll: "Selecionar todos desta p\xE1gina",
|
|
1244
|
-
downloadSelected: (count) => `Baixar ${count} selecionado${count === 1 ? "" : "s"} (.zip)`,
|
|
1245
|
-
archiveFailed: "N\xE3o foi poss\xEDvel montar o arquivo compactado.",
|
|
1246
|
-
total: (count) => `${count} arquivo${count === 1 ? "" : "s"}`,
|
|
1247
|
-
page: (current, last) => `${current} / ${last}`,
|
|
1248
|
-
searchPlaceholder: "Buscar por nome do arquivo",
|
|
1249
|
-
empty: "Nenhum arquivo nesta conversa.",
|
|
1250
|
-
loading: "Carregando arquivos\u2026",
|
|
1251
|
-
failure: "N\xE3o foi poss\xEDvel carregar os arquivos.",
|
|
1252
|
-
download: "Baixar"
|
|
1253
|
-
};
|
|
1254
|
-
var DEFAULT_PER_PAGE = 10;
|
|
1255
|
-
function ConversationDocumentsPanel({
|
|
1256
|
-
conversationId,
|
|
1257
|
-
open,
|
|
1258
|
-
perPage = DEFAULT_PER_PAGE,
|
|
1259
|
-
labels: labelsOverride,
|
|
1260
|
-
className,
|
|
1261
|
-
classNames
|
|
1262
|
-
}) {
|
|
1263
|
-
const labels = { ...DEFAULT_CONVERSATION_DOCUMENTS_LABELS, ...labelsOverride };
|
|
1264
|
-
const context = useConversations();
|
|
1265
|
-
const [search, setSearch] = useState8("");
|
|
1266
|
-
const [sourceFilter, setSourceFilter] = useState8(DOCUMENT_SOURCE_FILTER.ALL);
|
|
1267
|
-
const [sortDirection, setSortDirection] = useState8("desc");
|
|
1268
|
-
const [page, setPage] = useState8(1);
|
|
1269
|
-
const [selectedIds, setSelectedIds] = useState8([]);
|
|
1270
|
-
const [archiveError, setArchiveError] = useState8(false);
|
|
1271
|
-
const hasFilters = search !== "" || sourceFilter !== DOCUMENT_SOURCE_FILTER.ALL || sortDirection !== "desc";
|
|
1272
|
-
const { documents, total, loading, error } = useConversationDocuments(open ? conversationId : void 0, {
|
|
1273
|
-
search,
|
|
1274
|
-
page,
|
|
1275
|
-
limit: perPage,
|
|
1276
|
-
sortDirection,
|
|
1277
|
-
...sourceFilter === DOCUMENT_SOURCE_FILTER.ALL ? {} : { source: sourceFilter }
|
|
1278
|
-
});
|
|
1279
|
-
const lastPage = Math.max(1, Math.ceil(total / perPage));
|
|
1280
|
-
function applyFilter(change) {
|
|
1281
|
-
change();
|
|
1282
|
-
setPage(1);
|
|
1283
|
-
}
|
|
1284
|
-
async function handleOpen(uploadId, disposition) {
|
|
1285
|
-
const url = await context?.api.getDocumentUrl(uploadId, disposition);
|
|
1286
|
-
if (url) window.open(url, "_blank", "noopener,noreferrer");
|
|
1287
|
-
}
|
|
1288
|
-
const canArchive = typeof context?.api.downloadDocumentsArchive === "function";
|
|
1289
|
-
const pageIds = documents.map((document2) => document2.id);
|
|
1290
|
-
const allOnPageSelected = pageIds.length > 0 && pageIds.every((id) => selectedIds.includes(id));
|
|
1291
|
-
function toggleSelected(uploadId) {
|
|
1292
|
-
setArchiveError(false);
|
|
1293
|
-
setSelectedIds(
|
|
1294
|
-
(current) => current.includes(uploadId) ? current.filter((id) => id !== uploadId) : [...current, uploadId]
|
|
1295
|
-
);
|
|
1296
|
-
}
|
|
1297
|
-
function toggleAllOnPage() {
|
|
1298
|
-
setArchiveError(false);
|
|
1299
|
-
setSelectedIds(
|
|
1300
|
-
(current) => allOnPageSelected ? current.filter((id) => !pageIds.includes(id)) : [...current, ...pageIds.filter((id) => !current.includes(id))]
|
|
1301
|
-
);
|
|
1302
|
-
}
|
|
1303
|
-
async function handleDownloadSelected() {
|
|
1304
|
-
const archive = context?.api.downloadDocumentsArchive;
|
|
1305
|
-
if (!archive || selectedIds.length === 0) return;
|
|
1306
|
-
setArchiveError(false);
|
|
1307
|
-
try {
|
|
1308
|
-
const blob = await archive(conversationId, selectedIds);
|
|
1309
|
-
const url = URL.createObjectURL(blob);
|
|
1310
|
-
const anchor = document.createElement("a");
|
|
1311
|
-
anchor.href = url;
|
|
1312
|
-
anchor.download = `conversa-${conversationId}.zip`;
|
|
1313
|
-
anchor.click();
|
|
1314
|
-
URL.revokeObjectURL(url);
|
|
1315
|
-
setSelectedIds([]);
|
|
1316
|
-
} catch {
|
|
1317
|
-
setArchiveError(true);
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
if (!open) return null;
|
|
1321
|
-
return /* @__PURE__ */ jsx15("div", { className: cn("border-b", classNames?.root, className), children: /* @__PURE__ */ jsxs12("section", { className: cn("px-4 py-3", classNames?.body), children: [
|
|
1322
|
-
/* @__PURE__ */ jsx15("p", { className: cn("mb-2 text-sm font-medium", classNames?.title), children: labels.title }),
|
|
1323
|
-
/* @__PURE__ */ jsxs12("div", { className: cn("mb-2 flex flex-wrap items-center gap-2 border-b pb-2", classNames?.filters), children: [
|
|
1324
|
-
/* @__PURE__ */ jsx15(
|
|
1325
|
-
"input",
|
|
1326
|
-
{
|
|
1327
|
-
type: "search",
|
|
1328
|
-
value: search,
|
|
1329
|
-
onChange: (event) => applyFilter(() => setSearch(event.target.value)),
|
|
1330
|
-
placeholder: labels.searchPlaceholder,
|
|
1331
|
-
"aria-label": labels.searchPlaceholder,
|
|
1332
|
-
className: cn("w-full rounded-md border px-3 py-2 text-sm sm:w-52", classNames?.search)
|
|
1333
|
-
}
|
|
1334
|
-
),
|
|
1335
|
-
/* @__PURE__ */ jsxs12(
|
|
1336
|
-
"select",
|
|
1337
|
-
{
|
|
1338
|
-
value: sourceFilter,
|
|
1339
|
-
onChange: (event) => applyFilter(() => setSourceFilter(event.target.value)),
|
|
1340
|
-
"aria-label": labels.sourceFilterAll,
|
|
1341
|
-
className: cn("w-full rounded-md border px-2 py-2 text-sm sm:w-36", classNames?.sourceSelect),
|
|
1342
|
-
children: [
|
|
1343
|
-
/* @__PURE__ */ jsx15("option", { value: DOCUMENT_SOURCE_FILTER.ALL, children: labels.sourceFilterAll }),
|
|
1344
|
-
/* @__PURE__ */ jsx15("option", { value: DOCUMENT_SOURCE_FILTER.CUSTOMER, children: labels.sourceFilterCustomer }),
|
|
1345
|
-
/* @__PURE__ */ jsx15("option", { value: DOCUMENT_SOURCE_FILTER.TEAM, children: labels.sourceFilterTeam })
|
|
1346
|
-
]
|
|
1347
|
-
}
|
|
1348
|
-
),
|
|
1349
|
-
/* @__PURE__ */ jsxs12(
|
|
1350
|
-
"button",
|
|
1351
|
-
{
|
|
1352
|
-
type: "button",
|
|
1353
|
-
onClick: () => applyFilter(() => setSortDirection(sortDirection === "desc" ? "asc" : "desc")),
|
|
1354
|
-
className: cn("cv-header-action inline-flex items-center gap-1", classNames?.sortButton),
|
|
1355
|
-
children: [
|
|
1356
|
-
/* @__PURE__ */ jsx15(ArrowUpDown, { size: 14 }),
|
|
1357
|
-
sortDirection === "desc" ? labels.sortMostRecent : labels.sortOldest
|
|
1358
|
-
]
|
|
1359
|
-
}
|
|
1360
|
-
),
|
|
1361
|
-
hasFilters ? /* @__PURE__ */ jsx15(
|
|
1362
|
-
"button",
|
|
1363
|
-
{
|
|
1364
|
-
type: "button",
|
|
1365
|
-
onClick: () => applyFilter(() => {
|
|
1366
|
-
setSearch("");
|
|
1367
|
-
setSourceFilter(DOCUMENT_SOURCE_FILTER.ALL);
|
|
1368
|
-
setSortDirection("desc");
|
|
1369
|
-
}),
|
|
1370
|
-
className: cn("cv-header-action", classNames?.clearButton),
|
|
1371
|
-
children: labels.clearFilters
|
|
1372
|
-
}
|
|
1373
|
-
) : null
|
|
1374
|
-
] }),
|
|
1375
|
-
loading ? /* @__PURE__ */ jsx15("p", { className: cn("text-xs text-gray-500", classNames?.status), children: labels.loading }) : null,
|
|
1376
|
-
error ? /* @__PURE__ */ jsx15("p", { role: "alert", className: cn("text-xs text-red-600 dark:text-red-400", classNames?.status), children: labels.failure }) : null,
|
|
1377
|
-
!loading && !error && documents.length === 0 ? /* @__PURE__ */ jsx15("p", { className: cn("text-xs text-gray-500", classNames?.status), children: hasFilters ? labels.noResults : labels.empty }) : null,
|
|
1378
|
-
canArchive && documents.length > 0 ? /* @__PURE__ */ jsxs12("div", { className: cn("mb-2 flex flex-wrap items-center gap-3 text-xs", classNames?.selectionBar), children: [
|
|
1379
|
-
/* @__PURE__ */ jsxs12("label", { className: "inline-flex items-center gap-1.5", children: [
|
|
1380
|
-
/* @__PURE__ */ jsx15(
|
|
1381
|
-
"input",
|
|
1382
|
-
{
|
|
1383
|
-
type: "checkbox",
|
|
1384
|
-
checked: allOnPageSelected,
|
|
1385
|
-
onChange: toggleAllOnPage,
|
|
1386
|
-
className: cn(classNames?.checkbox)
|
|
1387
|
-
}
|
|
1388
|
-
),
|
|
1389
|
-
labels.selectAll
|
|
1390
|
-
] }),
|
|
1391
|
-
selectedIds.length > 0 ? /* @__PURE__ */ jsx15("button", { type: "button", onClick: () => void handleDownloadSelected(), className: "cv-header-action", children: labels.downloadSelected(selectedIds.length) }) : null,
|
|
1392
|
-
archiveError ? /* @__PURE__ */ jsx15("span", { role: "alert", className: "text-red-600 dark:text-red-400", children: labels.archiveFailed }) : null
|
|
1393
|
-
] }) : null,
|
|
1394
|
-
/* @__PURE__ */ jsx15("ul", { className: cn("space-y-2", classNames?.list), children: documents.map((document2) => {
|
|
1395
|
-
const isFromCustomer = !TEAM_SOURCES.has(document2.source);
|
|
1396
|
-
const SourceIcon = isFromCustomer ? Users : Bot;
|
|
1397
|
-
return /* @__PURE__ */ jsxs12(
|
|
1398
|
-
"li",
|
|
1399
|
-
{
|
|
1400
|
-
className: cn(
|
|
1401
|
-
"flex items-center justify-between gap-2 rounded-lg border px-3 py-2 dark:border-gray-700",
|
|
1402
|
-
classNames?.item
|
|
1403
|
-
),
|
|
1404
|
-
children: [
|
|
1405
|
-
/* @__PURE__ */ jsxs12("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
|
|
1406
|
-
canArchive ? /* @__PURE__ */ jsx15(
|
|
1407
|
-
"input",
|
|
1408
|
-
{
|
|
1409
|
-
type: "checkbox",
|
|
1410
|
-
checked: selectedIds.includes(document2.id),
|
|
1411
|
-
onChange: () => toggleSelected(document2.id),
|
|
1412
|
-
"aria-label": `${labels.download}: ${document2.filename}`,
|
|
1413
|
-
className: cn("shrink-0", classNames?.checkbox)
|
|
1414
|
-
}
|
|
1415
|
-
) : null,
|
|
1416
|
-
/* @__PURE__ */ jsx15(FileIcon, { filename: document2.filename, mimeType: document2.mimeType }),
|
|
1417
|
-
/* @__PURE__ */ jsxs12("div", { className: "min-w-0 flex-1", children: [
|
|
1418
|
-
/* @__PURE__ */ jsxs12(
|
|
1419
|
-
"div",
|
|
1420
|
-
{
|
|
1421
|
-
className: cn(
|
|
1422
|
-
"mb-0.5 flex items-center gap-1 text-[11px] font-medium",
|
|
1423
|
-
isFromCustomer ? "text-blue-600 dark:text-blue-400" : "text-emerald-600 dark:text-emerald-400",
|
|
1424
|
-
classNames?.sourceBadge
|
|
1425
|
-
),
|
|
1426
|
-
children: [
|
|
1427
|
-
/* @__PURE__ */ jsx15(SourceIcon, { size: 11 }),
|
|
1428
|
-
isFromCustomer ? labels.sourceFilterCustomer : labels.sourceFilterTeam
|
|
1429
|
-
]
|
|
1430
|
-
}
|
|
1431
|
-
),
|
|
1432
|
-
/* @__PURE__ */ jsx15(
|
|
1433
|
-
"div",
|
|
1434
|
-
{
|
|
1435
|
-
className: cn("truncate text-sm font-medium", classNames?.filename),
|
|
1436
|
-
title: document2.filename,
|
|
1437
|
-
children: document2.filename
|
|
1438
|
-
}
|
|
1439
|
-
),
|
|
1440
|
-
/* @__PURE__ */ jsxs12("div", { className: cn("text-xs text-gray-500 dark:text-gray-400", classNames?.meta), children: [
|
|
1441
|
-
formatDateTime(document2.linkedAt),
|
|
1442
|
-
" \xB7 ",
|
|
1443
|
-
formatFileSize(document2.sizeBytes)
|
|
1444
|
-
] })
|
|
1445
|
-
] })
|
|
1446
|
-
] }),
|
|
1447
|
-
/* @__PURE__ */ jsxs12("div", { className: "flex shrink-0 gap-1", children: [
|
|
1448
|
-
/* @__PURE__ */ jsx15(
|
|
1449
|
-
"button",
|
|
1450
|
-
{
|
|
1451
|
-
type: "button",
|
|
1452
|
-
onClick: () => void handleOpen(document2.id, "inline"),
|
|
1453
|
-
title: labels.view,
|
|
1454
|
-
"aria-label": `${labels.view}: ${document2.filename}`,
|
|
1455
|
-
className: cn("cv-header-icon", classNames?.viewButton),
|
|
1456
|
-
children: /* @__PURE__ */ jsx15(Eye, { size: 14 })
|
|
1457
|
-
}
|
|
1458
|
-
),
|
|
1459
|
-
/* @__PURE__ */ jsx15(
|
|
1460
|
-
"button",
|
|
1461
|
-
{
|
|
1462
|
-
type: "button",
|
|
1463
|
-
onClick: () => void handleOpen(document2.id, "attachment"),
|
|
1464
|
-
title: labels.download,
|
|
1465
|
-
"aria-label": `${labels.download}: ${document2.filename}`,
|
|
1466
|
-
className: cn("cv-header-icon", classNames?.downloadButton),
|
|
1467
|
-
children: /* @__PURE__ */ jsx15(Download, { size: 14 })
|
|
1468
|
-
}
|
|
1469
|
-
)
|
|
1470
|
-
] })
|
|
1471
|
-
]
|
|
1472
|
-
},
|
|
1473
|
-
document2.id
|
|
1474
|
-
);
|
|
1475
|
-
}) }),
|
|
1476
|
-
total > perPage ? /* @__PURE__ */ jsxs12(
|
|
1477
|
-
"div",
|
|
1478
|
-
{
|
|
1479
|
-
className: cn(
|
|
1480
|
-
"mt-2 flex items-center justify-between border-t pt-2 text-xs dark:border-gray-700",
|
|
1481
|
-
classNames?.pagination
|
|
1482
|
-
),
|
|
1483
|
-
children: [
|
|
1484
|
-
/* @__PURE__ */ jsx15("span", { className: "text-gray-400", children: labels.total(total) }),
|
|
1485
|
-
/* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2", children: [
|
|
1486
|
-
/* @__PURE__ */ jsx15(
|
|
1487
|
-
"button",
|
|
1488
|
-
{
|
|
1489
|
-
type: "button",
|
|
1490
|
-
onClick: () => setPage(page - 1),
|
|
1491
|
-
disabled: page <= 1,
|
|
1492
|
-
"aria-label": labels.sortOldest,
|
|
1493
|
-
className: "cv-header-icon disabled:opacity-40",
|
|
1494
|
-
children: "\u2039"
|
|
1495
|
-
}
|
|
1496
|
-
),
|
|
1497
|
-
/* @__PURE__ */ jsx15("span", { className: "text-gray-500", children: labels.page(page, lastPage) }),
|
|
1498
|
-
/* @__PURE__ */ jsx15(
|
|
1499
|
-
"button",
|
|
1500
|
-
{
|
|
1501
|
-
type: "button",
|
|
1502
|
-
onClick: () => setPage(page + 1),
|
|
1503
|
-
disabled: page >= lastPage,
|
|
1504
|
-
"aria-label": labels.sortMostRecent,
|
|
1505
|
-
className: "cv-header-icon disabled:opacity-40",
|
|
1506
|
-
children: "\u203A"
|
|
1507
|
-
}
|
|
1508
|
-
)
|
|
1509
|
-
] })
|
|
1510
|
-
]
|
|
1511
|
-
}
|
|
1512
|
-
) : null
|
|
1513
|
-
] }) });
|
|
1514
|
-
}
|
|
1515
|
-
|
|
1516
1153
|
// src/conversationTranscript.ts
|
|
1517
1154
|
var SENDER_LABEL = {
|
|
1518
1155
|
customer: "Cliente",
|
|
@@ -1549,7 +1186,7 @@ function downloadTextFile(filename, content) {
|
|
|
1549
1186
|
}
|
|
1550
1187
|
|
|
1551
1188
|
// src/useWaitingNotifications.ts
|
|
1552
|
-
import { useState as
|
|
1189
|
+
import { useState as useState7, useEffect as useEffect4, useRef as useRef3, useCallback as useCallback3 } from "react";
|
|
1553
1190
|
var DEFAULT_POLL_INTERVAL_MS = 1e4;
|
|
1554
1191
|
var DEFAULT_LIMIT = 50;
|
|
1555
1192
|
var DEFAULT_LABELS = {
|
|
@@ -1558,17 +1195,17 @@ var DEFAULT_LABELS = {
|
|
|
1558
1195
|
};
|
|
1559
1196
|
function useWaitingNotifications(params) {
|
|
1560
1197
|
const conversationsContext = useConversations();
|
|
1561
|
-
const [conversations, setConversations] =
|
|
1562
|
-
const previousUnreadMap =
|
|
1563
|
-
const notifiedIds =
|
|
1564
|
-
const isPollingRef =
|
|
1198
|
+
const [conversations, setConversations] = useState7([]);
|
|
1199
|
+
const previousUnreadMap = useRef3(/* @__PURE__ */ new Map());
|
|
1200
|
+
const notifiedIds = useRef3(/* @__PURE__ */ new Set());
|
|
1201
|
+
const isPollingRef = useRef3(false);
|
|
1565
1202
|
const isEnabled = params?.enabled ?? true;
|
|
1566
1203
|
const intervalMs = params?.intervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
1567
1204
|
const icon = params?.icon;
|
|
1568
1205
|
const listParams = params?.params;
|
|
1569
1206
|
const labelTitle = params?.labels?.title ?? DEFAULT_LABELS.title;
|
|
1570
1207
|
const labelBody = params?.labels?.body ?? DEFAULT_LABELS.body;
|
|
1571
|
-
const refresh =
|
|
1208
|
+
const refresh = useCallback3(async () => {
|
|
1572
1209
|
if (!conversationsContext || isPollingRef.current) return;
|
|
1573
1210
|
isPollingRef.current = true;
|
|
1574
1211
|
try {
|
|
@@ -1593,7 +1230,7 @@ function useWaitingNotifications(params) {
|
|
|
1593
1230
|
isPollingRef.current = false;
|
|
1594
1231
|
}
|
|
1595
1232
|
}, [conversationsContext, listParams, icon, labelTitle, labelBody]);
|
|
1596
|
-
|
|
1233
|
+
useEffect4(() => {
|
|
1597
1234
|
if (!isEnabled) return;
|
|
1598
1235
|
if (typeof window !== "undefined" && "Notification" in window && Notification.permission === "default") {
|
|
1599
1236
|
Notification.requestPermission();
|
|
@@ -1608,7 +1245,7 @@ function useWaitingNotifications(params) {
|
|
|
1608
1245
|
|
|
1609
1246
|
// src/settings/WhatsAppTemplateSettingsForm.tsx
|
|
1610
1247
|
import { Plus, RefreshCw, Save, Trash2 } from "lucide-react";
|
|
1611
|
-
import { jsx as
|
|
1248
|
+
import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1612
1249
|
var DEFAULT_LABELS2 = {
|
|
1613
1250
|
sectionTitle: "WhatsApp",
|
|
1614
1251
|
sectionDescription: "Template usado para reabrir a janela de 24h com o cliente.",
|
|
@@ -1667,16 +1304,16 @@ function WhatsAppTemplateSettingsForm({
|
|
|
1667
1304
|
}
|
|
1668
1305
|
onVariablesChange([...variables, token]);
|
|
1669
1306
|
}
|
|
1670
|
-
return /* @__PURE__ */
|
|
1671
|
-
/* @__PURE__ */
|
|
1672
|
-
/* @__PURE__ */
|
|
1673
|
-
/* @__PURE__ */
|
|
1307
|
+
return /* @__PURE__ */ jsxs12("section", { className: "bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden", children: [
|
|
1308
|
+
/* @__PURE__ */ jsxs12("div", { className: "px-6 py-4 border-b border-gray-100 dark:border-gray-700", children: [
|
|
1309
|
+
/* @__PURE__ */ jsx14("h2", { className: "text-sm font-semibold text-gray-900 dark:text-gray-100", children: labels.sectionTitle }),
|
|
1310
|
+
/* @__PURE__ */ jsx14("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1", children: labels.sectionDescription })
|
|
1674
1311
|
] }),
|
|
1675
|
-
/* @__PURE__ */
|
|
1676
|
-
/* @__PURE__ */
|
|
1677
|
-
/* @__PURE__ */
|
|
1678
|
-
/* @__PURE__ */
|
|
1679
|
-
/* @__PURE__ */
|
|
1312
|
+
/* @__PURE__ */ jsxs12("form", { onSubmit: onSave, className: "p-6 space-y-4", children: [
|
|
1313
|
+
/* @__PURE__ */ jsxs12("div", { children: [
|
|
1314
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-between mb-1.5", children: [
|
|
1315
|
+
/* @__PURE__ */ jsx14("label", { className: "text-sm font-medium text-gray-700 dark:text-gray-300", children: labels.templateLabel }),
|
|
1316
|
+
/* @__PURE__ */ jsxs12(
|
|
1680
1317
|
"button",
|
|
1681
1318
|
{
|
|
1682
1319
|
type: "button",
|
|
@@ -1684,31 +1321,31 @@ function WhatsAppTemplateSettingsForm({
|
|
|
1684
1321
|
disabled: loadingTemplates,
|
|
1685
1322
|
className: "flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:underline disabled:opacity-50",
|
|
1686
1323
|
children: [
|
|
1687
|
-
/* @__PURE__ */
|
|
1324
|
+
/* @__PURE__ */ jsx14(RefreshCw, { size: 11, className: loadingTemplates ? "animate-spin" : "" }),
|
|
1688
1325
|
labels.refreshList
|
|
1689
1326
|
]
|
|
1690
1327
|
}
|
|
1691
1328
|
)
|
|
1692
1329
|
] }),
|
|
1693
|
-
templatesError && /* @__PURE__ */
|
|
1330
|
+
templatesError && /* @__PURE__ */ jsxs12("div", { className: "mb-2 rounded-lg bg-amber-50 dark:bg-amber-950/40 border border-amber-200 dark:border-amber-800 px-3 py-2 text-xs text-amber-700 dark:text-amber-400", children: [
|
|
1694
1331
|
labels.errorLoading,
|
|
1695
|
-
/* @__PURE__ */
|
|
1696
|
-
/* @__PURE__ */
|
|
1332
|
+
/* @__PURE__ */ jsx14("br", {}),
|
|
1333
|
+
/* @__PURE__ */ jsxs12("span", { className: "text-gray-500 dark:text-gray-400 mt-0.5 block", children: [
|
|
1697
1334
|
labels.currentNameSaved,
|
|
1698
1335
|
" ",
|
|
1699
|
-
/* @__PURE__ */
|
|
1336
|
+
/* @__PURE__ */ jsx14("strong", { children: selectedTemplateName || "\u2014" })
|
|
1700
1337
|
] })
|
|
1701
1338
|
] }),
|
|
1702
|
-
loadingTemplates && /* @__PURE__ */
|
|
1703
|
-
!loadingTemplates && !templatesError && /* @__PURE__ */
|
|
1339
|
+
loadingTemplates && /* @__PURE__ */ jsx14("div", { className: "h-10 rounded-xl bg-gray-100 dark:bg-gray-700 animate-pulse" }),
|
|
1340
|
+
!loadingTemplates && !templatesError && /* @__PURE__ */ jsxs12(
|
|
1704
1341
|
"select",
|
|
1705
1342
|
{
|
|
1706
1343
|
value: selectedTemplateName,
|
|
1707
1344
|
onChange: (e) => handleSelect(e.target.value),
|
|
1708
1345
|
className: "w-full border border-gray-200 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100 rounded-xl px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 focus:border-transparent transition-all",
|
|
1709
1346
|
children: [
|
|
1710
|
-
/* @__PURE__ */
|
|
1711
|
-
templates.map((template) => /* @__PURE__ */
|
|
1347
|
+
/* @__PURE__ */ jsx14("option", { value: "", children: labels.selectPlaceholder }),
|
|
1348
|
+
templates.map((template) => /* @__PURE__ */ jsxs12("option", { value: template.name, disabled: template.status !== "APPROVED", children: [
|
|
1712
1349
|
template.displayName,
|
|
1713
1350
|
" \xB7 ",
|
|
1714
1351
|
template.shortId,
|
|
@@ -1720,27 +1357,27 @@ function WhatsAppTemplateSettingsForm({
|
|
|
1720
1357
|
]
|
|
1721
1358
|
}
|
|
1722
1359
|
),
|
|
1723
|
-
selected?.bodyText && /* @__PURE__ */
|
|
1360
|
+
selected?.bodyText && /* @__PURE__ */ jsx14("div", { className: "mt-2 rounded-lg bg-gray-50 dark:bg-gray-700/50 border border-gray-200 dark:border-gray-600 px-3 py-2 text-xs text-gray-600 dark:text-gray-300 whitespace-pre-wrap", children: selected.bodyText })
|
|
1724
1361
|
] }),
|
|
1725
|
-
/* @__PURE__ */
|
|
1726
|
-
/* @__PURE__ */
|
|
1727
|
-
/* @__PURE__ */
|
|
1728
|
-
/* @__PURE__ */
|
|
1362
|
+
/* @__PURE__ */ jsxs12("div", { children: [
|
|
1363
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-between mb-1.5", children: [
|
|
1364
|
+
/* @__PURE__ */ jsx14("label", { className: "text-sm font-medium text-gray-700 dark:text-gray-300", children: labels.variablesLabel }),
|
|
1365
|
+
/* @__PURE__ */ jsxs12(
|
|
1729
1366
|
"button",
|
|
1730
1367
|
{
|
|
1731
1368
|
type: "button",
|
|
1732
1369
|
onClick: () => onVariablesChange([...variables, ""]),
|
|
1733
1370
|
className: "flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:underline",
|
|
1734
1371
|
children: [
|
|
1735
|
-
/* @__PURE__ */
|
|
1372
|
+
/* @__PURE__ */ jsx14(Plus, { size: 12 }),
|
|
1736
1373
|
labels.addVariable
|
|
1737
1374
|
]
|
|
1738
1375
|
}
|
|
1739
1376
|
)
|
|
1740
1377
|
] }),
|
|
1741
|
-
availableVariables.length > 0 && /* @__PURE__ */
|
|
1742
|
-
/* @__PURE__ */
|
|
1743
|
-
/* @__PURE__ */
|
|
1378
|
+
availableVariables.length > 0 && /* @__PURE__ */ jsxs12("div", { className: "mb-3 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700/40 p-2.5", children: [
|
|
1379
|
+
/* @__PURE__ */ jsx14("p", { className: "text-xs font-medium text-gray-600 dark:text-gray-300 mb-1.5", children: labels.variablesAvailableTitle }),
|
|
1380
|
+
/* @__PURE__ */ jsx14("div", { className: "flex flex-wrap gap-1.5", children: availableVariables.map((available) => /* @__PURE__ */ jsxs12(
|
|
1744
1381
|
"button",
|
|
1745
1382
|
{
|
|
1746
1383
|
type: "button",
|
|
@@ -1748,8 +1385,8 @@ function WhatsAppTemplateSettingsForm({
|
|
|
1748
1385
|
title: `Inserir ${available.token}`,
|
|
1749
1386
|
className: "inline-flex items-center gap-1 rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 px-2 py-1 text-xs hover:border-blue-400 dark:hover:border-blue-500 transition-colors",
|
|
1750
1387
|
children: [
|
|
1751
|
-
/* @__PURE__ */
|
|
1752
|
-
/* @__PURE__ */
|
|
1388
|
+
/* @__PURE__ */ jsx14("code", { className: "text-blue-600 dark:text-blue-300", children: available.token }),
|
|
1389
|
+
/* @__PURE__ */ jsxs12("span", { className: "text-gray-400 dark:text-gray-500", children: [
|
|
1753
1390
|
"\xB7 ",
|
|
1754
1391
|
available.label
|
|
1755
1392
|
] })
|
|
@@ -1757,13 +1394,13 @@ function WhatsAppTemplateSettingsForm({
|
|
|
1757
1394
|
},
|
|
1758
1395
|
available.token
|
|
1759
1396
|
)) }),
|
|
1760
|
-
/* @__PURE__ */
|
|
1397
|
+
/* @__PURE__ */ jsx14("p", { className: "mt-1.5 text-[11px] text-gray-400 dark:text-gray-500", children: labels.variablesAvailableHint })
|
|
1761
1398
|
] }),
|
|
1762
|
-
/* @__PURE__ */
|
|
1763
|
-
variables.length === 0 && /* @__PURE__ */
|
|
1764
|
-
/* @__PURE__ */
|
|
1765
|
-
/* @__PURE__ */
|
|
1766
|
-
/* @__PURE__ */
|
|
1399
|
+
/* @__PURE__ */ jsx14("p", { className: "text-xs text-gray-400 dark:text-gray-500 mb-2", children: labels.variablesMappingHint }),
|
|
1400
|
+
variables.length === 0 && /* @__PURE__ */ jsx14("p", { className: "text-xs text-gray-400 dark:text-gray-500 italic", children: labels.noVariables }),
|
|
1401
|
+
/* @__PURE__ */ jsx14("div", { className: "space-y-2", children: variables.map((variable, index) => /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2", children: [
|
|
1402
|
+
/* @__PURE__ */ jsx14("span", { className: "text-xs text-gray-400 dark:text-gray-500 w-6 text-right flex-shrink-0", children: `{{${index + 1}}}` }),
|
|
1403
|
+
/* @__PURE__ */ jsx14(
|
|
1767
1404
|
"input",
|
|
1768
1405
|
{
|
|
1769
1406
|
type: "text",
|
|
@@ -1773,27 +1410,27 @@ function WhatsAppTemplateSettingsForm({
|
|
|
1773
1410
|
className: "flex-1 border border-gray-200 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 focus:border-transparent transition-all placeholder:text-gray-400 dark:placeholder:text-gray-500"
|
|
1774
1411
|
}
|
|
1775
1412
|
),
|
|
1776
|
-
/* @__PURE__ */
|
|
1413
|
+
/* @__PURE__ */ jsx14(
|
|
1777
1414
|
"button",
|
|
1778
1415
|
{
|
|
1779
1416
|
type: "button",
|
|
1780
1417
|
onClick: () => removeVariable(index),
|
|
1781
1418
|
className: "text-gray-400 hover:text-red-500 dark:hover:text-red-400 transition-colors flex-shrink-0",
|
|
1782
1419
|
title: labels.removeVariable,
|
|
1783
|
-
children: /* @__PURE__ */
|
|
1420
|
+
children: /* @__PURE__ */ jsx14(Trash2, { size: 14 })
|
|
1784
1421
|
}
|
|
1785
1422
|
)
|
|
1786
1423
|
] }, index)) })
|
|
1787
1424
|
] }),
|
|
1788
|
-
saveSuccess && /* @__PURE__ */
|
|
1789
|
-
/* @__PURE__ */
|
|
1425
|
+
saveSuccess && /* @__PURE__ */ jsx14("div", { className: "bg-green-50 dark:bg-green-950/40 border border-green-200 dark:border-green-800 rounded-xl px-4 py-3 text-sm text-green-700 dark:text-green-400", children: labels.saveSuccess }),
|
|
1426
|
+
/* @__PURE__ */ jsx14("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxs12(
|
|
1790
1427
|
"button",
|
|
1791
1428
|
{
|
|
1792
1429
|
type: "submit",
|
|
1793
1430
|
disabled: saving || !selectedTemplateName.trim(),
|
|
1794
1431
|
className: "flex items-center gap-2 bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-semibold px-5 py-2.5 rounded-xl transition-colors text-sm",
|
|
1795
1432
|
children: [
|
|
1796
|
-
saving ? /* @__PURE__ */
|
|
1433
|
+
saving ? /* @__PURE__ */ jsx14("span", { className: "w-4 h-4 border-2 border-white/40 border-t-white rounded-full animate-spin" }) : /* @__PURE__ */ jsx14(Save, { size: 14 }),
|
|
1797
1434
|
saving ? labels.saving : labels.save
|
|
1798
1435
|
]
|
|
1799
1436
|
}
|
|
@@ -1804,12 +1441,13 @@ function WhatsAppTemplateSettingsForm({
|
|
|
1804
1441
|
|
|
1805
1442
|
// src/settings/WhatsAppCreateTemplateForm.tsx
|
|
1806
1443
|
import { SendHorizonal } from "lucide-react";
|
|
1807
|
-
import { jsx as
|
|
1444
|
+
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1808
1445
|
var DEFAULT_LABELS3 = {
|
|
1809
1446
|
sectionTitle: "Criar novo template",
|
|
1810
1447
|
sectionDescription: "Envia um template para aprova\xE7\xE3o da Meta.",
|
|
1811
1448
|
nameLabel: "Nome do template",
|
|
1812
1449
|
nameHint: "Somente letras min\xFAsculas, n\xFAmeros e underscore.",
|
|
1450
|
+
namePlaceholder: "reengajamento_cliente",
|
|
1813
1451
|
categoryLabel: "Categoria",
|
|
1814
1452
|
languageLabel: "Idioma",
|
|
1815
1453
|
headerLabel: "Cabe\xE7alho",
|
|
@@ -1860,77 +1498,77 @@ function WhatsAppCreateTemplateForm({
|
|
|
1860
1498
|
function set(key, next) {
|
|
1861
1499
|
onChange({ ...value, [key]: next });
|
|
1862
1500
|
}
|
|
1863
|
-
return /* @__PURE__ */
|
|
1864
|
-
/* @__PURE__ */
|
|
1865
|
-
/* @__PURE__ */
|
|
1866
|
-
/* @__PURE__ */
|
|
1501
|
+
return /* @__PURE__ */ jsxs13("section", { className: "bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden", children: [
|
|
1502
|
+
/* @__PURE__ */ jsxs13("div", { className: "px-6 py-4 border-b border-gray-100 dark:border-gray-700", children: [
|
|
1503
|
+
/* @__PURE__ */ jsx15("h2", { className: "text-sm font-semibold text-gray-900 dark:text-gray-100", children: labels.sectionTitle }),
|
|
1504
|
+
/* @__PURE__ */ jsx15("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1", children: labels.sectionDescription })
|
|
1867
1505
|
] }),
|
|
1868
|
-
/* @__PURE__ */
|
|
1869
|
-
/* @__PURE__ */
|
|
1870
|
-
/* @__PURE__ */
|
|
1871
|
-
/* @__PURE__ */
|
|
1872
|
-
/* @__PURE__ */
|
|
1506
|
+
/* @__PURE__ */ jsxs13("form", { onSubmit, className: "p-6 space-y-4", children: [
|
|
1507
|
+
/* @__PURE__ */ jsxs13("div", { children: [
|
|
1508
|
+
/* @__PURE__ */ jsx15("label", { className: "text-sm font-medium text-gray-700 dark:text-gray-300", children: labels.nameLabel }),
|
|
1509
|
+
/* @__PURE__ */ jsx15("p", { className: "text-xs text-gray-400 mb-1.5", children: labels.nameHint }),
|
|
1510
|
+
/* @__PURE__ */ jsx15(
|
|
1873
1511
|
"input",
|
|
1874
1512
|
{
|
|
1875
1513
|
type: "text",
|
|
1876
1514
|
value: value.name,
|
|
1877
1515
|
onChange: (e) => set("name", e.target.value.toLowerCase().replace(/[^a-z0-9_]/g, "_")),
|
|
1878
|
-
placeholder:
|
|
1516
|
+
placeholder: labels.namePlaceholder,
|
|
1879
1517
|
className: "w-full border border-gray-200 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100 rounded-xl px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 focus:border-transparent transition-all",
|
|
1880
1518
|
required: true
|
|
1881
1519
|
}
|
|
1882
1520
|
)
|
|
1883
1521
|
] }),
|
|
1884
|
-
/* @__PURE__ */
|
|
1885
|
-
/* @__PURE__ */
|
|
1886
|
-
/* @__PURE__ */
|
|
1887
|
-
/* @__PURE__ */
|
|
1522
|
+
/* @__PURE__ */ jsxs13("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
1523
|
+
/* @__PURE__ */ jsxs13("div", { children: [
|
|
1524
|
+
/* @__PURE__ */ jsx15("label", { className: "text-sm font-medium text-gray-700 dark:text-gray-300", children: labels.categoryLabel }),
|
|
1525
|
+
/* @__PURE__ */ jsxs13(
|
|
1888
1526
|
"select",
|
|
1889
1527
|
{
|
|
1890
1528
|
value: value.category,
|
|
1891
1529
|
onChange: (e) => set("category", e.target.value),
|
|
1892
1530
|
className: "w-full border border-gray-200 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100 rounded-xl px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 focus:border-transparent transition-all",
|
|
1893
1531
|
children: [
|
|
1894
|
-
/* @__PURE__ */
|
|
1895
|
-
/* @__PURE__ */
|
|
1532
|
+
/* @__PURE__ */ jsx15("option", { value: "UTILITY", children: "UTILITY (Transacional)" }),
|
|
1533
|
+
/* @__PURE__ */ jsx15("option", { value: "MARKETING", children: "MARKETING (Promocional)" })
|
|
1896
1534
|
]
|
|
1897
1535
|
}
|
|
1898
1536
|
)
|
|
1899
1537
|
] }),
|
|
1900
|
-
/* @__PURE__ */
|
|
1901
|
-
/* @__PURE__ */
|
|
1902
|
-
/* @__PURE__ */
|
|
1538
|
+
/* @__PURE__ */ jsxs13("div", { children: [
|
|
1539
|
+
/* @__PURE__ */ jsx15("label", { className: "text-sm font-medium text-gray-700 dark:text-gray-300", children: labels.languageLabel }),
|
|
1540
|
+
/* @__PURE__ */ jsxs13(
|
|
1903
1541
|
"select",
|
|
1904
1542
|
{
|
|
1905
1543
|
value: value.language,
|
|
1906
1544
|
onChange: (e) => set("language", e.target.value),
|
|
1907
1545
|
className: "w-full border border-gray-200 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100 rounded-xl px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 focus:border-transparent transition-all",
|
|
1908
1546
|
children: [
|
|
1909
|
-
/* @__PURE__ */
|
|
1910
|
-
/* @__PURE__ */
|
|
1911
|
-
/* @__PURE__ */
|
|
1547
|
+
/* @__PURE__ */ jsx15("option", { value: "pt_BR", children: "Portugu\xEAs (Brasil)" }),
|
|
1548
|
+
/* @__PURE__ */ jsx15("option", { value: "en_US", children: "Ingl\xEAs (EUA)" }),
|
|
1549
|
+
/* @__PURE__ */ jsx15("option", { value: "es_ES", children: "Espanhol" })
|
|
1912
1550
|
]
|
|
1913
1551
|
}
|
|
1914
1552
|
)
|
|
1915
1553
|
] })
|
|
1916
1554
|
] }),
|
|
1917
|
-
/* @__PURE__ */
|
|
1918
|
-
/* @__PURE__ */
|
|
1919
|
-
/* @__PURE__ */
|
|
1920
|
-
/* @__PURE__ */
|
|
1921
|
-
/* @__PURE__ */
|
|
1555
|
+
/* @__PURE__ */ jsxs13("div", { children: [
|
|
1556
|
+
/* @__PURE__ */ jsx15("label", { className: "text-sm font-medium text-gray-700 dark:text-gray-300", children: labels.headerLabel }),
|
|
1557
|
+
/* @__PURE__ */ jsx15("p", { className: "text-xs text-gray-400 mb-1.5", children: labels.headerHint }),
|
|
1558
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex gap-2", children: [
|
|
1559
|
+
/* @__PURE__ */ jsxs13(
|
|
1922
1560
|
"select",
|
|
1923
1561
|
{
|
|
1924
1562
|
value: value.headerType,
|
|
1925
1563
|
onChange: (e) => set("headerType", e.target.value),
|
|
1926
1564
|
className: "border border-gray-200 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100 rounded-xl px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 transition-all",
|
|
1927
1565
|
children: [
|
|
1928
|
-
/* @__PURE__ */
|
|
1929
|
-
/* @__PURE__ */
|
|
1566
|
+
/* @__PURE__ */ jsx15("option", { value: "NONE", children: labels.headerNone }),
|
|
1567
|
+
/* @__PURE__ */ jsx15("option", { value: "TEXT", children: labels.headerText })
|
|
1930
1568
|
]
|
|
1931
1569
|
}
|
|
1932
1570
|
),
|
|
1933
|
-
value.headerType === "TEXT" && /* @__PURE__ */
|
|
1571
|
+
value.headerType === "TEXT" && /* @__PURE__ */ jsx15(
|
|
1934
1572
|
"input",
|
|
1935
1573
|
{
|
|
1936
1574
|
type: "text",
|
|
@@ -1943,10 +1581,10 @@ function WhatsAppCreateTemplateForm({
|
|
|
1943
1581
|
)
|
|
1944
1582
|
] })
|
|
1945
1583
|
] }),
|
|
1946
|
-
/* @__PURE__ */
|
|
1947
|
-
/* @__PURE__ */
|
|
1948
|
-
/* @__PURE__ */
|
|
1949
|
-
/* @__PURE__ */
|
|
1584
|
+
/* @__PURE__ */ jsxs13("div", { children: [
|
|
1585
|
+
/* @__PURE__ */ jsx15("label", { className: "text-sm font-medium text-gray-700 dark:text-gray-300", children: labels.bodyLabel }),
|
|
1586
|
+
/* @__PURE__ */ jsx15("p", { className: "text-xs text-gray-400 mb-1.5", children: labels.bodyHint }),
|
|
1587
|
+
/* @__PURE__ */ jsx15(
|
|
1950
1588
|
"textarea",
|
|
1951
1589
|
{
|
|
1952
1590
|
value: value.bodyText,
|
|
@@ -1957,26 +1595,26 @@ function WhatsAppCreateTemplateForm({
|
|
|
1957
1595
|
required: true
|
|
1958
1596
|
}
|
|
1959
1597
|
),
|
|
1960
|
-
detectedVariables.length > 0 && /* @__PURE__ */
|
|
1961
|
-
/* @__PURE__ */
|
|
1962
|
-
/* @__PURE__ */
|
|
1963
|
-
/* @__PURE__ */
|
|
1964
|
-
/* @__PURE__ */
|
|
1598
|
+
detectedVariables.length > 0 && /* @__PURE__ */ jsxs13("div", { className: "mt-2 rounded-lg bg-gray-50 dark:bg-gray-700/50 border border-gray-200 dark:border-gray-600 px-3 py-2", children: [
|
|
1599
|
+
/* @__PURE__ */ jsx15("p", { className: "font-medium text-gray-500 dark:text-gray-400 mb-1.5 uppercase tracking-wide text-xs", children: labels.detectedVariables }),
|
|
1600
|
+
/* @__PURE__ */ jsx15("div", { className: "flex flex-wrap gap-2", children: detectedVariables.map((num) => /* @__PURE__ */ jsxs13("span", { className: "inline-flex items-center gap-1 text-xs", children: [
|
|
1601
|
+
/* @__PURE__ */ jsx15("code", { className: "bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 px-1.5 py-0.5 rounded font-mono", children: `{{${num}}}` }),
|
|
1602
|
+
/* @__PURE__ */ jsxs13("span", { className: "text-gray-400 dark:text-gray-500", children: [
|
|
1965
1603
|
"= ",
|
|
1966
1604
|
variableExamples[Number(num) - 1] ?? labels.variableLabel(Number(num))
|
|
1967
1605
|
] })
|
|
1968
1606
|
] }, num)) }),
|
|
1969
|
-
/* @__PURE__ */
|
|
1607
|
+
/* @__PURE__ */ jsxs13("p", { className: "text-gray-400 dark:text-gray-500 mt-1.5 text-xs", children: [
|
|
1970
1608
|
labels.configureHintPrefix,
|
|
1971
|
-
/* @__PURE__ */
|
|
1609
|
+
/* @__PURE__ */ jsx15("strong", { children: labels.configureHintLink }),
|
|
1972
1610
|
labels.configureHintSuffix
|
|
1973
1611
|
] })
|
|
1974
1612
|
] })
|
|
1975
1613
|
] }),
|
|
1976
|
-
/* @__PURE__ */
|
|
1977
|
-
/* @__PURE__ */
|
|
1978
|
-
/* @__PURE__ */
|
|
1979
|
-
/* @__PURE__ */
|
|
1614
|
+
/* @__PURE__ */ jsxs13("div", { children: [
|
|
1615
|
+
/* @__PURE__ */ jsx15("label", { className: "text-sm font-medium text-gray-700 dark:text-gray-300", children: labels.footerLabel }),
|
|
1616
|
+
/* @__PURE__ */ jsx15("p", { className: "text-xs text-gray-400 mb-1.5", children: labels.footerHint }),
|
|
1617
|
+
/* @__PURE__ */ jsx15(
|
|
1980
1618
|
"input",
|
|
1981
1619
|
{
|
|
1982
1620
|
type: "text",
|
|
@@ -1988,48 +1626,48 @@ function WhatsAppCreateTemplateForm({
|
|
|
1988
1626
|
}
|
|
1989
1627
|
)
|
|
1990
1628
|
] }),
|
|
1991
|
-
/* @__PURE__ */
|
|
1992
|
-
/* @__PURE__ */
|
|
1993
|
-
/* @__PURE__ */
|
|
1994
|
-
/* @__PURE__ */
|
|
1995
|
-
/* @__PURE__ */
|
|
1996
|
-
/* @__PURE__ */
|
|
1997
|
-
/* @__PURE__ */
|
|
1998
|
-
/* @__PURE__ */
|
|
1629
|
+
/* @__PURE__ */ jsxs13("div", { children: [
|
|
1630
|
+
/* @__PURE__ */ jsx15("label", { className: "text-sm font-medium text-gray-700 dark:text-gray-300 mb-2 block", children: labels.previewLabel }),
|
|
1631
|
+
/* @__PURE__ */ jsxs13("div", { className: "rounded-2xl bg-[#e5ddd5] dark:bg-[#1a1a2e] border border-gray-300 dark:border-gray-600 overflow-hidden shadow-inner", children: [
|
|
1632
|
+
/* @__PURE__ */ jsxs13("div", { className: "bg-[#075e54] px-4 py-2.5 flex items-center gap-2", children: [
|
|
1633
|
+
/* @__PURE__ */ jsx15("div", { className: "w-8 h-8 rounded-full bg-white/20 flex items-center justify-center text-white text-xs font-bold", children: previewCompanyName.slice(0, 2).toUpperCase() }),
|
|
1634
|
+
/* @__PURE__ */ jsxs13("div", { children: [
|
|
1635
|
+
/* @__PURE__ */ jsx15("p", { className: "text-white text-xs font-semibold leading-tight", children: previewCompanyName }),
|
|
1636
|
+
/* @__PURE__ */ jsx15("p", { className: "text-white/60 text-xs", children: labels.previewOnline })
|
|
1999
1637
|
] })
|
|
2000
1638
|
] }),
|
|
2001
|
-
/* @__PURE__ */
|
|
2002
|
-
/* @__PURE__ */
|
|
2003
|
-
/* @__PURE__ */
|
|
2004
|
-
/* @__PURE__ */
|
|
1639
|
+
/* @__PURE__ */ jsxs13("div", { className: "px-3 py-4 space-y-3", style: { minHeight: "120px" }, children: [
|
|
1640
|
+
/* @__PURE__ */ jsx15("div", { className: "flex justify-start", style: { maxWidth: "85%" }, children: /* @__PURE__ */ jsxs13("div", { className: "bg-white dark:bg-gray-700 rounded-lg rounded-tl-none px-3 py-2 shadow-sm", children: [
|
|
1641
|
+
/* @__PURE__ */ jsx15("p", { className: "text-gray-500 dark:text-gray-400 leading-tight text-sm", children: labels.previewDescription }),
|
|
1642
|
+
/* @__PURE__ */ jsx15("p", { className: "text-gray-400 dark:text-gray-500 mt-1 text-right text-[9px]", children: "12:00" })
|
|
2005
1643
|
] }) }),
|
|
2006
|
-
/* @__PURE__ */
|
|
2007
|
-
value.headerType === "TEXT" && value.headerText && /* @__PURE__ */
|
|
2008
|
-
/* @__PURE__ */
|
|
2009
|
-
value.footerText && /* @__PURE__ */
|
|
2010
|
-
/* @__PURE__ */
|
|
1644
|
+
/* @__PURE__ */ jsx15("div", { className: "flex justify-end ml-auto", style: { maxWidth: "85%" }, children: /* @__PURE__ */ jsxs13("div", { className: "bg-[#dcf8c6] dark:bg-[#1b5e20] rounded-lg rounded-tr-none px-3 py-2 shadow-sm", children: [
|
|
1645
|
+
value.headerType === "TEXT" && value.headerText && /* @__PURE__ */ jsx15("p", { className: "text-xs font-bold text-gray-700 dark:text-gray-200 mb-1", children: fillPreviewTokens(value.headerText) || labels.previewHeaderFallback }),
|
|
1646
|
+
/* @__PURE__ */ jsx15("p", { className: "text-sm text-gray-800 dark:text-gray-100 leading-relaxed", children: value.bodyText ? fillPreviewTokens(value.bodyText) : /* @__PURE__ */ jsx15("span", { className: "text-gray-400 italic", children: labels.previewBodyPlaceholder }) }),
|
|
1647
|
+
value.footerText && /* @__PURE__ */ jsx15("p", { className: "text-gray-400 dark:text-gray-400 mt-1 text-xs", children: value.footerText }),
|
|
1648
|
+
/* @__PURE__ */ jsx15("p", { className: "text-gray-400 dark:text-gray-400 mt-1 text-right text-[9px]", children: "12:01 \u2713" })
|
|
2011
1649
|
] }) })
|
|
2012
1650
|
] })
|
|
2013
1651
|
] })
|
|
2014
1652
|
] }),
|
|
2015
|
-
result && /* @__PURE__ */
|
|
1653
|
+
result && /* @__PURE__ */ jsxs13(
|
|
2016
1654
|
"div",
|
|
2017
1655
|
{
|
|
2018
1656
|
className: `rounded-xl px-4 py-3 text-sm ${result.ok ? "bg-green-50 dark:bg-green-950/40 border border-green-200 dark:border-green-800 text-green-700 dark:text-green-400" : "bg-red-50 dark:bg-red-950/40 border border-red-200 dark:border-red-800 text-red-700 dark:text-red-400"}`,
|
|
2019
1657
|
children: [
|
|
2020
1658
|
result.message,
|
|
2021
|
-
result.ok && result.status && /* @__PURE__ */
|
|
1659
|
+
result.ok && result.status && /* @__PURE__ */ jsx15("p", { className: "text-xs mt-1 opacity-75", children: labels.successStatus(result.status) })
|
|
2022
1660
|
]
|
|
2023
1661
|
}
|
|
2024
1662
|
),
|
|
2025
|
-
/* @__PURE__ */
|
|
1663
|
+
/* @__PURE__ */ jsx15("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxs13(
|
|
2026
1664
|
"button",
|
|
2027
1665
|
{
|
|
2028
1666
|
type: "submit",
|
|
2029
1667
|
disabled: submitting || !value.name || !value.bodyText,
|
|
2030
1668
|
className: "flex items-center gap-2 bg-emerald-600 hover:bg-emerald-700 disabled:bg-emerald-400 text-white font-semibold px-5 py-2.5 rounded-xl transition-colors text-sm",
|
|
2031
1669
|
children: [
|
|
2032
|
-
submitting ? /* @__PURE__ */
|
|
1670
|
+
submitting ? /* @__PURE__ */ jsx15("span", { className: "w-4 h-4 border-2 border-white/40 border-t-white rounded-full animate-spin" }) : /* @__PURE__ */ jsx15(SendHorizonal, { size: 14 }),
|
|
2033
1671
|
submitting ? labels.sending : labels.sendForApproval
|
|
2034
1672
|
]
|
|
2035
1673
|
}
|
|
@@ -2040,7 +1678,7 @@ function WhatsAppCreateTemplateForm({
|
|
|
2040
1678
|
|
|
2041
1679
|
// src/settings/WelcomeFarewellForm.tsx
|
|
2042
1680
|
import { LogOut, Mail, Save as Save2 } from "lucide-react";
|
|
2043
|
-
import { jsx as
|
|
1681
|
+
import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2044
1682
|
var DEFAULT_LABELS4 = {
|
|
2045
1683
|
sectionTitle: "Boas-vindas e encerramento",
|
|
2046
1684
|
welcomeMessage: "Mensagem de boas-vindas",
|
|
@@ -2068,15 +1706,15 @@ function WelcomeFarewellForm({
|
|
|
2068
1706
|
labels: labelsOverride
|
|
2069
1707
|
}) {
|
|
2070
1708
|
const labels = { ...DEFAULT_LABELS4, ...labelsOverride };
|
|
2071
|
-
return /* @__PURE__ */
|
|
2072
|
-
/* @__PURE__ */
|
|
2073
|
-
/* @__PURE__ */
|
|
2074
|
-
/* @__PURE__ */
|
|
2075
|
-
/* @__PURE__ */
|
|
2076
|
-
/* @__PURE__ */
|
|
1709
|
+
return /* @__PURE__ */ jsxs14("section", { className: "bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden", children: [
|
|
1710
|
+
/* @__PURE__ */ jsx16("div", { className: "px-6 py-4 border-b border-gray-100 dark:border-gray-700", children: /* @__PURE__ */ jsx16("h2", { className: "text-sm font-semibold text-gray-900 dark:text-gray-100", children: labels.sectionTitle }) }),
|
|
1711
|
+
/* @__PURE__ */ jsxs14("form", { onSubmit: onSave, className: "p-6 space-y-5", children: [
|
|
1712
|
+
/* @__PURE__ */ jsxs14("div", { children: [
|
|
1713
|
+
/* @__PURE__ */ jsxs14("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5 flex items-center gap-1.5", children: [
|
|
1714
|
+
/* @__PURE__ */ jsx16(Mail, { size: 13, className: "text-blue-600 dark:text-blue-400" }),
|
|
2077
1715
|
labels.welcomeMessage
|
|
2078
1716
|
] }),
|
|
2079
|
-
/* @__PURE__ */
|
|
1717
|
+
/* @__PURE__ */ jsx16(
|
|
2080
1718
|
WhatsAppMessageEditor,
|
|
2081
1719
|
{
|
|
2082
1720
|
value: welcomeMessage,
|
|
@@ -2085,14 +1723,14 @@ function WelcomeFarewellForm({
|
|
|
2085
1723
|
placeholders: welcomePlaceholders
|
|
2086
1724
|
}
|
|
2087
1725
|
),
|
|
2088
|
-
/* @__PURE__ */
|
|
1726
|
+
/* @__PURE__ */ jsx16("p", { className: "mt-1.5 text-xs text-gray-500 dark:text-gray-400", children: labels.welcomeMessageHint })
|
|
2089
1727
|
] }),
|
|
2090
|
-
/* @__PURE__ */
|
|
2091
|
-
/* @__PURE__ */
|
|
2092
|
-
/* @__PURE__ */
|
|
1728
|
+
/* @__PURE__ */ jsxs14("div", { children: [
|
|
1729
|
+
/* @__PURE__ */ jsxs14("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5 flex items-center gap-1.5", children: [
|
|
1730
|
+
/* @__PURE__ */ jsx16(LogOut, { size: 13, className: "text-blue-600 dark:text-blue-400" }),
|
|
2093
1731
|
labels.farewellMessage
|
|
2094
1732
|
] }),
|
|
2095
|
-
/* @__PURE__ */
|
|
1733
|
+
/* @__PURE__ */ jsx16(
|
|
2096
1734
|
WhatsAppMessageEditor,
|
|
2097
1735
|
{
|
|
2098
1736
|
value: farewellMessage,
|
|
@@ -2101,17 +1739,17 @@ function WelcomeFarewellForm({
|
|
|
2101
1739
|
placeholders: farewellPlaceholders
|
|
2102
1740
|
}
|
|
2103
1741
|
),
|
|
2104
|
-
/* @__PURE__ */
|
|
1742
|
+
/* @__PURE__ */ jsx16("p", { className: "mt-1.5 text-xs text-gray-500 dark:text-gray-400", children: labels.farewellMessageHint })
|
|
2105
1743
|
] }),
|
|
2106
|
-
saveSuccess && /* @__PURE__ */
|
|
2107
|
-
/* @__PURE__ */
|
|
1744
|
+
saveSuccess && /* @__PURE__ */ jsx16("div", { className: "bg-green-50 dark:bg-green-950/40 border border-green-200 dark:border-green-800 rounded-xl px-4 py-3 text-sm text-green-700 dark:text-green-400", children: labels.saveSuccess }),
|
|
1745
|
+
/* @__PURE__ */ jsx16("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxs14(
|
|
2108
1746
|
"button",
|
|
2109
1747
|
{
|
|
2110
1748
|
type: "submit",
|
|
2111
1749
|
disabled: saving,
|
|
2112
1750
|
className: "flex items-center gap-2 bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-semibold px-5 py-2.5 rounded-xl transition-colors text-sm",
|
|
2113
1751
|
children: [
|
|
2114
|
-
saving ? /* @__PURE__ */
|
|
1752
|
+
saving ? /* @__PURE__ */ jsx16("span", { className: "w-4 h-4 border-2 border-white/40 border-t-white rounded-full animate-spin" }) : /* @__PURE__ */ jsx16(Save2, { size: 14 }),
|
|
2115
1753
|
saving ? labels.saving : labels.save
|
|
2116
1754
|
]
|
|
2117
1755
|
}
|
|
@@ -2121,8 +1759,8 @@ function WelcomeFarewellForm({
|
|
|
2121
1759
|
}
|
|
2122
1760
|
|
|
2123
1761
|
// src/settings/WhatsAppTemplatesSettings.tsx
|
|
2124
|
-
import { useState as
|
|
2125
|
-
import { jsx as
|
|
1762
|
+
import { useState as useState8 } from "react";
|
|
1763
|
+
import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2126
1764
|
var TEMPLATE_SETTINGS_TAB = {
|
|
2127
1765
|
SELECT: "select",
|
|
2128
1766
|
CREATE: "create"
|
|
@@ -2137,10 +1775,10 @@ function WhatsAppTemplatesSettings({
|
|
|
2137
1775
|
...settingsProps
|
|
2138
1776
|
}) {
|
|
2139
1777
|
const labels = { ...DEFAULT_TEMPLATES_SETTINGS_LABELS, ...labelsOverride };
|
|
2140
|
-
const [tab, setTab] =
|
|
2141
|
-
return /* @__PURE__ */
|
|
2142
|
-
/* @__PURE__ */
|
|
2143
|
-
/* @__PURE__ */
|
|
1778
|
+
const [tab, setTab] = useState8(TEMPLATE_SETTINGS_TAB.SELECT);
|
|
1779
|
+
return /* @__PURE__ */ jsxs15("div", { className: "space-y-4", children: [
|
|
1780
|
+
/* @__PURE__ */ jsxs15("nav", { className: "flex gap-1 border-b", role: "tablist", children: [
|
|
1781
|
+
/* @__PURE__ */ jsx17(
|
|
2144
1782
|
"button",
|
|
2145
1783
|
{
|
|
2146
1784
|
type: "button",
|
|
@@ -2151,7 +1789,7 @@ function WhatsAppTemplatesSettings({
|
|
|
2151
1789
|
children: labels.selectTab
|
|
2152
1790
|
}
|
|
2153
1791
|
),
|
|
2154
|
-
create ? /* @__PURE__ */
|
|
1792
|
+
create ? /* @__PURE__ */ jsx17(
|
|
2155
1793
|
"button",
|
|
2156
1794
|
{
|
|
2157
1795
|
type: "button",
|
|
@@ -2163,13 +1801,13 @@ function WhatsAppTemplatesSettings({
|
|
|
2163
1801
|
}
|
|
2164
1802
|
) : null
|
|
2165
1803
|
] }),
|
|
2166
|
-
tab === TEMPLATE_SETTINGS_TAB.SELECT ? /* @__PURE__ */
|
|
1804
|
+
tab === TEMPLATE_SETTINGS_TAB.SELECT ? /* @__PURE__ */ jsx17(WhatsAppTemplateSettingsForm, { ...settingsProps }) : create ? /* @__PURE__ */ jsx17(WhatsAppCreateTemplateForm, { ...create }) : null
|
|
2167
1805
|
] });
|
|
2168
1806
|
}
|
|
2169
1807
|
|
|
2170
1808
|
// src/settings/TopicsForm.tsx
|
|
2171
1809
|
import { Megaphone, Save as Save3 } from "lucide-react";
|
|
2172
|
-
import { jsx as
|
|
1810
|
+
import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2173
1811
|
var DEFAULT_LABELS5 = {
|
|
2174
1812
|
sectionTitle: "T\xF3picos intermedi\xE1rios",
|
|
2175
1813
|
sectionDescription: "Mensagens autom\xE1ticas para assuntos espec\xEDficos, disparadas quando o cliente demonstra interesse.",
|
|
@@ -2187,19 +1825,19 @@ function TopicsForm({
|
|
|
2187
1825
|
labels: labelsOverride
|
|
2188
1826
|
}) {
|
|
2189
1827
|
const labels = { ...DEFAULT_LABELS5, ...labelsOverride };
|
|
2190
|
-
return /* @__PURE__ */
|
|
2191
|
-
/* @__PURE__ */
|
|
2192
|
-
/* @__PURE__ */
|
|
2193
|
-
/* @__PURE__ */
|
|
1828
|
+
return /* @__PURE__ */ jsxs16("section", { className: "bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden", children: [
|
|
1829
|
+
/* @__PURE__ */ jsxs16("div", { className: "px-6 py-4 border-b border-gray-100 dark:border-gray-700", children: [
|
|
1830
|
+
/* @__PURE__ */ jsxs16("h2", { className: "text-sm font-semibold text-gray-900 dark:text-gray-100 flex items-center gap-2", children: [
|
|
1831
|
+
/* @__PURE__ */ jsx18(Megaphone, { size: 16, className: "text-orange-600 dark:text-orange-400" }),
|
|
2194
1832
|
labels.sectionTitle
|
|
2195
1833
|
] }),
|
|
2196
|
-
/* @__PURE__ */
|
|
1834
|
+
/* @__PURE__ */ jsx18("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1", children: labels.sectionDescription })
|
|
2197
1835
|
] }),
|
|
2198
|
-
/* @__PURE__ */
|
|
2199
|
-
topics.map((topic) => /* @__PURE__ */
|
|
2200
|
-
/* @__PURE__ */
|
|
2201
|
-
/* @__PURE__ */
|
|
2202
|
-
/* @__PURE__ */
|
|
1836
|
+
/* @__PURE__ */ jsxs16("form", { onSubmit: onSave, className: "p-6 space-y-6", children: [
|
|
1837
|
+
topics.map((topic) => /* @__PURE__ */ jsxs16("div", { className: "space-y-2", children: [
|
|
1838
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex items-start gap-4", children: [
|
|
1839
|
+
/* @__PURE__ */ jsx18("div", { className: "flex-1", children: /* @__PURE__ */ jsx18("p", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: topic.label }) }),
|
|
1840
|
+
/* @__PURE__ */ jsx18(
|
|
2203
1841
|
"button",
|
|
2204
1842
|
{
|
|
2205
1843
|
type: "button",
|
|
@@ -2207,7 +1845,7 @@ function TopicsForm({
|
|
|
2207
1845
|
className: `relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none ${topic.enabled ? "bg-blue-600 dark:bg-blue-500" : "bg-gray-200 dark:bg-gray-700"}`,
|
|
2208
1846
|
role: "switch",
|
|
2209
1847
|
"aria-checked": topic.enabled,
|
|
2210
|
-
children: /* @__PURE__ */
|
|
1848
|
+
children: /* @__PURE__ */ jsx18(
|
|
2211
1849
|
"span",
|
|
2212
1850
|
{
|
|
2213
1851
|
className: `pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ${topic.enabled ? "translate-x-5" : "translate-x-0"}`
|
|
@@ -2216,7 +1854,7 @@ function TopicsForm({
|
|
|
2216
1854
|
}
|
|
2217
1855
|
)
|
|
2218
1856
|
] }),
|
|
2219
|
-
/* @__PURE__ */
|
|
1857
|
+
/* @__PURE__ */ jsx18(
|
|
2220
1858
|
"textarea",
|
|
2221
1859
|
{
|
|
2222
1860
|
value: topic.message,
|
|
@@ -2228,27 +1866,27 @@ function TopicsForm({
|
|
|
2228
1866
|
}
|
|
2229
1867
|
)
|
|
2230
1868
|
] }, topic.key)),
|
|
2231
|
-
/* @__PURE__ */
|
|
2232
|
-
/* @__PURE__ */
|
|
1869
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-3", children: [
|
|
1870
|
+
/* @__PURE__ */ jsxs16(
|
|
2233
1871
|
"button",
|
|
2234
1872
|
{
|
|
2235
1873
|
type: "submit",
|
|
2236
1874
|
disabled: saving,
|
|
2237
1875
|
className: "inline-flex items-center gap-2 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 disabled:opacity-50",
|
|
2238
1876
|
children: [
|
|
2239
|
-
/* @__PURE__ */
|
|
1877
|
+
/* @__PURE__ */ jsx18(Save3, { size: 14 }),
|
|
2240
1878
|
labels.saveButton
|
|
2241
1879
|
]
|
|
2242
1880
|
}
|
|
2243
1881
|
),
|
|
2244
|
-
saveSuccess && /* @__PURE__ */
|
|
1882
|
+
saveSuccess && /* @__PURE__ */ jsx18("span", { className: "text-sm text-green-600 dark:text-green-400", children: labels.saveSuccess })
|
|
2245
1883
|
] })
|
|
2246
1884
|
] })
|
|
2247
1885
|
] });
|
|
2248
1886
|
}
|
|
2249
1887
|
|
|
2250
1888
|
// src/hooks/useConversationMessages.ts
|
|
2251
|
-
import { useCallback as
|
|
1889
|
+
import { useCallback as useCallback4 } from "react";
|
|
2252
1890
|
function useConversationMessages(conversationId, params) {
|
|
2253
1891
|
const context = useConversations();
|
|
2254
1892
|
if (!context) {
|
|
@@ -2259,7 +1897,7 @@ function useConversationMessages(conversationId, params) {
|
|
|
2259
1897
|
() => api.fetchMessages(conversationId, params),
|
|
2260
1898
|
[conversationId, params?.limit, params?.before]
|
|
2261
1899
|
);
|
|
2262
|
-
const sendMessage =
|
|
1900
|
+
const sendMessage = useCallback4(
|
|
2263
1901
|
async (text) => {
|
|
2264
1902
|
const message = await api.sendMessage(conversationId, text);
|
|
2265
1903
|
await refetch();
|
|
@@ -2267,7 +1905,7 @@ function useConversationMessages(conversationId, params) {
|
|
|
2267
1905
|
},
|
|
2268
1906
|
[api, conversationId, refetch]
|
|
2269
1907
|
);
|
|
2270
|
-
const sendMedia =
|
|
1908
|
+
const sendMedia = useCallback4(
|
|
2271
1909
|
async (mediaData) => {
|
|
2272
1910
|
const message = await api.sendMedia(conversationId, mediaData);
|
|
2273
1911
|
await refetch();
|
|
@@ -2275,14 +1913,14 @@ function useConversationMessages(conversationId, params) {
|
|
|
2275
1913
|
},
|
|
2276
1914
|
[api, conversationId, refetch]
|
|
2277
1915
|
);
|
|
2278
|
-
const sendTemplate =
|
|
1916
|
+
const sendTemplate = useCallback4(
|
|
2279
1917
|
async (templateData) => {
|
|
2280
1918
|
await api.sendTemplate(conversationId, templateData);
|
|
2281
1919
|
await refetch();
|
|
2282
1920
|
},
|
|
2283
1921
|
[api, conversationId, refetch]
|
|
2284
1922
|
);
|
|
2285
|
-
const markRead =
|
|
1923
|
+
const markRead = useCallback4(() => api.markRead(conversationId), [api, conversationId]);
|
|
2286
1924
|
return { messages: data ?? [], loading, error, refetch, sendMessage, sendMedia, sendTemplate, markRead };
|
|
2287
1925
|
}
|
|
2288
1926
|
|
|
@@ -2316,12 +1954,12 @@ function useConversationContext(conversationId) {
|
|
|
2316
1954
|
}
|
|
2317
1955
|
|
|
2318
1956
|
// src/hooks/useConversationRealtime.ts
|
|
2319
|
-
import { useEffect as
|
|
1957
|
+
import { useEffect as useEffect5, useRef as useRef4 } from "react";
|
|
2320
1958
|
function useConversationRealtime(conversationId, onEvent) {
|
|
2321
1959
|
const context = useConversations();
|
|
2322
|
-
const onEventRef =
|
|
1960
|
+
const onEventRef = useRef4(onEvent);
|
|
2323
1961
|
onEventRef.current = onEvent;
|
|
2324
|
-
|
|
1962
|
+
useEffect5(() => {
|
|
2325
1963
|
if (!context || !conversationId) return;
|
|
2326
1964
|
const source = context.sse.connectConversationStream(conversationId);
|
|
2327
1965
|
const handler = (event) => onEventRef.current(event);
|
|
@@ -2334,9 +1972,9 @@ function useConversationRealtime(conversationId, onEvent) {
|
|
|
2334
1972
|
}
|
|
2335
1973
|
function useGlobalRealtime(onEvent) {
|
|
2336
1974
|
const context = useConversations();
|
|
2337
|
-
const onEventRef =
|
|
1975
|
+
const onEventRef = useRef4(onEvent);
|
|
2338
1976
|
onEventRef.current = onEvent;
|
|
2339
|
-
|
|
1977
|
+
useEffect5(() => {
|
|
2340
1978
|
if (!context) return;
|
|
2341
1979
|
const source = context.sse.connectGlobalStream();
|
|
2342
1980
|
const handler = (event) => onEventRef.current(event);
|
|
@@ -2396,16 +2034,29 @@ export {
|
|
|
2396
2034
|
ConversationRow,
|
|
2397
2035
|
ConversationWallpaper,
|
|
2398
2036
|
ConversationsProvider,
|
|
2037
|
+
DEFAULT_ACCEPTED_FILE_TYPES,
|
|
2038
|
+
DEFAULT_AVATAR_LABELS,
|
|
2399
2039
|
DEFAULT_CONVERSATION_CHANNEL,
|
|
2400
2040
|
DEFAULT_CONVERSATION_CONTEXT_LABELS,
|
|
2401
2041
|
DEFAULT_CONVERSATION_DOCUMENTS_LABELS,
|
|
2402
2042
|
DEFAULT_CONVERSATION_HEADER_LABELS,
|
|
2043
|
+
DEFAULT_CONVERSATION_LIST_ITEM_LABELS,
|
|
2044
|
+
DEFAULT_DOCUMENTS_LIBRARY_LABELS,
|
|
2045
|
+
DEFAULT_EMOJI_PICKER_LABELS,
|
|
2046
|
+
DEFAULT_INTERACTIVE_MESSAGE_LABELS,
|
|
2047
|
+
DEFAULT_LIGHTBOX_LABELS,
|
|
2048
|
+
DEFAULT_MESSAGE_COMPOSER_LABELS,
|
|
2403
2049
|
DEFAULT_TEMPLATES_SETTINGS_LABELS,
|
|
2050
|
+
DEFAULT_WHATSAPP_MESSAGE_EDITOR_LABELS,
|
|
2404
2051
|
DEFAULT_WINDOW_EXPIRED_LABELS,
|
|
2052
|
+
DOCUMENT_SOURCE_FILTER,
|
|
2405
2053
|
DateDivider,
|
|
2054
|
+
DocumentsLibrary,
|
|
2055
|
+
EMOJI_CATEGORIES,
|
|
2406
2056
|
EmojiPicker,
|
|
2407
2057
|
FileIcon,
|
|
2408
2058
|
HANDLE_KIND,
|
|
2059
|
+
InteractiveMessage,
|
|
2409
2060
|
Lightbox,
|
|
2410
2061
|
MediaRenderer,
|
|
2411
2062
|
MessageBubble,
|
|
@@ -2432,6 +2083,7 @@ export {
|
|
|
2432
2083
|
capabilitiesOf,
|
|
2433
2084
|
channelFiltersFor,
|
|
2434
2085
|
contactFlag,
|
|
2086
|
+
createMediaUrlResolver,
|
|
2435
2087
|
downloadTextFile,
|
|
2436
2088
|
formatContactHandle,
|
|
2437
2089
|
formatDateTime,
|
|
@@ -2444,6 +2096,7 @@ export {
|
|
|
2444
2096
|
isWindowBlocking,
|
|
2445
2097
|
parseWhatsAppFormatting,
|
|
2446
2098
|
phoneInitials,
|
|
2099
|
+
searchEmojis,
|
|
2447
2100
|
toast,
|
|
2448
2101
|
useConversationActions,
|
|
2449
2102
|
useConversationContext,
|