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,
  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 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 = 'Hyper-personalization';

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

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

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

  const features_points = [
    {
      name: 'Personalized Outfit Suggestions',
      description:
        'Receive tailored outfit recommendations based on your preferences and occasions. Our AI ensures you always look your best.',
      icon: 'mdiAccountCircle',
    },
    {
      name: 'Occasion-Based Styling',
      description:
        "Whether it's a college event or a wedding, get the perfect look for any occasion with our comprehensive style guides.",
      icon: 'mdiCalendar',
    },
    {
      name: 'Complete Look Visualization',
      description:
        'Visualize your entire outfit, from clothing to accessories, with our intuitive interface. See how everything comes together effortlessly.',
      icon: 'mdiEye',
    },
  ];

  const [images, setImages] = useState([]);
  const pexelsQueriesWebSite = [
    'Chic college wear outfits',
    'Elegant wedding attire',
    'Trendy party wear looks',
    'Traditional temple wear',
    'Complete outfit with accessories',
  ];
  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>{`Discover Your Perfect Outfit with Our AI-Powered Fashion Guide`}</title>
        <meta
          name='description'
          content={`Explore our AI-driven fashion platform to find personalized outfit suggestions for every occasion. From college wear to wedding ensembles, let us help you look your best.`}
        />
      </Head>
      <WebSiteHeader projectName={'Hyper-personalization'} pages={pages} />
      <main className={`flex-grow  ${bgColor}    rounded-none  `}>
        <HeroSection
          projectName={'Hyper-personalization'}
          image={['Stylish outfits for every occasion']}
          mainText={`Transform Your Style with AI Fashion`}
          subTitle={`Discover personalized outfit suggestions for every occasion with ${projectName}. From college wear to weddings, let our AI guide your fashion choices.`}
          design={HeroDesigns.IMAGE_BG || ''}
          buttonText={`Explore Now`}
        />

        <FeaturesSection
          projectName={'Hyper-personalization'}
          image={['AI-driven fashion suggestions']}
          withBg={1}
          features={features_points}
          mainText={`Explore ${projectName} Features`}
          subTitle={`Discover how ${projectName} revolutionizes your fashion experience with AI-driven personalization and seamless outfit suggestions.`}
          design={FeaturesDesigns.CARDS_GRID_WITH_ICONS || ''}
        />

        <GalleryPortfolioSection
          projectName={'Hyper-personalization'}
          images={images}
          mainText={`Discover Your Style Journey`}
          design={GalleryPortfolioDesigns.OVERLAPPING_CENTRAL_IMAGE || ''}
        />

        <ContactFormSection
          projectName={'Hyper-personalization'}
          design={ContactFormDesigns.WITH_IMAGE || ''}
          image={['Fashion consultation and support']}
          mainText={`Get in Touch with ${projectName} `}
          subTitle={`Reach out anytime for personalized fashion advice or inquiries. Our team at ${projectName} is here to assist you promptly.`}
        />
      </main>
      <WebSiteFooter projectName={'Hyper-personalization'} pages={pages} />
    </div>
  );
}

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