mirror of
https://github.com/vercel/commerce.git
synced 2025-06-07 16:56:59 +00:00
refactor: getCollections
This commit is contained in:
parent
692ef9d8df
commit
18ce43d0a4
@ -312,14 +312,12 @@ export async function getCollectionProducts(handle: string): Promise<Product[]>
|
|||||||
export async function getCollections(): Promise<ProductCollection[]> {
|
export async function getCollections(): Promise<ProductCollection[]> {
|
||||||
const res = await medusaRequest('GET', '/collections');
|
const res = await medusaRequest('GET', '/collections');
|
||||||
|
|
||||||
const collections: ProductCollection[] = res.body.collections.map(
|
// Reshape collections and hide collections starting with 'hidden'
|
||||||
(collection: MedusaProductCollection) => reshapeCollection(collection)
|
const collections = res.body.collections
|
||||||
);
|
.map((collection: MedusaProductCollection) => reshapeCollection(collection))
|
||||||
|
.filter((collection: MedusaProductCollection) => !collection.handle.startsWith('hidden'));
|
||||||
|
|
||||||
// Hide collections starting with 'hidden'
|
return collections;
|
||||||
const filtered = collections.filter((collection) => !collection.handle.startsWith('hidden'));
|
|
||||||
|
|
||||||
return filtered;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getProduct(handle: string): Promise<Product> {
|
export async function getProduct(handle: string): Promise<Product> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user