@fayz-ai/plugin-conversations 0.23.15 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-LJKLHGFX.js → ConversationsPage-BTRYZPM7.js} +129 -123
- package/dist/ConversationsPage-BTRYZPM7.js.map +1 -0
- package/dist/{ConversationsSettings-7UQYM26R.js → ConversationsSettings-Q3PGQMB3.js} +3 -3
- package/dist/{ConversationsSettings-7UQYM26R.js.map → ConversationsSettings-Q3PGQMB3.js.map} +1 -1
- package/dist/{chunk-3FZX3ZQ3.js → chunk-2JV6B366.js} +77 -76
- package/dist/chunk-2JV6B366.js.map +1 -0
- package/dist/chunk-X7BP2JH6.js +74 -0
- package/dist/chunk-X7BP2JH6.js.map +1 -0
- package/dist/components/InboxWatcher.d.ts +6 -15
- package/dist/components/InboxWatcher.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +122 -143
- package/dist/index.js.map +1 -1
- package/dist/integrations/evolution/connectorDef.d.ts +4 -0
- package/dist/integrations/evolution/connectorDef.d.ts.map +1 -0
- package/dist/views/ConversationList.d.ts.map +1 -1
- package/dist/views/WhatsAppConnectionFooter.d.ts +8 -0
- package/dist/views/WhatsAppConnectionFooter.d.ts.map +1 -0
- package/package.json +4 -4
- package/dist/ConversationsPage-4V4VLM4D.js +0 -47
- package/dist/ConversationsPage-4V4VLM4D.js.map +0 -1
- package/dist/chunk-3FZX3ZQ3.js.map +0 -1
- package/dist/chunk-LJKLHGFX.js.map +0 -1
- package/dist/components/ConversationsRailPanel.d.ts +0 -15
- package/dist/components/ConversationsRailPanel.d.ts.map +0 -1
|
@@ -1,48 +1,13 @@
|
|
|
1
|
+
import { ConversationsContextProvider, useConversationsStore, assinarChegada, useConversationsConfig, CHANNEL_LABELS, isWaitingOnUs } from './chunk-X7BP2JH6.js';
|
|
1
2
|
import { providersApi } from './chunk-HMWUU5O7.js';
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
|
-
import { SquarePen, MessageSquare, Globe, Mail, Instagram, Phone, Search, User, Inbox, CheckCheck, ChevronLeft, Archive, PanelRight, Send, X, MapPin, Tag, StickyNote, Link2, MoreVertical, Loader2, AlertTriangle, Check, Clock, Snowflake, Sun, Flame, Building2, ExternalLink, UserRound, Copy, FileText, Download } from 'lucide-react';
|
|
3
|
+
import * as React9 from 'react';
|
|
4
|
+
import React9__default from 'react';
|
|
5
|
+
import { SquarePen, MessageSquare, Globe, Mail, Instagram, Phone, Search, User, Inbox, CheckCheck, ChevronLeft, Archive, PanelRight, Send, X, MapPin, Tag, StickyNote, Link2, CheckCircle2, MoreVertical, Loader2, AlertTriangle, Check, Clock, Snowflake, Sun, Flame, Building2, ExternalLink, UserRound, Copy, FileText, Download } from 'lucide-react';
|
|
7
6
|
import { PageHeaderActions, cn, Button, Modal, ModalContent, ModalHeader, ModalTitle, ModalBody, Textarea, ModalFooter, Input, FilterChip, Skeleton, toast } from '@fayz-ai/ui';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
var DEFAULT_CONVERSATIONS_CONFIG = {
|
|
12
|
-
contactKind: "contact"
|
|
13
|
-
};
|
|
14
|
-
var StoreContext = React10__default.createContext(null);
|
|
15
|
-
var ConfigContext = React10__default.createContext(DEFAULT_CONVERSATIONS_CONFIG);
|
|
16
|
-
function ConversationsContextProvider({
|
|
17
|
-
store,
|
|
18
|
-
config = DEFAULT_CONVERSATIONS_CONFIG,
|
|
19
|
-
children
|
|
20
|
-
}) {
|
|
21
|
-
return /* @__PURE__ */ jsx(StoreContext.Provider, { value: store, children: /* @__PURE__ */ jsx(ConfigContext.Provider, { value: config, children }) });
|
|
22
|
-
}
|
|
23
|
-
function useConversationsStore(selector) {
|
|
24
|
-
const store = React10__default.useContext(StoreContext);
|
|
25
|
-
if (!store) throw new Error("useConversationsStore must be used within ConversationsPage");
|
|
26
|
-
return useStore(store, selector);
|
|
27
|
-
}
|
|
28
|
-
function useConversationsConfig() {
|
|
29
|
-
return React10__default.useContext(ConfigContext);
|
|
30
|
-
}
|
|
7
|
+
import { useRightRailStore, PageActions, useLimitGuard, ContactPicker, invalidateLimit, useConnectors, adminNavigateTo } from '@fayz-ai/admin';
|
|
8
|
+
import { currentAppPath, appHref, useTranslation, useActiveTenantId, errorMessage, tl, getSupabaseClientOptional, getActiveTenantId } from '@fayz-ai/core';
|
|
9
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
31
10
|
|
|
32
|
-
// src/types.ts
|
|
33
|
-
var CHANNEL_LABELS = {
|
|
34
|
-
sms: "SMS",
|
|
35
|
-
whatsapp: "WhatsApp",
|
|
36
|
-
instagram: "Instagram",
|
|
37
|
-
email: "Email",
|
|
38
|
-
webchat: "Web Chat"
|
|
39
|
-
};
|
|
40
|
-
function isWaitingOnUs(conversation) {
|
|
41
|
-
if (conversation.status !== "open") return false;
|
|
42
|
-
if (conversation.acknowledgedAt && conversation.lastMessageAt && conversation.acknowledgedAt >= conversation.lastMessageAt) return false;
|
|
43
|
-
if (conversation.lastMessageDirection) return conversation.lastMessageDirection === "inbound";
|
|
44
|
-
return conversation.unreadCount > 0;
|
|
45
|
-
}
|
|
46
11
|
var CHANNEL_ICON = {
|
|
47
12
|
sms: Phone,
|
|
48
13
|
whatsapp: MessageSquare,
|
|
@@ -58,10 +23,10 @@ var CHANNEL_ACCENT = {
|
|
|
58
23
|
webchat: { color: "#f59e0b", badge: "bg-[#f59e0b]/12 text-[#b45309] dark:text-[#fcd34d]" }
|
|
59
24
|
};
|
|
60
25
|
function useMediaQuery(query) {
|
|
61
|
-
const [matches, setMatches] =
|
|
26
|
+
const [matches, setMatches] = React9__default.useState(
|
|
62
27
|
() => typeof window !== "undefined" && window.matchMedia(query).matches
|
|
63
28
|
);
|
|
64
|
-
|
|
29
|
+
React9__default.useEffect(() => {
|
|
65
30
|
if (typeof window === "undefined") return;
|
|
66
31
|
const mql = window.matchMedia(query);
|
|
67
32
|
const onChange = () => setMatches(mql.matches);
|
|
@@ -143,9 +108,9 @@ var whatsappConnected = () => {
|
|
|
143
108
|
return whatsappCache;
|
|
144
109
|
};
|
|
145
110
|
function useChannelConnections() {
|
|
146
|
-
const [whatsapp, setWhatsapp] =
|
|
111
|
+
const [whatsapp, setWhatsapp] = React9.useState(void 0);
|
|
147
112
|
const { connectors } = useConnectors({ hostPluginId: "conversations", includeGrants: false });
|
|
148
|
-
|
|
113
|
+
React9.useEffect(() => {
|
|
149
114
|
let cancelled = false;
|
|
150
115
|
void whatsappConnected().then((v) => {
|
|
151
116
|
if (!cancelled) setWhatsapp(v);
|
|
@@ -154,12 +119,48 @@ function useChannelConnections() {
|
|
|
154
119
|
cancelled = true;
|
|
155
120
|
};
|
|
156
121
|
}, []);
|
|
157
|
-
return
|
|
122
|
+
return React9.useMemo(() => {
|
|
158
123
|
if (whatsapp === void 0) return void 0;
|
|
159
124
|
const live = (needle) => (connectors ?? []).some((c) => c.state === "connected" && c.slug.toLowerCase().includes(needle));
|
|
160
125
|
return { whatsapp: whatsapp || live("whatsapp"), email: live("mail"), instagram: live("instagram") };
|
|
161
126
|
}, [whatsapp, connectors]);
|
|
162
127
|
}
|
|
128
|
+
var CONNECTORS_ROUTE = "/settings/conversations/connectors";
|
|
129
|
+
function WhatsAppConnectionFooter() {
|
|
130
|
+
const connected = useChannelConnections();
|
|
131
|
+
return /* @__PURE__ */ jsx("div", { className: "shrink-0 border-t border-border p-3", children: connected === void 0 ? /* @__PURE__ */ jsx("div", { className: "h-10", "aria-hidden": true }) : connected.whatsapp ? /* @__PURE__ */ jsxs(
|
|
132
|
+
Button,
|
|
133
|
+
{
|
|
134
|
+
variant: "bare",
|
|
135
|
+
size: "bare",
|
|
136
|
+
type: "button",
|
|
137
|
+
onClick: () => adminNavigateTo(CONNECTORS_ROUTE),
|
|
138
|
+
className: "font-normal whitespace-normal justify-start fz-tap flex h-10 w-full items-center gap-2 rounded-button px-2 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",
|
|
139
|
+
children: [
|
|
140
|
+
/* @__PURE__ */ jsx(CheckCircle2, { className: "h-4 w-4 text-[#25D366]", "aria-hidden": true }),
|
|
141
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-left", children: tl("WhatsApp connected", "WhatsApp conectado") }),
|
|
142
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-primary", children: tl("Manage", "Gerenciar") })
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
) : /* @__PURE__ */ jsxs(
|
|
146
|
+
Button,
|
|
147
|
+
{
|
|
148
|
+
variant: "bare",
|
|
149
|
+
size: "bare",
|
|
150
|
+
type: "button",
|
|
151
|
+
onClick: () => adminNavigateTo(CONNECTORS_ROUTE),
|
|
152
|
+
"data-testid": "inbox-connect-whatsapp",
|
|
153
|
+
className: "font-normal whitespace-normal fz-tap flex h-11 w-full items-center justify-center gap-2 rounded-button bg-[#25D366] text-sm font-semibold text-white shadow-sm transition-colors hover:bg-[#1EBE5A] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#25D366] focus-visible:ring-offset-2",
|
|
154
|
+
children: [
|
|
155
|
+
/* @__PURE__ */ jsx(WhatsAppMark, { className: "h-[18px] w-[18px]" }),
|
|
156
|
+
tl("Connect WhatsApp", "Conectar WhatsApp")
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
) });
|
|
160
|
+
}
|
|
161
|
+
function WhatsAppMark({ className }) {
|
|
162
|
+
return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", className, "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M17.47 14.38c-.3-.15-1.76-.87-2.03-.97-.27-.1-.47-.15-.67.15-.2.3-.77.96-.94 1.16-.17.2-.35.22-.65.07-.3-.15-1.26-.46-2.4-1.48-.89-.79-1.49-1.77-1.66-2.07-.17-.3-.02-.46.13-.61.13-.13.3-.35.45-.52.15-.17.2-.3.3-.5.1-.2.05-.37-.02-.52-.08-.15-.67-1.61-.92-2.2-.24-.58-.49-.5-.67-.51h-.57c-.2 0-.52.07-.79.37-.27.3-1.04 1.02-1.04 2.48s1.07 2.88 1.21 3.08c.15.2 2.1 3.2 5.08 4.49.71.31 1.26.49 1.69.63.71.22 1.36.19 1.87.12.57-.09 1.76-.72 2.01-1.41.25-.7.25-1.29.17-1.41-.07-.13-.27-.2-.57-.35zM12.05 21.5h-.01a9.4 9.4 0 0 1-4.8-1.32l-.34-.2-3.56.93.95-3.47-.22-.36a9.4 9.4 0 0 1-1.44-5.02c0-5.2 4.23-9.43 9.43-9.43 2.52 0 4.89.98 6.67 2.77a9.37 9.37 0 0 1 2.76 6.67c0 5.2-4.23 9.43-9.44 9.43zm8.03-17.46A11.3 11.3 0 0 0 12.05.72C5.79.72.7 5.81.7 12.07c0 2 .52 3.95 1.52 5.67L.6 23.6l6-1.57a11.32 11.32 0 0 0 5.44 1.39h.01c6.26 0 11.35-5.1 11.35-11.35 0-3.03-1.18-5.88-3.32-8.03z" }) });
|
|
163
|
+
}
|
|
163
164
|
var FILTERS = ["all", "whatsapp", "instagram", "email"];
|
|
164
165
|
function ConversationList({ className }) {
|
|
165
166
|
const t = useTranslation();
|
|
@@ -177,7 +178,7 @@ function ConversationList({ className }) {
|
|
|
177
178
|
setLeadOwnerFilter,
|
|
178
179
|
setSearch
|
|
179
180
|
} = useConversationsStore((s) => s);
|
|
180
|
-
const donos =
|
|
181
|
+
const donos = React9__default.useMemo(() => {
|
|
181
182
|
const vistos = /* @__PURE__ */ new Map();
|
|
182
183
|
for (const c of conversations) {
|
|
183
184
|
if (c.leadOwnerId) vistos.set(c.leadOwnerId, c.leadOwnerName ?? c.leadOwnerId);
|
|
@@ -318,13 +319,14 @@ function ConversationList({ className }) {
|
|
|
318
319
|
] }, c.id)
|
|
319
320
|
);
|
|
320
321
|
})
|
|
321
|
-
] })
|
|
322
|
+
] }),
|
|
323
|
+
/* @__PURE__ */ jsx(WhatsAppConnectionFooter, {})
|
|
322
324
|
] });
|
|
323
325
|
}
|
|
324
326
|
function useSendWindow(conversationId) {
|
|
325
|
-
const [row, setRow] =
|
|
326
|
-
const [providers, setProviders] =
|
|
327
|
-
|
|
327
|
+
const [row, setRow] = React9__default.useState(null);
|
|
328
|
+
const [providers, setProviders] = React9__default.useState(null);
|
|
329
|
+
React9__default.useEffect(() => {
|
|
328
330
|
let alive = true;
|
|
329
331
|
providersApi.list().then((p) => {
|
|
330
332
|
if (alive) setProviders(p);
|
|
@@ -335,7 +337,7 @@ function useSendWindow(conversationId) {
|
|
|
335
337
|
alive = false;
|
|
336
338
|
};
|
|
337
339
|
}, []);
|
|
338
|
-
|
|
340
|
+
React9__default.useEffect(() => {
|
|
339
341
|
let alive = true;
|
|
340
342
|
if (!conversationId) {
|
|
341
343
|
setRow(null);
|
|
@@ -356,7 +358,7 @@ function useSendWindow(conversationId) {
|
|
|
356
358
|
};
|
|
357
359
|
}, [conversationId]);
|
|
358
360
|
const provider = (providers ?? []).find((p) => p.isActive);
|
|
359
|
-
const mode =
|
|
361
|
+
const mode = React9__default.useMemo(() => {
|
|
360
362
|
if (!provider) return { kind: "blocked", reason: "no_provider" };
|
|
361
363
|
if (!provider.capabilities?.requires_template) {
|
|
362
364
|
return { kind: "free", until: null, minutesLeft: null };
|
|
@@ -431,10 +433,10 @@ function DeliveryMark({ m }) {
|
|
|
431
433
|
] });
|
|
432
434
|
}
|
|
433
435
|
function MessageMenu({ m }) {
|
|
434
|
-
const [open, setOpen] =
|
|
435
|
-
const [detail, setDetail] =
|
|
436
|
-
const [loading, setLoading] =
|
|
437
|
-
const [err, setErr] =
|
|
436
|
+
const [open, setOpen] = React9__default.useState(false);
|
|
437
|
+
const [detail, setDetail] = React9__default.useState(null);
|
|
438
|
+
const [loading, setLoading] = React9__default.useState(false);
|
|
439
|
+
const [err, setErr] = React9__default.useState(null);
|
|
438
440
|
async function load() {
|
|
439
441
|
setOpen(true);
|
|
440
442
|
if (!m.providerMessageId) return;
|
|
@@ -512,9 +514,9 @@ function temArquivo(m) {
|
|
|
512
514
|
return !!m.mediaPath && COM_ARQUIVO.has(String(m.messageType));
|
|
513
515
|
}
|
|
514
516
|
function useUrlAssinada(m, visivel) {
|
|
515
|
-
const [url, setUrl] =
|
|
516
|
-
const [erro, setErro] =
|
|
517
|
-
|
|
517
|
+
const [url, setUrl] = React9.useState(null);
|
|
518
|
+
const [erro, setErro] = React9.useState(false);
|
|
519
|
+
React9.useEffect(() => {
|
|
518
520
|
if (!visivel || url || erro || !temArquivo(m)) return;
|
|
519
521
|
let vivo = true;
|
|
520
522
|
(async () => {
|
|
@@ -549,10 +551,10 @@ function duracao(seg) {
|
|
|
549
551
|
return `${m}:${String(s).padStart(2, "0")}`;
|
|
550
552
|
}
|
|
551
553
|
function MediaBubble({ m, outbound }) {
|
|
552
|
-
const ref =
|
|
553
|
-
const [visivel, setVisivel] =
|
|
554
|
+
const ref = React9.useRef(null);
|
|
555
|
+
const [visivel, setVisivel] = React9.useState(false);
|
|
554
556
|
const { url, erro } = useUrlAssinada(m, visivel);
|
|
555
|
-
|
|
557
|
+
React9.useEffect(() => {
|
|
556
558
|
const el = ref.current;
|
|
557
559
|
if (!el || typeof IntersectionObserver === "undefined") {
|
|
558
560
|
setVisivel(true);
|
|
@@ -636,7 +638,7 @@ function MediaBubble({ m, outbound }) {
|
|
|
636
638
|
] });
|
|
637
639
|
}
|
|
638
640
|
function ContactCard({ contacts, outbound }) {
|
|
639
|
-
const [copied, setCopied] =
|
|
641
|
+
const [copied, setCopied] = React9__default.useState(null);
|
|
640
642
|
const copy = (value) => {
|
|
641
643
|
void navigator.clipboard?.writeText(value);
|
|
642
644
|
setCopied(value);
|
|
@@ -703,14 +705,14 @@ function buildRows(messages) {
|
|
|
703
705
|
function MessageThread({ selected, onTogglePanel, panelOpen, onBack, backAlways, className }) {
|
|
704
706
|
const t = useTranslation();
|
|
705
707
|
const { messages, sending, send, setStatus, refreshMessages } = useConversationsStore((s) => s);
|
|
706
|
-
const [draft, setDraft] =
|
|
708
|
+
const [draft, setDraft] = React9__default.useState("");
|
|
707
709
|
const win = useSendWindow(selected.id);
|
|
708
710
|
const canType = win.mode.kind === "free";
|
|
709
|
-
const threadRef =
|
|
710
|
-
|
|
711
|
+
const threadRef = React9__default.useRef(null);
|
|
712
|
+
React9__default.useEffect(() => {
|
|
711
713
|
threadRef.current?.scrollTo({ top: threadRef.current.scrollHeight, behavior: "smooth" });
|
|
712
714
|
}, [messages.length, selected.id]);
|
|
713
|
-
|
|
715
|
+
React9__default.useEffect(() => {
|
|
714
716
|
if (!selected.id) return;
|
|
715
717
|
let timer = null;
|
|
716
718
|
const start = () => {
|
|
@@ -739,7 +741,7 @@ function MessageThread({ selected, onTogglePanel, panelOpen, onBack, backAlways,
|
|
|
739
741
|
await send(body);
|
|
740
742
|
}
|
|
741
743
|
const accent = CHANNEL_ACCENT[selected.channel];
|
|
742
|
-
const rows =
|
|
744
|
+
const rows = React9__default.useMemo(() => buildRows(messages), [messages]);
|
|
743
745
|
return /* @__PURE__ */ jsxs("section", { className: cn("flex min-w-0 flex-1 flex-col bg-muted/20", className), children: [
|
|
744
746
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 border-b border-border bg-card px-3 py-2.5 md:px-5", children: [
|
|
745
747
|
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2 md:gap-3", children: [
|
|
@@ -851,8 +853,8 @@ var TEMP = {
|
|
|
851
853
|
cold: { icon: Snowflake, cls: "bg-info-soft text-info-soft-foreground", label: "Frio" }
|
|
852
854
|
};
|
|
853
855
|
function LeadCard({ personId, handle }) {
|
|
854
|
-
const [lead, setLead] =
|
|
855
|
-
|
|
856
|
+
const [lead, setLead] = React9__default.useState(void 0);
|
|
857
|
+
React9__default.useEffect(() => {
|
|
856
858
|
let alive = true;
|
|
857
859
|
const sb = getSupabaseClientOptional();
|
|
858
860
|
const tenantId = getActiveTenantId();
|
|
@@ -1019,14 +1021,14 @@ function NewConversationPanel({
|
|
|
1019
1021
|
const create = useConversationsStore((s) => s.create);
|
|
1020
1022
|
const config = useConversationsConfig();
|
|
1021
1023
|
const guardConversations = useLimitGuard("conversations_month");
|
|
1022
|
-
const [channel, setChannel] =
|
|
1023
|
-
const [contact, setContact] =
|
|
1024
|
-
const [typedHandle, setTypedHandle] =
|
|
1025
|
-
const [creatingContact, setCreatingContact] =
|
|
1026
|
-
const [firstMessage, setFirstMessage] =
|
|
1027
|
-
const [submitting, setSubmitting] =
|
|
1028
|
-
const [pickerKey, setPickerKey] =
|
|
1029
|
-
|
|
1024
|
+
const [channel, setChannel] = React9__default.useState("whatsapp");
|
|
1025
|
+
const [contact, setContact] = React9__default.useState(null);
|
|
1026
|
+
const [typedHandle, setTypedHandle] = React9__default.useState("");
|
|
1027
|
+
const [creatingContact, setCreatingContact] = React9__default.useState(false);
|
|
1028
|
+
const [firstMessage, setFirstMessage] = React9__default.useState("");
|
|
1029
|
+
const [submitting, setSubmitting] = React9__default.useState(false);
|
|
1030
|
+
const [pickerKey, setPickerKey] = React9__default.useState(0);
|
|
1031
|
+
React9__default.useEffect(() => {
|
|
1030
1032
|
if (open) {
|
|
1031
1033
|
setChannel("whatsapp");
|
|
1032
1034
|
setContact(null);
|
|
@@ -1138,47 +1140,14 @@ function NewConversationPanel({
|
|
|
1138
1140
|
] })
|
|
1139
1141
|
] }) });
|
|
1140
1142
|
}
|
|
1141
|
-
var porConta = /* @__PURE__ */ new Map();
|
|
1142
|
-
function assinarChegada(tenantId, ouvinte) {
|
|
1143
|
-
const supabase = getSupabaseClientOptional();
|
|
1144
|
-
if (!supabase?.channel || !tenantId) return () => {
|
|
1145
|
-
};
|
|
1146
|
-
let assinatura = porConta.get(tenantId);
|
|
1147
|
-
if (!assinatura) {
|
|
1148
|
-
const ouvintes = /* @__PURE__ */ new Set();
|
|
1149
|
-
const canal = supabase.channel(`conversas:${tenantId}`).on("broadcast", { event: "inbound" }, (msg) => {
|
|
1150
|
-
const carga = { conversationId: msg?.payload?.conversationId };
|
|
1151
|
-
for (const f of [...ouvintes]) {
|
|
1152
|
-
try {
|
|
1153
|
-
f(carga);
|
|
1154
|
-
} catch {
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
}).subscribe();
|
|
1158
|
-
assinatura = { canal, ouvintes };
|
|
1159
|
-
porConta.set(tenantId, assinatura);
|
|
1160
|
-
}
|
|
1161
|
-
assinatura.ouvintes.add(ouvinte);
|
|
1162
|
-
return () => {
|
|
1163
|
-
const a = porConta.get(tenantId);
|
|
1164
|
-
if (!a) return;
|
|
1165
|
-
a.ouvintes.delete(ouvinte);
|
|
1166
|
-
if (a.ouvintes.size === 0) {
|
|
1167
|
-
porConta.delete(tenantId);
|
|
1168
|
-
void getSupabaseClientOptional()?.removeChannel?.(a.canal);
|
|
1169
|
-
}
|
|
1170
|
-
};
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
// src/views/useCaixaAoVivo.ts
|
|
1174
1143
|
function useCaixaAoVivo() {
|
|
1175
1144
|
const tenantId = useActiveTenantId();
|
|
1176
1145
|
const load = useConversationsStore((s) => s.load);
|
|
1177
1146
|
const refreshMessages = useConversationsStore((s) => s.refreshMessages);
|
|
1178
1147
|
const selectedId = useConversationsStore((s) => s.selectedId);
|
|
1179
|
-
const abertoRef =
|
|
1148
|
+
const abertoRef = React9.useRef(selectedId);
|
|
1180
1149
|
abertoRef.current = selectedId;
|
|
1181
|
-
|
|
1150
|
+
React9.useEffect(() => {
|
|
1182
1151
|
if (!tenantId) return;
|
|
1183
1152
|
return assinarChegada(tenantId, ({ conversationId }) => {
|
|
1184
1153
|
void load();
|
|
@@ -1196,16 +1165,16 @@ function InboxView({ layout = "page", newSignal = 0 } = {}) {
|
|
|
1196
1165
|
const isWideViewport = useMediaQuery("(min-width: 1280px)");
|
|
1197
1166
|
const isWidePanel = isWideViewport && !dock;
|
|
1198
1167
|
const railOpen = useRightRailStore((s) => s.open);
|
|
1199
|
-
const [panelOpen, setPanelOpen] =
|
|
1200
|
-
const [newOpen, setNewOpen] =
|
|
1168
|
+
const [panelOpen, setPanelOpen] = React9__default.useState(false);
|
|
1169
|
+
const [newOpen, setNewOpen] = React9__default.useState(false);
|
|
1201
1170
|
const selected = conversations.find((c) => c.id === selectedId) ?? null;
|
|
1202
|
-
|
|
1171
|
+
React9__default.useEffect(() => {
|
|
1203
1172
|
if (newSignal > 0) setNewOpen(true);
|
|
1204
1173
|
}, [newSignal]);
|
|
1205
|
-
|
|
1174
|
+
React9__default.useEffect(() => {
|
|
1206
1175
|
setPanelOpen(isWidePanel && !railOpen);
|
|
1207
1176
|
}, [isWidePanel, railOpen]);
|
|
1208
|
-
const newActions =
|
|
1177
|
+
const newActions = React9__default.useMemo(() => [{
|
|
1209
1178
|
id: "new-conversation",
|
|
1210
1179
|
label: t("conversations.list.new"),
|
|
1211
1180
|
icon: SquarePen,
|
|
@@ -1262,7 +1231,44 @@ function InboxView({ layout = "page", newSignal = 0 } = {}) {
|
|
|
1262
1231
|
] })
|
|
1263
1232
|
] });
|
|
1264
1233
|
}
|
|
1234
|
+
var CHANNELS2 = ["sms", "whatsapp", "instagram", "email", "webchat"];
|
|
1235
|
+
function requestedContact() {
|
|
1236
|
+
try {
|
|
1237
|
+
const hash = currentAppPath();
|
|
1238
|
+
const qs = hash.includes("?") ? hash.slice(hash.indexOf("?") + 1) : "";
|
|
1239
|
+
if (!qs) return null;
|
|
1240
|
+
const p = new URLSearchParams(qs);
|
|
1241
|
+
const handle = (p.get("handle") ?? "").trim();
|
|
1242
|
+
const name = (p.get("name") ?? "").trim();
|
|
1243
|
+
const personId = (p.get("personId") ?? "").trim() || void 0;
|
|
1244
|
+
if (!handle) return null;
|
|
1245
|
+
const raw = (p.get("channel") ?? "whatsapp").toLowerCase();
|
|
1246
|
+
const channel = CHANNELS2.includes(raw) ? raw : "whatsapp";
|
|
1247
|
+
return { personId, name: name || handle, handle, channel };
|
|
1248
|
+
} catch {
|
|
1249
|
+
return null;
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
function ConversationsPage({ store, config }) {
|
|
1253
|
+
React9__default.useEffect(() => {
|
|
1254
|
+
const wanted = requestedContact();
|
|
1255
|
+
if (!wanted) {
|
|
1256
|
+
void store.getState().load();
|
|
1257
|
+
return;
|
|
1258
|
+
}
|
|
1259
|
+
void store.getState().openForPerson(wanted).catch(() => {
|
|
1260
|
+
void store.getState().load();
|
|
1261
|
+
});
|
|
1262
|
+
try {
|
|
1263
|
+
const hash = currentAppPath();
|
|
1264
|
+
const clean = hash.includes("?") ? hash.slice(0, hash.indexOf("?")) : hash;
|
|
1265
|
+
window.history.replaceState(null, "", appHref(clean || "/conversations"));
|
|
1266
|
+
} catch {
|
|
1267
|
+
}
|
|
1268
|
+
}, []);
|
|
1269
|
+
return /* @__PURE__ */ jsx(ConversationsContextProvider, { store, config, children: /* @__PURE__ */ jsx(InboxView, {}) });
|
|
1270
|
+
}
|
|
1265
1271
|
|
|
1266
|
-
export {
|
|
1267
|
-
//# sourceMappingURL=
|
|
1268
|
-
//# sourceMappingURL=
|
|
1272
|
+
export { ConversationsPage };
|
|
1273
|
+
//# sourceMappingURL=ConversationsPage-BTRYZPM7.js.map
|
|
1274
|
+
//# sourceMappingURL=ConversationsPage-BTRYZPM7.js.map
|