// App — client-side router for the Eventi Vino Milano website UI kit.
function App() {
  const NS = window.EventiVinoMilanoDesignSystem_98fdb6;
  const { Header, Footer } = NS;
  const [route, setRoute] = React.useState('Home');
  const [eventId, setEventId] = React.useState(null);
  const [articleId, setArticleId] = React.useState(null);

  const go = (r, id) => {
    if (r === 'EventDetail') setEventId(id);
    if (r === 'ArticleDetail') setArticleId(id);
    setRoute(r);
    window.scrollTo(0, 0);
  };
  const navActive = route === 'EventDetail' ? 'Eventi' : (route === 'ArticleDetail' ? 'Blog' : route);

  let Screen;
  switch (route) {
    case 'Eventi': Screen = <window.EventiScreen go={go} />; break;
    case 'EventDetail': Screen = <window.EventDetailScreen go={go} eventId={eventId} />; break;
    case 'Chi sono': Screen = <window.ChiSonoScreen go={go} />; break;
    case 'Blog': Screen = <window.BlogScreen go={go} />; break;
    case 'ArticleDetail': Screen = <window.ArticleDetailScreen go={go} articleId={articleId} />; break;
    case 'Contatti': Screen = <window.ContattiScreen go={go} />; break;
    default: Screen = <window.HomeScreen go={go} />;
  }

  return (
    <div>
      <Header logo="immagini/logo-eventi-vino-milano.png" active={navActive} onNavigate={go} />
      {Screen}
      <Footer logo="immagini/logo-eventi-vino-milano.png" />
    </div>
  );
}
window.EVMApp = App;
