@fayz-ai/plugin-conversations 0.40.0 → 0.41.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.
|
@@ -2,7 +2,7 @@ import { ConversationsContextProvider, useConversationsStore, assinarChegada, us
|
|
|
2
2
|
import { providersApi } from './chunk-HMWUU5O7.js';
|
|
3
3
|
import * as React7 from 'react';
|
|
4
4
|
import React7__default from 'react';
|
|
5
|
-
import { SquarePen, MessageSquare, LifeBuoy, Globe, Mail, Instagram, Phone, Search,
|
|
5
|
+
import { SquarePen, MessageSquare, LifeBuoy, Globe, Mail, Instagram, Phone, Search, User, Archive, Inbox, CheckCheck, ChevronLeft, MoreHorizontal, MailWarning, ArchiveRestore, X, Building2, Tag, Ban, ThumbsDown, PhoneMissed, MessageSquareOff, PhoneOff, MoreVertical, Loader2, Forward, AlertTriangle, Check, Clock, ExternalLink, Reply, FileText, Trash2, Paperclip, Square, Mic, Send, Snowflake, Sun, Flame, BarChart3, MapPin, UserRound, Copy, Download } from 'lucide-react';
|
|
6
6
|
import { PageHeaderActions, cn, Button, Modal, ModalContent, ModalHeader, ModalTitle, ModalBody, Textarea, ModalFooter, Input, FilterChip, Skeleton, Dropdown, DropdownTrigger, DropdownContent, DropdownItem, toast, DropdownSub, DropdownSubTrigger, DropdownSubContent, ModalDescription } from '@fayz-ai/ui';
|
|
7
7
|
import { useRightRailStore, PageActions, useLimitGuard, ContactPicker, invalidateLimit, useConnectors } from '@fayz-ai/admin';
|
|
8
8
|
import { currentAppPath, appHref, onAppPathChange, replaceApp, useTranslation, useActiveTenantId, errorMessage, getSupabaseClientOptional, getActiveTenantId } from '@fayz-ai/core';
|
|
@@ -149,16 +149,34 @@ function ConversationList({ className }) {
|
|
|
149
149
|
setSearch
|
|
150
150
|
} = useConversationsStore((s) => s);
|
|
151
151
|
const [archived, setArchived] = React7__default.useState(false);
|
|
152
|
-
const [mineOnly, setMineOnly] = React7__default.useState(false);
|
|
153
152
|
const [me, setMe] = React7__default.useState(null);
|
|
154
153
|
React7__default.useEffect(() => {
|
|
155
154
|
void currentUserId().then(setMe);
|
|
156
155
|
}, []);
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
156
|
+
const mine = Boolean(me) && leadOwnerFilter === me;
|
|
157
|
+
const decided = React7__default.useRef(false);
|
|
158
|
+
React7__default.useEffect(() => {
|
|
159
|
+
if (decided.current || !me || loading || conversations.length === 0) return;
|
|
160
|
+
decided.current = true;
|
|
161
|
+
let pref = null;
|
|
162
|
+
try {
|
|
163
|
+
pref = localStorage.getItem("conversas.owner");
|
|
164
|
+
} catch {
|
|
165
|
+
}
|
|
166
|
+
const ownsAny = conversations.some((c) => c.leadOwnerId === me);
|
|
167
|
+
if (leadOwnerFilter === void 0 && (pref === "me" || pref === null && ownsAny)) void setLeadOwnerFilter(me);
|
|
168
|
+
}, [me, loading, conversations, leadOwnerFilter, setLeadOwnerFilter]);
|
|
169
|
+
const pickOwner = (v) => {
|
|
170
|
+
try {
|
|
171
|
+
localStorage.setItem("conversas.owner", v && v === me ? "me" : "any");
|
|
172
|
+
} catch {
|
|
173
|
+
}
|
|
174
|
+
void setLeadOwnerFilter(v);
|
|
175
|
+
};
|
|
176
|
+
const mineCount = React7__default.useMemo(
|
|
177
|
+
() => mine ? conversations.filter((c) => c.status !== "closed" && isWaitingOnUs(c)).length : 0,
|
|
178
|
+
[conversations, mine]
|
|
160
179
|
);
|
|
161
|
-
const mineCount = React7__default.useMemo(() => conversations.filter(isMineWaiting).length, [conversations, isMineWaiting]);
|
|
162
180
|
const [inbox, setInbox] = React7__default.useState("commercial");
|
|
163
181
|
const inboxes = React7__default.useMemo(() => new Set(conversations.map((c) => c.inbox ?? "commercial")), [conversations]);
|
|
164
182
|
const bothInboxes = inboxes.size > 1;
|
|
@@ -166,8 +184,8 @@ function ConversationList({ className }) {
|
|
|
166
184
|
const shown = React7__default.useMemo(
|
|
167
185
|
// Waiting on us stays pinned on top (newest first among them): a red thread
|
|
168
186
|
// is a contact to make, and it must not sink under newer chatter.
|
|
169
|
-
() => conversations.filter((c) => !bothInboxes || (c.inbox ?? "commercial") === inbox).filter((c) =>
|
|
170
|
-
[conversations, archived, bothInboxes, inbox
|
|
187
|
+
() => conversations.filter((c) => !bothInboxes || (c.inbox ?? "commercial") === inbox).filter((c) => archived ? c.status === "closed" : c.status !== "closed").map((c, i) => ({ c, i, waiting: isWaitingOnUs(c) })).sort((a, b) => a.waiting === b.waiting ? a.i - b.i : a.waiting ? -1 : 1).map(({ c }) => c),
|
|
188
|
+
[conversations, archived, bothInboxes, inbox]
|
|
171
189
|
);
|
|
172
190
|
const donos = React7__default.useMemo(() => {
|
|
173
191
|
const vistos = /* @__PURE__ */ new Map();
|
|
@@ -209,56 +227,38 @@ function ConversationList({ className }) {
|
|
|
209
227
|
}
|
|
210
228
|
)
|
|
211
229
|
] }),
|
|
212
|
-
/* @__PURE__ */
|
|
213
|
-
|
|
230
|
+
/* @__PURE__ */ jsx("div", { className: "mt-2 flex flex-wrap gap-1", children: FILTERS.map((id) => {
|
|
231
|
+
const off = id !== "all" && connected !== void 0 && !connected[id];
|
|
232
|
+
return /* @__PURE__ */ jsx(
|
|
214
233
|
Button,
|
|
215
234
|
{
|
|
216
235
|
variant: "bare",
|
|
217
236
|
size: "bare",
|
|
218
|
-
onClick: () =>
|
|
219
|
-
title:
|
|
237
|
+
onClick: () => setChannelFilter(id),
|
|
238
|
+
title: off ? t("conversations.filter.notConnected") : void 0,
|
|
220
239
|
className: cn(
|
|
221
|
-
"
|
|
222
|
-
|
|
240
|
+
"rounded-full border px-2.5 py-1 text-xs font-medium transition-colors",
|
|
241
|
+
channelFilter === id ? "border-transparent bg-primary text-primary-foreground" : off ? "border-dashed border-muted-foreground/40 bg-transparent text-muted-foreground hover:bg-muted/50" : "border-transparent bg-muted text-muted-foreground hover:bg-muted/70"
|
|
223
242
|
),
|
|
224
|
-
children:
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
),
|
|
231
|
-
FILTERS.map((id) => {
|
|
232
|
-
const off = id !== "all" && connected !== void 0 && !connected[id];
|
|
233
|
-
return /* @__PURE__ */ jsx(
|
|
234
|
-
Button,
|
|
235
|
-
{
|
|
236
|
-
variant: "bare",
|
|
237
|
-
size: "bare",
|
|
238
|
-
onClick: () => setChannelFilter(id),
|
|
239
|
-
title: off ? t("conversations.filter.notConnected") : void 0,
|
|
240
|
-
className: cn(
|
|
241
|
-
"rounded-full border px-2.5 py-1 text-xs font-medium transition-colors",
|
|
242
|
-
channelFilter === id ? "border-transparent bg-primary text-primary-foreground" : off ? "border-dashed border-muted-foreground/40 bg-transparent text-muted-foreground hover:bg-muted/50" : "border-transparent bg-muted text-muted-foreground hover:bg-muted/70"
|
|
243
|
-
),
|
|
244
|
-
children: t(`conversations.filter.${id}`)
|
|
245
|
-
},
|
|
246
|
-
id
|
|
247
|
-
);
|
|
248
|
-
})
|
|
249
|
-
] }),
|
|
243
|
+
children: t(`conversations.filter.${id}`)
|
|
244
|
+
},
|
|
245
|
+
id
|
|
246
|
+
);
|
|
247
|
+
}) }),
|
|
250
248
|
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex flex-wrap items-center gap-1", children: [
|
|
251
|
-
donos.length > 0 && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
249
|
+
(donos.length > 0 || mine) && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
252
250
|
FilterChip,
|
|
253
251
|
{
|
|
254
252
|
label: t("conversations.contact.leadOwner"),
|
|
255
253
|
icon: User,
|
|
256
254
|
allLabel: t("conversations.filter.anyOwner"),
|
|
257
|
-
options: [
|
|
255
|
+
options: [
|
|
256
|
+
...me ? [{ value: me, label: mine && mineCount > 0 ? `Meus leads \xB7 ${mineCount} esperando` : "Meus leads" }] : [],
|
|
257
|
+
{ value: "none", label: t("conversations.filter.noOwner") },
|
|
258
|
+
...donos.filter((d) => d.value !== me)
|
|
259
|
+
],
|
|
258
260
|
value: leadOwnerFilter,
|
|
259
|
-
onChange: (v) =>
|
|
260
|
-
void setLeadOwnerFilter(v);
|
|
261
|
-
}
|
|
261
|
+
onChange: (v) => pickOwner(v)
|
|
262
262
|
}
|
|
263
263
|
) }),
|
|
264
264
|
/* @__PURE__ */ jsxs(
|
|
@@ -294,11 +294,24 @@ function ConversationList({ className }) {
|
|
|
294
294
|
/* @__PURE__ */ jsx(Skeleton, { className: "mt-1.5 h-3 w-3/4" })
|
|
295
295
|
] })
|
|
296
296
|
] }, i)),
|
|
297
|
-
!loading && shown.length === 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-2 p-8 text-center text-muted-foreground", children: [
|
|
297
|
+
!loading && mine && !archived && shown.length === 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-2 p-8 text-center text-muted-foreground", children: [
|
|
298
|
+
/* @__PURE__ */ jsx(Inbox, { className: "h-6 w-6" }),
|
|
299
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm", children: "Voc\xEA ainda n\xE3o tem leads nas conversas." }),
|
|
300
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "outline", onClick: () => pickOwner(void 0), children: "Ver todas as conversas" })
|
|
301
|
+
] }),
|
|
302
|
+
!loading && !(mine && !archived) && shown.length === 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-2 p-8 text-center text-muted-foreground", children: [
|
|
298
303
|
/* @__PURE__ */ jsx(Inbox, { className: "h-6 w-6" }),
|
|
299
304
|
/* @__PURE__ */ jsx("p", { className: "text-sm", children: archived ? t("conversations.list.emptyArchived") : t("conversations.list.empty") })
|
|
300
305
|
] }),
|
|
301
|
-
shown.
|
|
306
|
+
!loading && mine && !archived && shown.length > 0 && !isWaitingOnUs(shown[0]) && /* @__PURE__ */ jsxs("div", { className: "m-3 flex items-center gap-2 rounded-lg border border-success/30 bg-success-soft px-3 py-2.5 text-sm text-success-soft-foreground", children: [
|
|
307
|
+
/* @__PURE__ */ jsx(CheckCheck, { className: "h-4 w-4 shrink-0" }),
|
|
308
|
+
" Nenhum lead esperando sua resposta."
|
|
309
|
+
] }),
|
|
310
|
+
shown.map((c, idx) => {
|
|
311
|
+
const sectionHeader = mine && !archived ? idx === 0 && isWaitingOnUs(c) ? /* @__PURE__ */ jsxs("p", { className: "sticky top-0 z-[1] bg-destructive-soft px-3 py-1.5 text-xs font-semibold text-destructive-soft-foreground", children: [
|
|
312
|
+
"Esperando sua resposta \xB7 ",
|
|
313
|
+
shown.filter(isWaitingOnUs).length
|
|
314
|
+
] }, `h-wait`) : idx > 0 && isWaitingOnUs(shown[idx - 1]) && !isWaitingOnUs(c) ? /* @__PURE__ */ jsx("p", { className: "bg-muted/60 px-3 py-1.5 text-xs font-medium text-muted-foreground", children: "Em dia" }, `h-ok`) : null : null;
|
|
302
315
|
const active = c.id === selectedId;
|
|
303
316
|
const unread = isWaitingOnUs(c);
|
|
304
317
|
return (
|
|
@@ -306,67 +319,70 @@ function ConversationList({ className }) {
|
|
|
306
319
|
// aninhar, e o navegador resolve isso silenciosamente movendo o
|
|
307
320
|
// interno para fora — a linha inteira deixa de ser clicável e
|
|
308
321
|
// ninguém entende por quê.
|
|
309
|
-
/* @__PURE__ */ jsxs(
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
/* @__PURE__ */
|
|
335
|
-
|
|
336
|
-
/* @__PURE__ */
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
/* @__PURE__ */ jsx(
|
|
343
|
-
c.leadOwnerName
|
|
322
|
+
/* @__PURE__ */ jsxs(React7__default.Fragment, { children: [
|
|
323
|
+
sectionHeader,
|
|
324
|
+
/* @__PURE__ */ jsxs("div", { className: "group relative", children: [
|
|
325
|
+
/* @__PURE__ */ jsxs(
|
|
326
|
+
Button,
|
|
327
|
+
{
|
|
328
|
+
variant: "bare",
|
|
329
|
+
size: "bare",
|
|
330
|
+
onClick: () => select(c.id),
|
|
331
|
+
className: cn(
|
|
332
|
+
"flex w-full items-start justify-start gap-3 rounded-none border-b border-border/50 px-3 py-3 text-left font-normal transition-colors",
|
|
333
|
+
// Um TOM da cor de marca, e não `bg-accent`.
|
|
334
|
+
//
|
|
335
|
+
// `bg-accent` resolve para quase preto neste tema, e a linha da
|
|
336
|
+
// conversa aberta ficava escura sobre escura. Trocar junto o
|
|
337
|
+
// `text-accent-foreground` deixava legível, mas pintava de
|
|
338
|
+
// preto a única linha que se está a ler — chamava mais atenção
|
|
339
|
+
// que a conversa.
|
|
340
|
+
//
|
|
341
|
+
// `bg-primary/10` é um véu: o texto continua com as cores dele,
|
|
342
|
+
// a seleção se lê como seleção e não como bloco, e funciona nos
|
|
343
|
+
// dois temas porque não presume nada sobre o fundo.
|
|
344
|
+
active ? "bg-primary/10" : "hover:bg-muted/50"
|
|
345
|
+
),
|
|
346
|
+
children: [
|
|
347
|
+
/* @__PURE__ */ jsx(Avatar, { name: c.contactName, accent: c.accent, channel: c.channel }),
|
|
348
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
349
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
350
|
+
/* @__PURE__ */ jsx("span", { className: cn("truncate text-sm text-foreground", unread ? "font-semibold" : "font-medium"), children: c.contactName }),
|
|
351
|
+
/* @__PURE__ */ jsx("span", { className: cn("shrink-0 text-[11px]", unread ? "font-semibold text-primary" : "text-muted-foreground"), children: relativeTime(c.lastMessageAt) })
|
|
352
|
+
] }),
|
|
353
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-2", children: [
|
|
354
|
+
/* @__PURE__ */ jsx(ChannelBadge, { channel: c.channel }),
|
|
355
|
+
c.status !== "open" && /* @__PURE__ */ jsx("span", { className: "text-[10px] uppercase tracking-wide text-muted-foreground/70", children: t(`conversations.status.${c.status}`) }),
|
|
356
|
+
c.leadOwnerName && /* @__PURE__ */ jsxs("span", { className: "inline-flex shrink-0 items-center gap-0.5 rounded-full bg-muted px-1.5 text-[10px] text-muted-foreground", children: [
|
|
357
|
+
/* @__PURE__ */ jsx(User, { className: "h-2.5 w-2.5" }),
|
|
358
|
+
c.leadOwnerName.split(" ")[0]
|
|
359
|
+
] })
|
|
360
|
+
] }),
|
|
361
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center justify-between gap-2", children: [
|
|
362
|
+
/* @__PURE__ */ jsx("span", { className: cn("truncate text-xs", unread ? "text-foreground" : "text-muted-foreground"), children: /* @__PURE__ */ jsx(MessagePreview, { text: c.lastMessagePreview }) }),
|
|
363
|
+
unread && /* @__PURE__ */ jsx("span", { className: "flex h-[18px] min-w-[18px] shrink-0 items-center justify-center rounded-full bg-destructive px-1.5 text-[10px] font-semibold text-destructive-foreground group-hover:invisible", children: c.unreadCount > 0 ? c.unreadCount : "\xB7" })
|
|
344
364
|
] })
|
|
345
|
-
] }),
|
|
346
|
-
/* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center justify-between gap-2", children: [
|
|
347
|
-
/* @__PURE__ */ jsx("span", { className: cn("truncate text-xs", unread ? "text-foreground" : "text-muted-foreground"), children: /* @__PURE__ */ jsx(MessagePreview, { text: c.lastMessagePreview }) }),
|
|
348
|
-
unread && /* @__PURE__ */ jsx("span", { className: "flex h-[18px] min-w-[18px] shrink-0 items-center justify-center rounded-full bg-destructive px-1.5 text-[10px] font-semibold text-destructive-foreground group-hover:invisible", children: c.unreadCount > 0 ? c.unreadCount : "\xB7" })
|
|
349
365
|
] })
|
|
350
|
-
]
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
)
|
|
366
|
+
]
|
|
367
|
+
}
|
|
368
|
+
),
|
|
369
|
+
unread && /* @__PURE__ */ jsx(
|
|
370
|
+
Button,
|
|
371
|
+
{
|
|
372
|
+
variant: "bare",
|
|
373
|
+
size: "bare",
|
|
374
|
+
type: "button",
|
|
375
|
+
title: t("conversations.markRead"),
|
|
376
|
+
"aria-label": t("conversations.markRead"),
|
|
377
|
+
onClick: (e) => {
|
|
378
|
+
e.stopPropagation();
|
|
379
|
+
void markRead(c.id);
|
|
380
|
+
},
|
|
381
|
+
className: "absolute bottom-2.5 right-2.5 hidden rounded-full p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground group-hover:block",
|
|
382
|
+
children: /* @__PURE__ */ jsx(CheckCheck, { className: "h-3.5 w-3.5" })
|
|
383
|
+
}
|
|
384
|
+
)
|
|
385
|
+
] })
|
|
370
386
|
] }, c.id)
|
|
371
387
|
);
|
|
372
388
|
})
|
|
@@ -2143,5 +2159,5 @@ function ConversationsPage({ store, config }) {
|
|
|
2143
2159
|
}
|
|
2144
2160
|
|
|
2145
2161
|
export { ConversationsPage, conversationIdFromPath };
|
|
2146
|
-
//# sourceMappingURL=ConversationsPage-
|
|
2147
|
-
//# sourceMappingURL=ConversationsPage-
|
|
2162
|
+
//# sourceMappingURL=ConversationsPage-Z3YKLAOJ.js.map
|
|
2163
|
+
//# sourceMappingURL=ConversationsPage-Z3YKLAOJ.js.map
|