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 { useLocation } from 'react-router-dom';
|
||||
import { useWhatsAppInstances } from '@/hooks/useWhatsAppInstances';
|
||||
import { listWhatsAppGroups } from '@/services/whatsAppGroupsService';
|
||||
|
||||
const TOUR_SESSION_KEY = 'onboarding_tour_shown';
|
||||
@ -12,17 +11,22 @@ export const useOnboardingTour = () => {
|
||||
const [shouldShowTour, setShouldShowTour] = useState(false);
|
||||
const [tourShownThisSession, setTourShownThisSession] = useState(false);
|
||||
const location = useLocation();
|
||||
const { instances } = useWhatsAppInstances();
|
||||
|
||||
// Verificar se o tour deve ser exibido
|
||||
const checkTourConditions = async () => {
|
||||
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
|
||||
const shownThisSession = sessionStorage.getItem(TOUR_SESSION_KEY) === 'true';
|
||||
|
||||
console.log('🔍 Verificando condições do tour:', {
|
||||
shownThisSession,
|
||||
instances: instances.length,
|
||||
location: location.pathname
|
||||
});
|
||||
|
||||
@ -33,21 +37,6 @@ export const useOnboardingTour = () => {
|
||||
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
|
||||
let hasGroups = false;
|
||||
try {
|
||||
@ -59,11 +48,10 @@ export const useOnboardingTour = () => {
|
||||
hasGroups = false;
|
||||
}
|
||||
|
||||
// Tour deve aparecer se NÃO tiver instância conectada OU NÃO tiver grupos
|
||||
const shouldShow = !hasConnectedInstance || !hasGroups;
|
||||
// Tour deve aparecer se NÃO tiver grupos
|
||||
const shouldShow = !hasGroups;
|
||||
|
||||
console.log('🎯 Resultado da verificação:', {
|
||||
hasConnectedInstance,
|
||||
hasGroups,
|
||||
shouldShow,
|
||||
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(() => {
|
||||
console.log('🔄 Efeito disparado - verificando condições do tour');
|
||||
checkTourConditions();
|
||||
}, [instances, location.pathname]);
|
||||
}, [location.pathname]);
|
||||
|
||||
// Limpar tour ao mudar de sessão
|
||||
useEffect(() => {
|
||||
|
||||
@ -9,7 +9,6 @@ import { useWhatsAppActions } from '@/hooks/useWhatsAppActions';
|
||||
import { useWhatsAppInstance, WHATSAPP_INSTANCE_KEY } from '@/hooks/whatsApp/useWhatsAppInstance';
|
||||
import { usePeriodicStatusCheck } from '@/hooks/whatsApp/usePeriodicStatusCheck';
|
||||
import { useExistingInstanceCheck } from '@/hooks/whatsapp/useExistingInstanceCheck';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
const WhatsApp = () => {
|
||||
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) {
|
||||
return (
|
||||
<Layout>
|
||||
@ -107,24 +100,6 @@ const WhatsApp = () => {
|
||||
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
|
||||
hasExistingInstance={hasExistingInstance}
|
||||
existingInstanceData={existingInstanceData}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user