import React from 'react' import "./Home.css" import Product from '../Product/Product' import { toast } from 'react-toastify'; import { useEffect } from 'react' import faker from 'faker' import { ToastContainer } from 'react-toastify'; const Home = () => { useEffect(() => ( slider(0) ), []) return (
{/* Image Banner */}
image0
image1
image2
image3
image4
image5
image6
{/* Product id, title, price, rating, image */}
{/* Product */}
{/* Product */}
{/* Product */}
{/* Product */}
) } function slider(counter) { const slides = document.querySelectorAll(".home__image"); slides.forEach((slide, index) => { if (index !== counter) { slide.style.visibility = `hidden` slide.classList.add(`image-${index}`) } }) moveCorousal(counter, slides, slides.length) } function moveCorousal(counter, slides, len) { if (slides) { if (counter >= len - 1) counter = 0 else counter += 1 slides.forEach((slide, index) => { if (index === counter) { slide.style.visibility = `visible` } else { slide.style.visibility = `hidden` } }) } setTimeout(() => { moveCorousal(counter, slides, len); }, 5000) parseInt(counter) % 5 === 0 ? ( setTimeout(() => { toast.info(`${faker.name.findName()} added new product to cart`, { position: "bottom-left" }); }, 10500) ) : ( setTimeout(() => { }, 21000) ) } export default Home