empty data component

This commit is contained in:
nabijonovdavronbek619@gmail.com
2025-12-11 18:54:27 +05:00
parent cf26b778fc
commit 6e41a836a7
6 changed files with 101 additions and 16 deletions

View File

@@ -1,16 +1,24 @@
"use client";
import { allProduct } from "@/lib/allProducts";
import React, { useEffect, useState } from "react";
import { useEffect, useState } from "react";
import EmptyState from "./emptyData";
export default function Products() {
const [allProducts, setAllProducts] = useState<any>(null);
useEffect(() => {
const all = allProduct();
all && Array.isArray(all) ? setAllProducts(all) : setAllProducts([]);
all && Array.isArray(all) && all.length > 0
? setAllProducts(all)
: setAllProducts([]);
setAllProducts;
}, [allProducts]);
}, []);
return (
<div>
<div className="grid lg:grid-cols-3 sm:grid-cols-2 grid-cols-1 gap-4"></div>
<div className="">
{allProducts && allProducts.length > 0 ? (
<div className="grid lg:grid-cols-3 sm:grid-cols-2 grid-cols-1 gap-4"></div>
) : (
<EmptyState />
)}
</div>
);
}