"use client"; import { products } from "@/data/products"; import React from "react"; import { Swiper, SwiperSlide } from "swiper/react"; import Link from "next/link"; import Image from "next/image"; import { Pagination } from "swiper/modules"; import { useContextElement } from "@/context/Context"; export default function RelatedProducts() { const { addProductToCart, isAddedToCartProducts } = useContextElement(); return (

Related products

See All
{products.map((product, i) => (
item
{product.title}
{product.oldPrice ? ( <> $ {product.price.toFixed( product.price % 1 === 0 ? 0 : 2 )} $ {product.oldPrice.toFixed( product.oldPrice % 1 === 0 ? 0 : 2 )} ) : ( `$${product.price.toFixed( product.price % 1 === 0 ? 0 : 2 )}` )}
{ e.preventDefault(); addProductToCart(product.id); }} className={`add-cart ${ isAddedToCartProducts(product.id) ? "cart-added" : "" }`} >
))}
); }