feat: WhatsApp dinâmico do CMS - Criada API /api/contact-info que busca número do CMS - Header e botão flutuante agora puxam número dinamicamente - Número padrão: (35) 9882-9445
This commit is contained in:
@@ -2,13 +2,27 @@
|
||||
|
||||
import Link from 'next/link';
|
||||
import { useLanguage } from '@/contexts/LanguageContext';
|
||||
import { useState, useEffect } from 'react';
|
||||
|
||||
export default function WhatsAppButton() {
|
||||
const { t } = useLanguage();
|
||||
const [whatsappLink, setWhatsappLink] = useState('https://wa.me/5535988229445');
|
||||
|
||||
useEffect(() => {
|
||||
// Busca o número do WhatsApp do CMS
|
||||
fetch('/api/contact-info')
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
if (data.whatsappLink) {
|
||||
setWhatsappLink(data.whatsappLink);
|
||||
}
|
||||
})
|
||||
.catch(console.error);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Link
|
||||
href="https://wa.me/5511999999999" // Substitua pelo número real
|
||||
href={whatsappLink}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="fixed bottom-6 right-6 z-40 flex flex-row-reverse items-center justify-center bg-[#25D366] text-white w-14 h-14 rounded-full shadow-lg hover:bg-[#20bd5a] transition-all hover:scale-110 group animate-in slide-in-from-bottom-4 duration-700 delay-1000 hover:w-auto hover:px-6"
|
||||
|
||||
Reference in New Issue
Block a user