Skip to content

Commit 1f19973

Browse files
thematic total count fixes
1 parent 0f991bd commit 1f19973

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

mfes/content/src/components/Content/List.tsx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ export default function Content(props: Readonly<ContentProps>) {
311311
// }
312312
if(props.onTotalCountChange)
313313
{
314+
//console.log("hellooo")
315+
// filter.primaryCategory = [
316+
// 'Learning Resource','Practice Question Set','Activity','Story'];
317+
console.log("filter====>" , filter);
318+
314319
resultResponse = await ContentSearch({
315320
...filter,
316321
offset: adjustedOffset,
@@ -319,7 +324,8 @@ export default function Content(props: Readonly<ContentProps>) {
319324
primaryCategory: ['Course'],
320325
});
321326
}
322-
else{
327+
else{
328+
323329
resultResponse = await ContentSearch({
324330
...filter,
325331
offset: adjustedOffset,
@@ -330,15 +336,29 @@ export default function Content(props: Readonly<ContentProps>) {
330336
}
331337

332338

333-
if (resultResponse?.result?.count) {
339+
if(props.onTotalCountChange) {
340+
console.log("hellooo")
341+
// filter.primaryCategory = [
342+
// 'Learning Resource','Practice Question Set','Activity','Story'];
343+
console.log("filter====>" , filter);
334344

335-
setTotalCount(resultResponse?.result?.count);
336-
if(props.setTotalResources)
345+
const resultResponse2 = await ContentSearch({
346+
...filter,
347+
offset: adjustedOffset,
348+
limit: adjustedLimit,
349+
signal: controller.signal,
350+
primaryCategory: [
351+
'Learning Resource','Practice Question Set','Activity','Story'],
352+
});
353+
354+
setTotalCount(resultResponse2?.result?.count);
355+
}
356+
if(props.setTotalResources && resultResponse?.result?.count)
337357
{
338358
props.setTotalResources(resultResponse?.result?.count);
339359
}
340360

341-
}
361+
342362

343363
const response = resultResponse?.result;
344364
if (props?._config?.getContentData) {

mfes/content/src/services/Search.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,15 @@ export const ContentSearch = async ({
125125
limit = 5,
126126
offset = 0,
127127
noPrimaryCategory = false,
128+
primaryCategory,
128129
}: {
129130
type: string;
130131
query?: string;
131132
filters?: object;
132133
limit?: number;
133134
offset?: number;
134135
noPrimaryCategory?: boolean;
136+
primaryCategory?: string[];
135137
}): Promise<ContentResponse> => {
136138
try {
137139
// Ensure the environment variable is defined
@@ -150,7 +152,10 @@ export const ContentSearch = async ({
150152
status: ['live'],
151153
channel: localStorage.getItem('channelId'),
152154
};
153-
// console.log('filtersObject====>', filtersObject?.primaryCategory);
155+
if(primaryCategory){
156+
filtersObject.primaryCategory = primaryCategory;
157+
}
158+
console.log('filtersObject====>' , filters);
154159

155160
// Only add primaryCategory if noPrimaryCategory is false and primaryCategory is not already set
156161
if (!noPrimaryCategory && !filtersObject.primaryCategory) {
@@ -161,6 +166,7 @@ export const ContentSearch = async ({
161166
? ['Activity', 'Story']
162167
: ['Learning Resource', 'Practice Question Set'];
163168
}
169+
// console.log('filtersObject====>', filtersObject);
164170

165171
const data = {
166172
request: {

0 commit comments

Comments
 (0)