@@ -317,23 +317,42 @@ export default function Content(props: Readonly<ContentProps>) {
317317 // }
318318 if ( props . onTotalCountChange )
319319 {
320- //console.log("hellooo")
321- // filter.primaryCategory = [
322- // 'Learning Resource','Practice Question Set','Activity','Story'];
323- console . log ( "filter====>" , filter ) ;
324- resultResponse = await ContentSearch ( {
325- ...filter ,
326- offset : adjustedOffset ,
327- limit : adjustedLimit ,
328- signal : controller . signal ,
329- primaryCategory : [ 'Course' ] ,
330- } ) ;
320+ const isCourseType = [ 'course' , 'self' ] . includes ( filter . type ?. toLowerCase ( ) || '' ) ;
321+ if ( isCourseType ) {
322+ resultResponse = await ContentSearch ( {
323+ ...filter ,
324+ offset : adjustedOffset ,
325+ limit : adjustedLimit ,
326+ signal : controller . signal ,
327+ primaryCategory : [ 'Course' ] ,
328+ } ) ;
329+ const resultResponse2 = await ContentSearch ( {
330+ ...filter ,
331+ offset : adjustedOffset ,
332+ limit : adjustedLimit ,
333+ signal : controller . signal ,
334+ isPrimaryCategory : true ,
335+ primaryCategory : [
336+ 'Learning Resource' , 'Practice Question Set' , 'Activity' , 'Story' , 'Interactive' ] ,
337+ } ) ;
338+ setTotalCount ( resultResponse2 ?. result ?. count ) ;
339+ } else {
340+ resultResponse = await ContentSearch ( {
341+ ...filter ,
342+ offset : adjustedOffset ,
343+ limit : adjustedLimit ,
344+ signal : controller . signal ,
345+ isPrimaryCategory : true ,
346+ primaryCategory : [
347+ 'Learning Resource' , 'Practice Question Set' , 'Activity' , 'Story' , 'Interactive' ] ,
348+ } ) ;
349+ setTotalCount ( resultResponse ?. result ?. count ) ;
350+ }
331351 }
332- else {
352+ else {
333353 const program = searchParams . get ( 'program' ) ;
334354 const search = searchParams . get ( 'q' ) ;
335355
336-
337356 if ( program || ( search && ( tab === '0' || tab === null ) ) )
338357 {
339358 resultResponse = await ContentSearch ( {
@@ -344,48 +363,28 @@ export default function Content(props: Readonly<ContentProps>) {
344363 isPrimaryCategory : true ,
345364 primaryCategory : [
346365 'Learning Resource' , 'Practice Question Set' , 'Activity' , 'Story' , 'Interactive' ]
347- } ) ; }
366+ } ) ;
367+ }
348368 else {
349-
350- resultResponse = await ContentSearch ( {
351- ...filter ,
352- offset : adjustedOffset ,
353- limit : adjustedLimit ,
354- signal : controller . signal ,
355- } ) ;
356- }
357- }
358-
359-
360- if ( props . onTotalCountChange ) {
361- console . log ( "hellooo" )
362- // filter.primaryCategory = [
363- // 'Learning Resource','Practice Question Set','Activity','Story'];
364- console . log ( "filter====>" , filter ) ;
365- const resultResponse2 = await ContentSearch ( {
366- ...filter ,
367- offset : adjustedOffset ,
368- limit : adjustedLimit ,
369- signal : controller . signal ,
370- isPrimaryCategory : true ,
371- primaryCategory : [
372- 'Learning Resource' , 'Practice Question Set' , 'Activity' , 'Story' , 'Interactive' ] ,
373- } ) ;
374-
375- setTotalCount ( resultResponse2 ?. result ?. count ) ;
369+ resultResponse = await ContentSearch ( {
370+ ...filter ,
371+ offset : adjustedOffset ,
372+ limit : adjustedLimit ,
373+ signal : controller . signal ,
374+ } ) ;
375+ }
376376 }
377377 if ( props . setTotalResources && resultResponse ?. result ?. count )
378378 {
379379 props . setTotalResources ( resultResponse ?. result ?. count ) ;
380380 }
381381
382382
383-
383+ console . log ( 'API response for content search:' , resultResponse ) ;
384384 const response = resultResponse ?. result ;
385385 if ( props ?. _config ?. getContentData ) {
386386 props . _config . getContentData ( response ) ;
387387 }
388-
389388 content . push ( ...( response ?. content || [ ] ) ) ;
390389 QuestionSet . push ( ...( response ?. QuestionSet || [ ] ) ) ;
391390 count = response ?. count || 0 ;
@@ -523,6 +522,7 @@ export default function Content(props: Readonly<ContentProps>) {
523522 setIsLoading ( true ) ;
524523 try {
525524 const response = await fetchAllContent ( localFilters ) ;
525+ console . log ( 'Content response:' , response ) ;
526526 if ( ! response || ! isMounted ) return ;
527527 const newContentData = [
528528 ...( response . content ?? [ ] ) ,
0 commit comments