mirror of
https://github.com/vercel/commerce.git
synced 2025-05-12 20:57:51 +00:00
splitting getLiveProducts into wall & wardrobe
This commit is contained in:
parent
1b387d8073
commit
1219586292
13
lib/utils.ts
13
lib/utils.ts
@ -1,6 +1,9 @@
|
||||
import { ReadonlyURLSearchParams } from 'next/navigation';
|
||||
import { getCollectionProducts, getProducts } from './shopify';
|
||||
|
||||
const wardrobeConditions = ['hidden-product', 't-shirt']
|
||||
const wallConditions = ['hidden-product', 'wall']
|
||||
|
||||
export const createUrl = (pathname: string, params: URLSearchParams | ReadonlyURLSearchParams) => {
|
||||
const paramsString = params.toString();
|
||||
const queryString = `${paramsString.length ? '?' : ''}${paramsString}`;
|
||||
@ -8,9 +11,15 @@ export const createUrl = (pathname: string, params: URLSearchParams | ReadonlyUR
|
||||
return `${pathname}${queryString}`;
|
||||
};
|
||||
|
||||
export async function getLiveProducts(query: Parameters<typeof getProducts>[0]) {
|
||||
export async function getLiveWardrobeProducts(query: Parameters<typeof getProducts>[0]) {
|
||||
const products = await getProducts(query);
|
||||
const liveProducts = products.filter((product) => !product.tags.includes('hidden-product'));
|
||||
const liveProducts = products.filter((product) => !product.tags.includes('hidden-product') && product.tags.includes('tshirt'));
|
||||
return liveProducts;
|
||||
}
|
||||
|
||||
export async function getLiveWallProducts(query: Parameters<typeof getProducts>[0]) {
|
||||
const products = await getProducts(query);
|
||||
const liveProducts = products.filter((product) => !product.tags.includes('hidden-product') && product.tags.includes('wall'));
|
||||
return liveProducts;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user