Adds functionality to fetch a WhatsApp instance from the Evolution API when the "Conectar WhatsApp" menu is accessed. The request uses the instance name entered in the form, includes the necessary headers, and displays the instance information. It also handles cases where the user is not logged in and when the instance is not found.
Improve the visual appearance of the pie chart and the "Receitas vs Despesas" chart, aiming for a more modern look, without affecting other functionalities.
Implement workflow creation using a Supabase Edge Function, addressing CORS issues and enhancing security. The frontend now calls the Edge Function, which handles the n8n API interaction and Supabase updates.
The commit addresses two TypeScript errors in `n8nWorkflowService.ts`. The first error, TS2445, arises from attempting to access the protected `supabaseUrl` property directly. The second error, TS2339, occurs because the `session` property is not directly available on the `SupabaseAuthClient`. The fix involves adjusting how the Supabase client and its properties are accessed to align with the Supabase library's intended usage.
The frontend now calls a backend endpoint to create n8n workflows, addressing CORS issues. The backend handles the n8n API request, updates Supabase, and returns the result to the frontend.
Split `gruposWhatsAppService.ts` into smaller, more maintainable service files: `n8nWorkflowService.ts` and `whatsAppGroupsService.ts`. This improves code organization and readability.
The "Cadastrar Grupo" button now fails immediately. The priority is to ensure the n8n workflow creation request succeeds. This commit reviews the button's context and related code to address the issue.
The code was updated to create the n8n workflow when the "Cadastrar Grupo" button is pressed. It now makes a POST request to the n8n API with the user's email in the request body.
The user reported an error when clicking the "Cadastrar Grupo" button. This commit aims to identify the specific stage where the error occurs to facilitate debugging.
The "Cadastrar Grupo" button now creates a group in Supabase and attempts to create an empty workflow in n8n. If the workflow creation is successful, the workflow ID is saved. If it fails, the group is still created, but a specific error message is displayed.
Implement n8n API call to create an empty workflow when a new WhatsApp group is registered. Save the returned workflow ID to the Supabase record upon successful creation. Display success message to the user.
Integrate n8n workflow cloning upon WhatsApp group registration. Adds a `workflow_id` column to the `grupos_whatsapp` table and updates the `cadastrarGrupoWhatsApp` function to call the n8n webhook, capturing the returned workflow ID and saving it to the database. The button "Cadastrar Grupo" is only visible when the user is logged in.
The `cadastrarGrupoWhatsApp` function in `gruposWhatsAppService.ts` was updated to include the `remote_jid` field when inserting a new group into the `grupos_whatsapp` table. This resolves the TypeScript error related to missing properties in the insert call.
Update the system to use the user's email (login) as the primary identifier for linking users, WhatsApp groups, and transactions. This includes changes to the `grupos_whatsapp` and `transacoes` tables, as well as adjustments to queries and data retrieval logic. The `user_id` field is maintained for compatibility.
Apply the SQL schema changes to Supabase, including the creation of the `grupos_whatsapp` table and the addition of the `grupo_id` column to the `transacoes` table.
The user reported that no pages were visible and the menu had disappeared. This commit likely addresses the root cause of these issues, potentially related to layout, routing, or component rendering.
The AI identified and fixed an infinite re-render loop in `useWhatsAppInstances.ts` and `WhatsApp.tsx` by adding state checks, delays, and improving useEffect dependencies.
The AI will address two runtime errors: a minified React error (likely related to incorrect component usage or props) and a "too many re-renders" error (indicating an infinite loop). The AI will analyze the code, particularly the `WhatsApp` component and its related hooks and components, to identify and fix the root causes of these errors.
The `onViewQrCode` prop in `InstanceList` was expecting a function with two arguments, but the `handleViewQrCode` function only provided one. This commit fixes the type mismatch.
The commit fixes an import error in `Sidebar.tsx` related to the `@/config/site` module. The error message indicates that the module cannot be resolved. The fix likely involves ensuring the correct path to the module or creating the missing file.
The commit addresses a "Failed to resolve import" error in `src/pages/WhatsApp.tsx`. The error message indicates that the module `@/components/whatsapp` could not be found. This likely means the import path is incorrect, or the file does not exist at the specified location.
The commit fixes a TypeScript error in `useWhatsAppInstances.ts` where the `setInstances` function was receiving an array with incorrect types. The error occurred because the `connectionState` property was sometimes a string instead of the expected union type. The fix ensures that the `connectionState` is always of the correct type.
- Fixed instance deletion failures.
- Resolved the issue of instances appearing and disappearing in a loop.
- Addressed errors during instance updates.
- Check for missing information.
The commit addresses the issue where instance cards were not appearing after creation. It revisits the `WhatsApp.tsx` file and related components to ensure instances are correctly added to the state and displayed.
This commit refactors the `WhatsApp.tsx` file into smaller, more manageable components. The form, instance list, QR code dialog, and API functions are separated into their own files to improve code organization and maintainability. No functionality changes were made.
The fix ensures that when a new instance is created, even if the QR code isn't scanned immediately, the instance card appears in the "Desconectado" state, allowing the user to connect later.
The instance cards were not appearing after creation. This commit fixes the issue, ensuring that the cards are displayed whether the instance is connected or disconnected.
- Associate WhatsApp instances with logged-in users.
- Store user ID/email with instance data.
- Filter instance cards to show only the user's instances.
- Clear instances on logout/login.
Implement automatic connection status checks for each instance card, displaying "Conectado" or "Desconectado" based on the API response. Includes periodic updates and visual status indication.
Adds a section to display created WhatsApp instances as cards, each with a "View QR Code" button. Implements local storage for instance data and fetches QR codes from the API.
- Store instanceId and instanceName after instance creation.
- Add "Ver QR Code" button to fetch and display QR code from API.
- Implement QR code refresh functionality.
- Display success/error messages.
Adds a "Connect WhatsApp" menu item to the sidebar. Implements a form to input instance name and WhatsApp number, and a button to create a WhatsApp instance via a POST request to the Evolution API. Saves the returned instanceId and displays success/error messages.