import { useEffect } from "react";
import { useLocation } from "react-router-dom";

import Hero from "@/components/Hero";
import NewsSection from "@/components/NewsSection";
import TeamSection from "@/components/TeamSection";
import GallerySection from "@/components/GallerySection";
import AboutSection from "@/components/AboutSection";
import ContactSection from "@/components/ContactSection";
import EventsSection from "../components/EventsSection";

const Index = () => {
  const location = useLocation();

  useEffect(() => {
    const scrollToId = location.state?.scrollTo;
    if (scrollToId) {
      const element = document.getElementById(scrollToId);
      if (element) {
        element.scrollIntoView({ behavior: "smooth" });
      }
    }
  }, [location]);

  return (
    <div className="min-h-screen bg-white">
      <div id="top" />
      <Hero />
      <div id="news" />
      <NewsSection />
      <div id="events" />
      <EventsSection/>
      <div id="team" />
      <TeamSection />
      <div id="gallery" />
      <GallerySection />
      <div id="about" />
      <AboutSection />
      <div id="contact" />
      <ContactSection />
    </div>
  );
};

export default Index;
