@greatapps/greatchat-ui 0.1.3 → 0.1.5
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/index.d.ts +19 -1
- package/dist/index.js +128 -0
- package/dist/index.js.map +1 -1
- package/package.json +9 -3
- package/src/components/channel-card.tsx +100 -0
- package/src/components/index.ts +6 -0
- package/src/components/whatsapp-status-badge.tsx +72 -0
- package/src/index.ts +4 -0
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ClassValue } from 'clsx';
|
|
|
2
2
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
3
3
|
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
5
6
|
|
|
6
7
|
interface ApiResponse<T> {
|
|
7
8
|
status: 0 | 1;
|
|
@@ -466,4 +467,21 @@ interface NewConversationDialogProps {
|
|
|
466
467
|
}
|
|
467
468
|
declare function NewConversationDialog({ open, onOpenChange, contacts, channels, existingInboxes, onCreateInbox, isCreating, onCreated, }: NewConversationDialogProps): react_jsx_runtime.JSX.Element;
|
|
468
469
|
|
|
469
|
-
|
|
470
|
+
interface ChannelCardProps {
|
|
471
|
+
channel: Channel;
|
|
472
|
+
config: GchatHookConfig;
|
|
473
|
+
onEdit?: () => void;
|
|
474
|
+
onDelete?: () => void;
|
|
475
|
+
linkedAgentName?: string;
|
|
476
|
+
linkedAgentActive?: boolean;
|
|
477
|
+
actions?: ReactNode;
|
|
478
|
+
}
|
|
479
|
+
declare function ChannelCard({ channel, config, onEdit, onDelete, linkedAgentName, linkedAgentActive, actions, }: ChannelCardProps): react_jsx_runtime.JSX.Element;
|
|
480
|
+
|
|
481
|
+
interface WhatsappStatusBadgeProps {
|
|
482
|
+
status: WhatsappStatus | undefined | null;
|
|
483
|
+
hasSession: boolean;
|
|
484
|
+
}
|
|
485
|
+
declare function WhatsappStatusBadge({ status, hasSession, }: WhatsappStatusBadgeProps): react_jsx_runtime.JSX.Element;
|
|
486
|
+
|
|
487
|
+
export { type ApiResponse, type Channel, ChannelCard, type ChannelCardProps, ChatInput, type ChatInputProps, ChatView, type ChatViewProps, type Contact, ContactAvatar, type ContactAvatarProps, ContactInfoPanel, type ContactInfoPanelProps, DEFAULT_CHANNEL_STATUS_POLLING, DEFAULT_INBOX_POLLING, DEFAULT_MESSAGES_POLLING, DEFAULT_QR_POLLING, type GchatClientConfig, type GchatHookConfig, type Inbox, InboxItem, type InboxItemProps, type InboxMessage, InboxSidebar, type InboxSidebarProps, type InboxStats, MessageBubble, type MessageBubbleProps, type MessageContentType, NewConversationDialog, type NewConversationDialogProps, type WhatsappStatus, WhatsappStatusBadge, type WhatsappStatusBadgeProps, cn, createGchatClient, formatDateGroup, formatMessageTime, groupMessagesByDate, useChannelQR, useChannelWhatsappStatus, useChannels, useConnectChannel, useContacts, useCreateChannel, useCreateContact, useCreateInbox, useDeleteChannel, useDeleteContact, useDeleteInbox, useDisconnectChannel, useEditMessage, useGetContact, useInbox, useInboxMessages, useInboxStats, useInboxes, useLogoutChannel, useRetryMessage, useRevokeMessage, useSendMessage, useUpdateChannel, useUpdateContact, useUpdateInbox };
|
package/dist/index.js
CHANGED
|
@@ -2474,7 +2474,134 @@ function NewConversationDialog({
|
|
|
2474
2474
|
] })
|
|
2475
2475
|
] }) });
|
|
2476
2476
|
}
|
|
2477
|
+
|
|
2478
|
+
// src/components/whatsapp-status-badge.tsx
|
|
2479
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
2480
|
+
function WhatsappStatusBadge({
|
|
2481
|
+
status,
|
|
2482
|
+
hasSession
|
|
2483
|
+
}) {
|
|
2484
|
+
if (!hasSession) {
|
|
2485
|
+
return /* @__PURE__ */ jsx24(Badge, { variant: "outline", className: "text-xs text-zinc-500 border-zinc-300", children: "Sem sess\xE3o" });
|
|
2486
|
+
}
|
|
2487
|
+
if (!status) {
|
|
2488
|
+
return /* @__PURE__ */ jsx24(Badge, { variant: "outline", className: "text-xs text-zinc-500 border-zinc-300", children: "Verificando..." });
|
|
2489
|
+
}
|
|
2490
|
+
if (status.connected && status.logged_in) {
|
|
2491
|
+
return /* @__PURE__ */ jsx24(
|
|
2492
|
+
Badge,
|
|
2493
|
+
{
|
|
2494
|
+
variant: "outline",
|
|
2495
|
+
className: "text-xs bg-green-500/10 text-green-600 border-green-200",
|
|
2496
|
+
children: "Conectado"
|
|
2497
|
+
}
|
|
2498
|
+
);
|
|
2499
|
+
}
|
|
2500
|
+
if (status.connected && !status.logged_in) {
|
|
2501
|
+
return /* @__PURE__ */ jsx24(
|
|
2502
|
+
Badge,
|
|
2503
|
+
{
|
|
2504
|
+
variant: "outline",
|
|
2505
|
+
className: "text-xs bg-yellow-500/10 text-yellow-600 border-yellow-200",
|
|
2506
|
+
children: "Reconectando..."
|
|
2507
|
+
}
|
|
2508
|
+
);
|
|
2509
|
+
}
|
|
2510
|
+
if (status.logged_in && !status.connected) {
|
|
2511
|
+
return /* @__PURE__ */ jsx24(
|
|
2512
|
+
Badge,
|
|
2513
|
+
{
|
|
2514
|
+
variant: "outline",
|
|
2515
|
+
className: "text-xs bg-yellow-500/10 text-yellow-600 border-yellow-200",
|
|
2516
|
+
children: "Desconectado"
|
|
2517
|
+
}
|
|
2518
|
+
);
|
|
2519
|
+
}
|
|
2520
|
+
return /* @__PURE__ */ jsx24(
|
|
2521
|
+
Badge,
|
|
2522
|
+
{
|
|
2523
|
+
variant: "outline",
|
|
2524
|
+
className: "text-xs bg-red-500/10 text-red-600 border-red-200",
|
|
2525
|
+
children: "Offline"
|
|
2526
|
+
}
|
|
2527
|
+
);
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
// src/components/channel-card.tsx
|
|
2531
|
+
import { jsx as jsx25, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2532
|
+
function ChannelCard({
|
|
2533
|
+
channel,
|
|
2534
|
+
config,
|
|
2535
|
+
onEdit,
|
|
2536
|
+
onDelete,
|
|
2537
|
+
linkedAgentName,
|
|
2538
|
+
linkedAgentActive = true,
|
|
2539
|
+
actions
|
|
2540
|
+
}) {
|
|
2541
|
+
const { data: status } = useChannelWhatsappStatus(config, channel.id);
|
|
2542
|
+
const hasSession = !!channel.external_id;
|
|
2543
|
+
return /* @__PURE__ */ jsxs14("div", { className: "rounded-lg border bg-card text-card-foreground shadow-sm", children: [
|
|
2544
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex flex-row items-start justify-between p-4 pb-2", children: [
|
|
2545
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2", children: [
|
|
2546
|
+
/* @__PURE__ */ jsx25("div", { className: "flex h-9 w-9 items-center justify-center rounded-md bg-green-500/10", children: /* @__PURE__ */ jsx25("svg", { className: "h-5 w-5 text-green-600", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx25("path", { d: "M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z" }) }) }),
|
|
2547
|
+
/* @__PURE__ */ jsxs14("div", { children: [
|
|
2548
|
+
/* @__PURE__ */ jsx25("h3", { className: "text-sm font-medium", children: channel.name }),
|
|
2549
|
+
/* @__PURE__ */ jsx25("p", { className: "text-xs text-muted-foreground", children: channel.identifier || "Sem n\xFAmero" })
|
|
2550
|
+
] })
|
|
2551
|
+
] }),
|
|
2552
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-1", children: [
|
|
2553
|
+
onEdit && /* @__PURE__ */ jsx25(
|
|
2554
|
+
Button,
|
|
2555
|
+
{
|
|
2556
|
+
variant: "ghost",
|
|
2557
|
+
size: "icon",
|
|
2558
|
+
className: "h-7 w-7",
|
|
2559
|
+
onClick: onEdit,
|
|
2560
|
+
children: /* @__PURE__ */ jsxs14("svg", { className: "h-3.5 w-3.5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
2561
|
+
/* @__PURE__ */ jsx25("path", { d: "M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z" }),
|
|
2562
|
+
/* @__PURE__ */ jsx25("path", { d: "m15 5 4 4" })
|
|
2563
|
+
] })
|
|
2564
|
+
}
|
|
2565
|
+
),
|
|
2566
|
+
onDelete && /* @__PURE__ */ jsx25(
|
|
2567
|
+
Button,
|
|
2568
|
+
{
|
|
2569
|
+
variant: "ghost",
|
|
2570
|
+
size: "icon",
|
|
2571
|
+
className: "h-7 w-7 text-destructive hover:text-destructive",
|
|
2572
|
+
onClick: onDelete,
|
|
2573
|
+
children: /* @__PURE__ */ jsxs14("svg", { className: "h-3.5 w-3.5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
2574
|
+
/* @__PURE__ */ jsx25("path", { d: "M3 6h18" }),
|
|
2575
|
+
/* @__PURE__ */ jsx25("path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" }),
|
|
2576
|
+
/* @__PURE__ */ jsx25("path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" })
|
|
2577
|
+
] })
|
|
2578
|
+
}
|
|
2579
|
+
),
|
|
2580
|
+
/* @__PURE__ */ jsx25(WhatsappStatusBadge, { status, hasSession })
|
|
2581
|
+
] })
|
|
2582
|
+
] }),
|
|
2583
|
+
/* @__PURE__ */ jsxs14("div", { className: "p-4 pt-0 space-y-3", children: [
|
|
2584
|
+
linkedAgentName && /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-1.5 text-xs text-muted-foreground", children: [
|
|
2585
|
+
/* @__PURE__ */ jsxs14("svg", { className: "h-3.5 w-3.5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
2586
|
+
/* @__PURE__ */ jsx25("path", { d: "M12 8V4H8" }),
|
|
2587
|
+
/* @__PURE__ */ jsx25("rect", { width: "16", height: "12", x: "4", y: "8", rx: "2" }),
|
|
2588
|
+
/* @__PURE__ */ jsx25("path", { d: "M2 14h2" }),
|
|
2589
|
+
/* @__PURE__ */ jsx25("path", { d: "M20 14h2" }),
|
|
2590
|
+
/* @__PURE__ */ jsx25("path", { d: "M15 13v2" }),
|
|
2591
|
+
/* @__PURE__ */ jsx25("path", { d: "M9 13v2" })
|
|
2592
|
+
] }),
|
|
2593
|
+
/* @__PURE__ */ jsxs14("span", { children: [
|
|
2594
|
+
"Agent: ",
|
|
2595
|
+
/* @__PURE__ */ jsx25("strong", { children: linkedAgentName })
|
|
2596
|
+
] }),
|
|
2597
|
+
!linkedAgentActive && /* @__PURE__ */ jsx25("span", { className: "text-[10px] px-1 py-0 border rounded", children: "inativo" })
|
|
2598
|
+
] }),
|
|
2599
|
+
actions
|
|
2600
|
+
] })
|
|
2601
|
+
] });
|
|
2602
|
+
}
|
|
2477
2603
|
export {
|
|
2604
|
+
ChannelCard,
|
|
2478
2605
|
ChatInput,
|
|
2479
2606
|
ChatView,
|
|
2480
2607
|
ContactAvatar,
|
|
@@ -2487,6 +2614,7 @@ export {
|
|
|
2487
2614
|
InboxSidebar,
|
|
2488
2615
|
MessageBubble,
|
|
2489
2616
|
NewConversationDialog,
|
|
2617
|
+
WhatsappStatusBadge,
|
|
2490
2618
|
cn,
|
|
2491
2619
|
createGchatClient,
|
|
2492
2620
|
formatDateGroup,
|