"use client"; import { useEffect, useState } from "react"; import EmptyState from "./emptyData"; import { motion } from "framer-motion"; import { ProductCard } from "../productSection/ProductCard"; import axios from "axios"; import Loading from "../loading"; const itemVariants = { hidden: { opacity: 0, y: 20 }, visible: { opacity: 1, y: 0 }, }; export default function Products() { 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: ", res?.data); const allData = res?.data || []; setAllProducts(allData); setLoading(false); }); } getData(); }, []); return (
{loading && (
)} {loading || (allProducts && allProducts.length > 0) ? (
{allProducts.map((product: any) => ( ))}
) : ( )}
); }