From 78a79a44b773b232fc233cb1787b4f3090f18c14 Mon Sep 17 00:00:00 2001 From: Chloe Date: Wed, 8 May 2024 14:11:16 +0700 Subject: [PATCH] fix: update PLP display Signed-off-by: Chloe --- app/search/[collection]/page.tsx | 52 ++++++++++--------- app/search/layout.tsx | 9 ++-- components/breadcrumb/index.tsx | 3 +- components/grid/three-items.tsx | 3 +- components/grid/tile.tsx | 52 +++++++++---------- components/label.tsx | 27 ++++------ components/layout/product-grid-items.tsx | 2 +- .../layout/search/filters/mobile-filters.tsx | 17 ++---- components/layout/search/filters/sub-menu.tsx | 6 ++- components/layout/search/header.tsx | 21 ++++++++ components/layout/search/placeholder.tsx | 25 +++++++++ components/product/gallery.tsx | 2 +- package.json | 1 + pnpm-lock.yaml | 11 ++++ tailwind.config.js | 3 +- 15 files changed, 138 insertions(+), 96 deletions(-) create mode 100644 components/layout/search/header.tsx create mode 100644 components/layout/search/placeholder.tsx diff --git a/app/search/[collection]/page.tsx b/app/search/[collection]/page.tsx index 860dfea79..8cc6f3e14 100644 --- a/app/search/[collection]/page.tsx +++ b/app/search/[collection]/page.tsx @@ -1,4 +1,4 @@ -import { getCollection, getCollectionProducts, getMenu } from 'lib/shopify'; +import { getCollection, getCollectionProducts } from 'lib/shopify'; import { Metadata } from 'next'; import { notFound } from 'next/navigation'; @@ -9,6 +9,8 @@ import ProductGridItems from 'components/layout/product-grid-items'; import FiltersList from 'components/layout/search/filters/filters-list'; import MobileFilters from 'components/layout/search/filters/mobile-filters'; import SubMenu from 'components/layout/search/filters/sub-menu'; +import Header, { HeaderPlaceholder } from 'components/layout/search/header'; +import ProductsGridPlaceholder from 'components/layout/search/placeholder'; import SortingMenu from 'components/layout/search/sorting-menu'; import { AVAILABILITY_FILTER_ID, @@ -90,7 +92,7 @@ const constructFilterInput = (filters: { return results; }; -export default async function CategoryPage({ +async function CategoryPage({ params, searchParams }: { @@ -101,42 +103,23 @@ export default async function CategoryPage({ const { sortKey, reverse } = sorting.find((item) => item.slug === sort) || defaultSort; const filtersInput = constructFilterInput(rest); - const productsData = getCollectionProducts({ + const { products, filters } = await getCollectionProducts({ collection: params.collection, sortKey, reverse, ...(filtersInput.length ? { filters: filtersInput } : {}) }); - const collectionData = getCollection(params.collection); - const menuData = getMenu('main-menu'); - - const [{ products, filters }, collection, menu] = await Promise.all([ - productsData, - collectionData, - menuData - ]); return ( <> -
- }> - - -
- {collection ? ( -
-

{collection.title}

-

{collection.description}

-
- ) : null}
- + } />
@@ -154,3 +137,24 @@ export default async function CategoryPage({ ); } + +export default function CategorySearchPage(props: { + params: { collection: string }; + searchParams?: { [key: string]: string | string[] | undefined }; +}) { + return ( + <> +
+ }> + + +
+ }> +
+ + }> + + + + ); +} diff --git a/app/search/layout.tsx b/app/search/layout.tsx index 7bdb8cf47..786aee999 100644 --- a/app/search/layout.tsx +++ b/app/search/layout.tsx @@ -1,11 +1,12 @@ import Footer from 'components/layout/footer'; -import { Suspense } from 'react'; export default function SearchLayout({ children }: { children: React.ReactNode }) { return ( - -
{children}
+ <> +
+ {children} +