Remove localStorage do funil — reseta sempre ao abrir
Cada visita agora inicia o funil do zero. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
80956d6c61
commit
1be25e60be
1 changed files with 2 additions and 34 deletions
|
|
@ -100,17 +100,6 @@ function getAudioContext() {
|
||||||
return sharedAudioCtx;
|
return sharedAudioCtx;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FUNNEL_STORAGE_KEY = 'fm_whatsapp_funnel_state';
|
|
||||||
|
|
||||||
function loadSavedFunnelState() {
|
|
||||||
try {
|
|
||||||
const raw = localStorage.getItem(FUNNEL_STORAGE_KEY);
|
|
||||||
if (!raw) return null;
|
|
||||||
const parsed = JSON.parse(raw);
|
|
||||||
if (Array.isArray(parsed.messages) && parsed.messages.length > 0) return parsed;
|
|
||||||
} catch (e) {}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function playMessageSound() {
|
function playMessageSound() {
|
||||||
try {
|
try {
|
||||||
|
|
@ -222,31 +211,10 @@ export default function WhatsAppFunnel() {
|
||||||
if (!initialized.current) {
|
if (!initialized.current) {
|
||||||
initialized.current = true;
|
initialized.current = true;
|
||||||
getAudioContext();
|
getAudioContext();
|
||||||
|
|
||||||
const saved = loadSavedFunnelState();
|
|
||||||
if (saved) {
|
|
||||||
setMessages(saved.messages);
|
|
||||||
setCurrentOptions(saved.currentOptions || []);
|
|
||||||
setCurrentRequireEmail(saved.currentRequireEmail || false);
|
|
||||||
scrollToBottom();
|
|
||||||
} else {
|
|
||||||
playNode('start');
|
playNode('start');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Salva o progresso da conversa para retomar de onde parou caso a página recarregue
|
|
||||||
useEffect(() => {
|
|
||||||
if (messages.length === 0) return;
|
|
||||||
try {
|
|
||||||
localStorage.setItem(FUNNEL_STORAGE_KEY, JSON.stringify({
|
|
||||||
messages,
|
|
||||||
currentOptions,
|
|
||||||
currentRequireEmail,
|
|
||||||
}));
|
|
||||||
} catch (e) {}
|
|
||||||
}, [messages, currentOptions, currentRequireEmail]);
|
|
||||||
|
|
||||||
const handleOptionClick = (opt: OptionConfig) => {
|
const handleOptionClick = (opt: OptionConfig) => {
|
||||||
const ctx = getAudioContext();
|
const ctx = getAudioContext();
|
||||||
if (ctx && ctx.state === 'suspended') {
|
if (ctx && ctx.state === 'suspended') {
|
||||||
|
|
@ -307,7 +275,7 @@ export default function WhatsAppFunnel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.href = `/checkout?plan=starter&source=funil&email=${encodeURIComponent(emailInput)}`;
|
window.location.href = `https://festamagicaia.com.br/checkout?plan=starter&source=funil&email=${encodeURIComponent(emailInput)}`;
|
||||||
}, 800);
|
}, 800);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue