merge loginesuporte
This commit is contained in:
commit
d979105ad1
@ -499,3 +499,30 @@
|
|||||||
.profile-section {
|
.profile-section {
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Garantir pointer-events nos elementos do header e overlays criados por portal */
|
||||||
|
.header-container { pointer-events: auto; }
|
||||||
|
.phone-icon-container, .profile-section { pointer-events: auto; }
|
||||||
|
|
||||||
|
/* Força que os overlays criados por portal fiquem por cima */
|
||||||
|
.logout-modal-overlay, .suporte-card-overlay, .chat-overlay {
|
||||||
|
z-index: 110000 !important;
|
||||||
|
pointer-events: auto !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Pequeno ajuste visual dos botões do modal (pode se misturar com seu CSS atual) */
|
||||||
|
.logout-cancel-button {
|
||||||
|
padding: 10px 18px;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
background: white;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.logout-confirm-button {
|
||||||
|
padding: 10px 18px;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: none;
|
||||||
|
background: #dc3545;
|
||||||
|
color: #fff;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { useNavigate, useLocation } from 'react-router-dom';
|
|||||||
import './Header.css';
|
import './Header.css';
|
||||||
|
|
||||||
const Header = () => {
|
const Header = () => {
|
||||||
// --- Hooks (sempre chamados na mesma ordem) ---
|
// --- hooks (sempre na mesma ordem) ---
|
||||||
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
||||||
const [isSuporteCardOpen, setIsSuporteCardOpen] = useState(false);
|
const [isSuporteCardOpen, setIsSuporteCardOpen] = useState(false);
|
||||||
const [isChatOpen, setIsChatOpen] = useState(false);
|
const [isChatOpen, setIsChatOpen] = useState(false);
|
||||||
@ -13,61 +13,70 @@ const Header = () => {
|
|||||||
const [mensagens, setMensagens] = useState([]);
|
const [mensagens, setMensagens] = useState([]);
|
||||||
const [showLogoutModal, setShowLogoutModal] = useState(false);
|
const [showLogoutModal, setShowLogoutModal] = useState(false);
|
||||||
const [avatarUrl, setAvatarUrl] = useState(null);
|
const [avatarUrl, setAvatarUrl] = useState(null);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
const chatInputRef = useRef(null);
|
const chatInputRef = useRef(null);
|
||||||
const mensagensContainerRef = useRef(null);
|
const mensagensContainerRef = useRef(null);
|
||||||
|
|
||||||
// --- Efeitos ---
|
// foco quando abre chat
|
||||||
useEffect(() => {
|
|
||||||
const loadAvatar = () => {
|
|
||||||
const localAvatar = localStorage.getItem('user_avatar');
|
|
||||||
if (localAvatar) {
|
|
||||||
setAvatarUrl(localAvatar);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
loadAvatar();
|
|
||||||
|
|
||||||
const handleStorageChange = () => {
|
|
||||||
loadAvatar();
|
|
||||||
};
|
|
||||||
|
|
||||||
window.addEventListener('storage', handleStorageChange);
|
|
||||||
return () => window.removeEventListener('storage', handleStorageChange);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isChatOpen && chatInputRef.current) {
|
if (isChatOpen && chatInputRef.current) {
|
||||||
chatInputRef.current.focus();
|
chatInputRef.current.focus();
|
||||||
}
|
}
|
||||||
}, [isChatOpen]);
|
}, [isChatOpen]);
|
||||||
|
|
||||||
|
// scroll automático quando nova mensagem
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (mensagensContainerRef.current) {
|
if (mensagensContainerRef.current) {
|
||||||
mensagensContainerRef.current.scrollTop = mensagensContainerRef.current.scrollHeight;
|
mensagensContainerRef.current.scrollTop = mensagensContainerRef.current.scrollHeight;
|
||||||
}
|
}
|
||||||
}, [mensagens]);
|
}, [mensagens]);
|
||||||
|
|
||||||
// Fecha modal com ESC (útil para logout)
|
// carrega avatar se existir
|
||||||
|
useEffect(() => {
|
||||||
|
const loadAvatar = () => {
|
||||||
|
const localAvatar = localStorage.getItem('user_avatar');
|
||||||
|
if (localAvatar) setAvatarUrl(localAvatar);
|
||||||
|
};
|
||||||
|
loadAvatar();
|
||||||
|
const onStorage = () => loadAvatar();
|
||||||
|
window.addEventListener('storage', onStorage);
|
||||||
|
return () => window.removeEventListener('storage', onStorage);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// ESC fecha qualquer overlay/portal aberto (logout / suporte / chat)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const onKey = (e) => {
|
const onKey = (e) => {
|
||||||
if (e.key === 'Escape' && showLogoutModal) {
|
if (e.key === 'Escape') {
|
||||||
setShowLogoutModal(false);
|
if (showLogoutModal) setShowLogoutModal(false);
|
||||||
|
if (isSuporteCardOpen) setIsSuporteCardOpen(false);
|
||||||
|
if (isChatOpen) setIsChatOpen(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
window.addEventListener('keydown', onKey);
|
window.addEventListener('keydown', onKey);
|
||||||
return () => window.removeEventListener('keydown', onKey);
|
return () => window.removeEventListener('keydown', onKey);
|
||||||
}, [showLogoutModal]);
|
}, [showLogoutModal, isSuporteCardOpen, isChatOpen]);
|
||||||
|
|
||||||
// --- Lógica e handlers ---
|
// --- handlers logout (mantive comportamento) ---
|
||||||
const handleLogoutClick = () => {
|
const handleLogoutClick = () => {
|
||||||
setShowLogoutModal(true);
|
setShowLogoutModal(true);
|
||||||
setIsDropdownOpen(false);
|
setIsDropdownOpen(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleLogoutCancel = () => {
|
const clearAuthData = () => {
|
||||||
setShowLogoutModal(false);
|
["token","authToken","userToken","access_token","user","auth","userData"].forEach(key => {
|
||||||
|
localStorage.removeItem(key);
|
||||||
|
sessionStorage.removeItem(key);
|
||||||
|
});
|
||||||
|
if (window.caches) {
|
||||||
|
caches.keys().then(names => {
|
||||||
|
names.forEach(name => {
|
||||||
|
if (name.includes("auth") || name.includes("api")) caches.delete(name);
|
||||||
|
});
|
||||||
|
}).catch(()=>{});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleLogoutConfirm = async () => {
|
const handleLogoutConfirm = async () => {
|
||||||
@ -81,51 +90,34 @@ const Header = () => {
|
|||||||
sessionStorage.getItem("authToken");
|
sessionStorage.getItem("authToken");
|
||||||
|
|
||||||
if (token) {
|
if (token) {
|
||||||
// tentativa de logout no backend (se houver)
|
|
||||||
try {
|
try {
|
||||||
await fetch(
|
await fetch("https://mock.apidog.com/m1/1053378-0-default/auth/v1/logout", {
|
||||||
"https://mock.apidog.com/m1/1053378-0-default/auth/v1/logout",
|
method: "POST",
|
||||||
{
|
headers: {
|
||||||
method: "POST",
|
"Content-Type": "application/json",
|
||||||
headers: {
|
Authorization: `Bearer ${token}`,
|
||||||
"Content-Type": "application/json",
|
},
|
||||||
Authorization: `Bearer ${token}`,
|
});
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// não interrompe o fluxo se a API falhar — prosseguimos para limpar local
|
// ignora erro de rede / endpoint — prossegue para limpar local
|
||||||
console.warn('Erro ao chamar endpoint de logout (ignorado):', err);
|
console.warn('logout endpoint error (ignored):', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clearAuthData();
|
clearAuthData();
|
||||||
navigate("/login");
|
navigate('/login');
|
||||||
} catch (error) {
|
} catch (err) {
|
||||||
console.error("Erro durante logout:", error);
|
console.error('Erro no logout:', err);
|
||||||
clearAuthData();
|
clearAuthData();
|
||||||
navigate("/login");
|
navigate('/login');
|
||||||
} finally {
|
} finally {
|
||||||
setShowLogoutModal(false);
|
setShowLogoutModal(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearAuthData = () => {
|
const handleLogoutCancel = () => setShowLogoutModal(false);
|
||||||
["token", "authToken", "userToken", "access_token", "user", "auth", "userData"].forEach(key => {
|
|
||||||
localStorage.removeItem(key);
|
|
||||||
sessionStorage.removeItem(key);
|
|
||||||
});
|
|
||||||
|
|
||||||
// tenta limpar caches relacionados se existirem
|
|
||||||
if (window.caches) {
|
|
||||||
caches.keys().then(names => {
|
|
||||||
names.forEach(name => {
|
|
||||||
if (name.includes("auth") || name.includes("api")) caches.delete(name);
|
|
||||||
});
|
|
||||||
}).catch(()=>{ /* ignore */ });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// --- profile / suporte / chat handlers ---
|
||||||
const handleProfileClick = () => {
|
const handleProfileClick = () => {
|
||||||
setIsDropdownOpen(!isDropdownOpen);
|
setIsDropdownOpen(!isDropdownOpen);
|
||||||
if (isSuporteCardOpen) setIsSuporteCardOpen(false);
|
if (isSuporteCardOpen) setIsSuporteCardOpen(false);
|
||||||
@ -138,14 +130,12 @@ const Header = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSuporteClick = () => {
|
const handleSuporteClick = () => {
|
||||||
setIsSuporteCardOpen(!isSuporteCardOpen);
|
setIsSuporteCardOpen((s) => !s);
|
||||||
if (isDropdownOpen) setIsDropdownOpen(false);
|
setIsDropdownOpen(false);
|
||||||
if (isChatOpen) setIsChatOpen(false);
|
if (isChatOpen) setIsChatOpen(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCloseSuporteCard = () => {
|
const handleCloseSuporteCard = () => setIsSuporteCardOpen(false);
|
||||||
setIsSuporteCardOpen(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleChatClick = () => {
|
const handleChatClick = () => {
|
||||||
setIsChatOpen(true);
|
setIsChatOpen(true);
|
||||||
@ -153,7 +143,7 @@ const Header = () => {
|
|||||||
setMensagens([
|
setMensagens([
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
texto: 'Olá! Me chamo Ágatha e sou sua assistente virtual. 👋 Bem-vindo ao suporte Mediconnect. Como posso te ajudar hoje?',
|
texto: 'Olá! Bem-vindo ao suporte Mediconnect. Como podemos ajudar você hoje?',
|
||||||
remetente: 'suporte',
|
remetente: 'suporte',
|
||||||
hora: new Date().toLocaleTimeString('pt-BR', { hour: '2-digit', minute: '2-digit' })
|
hora: new Date().toLocaleTimeString('pt-BR', { hour: '2-digit', minute: '2-digit' })
|
||||||
}
|
}
|
||||||
@ -165,7 +155,7 @@ const Header = () => {
|
|||||||
setMensagem('');
|
setMensagem('');
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEnviarMensagem = async (e) => {
|
const handleEnviarMensagem = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (mensagem.trim() === '') return;
|
if (mensagem.trim() === '') return;
|
||||||
|
|
||||||
@ -179,37 +169,30 @@ const Header = () => {
|
|||||||
setMensagens(prev => [...prev, novaMensagemUsuario]);
|
setMensagens(prev => [...prev, novaMensagemUsuario]);
|
||||||
setMensagem('');
|
setMensagem('');
|
||||||
|
|
||||||
try {
|
setTimeout(() => {
|
||||||
const response = await fetch("http://localhost:5000/api/chat", {
|
if (chatInputRef.current) chatInputRef.current.focus();
|
||||||
method: "POST",
|
}, 0);
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: JSON.stringify({ message: mensagem }),
|
|
||||||
});
|
|
||||||
|
|
||||||
const data = await response.json();
|
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
const respostas = [
|
||||||
|
'Entendi sua dúvida. Vou verificar isso para você.',
|
||||||
|
'Obrigado pela informação. Estou analisando seu caso.',
|
||||||
|
'Pode me dar mais detalhes sobre o problema?',
|
||||||
|
'Já encaminhei sua solicitação para nossa equipe técnica.',
|
||||||
|
'Vou ajudar você a resolver isso!'
|
||||||
|
];
|
||||||
const respostaSuporte = {
|
const respostaSuporte = {
|
||||||
id: Date.now() + 1,
|
id: Date.now() + 1,
|
||||||
texto: data.resposta || data.reply || "Desculpe, não consegui processar sua pergunta no momento 😅",
|
texto: respostas[Math.floor(Math.random() * respostas.length)],
|
||||||
remetente: 'suporte',
|
remetente: 'suporte',
|
||||||
hora: new Date().toLocaleTimeString('pt-BR', { hour: '2-digit', minute: '2-digit' })
|
hora: new Date().toLocaleTimeString('pt-BR', { hour: '2-digit', minute: '2-digit' })
|
||||||
};
|
};
|
||||||
|
|
||||||
setMensagens(prev => [...prev, respostaSuporte]);
|
setMensagens(prev => [...prev, respostaSuporte]);
|
||||||
} catch (error) {
|
}, 900);
|
||||||
console.error("Erro ao conectar com o servidor:", error);
|
|
||||||
const erroMsg = {
|
|
||||||
id: Date.now() + 1,
|
|
||||||
texto: "Ops! Ocorreu um erro ao tentar falar com o suporte.",
|
|
||||||
remetente: 'suporte',
|
|
||||||
hora: new Date().toLocaleTimeString('pt-BR', { hour: '2-digit', minute: '2-digit' })
|
|
||||||
};
|
|
||||||
setMensagens(prev => [...prev, erroMsg]);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Subcomponentes ---
|
// --- subcomponentes (UI) ---
|
||||||
const SuporteCard = () => (
|
const SuporteCardContent = ({ onOpenChat }) => (
|
||||||
<div className="suporte-card">
|
<div className="suporte-card">
|
||||||
<h2 className="suporte-titulo">Suporte</h2>
|
<h2 className="suporte-titulo">Suporte</h2>
|
||||||
<p className="suporte-subtitulo">Entre em contato conosco através dos canais abaixo</p>
|
<p className="suporte-subtitulo">Entre em contato conosco através dos canais abaixo</p>
|
||||||
@ -228,7 +211,7 @@ const Header = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="contato-item clickable" onClick={handleChatClick}>
|
<div className="contato-item clickable" onClick={onOpenChat} role="button" tabIndex={0}>
|
||||||
<div className="contato-info">
|
<div className="contato-info">
|
||||||
<div className="contato-nome">Chat Online</div>
|
<div className="contato-nome">Chat Online</div>
|
||||||
<div className="contato-descricao">Disponível 24/7</div>
|
<div className="contato-descricao">Disponível 24/7</div>
|
||||||
@ -237,11 +220,11 @@ const Header = () => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
const ChatOnline = () => (
|
const ChatOnlineContent = ({ mensagens, onSend, onClose }) => (
|
||||||
<div className="chat-online">
|
<div className="chat-online" role="dialog" aria-modal="true">
|
||||||
<div className="chat-header">
|
<div className="chat-header">
|
||||||
<h3 className="chat-titulo">Chat de Suporte</h3>
|
<h3 className="chat-titulo">Chat de Suporte</h3>
|
||||||
<button type="button" className="fechar-chat" onClick={handleCloseChat}>×</button>
|
<button type="button" className="fechar-chat" onClick={onClose} aria-label="Fechar chat">×</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="chat-mensagens" ref={mensagensContainerRef}>
|
<div className="chat-mensagens" ref={mensagensContainerRef}>
|
||||||
@ -253,7 +236,7 @@ const Header = () => {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form className="chat-input" onSubmit={handleEnviarMensagem}>
|
<form className="chat-input" onSubmit={onSend}>
|
||||||
<input
|
<input
|
||||||
ref={chatInputRef}
|
ref={chatInputRef}
|
||||||
type="text"
|
type="text"
|
||||||
@ -268,12 +251,22 @@ const Header = () => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
// --- Modal de logout renderizado via Portal (garante top-most e clique) ---
|
// --- portals: Logout / Suporte / Chat (garante top-most e clickable) ---
|
||||||
|
const PortalWrapper = ({ children, z = 99999 }) => {
|
||||||
|
if (typeof document === 'undefined') return null;
|
||||||
|
return createPortal(
|
||||||
|
<div style={{ position: 'fixed', inset: 0, zIndex: z }}>
|
||||||
|
{children}
|
||||||
|
</div>,
|
||||||
|
document.body
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const LogoutModalPortal = ({ onCancel, onConfirm }) => {
|
const LogoutModalPortal = ({ onCancel, onConfirm }) => {
|
||||||
const modalContent = (
|
if (typeof document === 'undefined') return null;
|
||||||
|
return createPortal(
|
||||||
<div
|
<div
|
||||||
className="logout-modal-overlay"
|
className="logout-modal-overlay"
|
||||||
// inline style reforçando z-index e pointer events caso algum CSS global esteja atrapalhando
|
|
||||||
style={{
|
style={{
|
||||||
position: 'fixed',
|
position: 'fixed',
|
||||||
top: 0, left: 0, right: 0, bottom: 0,
|
top: 0, left: 0, right: 0, bottom: 0,
|
||||||
@ -281,11 +274,9 @@ const Header = () => {
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
zIndex: 99999,
|
zIndex: 110000
|
||||||
padding: '1rem'
|
|
||||||
}}
|
}}
|
||||||
role="dialog"
|
onClick={onCancel}
|
||||||
aria-modal="true"
|
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className="logout-modal-content"
|
className="logout-modal-content"
|
||||||
@ -303,91 +294,119 @@ const Header = () => {
|
|||||||
<h3 style={{ marginTop: 0 }}>Confirmar Logout</h3>
|
<h3 style={{ marginTop: 0 }}>Confirmar Logout</h3>
|
||||||
<p>Tem certeza que deseja encerrar a sessão?</p>
|
<p>Tem certeza que deseja encerrar a sessão?</p>
|
||||||
<div style={{ display: 'flex', gap: '1rem', justifyContent: 'center', marginTop: '1rem' }}>
|
<div style={{ display: 'flex', gap: '1rem', justifyContent: 'center', marginTop: '1rem' }}>
|
||||||
<button
|
<button onClick={onCancel} className="logout-cancel-button">Cancelar</button>
|
||||||
onClick={onCancel}
|
<button onClick={onConfirm} className="logout-confirm-button">Sair</button>
|
||||||
style={{
|
|
||||||
padding: '10px 18px',
|
|
||||||
borderRadius: '8px',
|
|
||||||
border: '1px solid #ccc',
|
|
||||||
background: 'white',
|
|
||||||
cursor: 'pointer'
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Cancelar
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={onConfirm}
|
|
||||||
style={{
|
|
||||||
padding: '10px 18px',
|
|
||||||
borderRadius: '8px',
|
|
||||||
border: 'none',
|
|
||||||
background: '#dc3545',
|
|
||||||
color: 'white',
|
|
||||||
cursor: 'pointer'
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Sair
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>,
|
||||||
|
document.body
|
||||||
);
|
);
|
||||||
|
|
||||||
// garante que exista document antes de criar portal (SSRed apps podem não ter)
|
|
||||||
if (typeof document === 'undefined') return null;
|
|
||||||
return createPortal(modalContent, document.body);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Agora sim: condicional de render baseado na rota ---
|
const SuportePortal = ({ onClose, children }) => {
|
||||||
|
if (typeof document === 'undefined') return null;
|
||||||
|
return createPortal(
|
||||||
|
<div
|
||||||
|
className="suporte-card-overlay"
|
||||||
|
style={{
|
||||||
|
position: 'fixed', top: 0, left: 0, right: 0, bottom: 0,
|
||||||
|
backgroundColor: 'transparent',
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'flex-end',
|
||||||
|
alignItems: 'flex-start',
|
||||||
|
zIndex: 105000,
|
||||||
|
pointerEvents: 'auto'
|
||||||
|
}}
|
||||||
|
onClick={onClose}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="suporte-card-container"
|
||||||
|
style={{ marginTop: '80px', marginRight: '20px' }}
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</div>,
|
||||||
|
document.body
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const ChatPortal = ({ onClose, children }) => {
|
||||||
|
if (typeof document === 'undefined') return null;
|
||||||
|
return createPortal(
|
||||||
|
<div
|
||||||
|
className="chat-overlay"
|
||||||
|
style={{
|
||||||
|
position: 'fixed', top: 0, left: 0, right: 0, bottom: 0,
|
||||||
|
backgroundColor: 'rgba(0,0,0,0.5)',
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'flex-end',
|
||||||
|
alignItems: 'flex-start',
|
||||||
|
zIndex: 115000,
|
||||||
|
pointerEvents: 'auto'
|
||||||
|
}}
|
||||||
|
onClick={onClose}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="chat-container"
|
||||||
|
style={{ marginTop: '80px', marginRight: '20px' }}
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</div>,
|
||||||
|
document.body
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// --- evita render na rota de login (mantendo hooks invocados) ---
|
||||||
if (location.pathname === '/login') {
|
if (location.pathname === '/login') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- JSX principal ---
|
// --- JSX principal (header visual) ---
|
||||||
return (
|
return (
|
||||||
<div className="header-container">
|
<div className="header-container" style={{ pointerEvents: 'auto' }}>
|
||||||
<div className="right-corner-elements">
|
<div className="right-corner-elements">
|
||||||
<div className="phone-icon-container" onClick={handleSuporteClick}>
|
<div
|
||||||
|
className="phone-icon-container"
|
||||||
|
onClick={handleSuporteClick}
|
||||||
|
role="button"
|
||||||
|
tabIndex={0}
|
||||||
|
style={{ pointerEvents: 'auto' }}
|
||||||
|
>
|
||||||
<span className="phone-icon" role="img" aria-label="telefone">📞</span>
|
<span className="phone-icon" role="img" aria-label="telefone">📞</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="profile-section">
|
<div className="profile-section" style={{ pointerEvents: 'auto' }}>
|
||||||
<div className="profile-picture-container" onClick={handleProfileClick}>
|
<div className="profile-picture-container" onClick={handleProfileClick} role="button" tabIndex={0}>
|
||||||
<div className="profile-placeholder"></div>
|
<div className="profile-placeholder"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{isDropdownOpen && (
|
{isDropdownOpen && (
|
||||||
<div className="profile-dropdown">
|
<div className="profile-dropdown" onClick={(e) => e.stopPropagation()}>
|
||||||
<button type="button" onClick={handleViewProfile} className="dropdown-button">
|
<button type="button" onClick={handleViewProfile} className="dropdown-button">Ver Perfil</button>
|
||||||
Ver Perfil
|
<button type="button" onClick={handleLogoutClick} className="dropdown-button logout-button">Sair (Logout)</button>
|
||||||
</button>
|
|
||||||
<button type="button" onClick={handleLogoutClick} className="dropdown-button logout-button">
|
|
||||||
Sair (Logout)
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Modal de Logout via portal */}
|
{/* logout modal via portal */}
|
||||||
{showLogoutModal && (
|
{showLogoutModal && <LogoutModalPortal onCancel={handleLogoutCancel} onConfirm={handleLogoutConfirm} />}
|
||||||
<LogoutModalPortal onCancel={handleLogoutCancel} onConfirm={handleLogoutConfirm} />
|
|
||||||
)}
|
|
||||||
|
|
||||||
|
{/* suporte portal */}
|
||||||
{isSuporteCardOpen && (
|
{isSuporteCardOpen && (
|
||||||
<div className="suporte-card-overlay" onClick={handleCloseSuporteCard}>
|
<SuportePortal onClose={handleCloseSuporteCard}>
|
||||||
<div className="suporte-card-container" onClick={(e) => e.stopPropagation()}>
|
<SuporteCardContent onOpenChat={handleChatClick} />
|
||||||
<SuporteCard />
|
</SuportePortal>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* chat portal */}
|
||||||
{isChatOpen && (
|
{isChatOpen && (
|
||||||
<div className="chat-overlay">
|
<ChatPortal onClose={handleCloseChat}>
|
||||||
<div className="chat-container">
|
<ChatOnlineContent mensagens={mensagens} onSend={handleEnviarMensagem} onClose={handleCloseChat} />
|
||||||
<ChatOnline />
|
</ChatPortal>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user