From d2f0ac2041b04117e24db0316b470646489aca07 Mon Sep 17 00:00:00 2001 From: Samantha Kellow Date: Wed, 24 Apr 2024 17:52:02 +0100 Subject: [PATCH] updating carousel to new style --- components/ui/carousel.tsx | 69 +++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 24 deletions(-) diff --git a/components/ui/carousel.tsx b/components/ui/carousel.tsx index 1b7f956ad..a16d2f957 100644 --- a/components/ui/carousel.tsx +++ b/components/ui/carousel.tsx @@ -1,37 +1,58 @@ import { getCollectionProducts } from 'lib/shopify'; +import { getAllLiveProducts } from 'lib/utils'; import Link from 'next/link'; import { GridTileImage } from '../grid/tile'; -export async function Carousel() { +type Collection = 'flower' | 'foliage' | 'nature' | 'urban' | 'sky'; + +export async function Carousel({collection}: + { + collection: Collection | undefined +}) { // Collections that start with `hidden-*` are hidden from the search page. - const products = await getCollectionProducts({ collection: 'hidden-homepage-carousel' }); - console.log("🐡🐠🐬 products", products); + const scapeTitle = collection ? `${collection[0]?.toUpperCase()}${collection.slice(1)}scapes` : ''; + const getProducts = async () => { + return !!collection ? getCollectionProducts({ collection: scapeTitle }) : getAllLiveProducts(); + }; + const products = await getProducts(); if (!products?.length) return null; return ( -
-
- {[...products, ...products].map((product, i) => ( - - - - ))} +
+ {scapeTitle && + +

{scapeTitle}

+ + } + {!scapeTitle && + // +

All Scapes

+ // + } +
+
+ {[...products, ...products].map((product, i) => ( + + + + ))} +
);