import React, { useEffect, useState } from 'react';
import type { ReactElement } from 'react';
import Head from 'next/head';
import Link from 'next/link';
import { useAppSelector } from '../stores/hooks';
import LayoutGuest from '../layouts/Guest';
import WebSiteHeader from '../components/WebPageComponents/Header';
import WebSiteFooter from '../components/WebPageComponents/Footer';
import {
  HeroDesigns,
  FeaturesDesigns,
  GalleryPortfolioDesigns,
  AboutUsDesigns,
  ContactFormDesigns,
} from '../components/WebPageComponents/designs';

import HeroSection from '../components/WebPageComponents/HeroComponent';

import FeaturesSection from '../components/WebPageComponents/FeaturesComponent';

import GalleryPortfolioSection from '../components/WebPageComponents/GalleryPortfolioComponent';

import { getMultiplePexelsImages } from '../helpers/pexels';

import AboutUsSection from '../components/WebPageComponents/AboutUsComponent';

import ContactFormSection from '../components/WebPageComponents/ContactFormComponent';

export default function WebSite() {
  const cardsStyle = useAppSelector((state) => state.style.cardsStyle);
  const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
  const projectName = 'Tucanus9050';

  useEffect(() => {
    const darkElement = document.querySelector('body .dark');
    if (darkElement) {
      darkElement.classList.remove('dark');
    }
  }, []);
  const pages = [
    {
      href: '/home',
      label: 'home',
    },

    {
      href: '/about',
      label: 'about',
    },

    {
      href: '/contact',
      label: 'contact',
    },

    {
      href: '/portfolio_gallery',
      label: 'portfolio_gallery',
    },
  ];

  const features_points = [
    {
      name: 'Task Management',
      description:
        'Efficiently manage and track tasks with real-time updates. Keep everyone on the same page and ensure timely completion of projects.',
      icon: 'mdiClipboardCheck',
    },
    {
      name: 'AI Chatbot Assistance',
      description:
        'Get instant help and guidance with our AI-powered chatbot. Enhance your learning and problem-solving with smart assistance.',
      icon: 'mdiRobot',
    },
    {
      name: 'Scouting System',
      description:
        'Collect and analyze match data with ease. Our interactive scouting system provides valuable insights and rankings for strategic planning.',
      icon: 'mdiChartLine',
    },
  ];

  const [images, setImages] = useState([]);
  const pexelsQueriesWebSite = [
    'Team building the robot',
    'Robotics competition excitement',
    'Innovative robot design process',
    'Team brainstorming session',
    'Celebrating competition success',
  ];
  useEffect(() => {
    const fetchImages = async () => {
      try {
        const images = await getMultiplePexelsImages(pexelsQueriesWebSite);
        const formattedImages = (images || []).map((image) => ({
          src: image?.src || undefined,
          photographer: image?.photographer || undefined,
          photographer_url: image?.photographer_url || undefined,
        }));
        setImages(formattedImages);
      } catch (error) {
        console.error('Error fetching images:', error);
      }
    };

    fetchImages();
  }, []);

  return (
    <div className='flex flex-col min-h-screen'>
      <Head>
        <title>{`Tucanus FRC #9050 Robotics Team - Home`}</title>
        <meta
          name='description'
          content={`Welcome to the official website of the Tucanus FRC #9050 Robotics Team from Nova Friburgo, RJ. Discover our innovative projects, meet our team, and learn about our journey in the FIRST Robotics Competition.`}
        />
      </Head>
      <WebSiteHeader projectName={'Tucanus9050'} pages={pages} />
      <main className={`flex-grow  ${bgColor}    rounded-none  `}>
        <HeroSection
          projectName={'Tucanus9050'}
          image={['Robotics team in action']}
          mainText={`Join the Tucanus Robotics Revolution!`}
          subTitle={`Explore the innovative world of the Tucanus FRC #9050 Robotics Team. Discover our passion for technology, creativity, and teamwork as we compete in the FIRST Robotics Competition.`}
          design={HeroDesigns.IMAGE_BG || ''}
          buttonText={`Discover More`}
        />

        <FeaturesSection
          projectName={'Tucanus9050'}
          image={['Team collaborating on robot design']}
          withBg={1}
          features={features_points}
          mainText={`Explore the Innovative Features of ${projectName}`}
          subTitle={`Discover the cutting-edge features that make the Tucanus FRC #9050 Robotics Team stand out in the FIRST Robotics Competition.`}
          design={FeaturesDesigns.CARDS_GRID_WITH_ICONS || ''}
        />

        <GalleryPortfolioSection
          projectName={'Tucanus9050'}
          images={images}
          mainText={`Showcasing Our Robotics Journey`}
          design={GalleryPortfolioDesigns.OVERLAPPING_CENTRAL_IMAGE || ''}
        />

        <AboutUsSection
          projectName={'Tucanus9050'}
          image={['Team members collaborating passionately']}
          mainText={`Meet the Innovators Behind ${projectName}`}
          subTitle={`Discover the passion and dedication driving the Tucanus FRC #9050 Robotics Team. Our mission is to inspire innovation and teamwork in the world of robotics.`}
          design={AboutUsDesigns.IMAGE_LEFT || ''}
          buttonText={`Learn More About Us`}
        />

        <ContactFormSection
          projectName={'Tucanus9050'}
          design={ContactFormDesigns.WITH_IMAGE || ''}
          image={['Contact us for more information']}
          mainText={`Get in Touch with ${projectName} `}
          subTitle={`Reach out to us anytime for inquiries or support. Our team is here to assist you with any questions about the Tucanus FRC #9050 Robotics Team.`}
        />
      </main>
      <WebSiteFooter projectName={'Tucanus9050'} pages={pages} />
    </div>
  );
}

WebSite.getLayout = function getLayout(page: ReactElement) {
  return <LayoutGuest>{page}</LayoutGuest>;
};
