import { useEffect } from 'react'; /** * Hook para gerenciar os metadados do documento (Título e Favicon) * baseado no ambiente e na página atual. * * @param {string} title - O título da página * @param {'fleet' | 'finance' | 'rh' | 'login'} type - O tipo de ambiente para o favicon */ export const useDocumentMetadata = (title, type) => { useEffect(() => { // 1. Atualizar o Título if (title) { document.title = title; } // 2. Atualizar o Favicon (SVG dinâmico baseado no tipo) if (type) { const updateFavicon = () => { const colors = { fleet: '#10b981', // Emerald 500 finance: '#059669', // Emerald 600 rh: '#10b981', // Emerald 500 (alinhado com o tema do ambiente RH) prafrot: '#eab308', // Yellow 500 login: '#64748b', // Slate 500 }; const iconPaths = { fleet: '', finance: '', rh: '', login: '' }; const color = colors[type] || colors.login; const path = (type === 'prafrot') ? iconPaths.fleet : (iconPaths[type] || iconPaths.login); const svg = ` ${path} `.replace(/\s+/g, ' ').trim(); const dataUrl = `data:image/svg+xml;base64,${btoa(svg)}`; let link = document.querySelector("link[rel*='icon']"); if (!link) { link = document.createElement('link'); link.rel = 'icon'; document.head.appendChild(link); } link.href = dataUrl; }; updateFavicon(); } }, [title, type]); };