File tree Expand file tree Collapse file tree 7 files changed +17
-6
lines changed
modules/collections/templates Expand file tree Collapse file tree 7 files changed +17
-6
lines changed File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ export async function GET(request: NextRequest) {
8
8
const handle = searchParams . get ( "handle" ) ?? ""
9
9
const pageParam = searchParams . get ( "pageParam" ) ?? "0"
10
10
const limit = searchParams . get ( "limit" ) ?? "12"
11
+ const cart_id = searchParams . get ( "cart_id" ) ?? ""
11
12
12
13
const collection = await fetchCollection ( handle )
13
14
. then ( ( res ) => res )
@@ -19,6 +20,7 @@ export async function GET(request: NextRequest) {
19
20
pageParam,
20
21
id : collection . id ,
21
22
limit,
23
+ cart_id,
22
24
} ) . then ( ( res ) => res )
23
25
24
26
return NextResponse . json ( {
@@ -45,15 +47,18 @@ async function fetchCollectionProducts({
45
47
pageParam,
46
48
id,
47
49
limit,
50
+ cart_id,
48
51
} : {
49
52
pageParam : string
50
53
id : string
51
54
limit : string
55
+ cart_id : string
52
56
} ) {
53
57
const { products, count, offset } = await medusaRequest (
54
58
"GET" ,
55
59
`/products?collection_id[]=${ id } ` ,
56
60
{
61
+ cart_id,
57
62
limit,
58
63
offset : pageParam ,
59
64
expand : "variants,variants.prices" ,
Original file line number Diff line number Diff line change @@ -126,6 +126,10 @@ export const fetchProductsList = async ({
126
126
...queryParams ,
127
127
} )
128
128
129
+ console . log ( { pageParam, ...queryParams } )
130
+
131
+ console . log ( { products, count, offset } )
132
+
129
133
return {
130
134
response : { products, count } ,
131
135
nextPage : count > offset + 12 ? offset + 12 : null ,
Original file line number Diff line number Diff line change @@ -86,12 +86,14 @@ const CollectionTemplate: React.FC<CollectionTemplateProps> = ({
86
86
< h1 > { collection . title } </ h1 >
87
87
</ div >
88
88
< ul className = "grid grid-cols-2 small:grid-cols-3 medium:grid-cols-4 gap-x-4 gap-y-8" >
89
- { previews . map ( ( p ) => (
90
- < li key = { p . id } >
91
- { console . log ( p ) }
92
- < ProductPreview { ...p } />
93
- </ li >
94
- ) ) }
89
+ { previews . map ( ( p ) => {
90
+ console . log ( p )
91
+ return (
92
+ < li key = { p . id } >
93
+ < ProductPreview { ...p } />
94
+ </ li >
95
+ )
96
+ } ) }
95
97
{ isFetchingNextPage &&
96
98
repeat ( getNumberOfSkeletons ( infiniteData ?. pages ) ) . map ( ( index ) => (
97
99
< li key = { index } >
File renamed without changes.
You can’t perform that action at this time.
0 commit comments