Skip to content

Commit e59621f

Browse files
committed
Featured list and testimonials only for unit channels
1 parent abf1fae commit e59621f

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

frontends/api/src/ssr/prefetch.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export const prefetch = async (
1212
queryClient = queryClient || new QueryClient()
1313

1414
await Promise.all(
15-
queries.map((query) => queryClient.prefetchQuery(query as Query)),
15+
queries
16+
.filter(Boolean)
17+
.map((query) => queryClient.prefetchQuery(query as Query)),
1618
)
1719

1820
return { dehydratedState: dehydrate(queryClient), queryClient }

frontends/main/src/app/c/[channelType]/[name]/page.tsx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { channels } from "api/hooks/channels"
1717
import { testimonials } from "api/hooks/testimonials"
1818
import handleNotFound from "@/common/handleNotFound"
1919
import type { PageParams } from "@/app/types"
20-
// import { facetNames } from "@/app-pages/SearchPage/searchPageConfig"
2120
import getSearchParams from "@/page-components/SearchDisplay/getSearchParams"
2221
import {
2322
getConstantSearchParams,
@@ -60,16 +59,18 @@ const Page: React.FC = async ({
6059

6160
const { queryClient } = await prefetch([
6261
learningResources.offerors({}),
63-
learningResources.featured({
64-
limit: 12,
65-
offered_by: [name],
66-
}),
67-
testimonials.list({ offerors: [name] }),
68-
channels.detailByType("unit", name),
62+
channelType === ChannelTypeEnum.Unit &&
63+
learningResources.featured({
64+
limit: 12,
65+
offered_by: [name],
66+
}),
67+
channelType === ChannelTypeEnum.Unit &&
68+
testimonials.list({ offerors: [name] }),
69+
channels.detailByType(channelType, name),
6970
])
7071

71-
const unitChannel = queryClient.getQueryData<UnitChannel>(
72-
channels.detailByType("unit", name).queryKey,
72+
const channel = queryClient.getQueryData<UnitChannel>(
73+
channels.detailByType(channelType, name).queryKey,
7374
)
7475
const offerors = queryClient
7576
.getQueryData<PaginatedLearningResourceOfferorDetailList>(
@@ -83,9 +84,7 @@ const Page: React.FC = async ({
8384
[],
8485
)
8586

86-
const constantSearchParams = getConstantSearchParams(
87-
unitChannel?.search_filter,
88-
)
87+
const constantSearchParams = getConstantSearchParams(channel?.search_filter)
8988

9089
const { facetNames } = getFacets(
9190
channelType,
@@ -115,7 +114,6 @@ const Page: React.FC = async ({
115114
[learningResources.search(searchRequest as LRSearchRequest)],
116115
queryClient,
117116
)
118-
119117
return (
120118
<Hydrate state={dehydratedState}>
121119
<ChannelPage />

0 commit comments

Comments
 (0)