Skip to content

Commit 7db9eab

Browse files
committed
fix: cleanup
1 parent 415a1c7 commit 7db9eab

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/lib/data/index.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import medusaRequest from "../medusa-fetch"
22
import { StoreGetProductsParams } from "@medusajs/medusa"
33

4-
type GetProductListParams = {
5-
pageParam?: number
6-
queryParams: StoreGetProductsParams
7-
}
8-
94
/**
105
* This file contains functions for fetching products and collections from the Medusa API or the Medusa Product Module,
116
* depending on the feature flag. By default, the standard Medusa API is used. To use the Medusa Product Module, set the feature flag to true.
@@ -19,7 +14,7 @@ const PRODUCT_MODULE_ENABLED =
1914
const API_BASE_URL = process.env.NEXT_PUBLIC_BASE_URL || "http://localhost:8000"
2015

2116
// Set DEBUG to true to console.log where the data is coming from.
22-
const DEBUG = true
17+
const DEBUG = false
2318

2419
/**
2520
* Fetches a product by handle, using the Medusa API or the Medusa Product Module, depending on the feature flag.
@@ -64,7 +59,10 @@ export async function getProductByHandle(handle: string) {
6459
export async function getProductsList({
6560
pageParam = 0,
6661
queryParams,
67-
}: GetProductListParams) {
62+
}: {
63+
pageParam?: number
64+
queryParams: StoreGetProductsParams
65+
}) {
6866
const limit = queryParams.limit || 12
6967

7068
if (PRODUCT_MODULE_ENABLED) {
@@ -157,7 +155,9 @@ export async function getCollectionsList(offset: number = 0) {
157155
/**
158156
* Fetches a collection by handle, using the Medusa API or the Medusa Product Module, depending on the feature flag.
159157
* @param handle (string) - The handle of the collection to retrieve
160-
* @returns (array) - An array of collections (should only be one)
158+
* @returns collections (array) - An array of collections (should only be one)
159+
* @returns response (object) - An object containing the products and the number of products in the collection
160+
* @returns nextPage (number) - The offset of the next page of products
161161
*/
162162
export async function getCollectionByHandle(handle: string) {
163163
if (PRODUCT_MODULE_ENABLED) {
@@ -185,6 +185,14 @@ export async function getCollectionByHandle(handle: string) {
185185
return data
186186
}
187187

188+
/**
189+
* Fetches a list of products in a collection, using the Medusa API or the Medusa Product Module, depending on the feature flag.
190+
* @param pageParam (number) - The offset of the products to retrieve
191+
* @param handle (string) - The handle of the collection to retrieve
192+
* @param cartId (string) - The ID of the cart
193+
* @returns response (object) - An object containing the products and the number of products in the collection
194+
* @returns nextPage (number) - The offset of the next page of products
195+
*/
188196
export async function getProductsByCollectionHandle({
189197
pageParam = 0,
190198
handle,

0 commit comments

Comments
 (0)