Skip to content

Commit 77ee1a5

Browse files
committed
Merge branch 'release/2.3.5'
2 parents e510b5f + f054b9b commit 77ee1a5

File tree

12 files changed

+513
-22
lines changed

12 files changed

+513
-22
lines changed

package-lock.json

Lines changed: 425 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"@radix-ui/react-slot": "^1.1.0",
6464
"@radix-ui/react-switch": "^1.1.0",
6565
"@radix-ui/react-tabs": "^1.1.0",
66+
"@radix-ui/react-tooltip": "^1.2.8",
6667
"@tanstack/react-query": "^5.52.1",
6768
"@tanstack/react-table": "^8.20.1",
6869
"axios": "^1.7.2",

src/components/ui/tooltip.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import * as Tooltip from "@radix-ui/react-tooltip";
2+
import { ReactNode } from "react";
3+
4+
interface TooltipWrapperProps {
5+
content: ReactNode; // o texto que vai aparecer no tooltip
6+
children: ReactNode; // o trigger (qualquer elemento)
7+
side?: "top" | "right" | "bottom" | "left"; // posição opcional
8+
}
9+
10+
export function TooltipWrapper({ content, children, side = "top" }: TooltipWrapperProps) {
11+
return (
12+
<Tooltip.Provider delayDuration={200}>
13+
<Tooltip.Root>
14+
<Tooltip.Trigger asChild>
15+
{children}
16+
</Tooltip.Trigger>
17+
<Tooltip.Portal>
18+
<Tooltip.Content
19+
side={side}
20+
className="
21+
rounded px-3 py-1.5 text-sm z-50 border shadow-lg
22+
bg-gray-100 text-gray-900 border-gray-300
23+
dark:bg-gray-800 dark:text-gray-100 dark:border-gray-700
24+
"
25+
>
26+
{content}
27+
<Tooltip.Arrow className="fill-gray-100 dark:fill-gray-800" width={18} height={9} />
28+
</Tooltip.Content>
29+
</Tooltip.Portal>
30+
</Tooltip.Root>
31+
</Tooltip.Provider>
32+
);
33+
}

src/contexts/EmbedInstanceContext.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,21 @@ export function EmbedInstanceProvider({ children }: { children: React.ReactNode
2828
const validateAndFetchInstance = async () => {
2929
const token = searchParams.get("token");
3030
const instanceName = searchParams.get("instanceName");
31+
const apiUrl = searchParams.get("apiUrl");
3132

32-
if (!token || !instanceName) {
33-
setError("Token e instanceName são obrigatórios");
33+
if (!token || !instanceName || !apiUrl) {
34+
setError("Token, instanceName e apiUrl são obrigatórios");
3435
setIsLoading(false);
3536
return;
3637
}
3738

3839
try {
39-
const apiUrl = "https://integracaov2.icommarketing.com.br";
40-
localStorage.setItem(TOKEN_ID.API_URL, apiUrl);
40+
// Format URL (remove trailing slash if present)
41+
const formattedUrl = apiUrl.endsWith("/") ? apiUrl.slice(0, -1) : apiUrl;
42+
localStorage.setItem(TOKEN_ID.API_URL, formattedUrl);
4143
localStorage.setItem(TOKEN_ID.INSTANCE_TOKEN, token);
4244

43-
const { data } = await axios.get(`${apiUrl}/instance/fetchInstances?instanceName=${instanceName}`, {
45+
const { data } = await axios.get(`${formattedUrl}/instance/fetchInstances?instanceName=${instanceName}`, {
4446
headers: {
4547
apikey: token,
4648
},

src/pages/Dashboard/index.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { useManageInstance } from "@/lib/queries/instance/manageInstance";
1919
import { Instance } from "@/types/evolution.types";
2020

2121
import { NewInstance } from "./NewInstance";
22+
import { TooltipWrapper } from "@/components/ui/tooltip";
2223

2324
function Dashboard() {
2425
const { t } = useTranslation();
@@ -114,15 +115,20 @@ function Dashboard() {
114115
</div>
115116
<main className="grid gap-6 sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
116117
{filteredInstances.length > 0 &&
117-
Array.isArray(instances) &&
118-
instances.map((instance: Instance) => (
118+
Array.isArray(filteredInstances) ? (
119+
filteredInstances.map((instance: Instance) => (
119120
<Card key={instance.id}>
120121
<CardHeader>
121122
<Link to={`/manager/instance/${instance.id}/dashboard`} className="flex w-full flex-row items-center justify-between gap-4">
122-
<h3 className="text-wrap font-semibold">{instance.name}</h3>
123-
<Button variant="ghost" size="icon">
124-
<Cog className="card-icon" size="20" />
125-
</Button>
123+
<TooltipWrapper content={instance.name} side="top">
124+
<h3 className="text-wrap font-semibold truncate">{instance.name}</h3>
125+
</TooltipWrapper>
126+
127+
<TooltipWrapper content={t("dashboard.settings")} side="top">
128+
<Button variant="ghost" size="icon">
129+
<Cog className="card-icon" size="20" />
130+
</Button>
131+
</TooltipWrapper>
126132
</Link>
127133
</CardHeader>
128134
<CardContent className="flex-1 space-y-6">
@@ -161,7 +167,9 @@ function Dashboard() {
161167
</Button>
162168
</CardFooter>
163169
</Card>
164-
))}
170+
))) :(
171+
<p>{t("dashboard.instancesNotFound")}</p>
172+
)}
165173
</main>
166174

167175
{!!deleteConfirmation && (

src/pages/instance/Chat/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
1111
import { useInstance } from "@/contexts/InstanceContext";
1212

1313
import { useFindChats } from "@/lib/queries/chat/findChats";
14+
import { getToken, TOKEN_ID } from "@/lib/queries/token";
1415

1516
import { Chat as ChatType } from "@/types/evolution.types";
1617

@@ -76,7 +77,12 @@ function Chat() {
7677
useEffect(() => {
7778
if (!instance?.name) return;
7879

79-
const serverUrl = "https://integracaov2.icommarketing.com.br";
80+
const serverUrl = getToken(TOKEN_ID.API_URL);
81+
if (!serverUrl) {
82+
console.error("API URL not found in localStorage");
83+
return;
84+
}
85+
8086
const socket = connectSocket(serverUrl);
8187

8288
// Function to update chats from websocket events

src/pages/instance/Chat/messages.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { useInstance } from "@/contexts/InstanceContext";
1313
import { useFindChat } from "@/lib/queries/chat/findChat";
1414
import { useFindMessages } from "@/lib/queries/chat/findMessages";
1515
import { useSendMessage, useSendMedia } from "@/lib/queries/chat/sendMessage";
16+
import { getToken, TOKEN_ID } from "@/lib/queries/token";
1617

1718
import { Message } from "@/types/evolution.types";
1819

@@ -429,7 +430,12 @@ function Messages({ textareaRef, handleTextareaChange, textareaHeight, lastMessa
429430
useEffect(() => {
430431
if (!instance?.name || !remoteJid) return;
431432

432-
const serverUrl = "https://icom-socket-gateway.icommarketing.com.br";
433+
const serverUrl = getToken(TOKEN_ID.API_URL);
434+
if (!serverUrl) {
435+
console.error("API URL not found in localStorage");
436+
return;
437+
}
438+
433439
const socket = connectSocket(serverUrl);
434440

435441
// Function to update messages from websocket events

src/pages/instance/EmbedChatMessage/index.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import { ReplyMessageProvider } from "@/contexts/ReplyingMessage/ReplyingMessage
2121
// import { useWebphone } from "@/contexts/Webphone";
2222

2323
import { api } from "@/lib/queries/api";
24-
25-
// import { TOKEN_ID, getToken } from "@/lib/queries/token";
24+
import { TOKEN_ID, getToken } from "@/lib/queries/token";
2625

2726
import { connectSocket, disconnectSocket } from "@/services/websocket/socket";
2827

@@ -114,9 +113,12 @@ function EmbedChatMessage() {
114113
useEffect(() => {
115114
if (!activeInstance) return;
116115

117-
const serverUrl = "https://icom-socket-gateway.icommarketing.com.br";
116+
const serverUrl = getToken(TOKEN_ID.API_URL);
118117

119-
if (!serverUrl) return;
118+
if (!serverUrl) {
119+
console.error("API URL not found in localStorage");
120+
return;
121+
}
120122

121123
const currentToken = localStorage.getItem("accessToken");
122124

src/translate/languages/en-US.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"dashboard": {
33
"title": "Instances",
44
"search": "Search",
5-
"status": "Status"
5+
"status": "Status",
6+
"settings": "Settings",
7+
"instancesNotFound": "No instances found"
68
},
79
"button": {
810
"delete": "Delete",

src/translate/languages/es-ES.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"dashboard": {
33
"title": "Instancias",
44
"search": "Buscar",
5-
"status": "Estado"
5+
"status": "Estado",
6+
"settings": "Configuraciones",
7+
"instancesNotFound": "No se encontraron instancias"
68
},
79
"button": {
810
"delete": "Eliminar",

0 commit comments

Comments
 (0)