Skip to content

Commit

Permalink
conditional rendering in catalougue
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakob-SA committed Nov 23, 2024
1 parent 96b11f4 commit 0112bdb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Frontend/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ a:hover {

body {
margin: 0;
padding-top: 5rem;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}
Expand Down
32 changes: 19 additions & 13 deletions Frontend/src/views/product-catalogue/product-catalogue-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const ProductCataloguePage: React.FC = () => {
}

return (
<div className="relative z-10 p-8">
<div className="min-h-dvh">
<h1 className="text-4xl font-bold mb-8">Product Catalogue</h1>
<input
type="text"
Expand All @@ -74,19 +74,25 @@ const ProductCataloguePage: React.FC = () => {
className="mb-4 p-2 border border-gray-300 rounded"
/>
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-8">
{products.map((product) => (
<Link key={product.itemId} to={`/products/${product.itemId}`}>
<ProductCard
imageSrc={product.itemName} // Adjust this to the actual image URL property
productName={product.itemName}
description={product.description}
listing={product.currentPrice}
category={"Category"} // Adjust this if you have a category
/>
</Link>
))}
{products.length === 0 ? (
<div className="col-span-full text-center">
No products match your search.
</div>
) : (
products.map((product) => (
<Link key={product.itemId} to={`/products/${product.itemId}`}>
<ProductCard
imageSrc={product.itemName} // Adjust this to the actual image URL property
productName={product.itemName}
description={product.description}
listing={product.currentPrice}
category={"Category"} // Adjust this if you have a category
/>
</Link>
))
)}
</div>
<div className="flex justify-between mt-4">
<div className="flex justify-between mt-auto">
<button
onClick={handlePreviousPage}
disabled={page === 1}
Expand Down

0 comments on commit 0112bdb

Please sign in to comment.