mirror of
https://github.com/vercel/commerce.git
synced 2025-05-12 12:47:50 +00:00
fix broken PLP page
Signed-off-by: Chloe <pinkcloudvnn@gmail.com>
This commit is contained in:
parent
8333eb36fc
commit
7015d1caef
@ -44,7 +44,8 @@ async function CategoryPage({
|
||||
searchParams?: { [key: string]: string | string[] | undefined };
|
||||
}) {
|
||||
const { products, filters, pageInfo } = await getProductsInCollection({
|
||||
searchParams
|
||||
searchParams,
|
||||
collection: params.collection
|
||||
});
|
||||
|
||||
return (
|
||||
@ -65,7 +66,7 @@ async function CategoryPage({
|
||||
<ProductsList
|
||||
initialProducts={products}
|
||||
pageInfo={pageInfo}
|
||||
page="collection"
|
||||
collection={params.collection}
|
||||
searchParams={searchParams}
|
||||
key={JSON.stringify(searchParams)}
|
||||
/>
|
||||
@ -95,7 +96,10 @@ export default async function CategorySearchPage(props: {
|
||||
fallback={<FiltersListPlaceholder />}
|
||||
key={`filters-${props.params.collection}`}
|
||||
>
|
||||
<FiltersContainer searchParams={props.searchParams} />
|
||||
<FiltersContainer
|
||||
searchParams={props.searchParams}
|
||||
collection={props.params.collection}
|
||||
/>
|
||||
<HelpfulLinks collection={props.params.collection} />
|
||||
</Suspense>
|
||||
</aside>
|
||||
|
@ -41,7 +41,6 @@ export default async function SearchPage({
|
||||
initialProducts={products}
|
||||
pageInfo={pageInfo}
|
||||
searchParams={searchParams}
|
||||
page="search"
|
||||
/>
|
||||
</Grid>
|
||||
) : null}
|
||||
|
@ -64,14 +64,16 @@ const constructFilterInput = (filters: {
|
||||
|
||||
export const getProductsInCollection = async ({
|
||||
searchParams,
|
||||
afterCursor
|
||||
afterCursor,
|
||||
collection
|
||||
}: {
|
||||
searchParams?: {
|
||||
[key: string]: string | string[] | undefined;
|
||||
};
|
||||
afterCursor?: string;
|
||||
collection?: string;
|
||||
}) => {
|
||||
const { sort, q, collection, ...rest } = searchParams as { [key: string]: string };
|
||||
const { sort, q, ...rest } = searchParams as { [key: string]: string };
|
||||
const { sortKey, reverse } = sorting.find((item) => item.slug === sort) || defaultSort;
|
||||
const filtersInput = constructFilterInput(rest);
|
||||
|
||||
|
@ -13,7 +13,7 @@ const ProductsList = ({
|
||||
initialProducts,
|
||||
pageInfo,
|
||||
searchParams,
|
||||
page
|
||||
collection
|
||||
}: {
|
||||
initialProducts: Product[];
|
||||
pageInfo: {
|
||||
@ -21,7 +21,7 @@ const ProductsList = ({
|
||||
hasNextPage: boolean;
|
||||
};
|
||||
searchParams?: { [key: string]: string | string[] | undefined };
|
||||
page: 'search' | 'collection';
|
||||
collection?: string;
|
||||
}) => {
|
||||
const [products, setProducts] = useState(initialProducts);
|
||||
const [_pageInfo, setPageInfo] = useState(pageInfo);
|
||||
@ -31,11 +31,11 @@ const ProductsList = ({
|
||||
try {
|
||||
const params = {
|
||||
searchParams,
|
||||
afterCursor: _pageInfo.endCursor
|
||||
afterCursor: _pageInfo.endCursor,
|
||||
collection
|
||||
};
|
||||
setIsLoading(true);
|
||||
const { products, pageInfo } =
|
||||
page === 'collection'
|
||||
const { products, pageInfo } = collection
|
||||
? await getProductsInCollection(params)
|
||||
: await searchProducts(params);
|
||||
|
||||
|
@ -2,12 +2,15 @@ import { getProductsInCollection } from 'components/layout/products-list/actions
|
||||
import FiltersList from './filters-list';
|
||||
|
||||
const FiltersContainer = async ({
|
||||
searchParams
|
||||
searchParams,
|
||||
collection
|
||||
}: {
|
||||
searchParams?: { [key: string]: string | string[] | undefined };
|
||||
collection: string;
|
||||
}) => {
|
||||
const { filters } = await getProductsInCollection({
|
||||
searchParams
|
||||
searchParams,
|
||||
collection
|
||||
});
|
||||
|
||||
return <FiltersList filters={filters} defaultOpen={false} />;
|
||||
|
Loading…
x
Reference in New Issue
Block a user