Remove debug tour button
Remove the debug button from the WhatsApp page and ensure the onboarding tour only appears on initial login if no groups are present.
This commit is contained in:
parent
a7b65653ac
commit
d4eabdb831
@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import { useWhatsAppInstances } from '@/hooks/useWhatsAppInstances';
|
|
||||||
import { listWhatsAppGroups } from '@/services/whatsAppGroupsService';
|
import { listWhatsAppGroups } from '@/services/whatsAppGroupsService';
|
||||||
|
|
||||||
const TOUR_SESSION_KEY = 'onboarding_tour_shown';
|
const TOUR_SESSION_KEY = 'onboarding_tour_shown';
|
||||||
@ -12,17 +11,22 @@ export const useOnboardingTour = () => {
|
|||||||
const [shouldShowTour, setShouldShowTour] = useState(false);
|
const [shouldShowTour, setShouldShowTour] = useState(false);
|
||||||
const [tourShownThisSession, setTourShownThisSession] = useState(false);
|
const [tourShownThisSession, setTourShownThisSession] = useState(false);
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const { instances } = useWhatsAppInstances();
|
|
||||||
|
|
||||||
// Verificar se o tour deve ser exibido
|
// Verificar se o tour deve ser exibido
|
||||||
const checkTourConditions = async () => {
|
const checkTourConditions = async () => {
|
||||||
try {
|
try {
|
||||||
|
// Só mostrar o tour na página inicial (dashboard)
|
||||||
|
if (location.pathname !== '/') {
|
||||||
|
console.log('❌ Tour só aparece no dashboard');
|
||||||
|
setShouldShowTour(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Verificar se já foi mostrado nesta sessão
|
// Verificar se já foi mostrado nesta sessão
|
||||||
const shownThisSession = sessionStorage.getItem(TOUR_SESSION_KEY) === 'true';
|
const shownThisSession = sessionStorage.getItem(TOUR_SESSION_KEY) === 'true';
|
||||||
|
|
||||||
console.log('🔍 Verificando condições do tour:', {
|
console.log('🔍 Verificando condições do tour:', {
|
||||||
shownThisSession,
|
shownThisSession,
|
||||||
instances: instances.length,
|
|
||||||
location: location.pathname
|
location: location.pathname
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -33,21 +37,6 @@ export const useOnboardingTour = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verificar se há instâncias conectadas
|
|
||||||
const hasConnectedInstance = instances.some(instance =>
|
|
||||||
instance.status === 'connected' || instance.connectionState === 'open'
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log('📱 Status das instâncias:', {
|
|
||||||
totalInstances: instances.length,
|
|
||||||
hasConnectedInstance,
|
|
||||||
instancesDetails: instances.map(i => ({
|
|
||||||
name: i.instanceName,
|
|
||||||
status: i.status,
|
|
||||||
connectionState: i.connectionState
|
|
||||||
}))
|
|
||||||
});
|
|
||||||
|
|
||||||
// Verificar se há grupos cadastrados
|
// Verificar se há grupos cadastrados
|
||||||
let hasGroups = false;
|
let hasGroups = false;
|
||||||
try {
|
try {
|
||||||
@ -59,11 +48,10 @@ export const useOnboardingTour = () => {
|
|||||||
hasGroups = false;
|
hasGroups = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tour deve aparecer se NÃO tiver instância conectada OU NÃO tiver grupos
|
// Tour deve aparecer se NÃO tiver grupos
|
||||||
const shouldShow = !hasConnectedInstance || !hasGroups;
|
const shouldShow = !hasGroups;
|
||||||
|
|
||||||
console.log('🎯 Resultado da verificação:', {
|
console.log('🎯 Resultado da verificação:', {
|
||||||
hasConnectedInstance,
|
|
||||||
hasGroups,
|
hasGroups,
|
||||||
shouldShow,
|
shouldShow,
|
||||||
currentPath: location.pathname
|
currentPath: location.pathname
|
||||||
@ -89,11 +77,11 @@ export const useOnboardingTour = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Verificar condições quando instâncias mudarem ou na inicialização
|
// Verificar condições quando a localização mudar ou na inicialização
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('🔄 Efeito disparado - verificando condições do tour');
|
console.log('🔄 Efeito disparado - verificando condições do tour');
|
||||||
checkTourConditions();
|
checkTourConditions();
|
||||||
}, [instances, location.pathname]);
|
}, [location.pathname]);
|
||||||
|
|
||||||
// Limpar tour ao mudar de sessão
|
// Limpar tour ao mudar de sessão
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import { useWhatsAppActions } from '@/hooks/useWhatsAppActions';
|
|||||||
import { useWhatsAppInstance, WHATSAPP_INSTANCE_KEY } from '@/hooks/whatsApp/useWhatsAppInstance';
|
import { useWhatsAppInstance, WHATSAPP_INSTANCE_KEY } from '@/hooks/whatsApp/useWhatsAppInstance';
|
||||||
import { usePeriodicStatusCheck } from '@/hooks/whatsApp/usePeriodicStatusCheck';
|
import { usePeriodicStatusCheck } from '@/hooks/whatsApp/usePeriodicStatusCheck';
|
||||||
import { useExistingInstanceCheck } from '@/hooks/whatsapp/useExistingInstanceCheck';
|
import { useExistingInstanceCheck } from '@/hooks/whatsapp/useExistingInstanceCheck';
|
||||||
import { Button } from '@/components/ui/button';
|
|
||||||
|
|
||||||
const WhatsApp = () => {
|
const WhatsApp = () => {
|
||||||
const {
|
const {
|
||||||
@ -84,12 +83,6 @@ const WhatsApp = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Função para resetar o tour (apenas para debug)
|
|
||||||
const resetTour = () => {
|
|
||||||
sessionStorage.removeItem('onboarding_tour_shown');
|
|
||||||
window.location.reload();
|
|
||||||
};
|
|
||||||
|
|
||||||
if (checkingExistingInstance || isLoading) {
|
if (checkingExistingInstance || isLoading) {
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
@ -107,24 +100,6 @@ const WhatsApp = () => {
|
|||||||
isRefreshing={checkingExistingInstance}
|
isRefreshing={checkingExistingInstance}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Botão temporário para debug do tour */}
|
|
||||||
{process.env.NODE_ENV === 'development' && (
|
|
||||||
<div className="p-4 bg-yellow-50 border border-yellow-200 rounded-lg">
|
|
||||||
<p className="text-sm text-yellow-700 mb-2">Debug do Tour:</p>
|
|
||||||
<Button
|
|
||||||
onClick={resetTour}
|
|
||||||
variant="outline"
|
|
||||||
size="sm"
|
|
||||||
className="mr-2"
|
|
||||||
>
|
|
||||||
Resetar Tour
|
|
||||||
</Button>
|
|
||||||
<span className="text-xs text-gray-500">
|
|
||||||
(Este botão só aparece em desenvolvimento)
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<WhatsAppManager
|
<WhatsAppManager
|
||||||
hasExistingInstance={hasExistingInstance}
|
hasExistingInstance={hasExistingInstance}
|
||||||
existingInstanceData={existingInstanceData}
|
existingInstanceData={existingInstanceData}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user