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:
@@ -12,12 +12,23 @@ export default function Header() {
|
||||
const { theme, setTheme } = useTheme();
|
||||
const { locale, setLocale, t } = useLocale();
|
||||
const [mounted, setMounted] = useState(false);
|
||||
const [whatsappLink, setWhatsappLink] = useState('https://wa.me/5535988229445');
|
||||
|
||||
// Prefixo para links baseado no locale
|
||||
const prefix = locale === 'pt' ? '' : `/${locale}`;
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true);
|
||||
|
||||
// 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);
|
||||
}, []);
|
||||
|
||||
// Prevent scrolling when mobile menu is open
|
||||
@@ -86,13 +97,15 @@ export default function Header() {
|
||||
</nav>
|
||||
|
||||
<div className="shrink-0 ml-2">
|
||||
<Link
|
||||
href={`${prefix}/contato`}
|
||||
<a
|
||||
href={whatsappLink}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="px-6 py-2.5 bg-primary text-white rounded-lg font-bold hover-primary transition-colors flex items-center gap-2"
|
||||
>
|
||||
<i className="ri-whatsapp-line"></i>
|
||||
<span className="hidden xl:inline">{t('nav.contactUs')}</span>
|
||||
</Link>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2 pl-4 border-l border-gray-200 dark:border-white/10">
|
||||
@@ -186,14 +199,16 @@ export default function Header() {
|
||||
</nav>
|
||||
|
||||
<div className="mt-6 flex flex-col gap-4 pb-8 shrink-0">
|
||||
<Link
|
||||
href={`${prefix}/contato`}
|
||||
<a
|
||||
href={whatsappLink}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
onClick={() => setIsMobileMenuOpen(false)}
|
||||
className="w-full py-4 bg-primary text-white rounded-xl font-bold text-center flex items-center justify-center gap-2 shadow-lg shadow-primary/20"
|
||||
>
|
||||
<i className="ri-whatsapp-line text-xl"></i>
|
||||
{t('nav.contactUs')}
|
||||
</Link>
|
||||
</a>
|
||||
|
||||
<div
|
||||
className="flex items-center justify-between p-4 bg-gray-50 dark:bg-white/5 rounded-xl cursor-pointer hover:bg-gray-100 dark:hover:bg-white/10 transition-colors"
|
||||
|
||||
Reference in New Issue
Block a user