Skip to content

Commit cd92df4

Browse files
Refactor product API to use ProductRepository for data retrieval and remove unused getProductsProps function
1 parent b850942 commit cd92df4

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

apps/nextjs-website/src/lib/api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
getGuideListPagesProps,
77
getGuidePageProps,
88
getOverviewsProps,
9-
getProductsProps,
109
getQuickStartGuidesProps,
1110
getReleaseNoteProps,
1211
getSolutionListPageProps,
@@ -27,6 +26,7 @@ import {
2726
getSolutionsMetadata,
2827
} from '@/helpers/s3Metadata.helpers';
2928
import { s3DocsPath } from '@/config';
29+
import { ProductRepository } from './product';
3030

3131
function manageUndefined<T>(props: undefined | null | T) {
3232
if (!props) {
@@ -112,7 +112,7 @@ export async function getOverview(locale: string, productSlug?: string) {
112112
}
113113

114114
export async function getProducts(locale: string): Promise<readonly Product[]> {
115-
return await getProductsProps(locale);
115+
return await ProductRepository.getAll(locale);
116116
}
117117

118118
export async function getQuickStartGuide(locale: string, productSlug?: string) {
@@ -193,7 +193,7 @@ export async function getApiDataParams(locale: string) {
193193
}
194194

195195
export async function getProduct(locale: string, productSlug: string) {
196-
const props = (await getProductsProps(locale)).find(
196+
const props = (await ProductRepository.getAll(locale)).find(
197197
(product) => product.slug === productSlug
198198
);
199199
return props;

apps/nextjs-website/src/lib/cmsApi.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { makeSolutionsProps } from './strapi/makeProps/makeSolutions';
1313
import { makeSolutionListPageProps } from './strapi/makeProps/makeSolutionListPage';
1414
import { fetchSolutionListPage } from './strapi/fetches/fetchSolutionListPage';
1515

16-
import { ProductRepository } from '@/lib/product';
1716
import { makeGuideListPagesProps } from './strapi/makeProps/makeGuideListPages';
1817
import { makeGuidesProps } from './strapi/makeProps/makeGuides';
1918
import { fetchOverviews } from '@/lib/strapi/fetches/fetchOverviews';
@@ -64,11 +63,6 @@ export const getWebinarsProps = async (locale: string) => {
6463
return makeWebinarsProps(strapiWebinars);
6564
};
6665

67-
export const getProductsProps = async (locale: string) => {
68-
const products = await ProductRepository.getAll(locale);
69-
return [...products];
70-
};
71-
7266
export const getWebinarCategoriesProps = async (locale: string) => {
7367
const strapiWebinarCategories = await fetchWebinarCategories(
7468
locale,

0 commit comments

Comments
 (0)