@greatapps/greatagents-ui 0.1.0 → 0.2.1

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.
@@ -0,0 +1,111 @@
1
+ import { useState } from "react";
2
+ import { useAgent } from "../hooks";
3
+ import { AgentTabs } from "../components/agents/agent-tabs";
4
+ import { AgentEditForm } from "../components/agents/agent-edit-form";
5
+ import { Badge, Button, Skeleton } from "@greatapps/greatauth-ui/ui";
6
+ import { EntityAvatar } from "@greatapps/greatauth-ui";
7
+ import { ArrowLeft, Pencil } from "lucide-react";
8
+ import type { GagentsHookConfig } from "../hooks/types";
9
+
10
+ export interface AgentDetailPageProps {
11
+ config: GagentsHookConfig;
12
+ agentId: number;
13
+ onBack?: () => void;
14
+ renderChatLink?: (inboxId: number) => React.ReactNode;
15
+ }
16
+
17
+ export function AgentDetailPage({
18
+ config,
19
+ agentId,
20
+ onBack,
21
+ renderChatLink,
22
+ }: AgentDetailPageProps) {
23
+ const { data: agent, isLoading } = useAgent(config, agentId);
24
+ const [editOpen, setEditOpen] = useState(false);
25
+
26
+ if (isLoading) {
27
+ return (
28
+ <div className="flex flex-col gap-4 p-4">
29
+ <Skeleton className="h-4 w-32" />
30
+ <Skeleton className="h-8 w-48" />
31
+ <Skeleton className="h-10 w-full" />
32
+ <Skeleton className="h-64 w-full" />
33
+ </div>
34
+ );
35
+ }
36
+
37
+ if (!agent) {
38
+ return (
39
+ <div className="flex flex-col items-center justify-center gap-2 p-8">
40
+ <p className="text-muted-foreground">Agente não encontrado</p>
41
+ {onBack && (
42
+ <Button variant="ghost" size="sm" onClick={onBack}>
43
+ <ArrowLeft className="mr-2 h-4 w-4" />
44
+ Voltar para agentes
45
+ </Button>
46
+ )}
47
+ </div>
48
+ );
49
+ }
50
+
51
+ return (
52
+ <div className="flex flex-col gap-6 p-4">
53
+ <div className="rounded-lg border p-4 md:p-6">
54
+ <div className="flex flex-col gap-4 md:flex-row md:items-start md:gap-6">
55
+ <div className="flex items-start gap-3 flex-1">
56
+ {onBack && (
57
+ <Button
58
+ variant="ghost"
59
+ size="icon"
60
+ className="shrink-0 mt-1"
61
+ onClick={onBack}
62
+ >
63
+ <ArrowLeft className="h-4 w-4" />
64
+ </Button>
65
+ )}
66
+
67
+ <EntityAvatar photo={agent.photo} name={agent.title} size="xl" />
68
+
69
+ <div className="flex-1 min-w-0">
70
+ <div className="flex items-center gap-2 flex-wrap">
71
+ <h1 className="text-xl font-semibold">{agent.title}</h1>
72
+ <Badge
73
+ variant={agent.active ? "default" : "destructive"}
74
+ className="text-xs"
75
+ >
76
+ {agent.active ? "Ativo" : "Inativo"}
77
+ </Badge>
78
+ </div>
79
+ </div>
80
+ </div>
81
+
82
+ <Button
83
+ variant="outline"
84
+ size="sm"
85
+ className="shrink-0 self-start"
86
+ onClick={() => setEditOpen(true)}
87
+ >
88
+ <Pencil className="mr-2 h-4 w-4" />
89
+ Editar
90
+ </Button>
91
+ </div>
92
+ </div>
93
+
94
+ <AgentTabs
95
+ agent={agent}
96
+ config={config}
97
+ renderChatLink={renderChatLink}
98
+ />
99
+
100
+ {editOpen && (
101
+ <AgentEditForm
102
+ agent={agent}
103
+ config={config}
104
+ idAccount={config.accountId}
105
+ open={editOpen}
106
+ onOpenChange={setEditOpen}
107
+ />
108
+ )}
109
+ </div>
110
+ );
111
+ }
@@ -0,0 +1,45 @@
1
+ import { useState } from "react";
2
+ import { AgentsTable } from "../components/agents/agents-table";
3
+ import { AgentFormDialog } from "../components/agents/agent-form-dialog";
4
+ import { Button } from "@greatapps/greatauth-ui/ui";
5
+ import { Plus } from "lucide-react";
6
+ import type { GagentsHookConfig } from "../hooks/types";
7
+
8
+ export interface AgentsPageProps {
9
+ config: GagentsHookConfig;
10
+ onNavigateToAgent?: (agentId: number) => void;
11
+ title?: string;
12
+ subtitle?: string;
13
+ }
14
+
15
+ export function AgentsPage({
16
+ config,
17
+ onNavigateToAgent,
18
+ title = "Agentes AI",
19
+ subtitle = "Gerencie seus agentes de atendimento inteligente",
20
+ }: AgentsPageProps) {
21
+ const [createOpen, setCreateOpen] = useState(false);
22
+
23
+ return (
24
+ <div className="flex flex-col gap-4 p-4">
25
+ <div className="flex items-center justify-between">
26
+ <div>
27
+ <h1 className="text-xl font-semibold">{title}</h1>
28
+ <p className="text-sm text-muted-foreground">{subtitle}</p>
29
+ </div>
30
+ <Button onClick={() => setCreateOpen(true)} size="sm">
31
+ <Plus className="mr-2 h-4 w-4" />
32
+ Novo Agente
33
+ </Button>
34
+ </div>
35
+
36
+ <AgentsTable config={config} onNavigateToAgent={onNavigateToAgent} />
37
+
38
+ <AgentFormDialog
39
+ config={config}
40
+ open={createOpen}
41
+ onOpenChange={setCreateOpen}
42
+ />
43
+ </div>
44
+ );
45
+ }
@@ -0,0 +1,50 @@
1
+ import { useState } from "react";
2
+ import { useToolCredentials } from "../hooks";
3
+ import { ToolCredentialsForm } from "../components/tools/tool-credentials-form";
4
+ import { Button } from "@greatapps/greatauth-ui/ui";
5
+ import { Plus } from "lucide-react";
6
+ import type { GagentsHookConfig } from "../hooks/types";
7
+
8
+ export interface CredentialsPageProps {
9
+ config: GagentsHookConfig;
10
+ gagentsApiUrl: string;
11
+ title?: string;
12
+ subtitle?: string;
13
+ }
14
+
15
+ export function CredentialsPage({
16
+ config,
17
+ gagentsApiUrl,
18
+ title = "Credenciais",
19
+ subtitle = "Gerencie as credenciais de autenticação das ferramentas",
20
+ }: CredentialsPageProps) {
21
+ const { data: credentialsData, isLoading: credentialsLoading } =
22
+ useToolCredentials(config);
23
+ const [createOpen, setCreateOpen] = useState(false);
24
+
25
+ const credentials = credentialsData?.data || [];
26
+
27
+ return (
28
+ <div className="flex flex-col gap-4 p-4">
29
+ <div className="flex items-center justify-between">
30
+ <div>
31
+ <h1 className="text-xl font-semibold">{title}</h1>
32
+ <p className="text-sm text-muted-foreground">{subtitle}</p>
33
+ </div>
34
+ <Button onClick={() => setCreateOpen(true)} size="sm">
35
+ <Plus className="mr-2 h-4 w-4" />
36
+ Nova Credencial
37
+ </Button>
38
+ </div>
39
+
40
+ <ToolCredentialsForm
41
+ config={config}
42
+ gagentsApiUrl={gagentsApiUrl}
43
+ credentials={credentials}
44
+ isLoading={credentialsLoading}
45
+ createOpen={createOpen}
46
+ onCreateOpenChange={setCreateOpen}
47
+ />
48
+ </div>
49
+ );
50
+ }
@@ -0,0 +1,4 @@
1
+ export { AgentsPage, type AgentsPageProps } from "./agents-page";
2
+ export { AgentDetailPage, type AgentDetailPageProps } from "./agent-detail-page";
3
+ export { ToolsPage, type ToolsPageProps } from "./tools-page";
4
+ export { CredentialsPage, type CredentialsPageProps } from "./credentials-page";
@@ -0,0 +1,52 @@
1
+ import { useState } from "react";
2
+ import { ToolsTable } from "../components/tools/tools-table";
3
+ import { ToolFormDialog } from "../components/tools/tool-form-dialog";
4
+ import { Button } from "@greatapps/greatauth-ui/ui";
5
+ import { Plus } from "lucide-react";
6
+ import type { GagentsHookConfig } from "../hooks/types";
7
+ import type { Tool } from "../types";
8
+
9
+ export interface ToolsPageProps {
10
+ config: GagentsHookConfig;
11
+ title?: string;
12
+ subtitle?: string;
13
+ }
14
+
15
+ export function ToolsPage({
16
+ config,
17
+ title = "Ferramentas",
18
+ subtitle = "Gerencie as ferramentas disponíveis para seus agentes",
19
+ }: ToolsPageProps) {
20
+ const [createOpen, setCreateOpen] = useState(false);
21
+ const [editTool, setEditTool] = useState<Tool | undefined>(undefined);
22
+
23
+ return (
24
+ <div className="flex flex-col gap-4 p-4">
25
+ <div className="flex items-center justify-between">
26
+ <div>
27
+ <h1 className="text-xl font-semibold">{title}</h1>
28
+ <p className="text-sm text-muted-foreground">{subtitle}</p>
29
+ </div>
30
+ <Button onClick={() => setCreateOpen(true)} size="sm">
31
+ <Plus className="mr-2 h-4 w-4" />
32
+ Nova Ferramenta
33
+ </Button>
34
+ </div>
35
+
36
+ <ToolsTable config={config} onEdit={(tool) => setEditTool(tool)} />
37
+
38
+ <ToolFormDialog
39
+ config={config}
40
+ open={createOpen}
41
+ onOpenChange={setCreateOpen}
42
+ />
43
+
44
+ <ToolFormDialog
45
+ config={config}
46
+ open={!!editTool}
47
+ onOpenChange={(open) => !open && setEditTool(undefined)}
48
+ tool={editTool}
49
+ />
50
+ </div>
51
+ );
52
+ }