"use client"; import { useEffect, useState } from "react"; import { motion } from "framer-motion"; import type { Product } from "@/lib/products"; import Image from "next/image"; import { useLanguage } from "@/context/language-context"; import Link from "next/link"; import { ChevronsRight } from "lucide-react"; import { ProductCard } from "./ProductCard"; import axios from "axios"; import EmptyState from "../productsPage/emptyData"; import Loading from "../loading"; import { getAllProducts } from "@/lib/api"; import { generateSlug } from "@/lib/slug"; // hello everyone export function ProductsGrid() { const { t } = useLanguage(); const [allProducts, setAllProducts] = useState([]); const [loading, setLoading] = useState(false); useEffect(() => { async function getData() { setLoading(true); const products = await getAllProducts(); setAllProducts( products.map((product: any) => ({ ...product, slug: generateSlug(product.name_uz), })).slice(0, 3) ); setLoading(false); } getData(); }, []); return ( <>
hero image
{/* Header */}

{t.products.title}

{loading && (
)} {/* Product Grid */} {loading || (allProducts && allProducts.length > 0) ? ( {allProducts.map((product: any) => ( ))} ) : ( )}
{t.more}
); }