- {items?.map((item) => (
- item.href ? (
-
- {item.icon}
- {item.title}
-
- ) : null
- ))}
+
+
+ {!collapsed && (
+
FinDash
+ )}
+
+
+
);
-}
+};
-export const defaultItems: MainNavItem[] = [
- {
- title: "Dashboard",
- href: "/",
- icon:
,
- },
- {
- title: "Usuários",
- href: "/usuarios",
- icon:
,
- },
- {
- title: "WhatsApp",
- href: "/whatsapp",
- icon:
,
- },
- {
- title: "Configurações",
- href: "/configuracoes",
- icon:
,
- },
- {
- title: "Áudios Rodrigo",
- href: "/rodrigo-audio",
- icon:
- },
-];
+export default Sidebar;
diff --git a/src/components/usuarios/UsersDialog.tsx b/src/components/usuarios/UsersDialog.tsx
deleted file mode 100644
index 99422a0..0000000
--- a/src/components/usuarios/UsersDialog.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-
-import React from "react";
-import UsersList from "./UsersList";
-import {
- Dialog,
- DialogContent,
- DialogDescription,
- DialogHeader,
- DialogTitle,
- DialogTrigger,
-} from "@/components/ui/dialog";
-import { Button } from "@/components/ui/button";
-import { UserRoundSearch } from "lucide-react";
-
-interface UsersDialogProps {
- trigger?: React.ReactNode;
-}
-
-export function UsersDialog({ trigger }: UsersDialogProps) {
- return (
-
- );
-}
-
-export default UsersDialog;
diff --git a/src/components/usuarios/UsersList.tsx b/src/components/usuarios/UsersList.tsx
deleted file mode 100644
index a091e3c..0000000
--- a/src/components/usuarios/UsersList.tsx
+++ /dev/null
@@ -1,143 +0,0 @@
-
-import React, { useState, useEffect } from 'react';
-import { format } from 'date-fns';
-import { ptBR } from 'date-fns/locale';
-import { UserInfo, getUsersRegisteredToday, getAllUsers } from '@/services/userService';
-import {
- Card,
- CardContent,
- CardDescription,
- CardFooter,
- CardHeader,
- CardTitle,
-} from "@/components/ui/card";
-import { Button } from "@/components/ui/button";
-import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
-import { useToast } from "@/hooks/use-toast";
-
-const UsersList: React.FC = () => {
- const [usersToday, setUsersToday] = useState
([]);
- const [allUsers, setAllUsers] = useState([]);
- const [loading, setLoading] = useState(false);
- const [activeTab, setActiveTab] = useState("today");
- const { toast } = useToast();
-
- const loadUsers = async (tab: string = activeTab) => {
- setLoading(true);
- try {
- if (tab === "today") {
- const users = await getUsersRegisteredToday();
- setUsersToday(users);
- } else {
- const users = await getAllUsers();
- setAllUsers(users);
- }
- } catch (error) {
- console.error("Erro ao carregar usuários:", error);
- toast({
- title: "Erro",
- description: "Falha ao carregar dados de usuários.",
- variant: "destructive",
- });
- } finally {
- setLoading(false);
- }
- };
-
- useEffect(() => {
- loadUsers();
- }, []);
-
- const handleTabChange = (value: string) => {
- setActiveTab(value);
- loadUsers(value);
- };
-
- const formatDate = (dateString: string) => {
- try {
- return format(new Date(dateString), "dd/MM/yyyy HH:mm", { locale: ptBR });
- } catch (error) {
- return "Data inválida";
- }
- };
-
- const displayUsers = activeTab === "today" ? usersToday : allUsers;
-
- return (
-
-
- Usuários Cadastrados
-
- {activeTab === "today"
- ? `${usersToday.length} usuários cadastrados hoje`
- : `${allUsers.length} usuários cadastrados no total`}
-
-
-
-
-
- Cadastrados Hoje
- Todos os Usuários
-
-
-
- {loading ? (
- Carregando...
- ) : usersToday.length > 0 ? (
-
- {usersToday.map((user) => (
-
-
{user.nome}
-
Email: {user.email}
- {user.empresa && (
-
Empresa: {user.empresa}
- )}
-
- Cadastrado em: {formatDate(user.created_at)}
-
-
- ))}
-
- ) : (
- Nenhum usuário cadastrado hoje.
- )}
-
-
-
- {loading ? (
- Carregando...
- ) : allUsers.length > 0 ? (
-
- {allUsers.map((user) => (
-
-
{user.nome}
-
Email: {user.email}
- {user.empresa && (
-
Empresa: {user.empresa}
- )}
-
- Cadastrado em: {formatDate(user.created_at)}
-
-
- ))}
-
- ) : (
- Nenhum usuário cadastrado.
- )}
-
-
-
-
-
-
-
- );
-};
-
-export default UsersList;
diff --git a/src/components/whatsapp/InstanceList.tsx b/src/components/whatsapp/InstanceList.tsx
index 228a9c4..21eedf1 100644
--- a/src/components/whatsapp/InstanceList.tsx
+++ b/src/components/whatsapp/InstanceList.tsx
@@ -8,20 +8,20 @@ import { RefreshCw } from 'lucide-react';
interface InstanceListProps {
instances: WhatsAppInstance[];
onViewQrCode: (instance: WhatsAppInstance) => void;
- onDeleteInstance: (instanceId: string) => void; // Only requires instanceId
- onRestartInstance: (instance: WhatsAppInstance) => Promise;
- onLogoutInstance: (instance: WhatsAppInstance) => Promise;
+ onDelete: (instanceId: string) => void;
+ onRestart: (instance: WhatsAppInstance) => Promise;
+ onLogout: (instance: WhatsAppInstance) => Promise;
onSetPresence: (instance: WhatsAppInstance, presence: 'online' | 'offline') => Promise;
- onRefreshInstances?: () => Promise;
- isRefreshing?: boolean;
+ onRefreshInstances: () => Promise;
+ isRefreshing: boolean;
}
const InstanceList = ({
instances,
onViewQrCode,
- onDeleteInstance,
- onRestartInstance,
- onLogoutInstance,
+ onDelete,
+ onRestart,
+ onLogout,
onSetPresence,
onRefreshInstances,
isRefreshing
@@ -43,17 +43,15 @@ const InstanceList = ({
Instâncias Criadas
- {onRefreshInstances && (
-
- )}
+
{instances.map((instance) => (
@@ -61,9 +59,9 @@ const InstanceList = ({
key={instance.instanceId}
instance={instance}
onViewQrCode={onViewQrCode}
- onDelete={onDeleteInstance}
- onRestart={onRestartInstance}
- onLogout={onLogoutInstance}
+ onDelete={onDelete}
+ onRestart={onRestart}
+ onLogout={onLogout}
onSetPresence={onSetPresence}
/>
))}
diff --git a/src/components/whatsapp/MessageWebhook.tsx b/src/components/whatsapp/MessageWebhook.tsx
deleted file mode 100644
index 8d030b4..0000000
--- a/src/components/whatsapp/MessageWebhook.tsx
+++ /dev/null
@@ -1,103 +0,0 @@
-
-import React, { useState } from 'react';
-import { Button } from '@/components/ui/button';
-import { Input } from '@/components/ui/input';
-import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card';
-import { useToast } from '@/hooks/use-toast';
-import { Label } from '@/components/ui/label';
-import { AudioMessage, storeAudioMessageForRodrigo } from '@/services/audioMessageService';
-import { WhatsAppInstance } from '@/types/whatsAppTypes';
-
-interface MessageWebhookProps {
- instance?: WhatsAppInstance;
-}
-
-const MessageWebhook: React.FC
= ({ instance }) => {
- const { toast } = useToast();
- const [webhookUrl, setWebhookUrl] = useState('');
-
- const handleSetWebhook = async () => {
- if (!instance) {
- toast({
- title: "Erro",
- description: "Selecione uma instância primeiro",
- variant: "destructive",
- });
- return;
- }
-
- try {
- // Here you would set the webhook URL for the Evolution API
- // This is a placeholder for the actual implementation
- toast({
- title: "Webhook Configurado",
- description: `Webhook configurado para ${instance.instanceName}`,
- });
-
- // Simulate receiving an audio message (for testing purposes)
- const testAudioMessage: AudioMessage = {
- sender_id: '120363420212322973@g.us',
- sender_name: 'Teste',
- instance_id: instance.instanceId,
- audio_url: 'https://example.com/audio.mp3',
- duration: 30,
- metadata: {
- test: true
- }
- };
-
- await storeAudioMessageForRodrigo(testAudioMessage);
- } catch (error) {
- console.error('Error setting webhook:', error);
- toast({
- title: "Erro",
- description: "Erro ao configurar webhook",
- variant: "destructive",
- });
- }
- };
-
- return (
-
-
- Configurar Webhook para Mensagens
-
- Configure um webhook para receber mensagens da Evolution API.
- Os áudios enviados para o grupo do Rodrigo serão armazenados automaticamente.
-
-
-
-
-
-
- setWebhookUrl(e.target.value)}
- />
-
- {instance ? (
-
- Configurando para: {instance.instanceName}
-
- ) : (
-
- Selecione uma instância primeiro.
-
- )}
-
-
-
-
-
-
- );
-};
-
-export default MessageWebhook;
diff --git a/src/components/whatsapp/QrCodeDialog.tsx b/src/components/whatsapp/QrCodeDialog.tsx
index feae5a6..1270559 100644
--- a/src/components/whatsapp/QrCodeDialog.tsx
+++ b/src/components/whatsapp/QrCodeDialog.tsx
@@ -1,5 +1,5 @@
-import { useState, useEffect } from 'react';
+import { useState } from 'react';
import {
Dialog,
DialogContent,
@@ -10,22 +10,21 @@ import {
import { Button } from '@/components/ui/button';
import { Alert, AlertDescription } from '@/components/ui/alert';
import { RefreshCw } from 'lucide-react';
+import { WhatsAppInstance } from '@/types/whatsAppTypes';
import { fetchQrCode } from '@/services/whatsAppService';
import { useToast } from '@/hooks/use-toast';
interface QrCodeDialogProps {
open: boolean;
- setOpen: (open: boolean) => void;
- instanceName: string;
- phoneNumber: string;
- onStatusCheck?: () => void;
+ onOpenChange: (open: boolean) => void;
+ activeInstance: WhatsAppInstance | null;
+ onStatusCheck: () => void;
}
const QrCodeDialog = ({
open,
- setOpen,
- instanceName,
- phoneNumber,
+ onOpenChange,
+ activeInstance,
onStatusCheck
}: QrCodeDialogProps) => {
const { toast } = useToast();
@@ -33,30 +32,23 @@ const QrCodeDialog = ({
const [qrCodeData, setQrCodeData] = useState(null);
const [qrError, setQrError] = useState(null);
- // Load QR code when dialog opens
- useEffect(() => {
- if (open && instanceName) {
- handleRefreshQrCode();
- }
- }, [open, instanceName]);
-
const handleOpenChange = (newOpen: boolean) => {
- setOpen(newOpen);
+ onOpenChange(newOpen);
// After dialog closes, trigger status check to update connection state
- if (!newOpen && onStatusCheck) {
+ if (!newOpen) {
onStatusCheck();
}
};
const handleRefreshQrCode = async () => {
- if (!instanceName) return;
+ if (!activeInstance) return;
setLoadingQR(true);
setQrError(null);
try {
- const data = await fetchQrCode(instanceName);
+ const data = await fetchQrCode(activeInstance.instanceName);
console.log('QR Code API response:', data);
// Using the "base64" field from the response as the QR code data
@@ -83,7 +75,7 @@ const QrCodeDialog = ({