// Main Latma app: routing + product modal
function App() {
const [route, setRoute] = React.useState(() => {
const hash = (window.location.hash || '#home').replace('#', '');
const valid = ['home', 'historia', 'produtos', 'contato'];
return valid.includes(hash) ? hash : 'home';
});
const [activeProduct, setActiveProduct] = React.useState(null);
React.useEffect(() => {
const onHashChange = () => {
const hash = (window.location.hash || '#home').replace('#', '');
const valid = ['home', 'historia', 'produtos', 'contato'];
if (valid.includes(hash)) setRoute(hash);
};
window.addEventListener('hashchange', onHashChange);
return () => window.removeEventListener('hashchange', onHashChange);
}, []);
const navigate = (r) => {
setRoute(r);
window.location.hash = r;
window.scrollTo({ top: 0, behavior: 'smooth' });
};
const showProduct = (p) => setActiveProduct(p);
const closeProduct = () => setActiveProduct(null);
React.useEffect(() => {
if (activeProduct) {
document.body.style.overflow = 'hidden';
} else {
document.body.style.overflow = '';
}
return () => { document.body.style.overflow = ''; };
}, [activeProduct]);
let pageEl;
if (route === 'historia') pageEl =
{activeProduct.desc}
{activeProduct.ingredientes}