"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"; // hello everyone export function ProductsGrid() { const { t } = useLanguage(); const [allProducts, setAllProducts] = useState([]); const [loading, setLoading] = useState(false); useEffect(() => { async function getData() { setLoading(true); await axios .get("https://admin.promtechno.uz/api/products/") .then((res) => { console.log("all data main page: ", res?.data); const allData = res?.data || []; setAllProducts(allData.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}
); }