Skip to content

Commit

Permalink
simplify render and quicker
Browse files Browse the repository at this point in the history
  • Loading branch information
ericspaghetti committed Mar 3, 2024
1 parent 3d19a13 commit 4c92913
Showing 1 changed file with 17 additions and 32 deletions.
49 changes: 17 additions & 32 deletions components/display-products.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ const DisplayEvents = ({
let parsedData = parseTags(event);
if (parsedData) parsedProductData.push(parsedData);
});
setIsProductLoading(false);
setProductEvents(parsedProductData);
setIsProductLoading(false);
}
}, [productEventContext]);

Expand Down Expand Up @@ -186,41 +186,26 @@ const DisplayEvents = ({
<>
<div className="w-full md:pl-4">
{/* DISPLAYS PRODUCT LISTINGS HERE */}
<div className="grid h-[90%] max-w-full grid-cols-[repeat(auto-fill,minmax(300px,1fr))] justify-items-center gap-4 overflow-x-hidden">
{productEvents.map((productData: ProductData, index) => {
return displayProductCard(productData, index);
})}
</div>
{profileMapContext.isLoading ||
productEventContext.isLoading ||
isProductsLoading ||
productEvents.length === 0 ? (
!isProductsLoading && isThereAFilter() ? (
<div className="mt-8 flex items-center justify-center">
<h1 className="text-2xl text-light-text dark:text-dark-text">
No products found...
</h1>
</div>
) : (
<div className="mt-8 flex items-center justify-center">
<ShopstrSpinner />
</div>
)
) : (
<div className="grid h-[90%] max-w-full grid-cols-[repeat(auto-fill,minmax(300px,1fr))] justify-items-center gap-4 overflow-x-hidden">
{productEvents.map((productData: ProductData, index) => {
return displayProductCard(productData, index);
})}
isLoadingMore ? (
<div className="mt-8 flex items-center justify-center">
<ShopstrSpinner />
</div>
)}
{canShowLoadMore && !profileMapContext.isLoading && !productEventContext.isLoading ? (
) : canShowLoadMore ? (
<div className="mt-8 h-20 px-4">
{!isLoadingMore ? (
<Button
className={`${SHOPSTRBUTTONCLASSNAMES} w-full`}
onClick={async () => await loadMoreListings()}
>
Load More
</Button>
) : (
<div className="mt-8 flex items-center justify-center">
<ShopstrSpinner />
</div>
)}
<Button
className={`${SHOPSTRBUTTONCLASSNAMES} w-full`}
onClick={async () => await loadMoreListings()}
>
Load More
</Button>
</div>
) : null}
</div>
Expand Down

0 comments on commit 4c92913

Please sign in to comment.