- Product Category
+
+
+
+
+
+
{{ product.data["tt_name"] }}
+
+ {{ product.data["tt_abstract"]?.substring(0, 45) }}...
+
+
+
+
+
+
diff --git a/composables/content.ts b/composables/content.ts
index c65bf461..703445f3 100644
--- a/composables/content.ts
+++ b/composables/content.ts
@@ -26,6 +26,17 @@ export function useContent() {
if (!cachedPages.value[route]) cachedPages.value[route] = data;
}
+ const cachedProducts = useState<{
+ [caasId: string]: Dataset[];
+ }>("cachedDatasets", () => ({}));
+
+ function findCachedProductsByRoute(route: string) {
+ return cachedProducts.value[route];
+ }
+ function addToCachedProducts(route: string, data: Dataset[]) {
+ if (!cachedProducts.value[route]) cachedProducts.value[route] = data;
+ }
+
return {
currentPage,
currentDataset,
@@ -33,7 +44,9 @@ export function useContent() {
cachedDatasets,
addToCachedPages,
addToCachedDatasets,
+ addToCachedProducts,
findCachedPageByRoute,
findCachedDatasetByRoute,
+ findCachedProductsByRoute,
};
}
diff --git a/tests/components/PageBodyContent/Section.spec.ts b/tests/components/PageBodyContent/Section.spec.ts
index 0ca71581..7fb56a07 100644
--- a/tests/components/PageBodyContent/Section.spec.ts
+++ b/tests/components/PageBodyContent/Section.spec.ts
@@ -1,6 +1,7 @@
/**
* @vitest-environment jsdom
*/
+import { Page, Dataset } from "fsxa-api";
import { vi, it, expect, describe, beforeEach } from "vitest";
import { render, cleanup } from "@testing-library/vue";
import Section from "../../../components/PageBodyContent/Section.vue";
@@ -9,7 +10,6 @@ import { createSection } from "../../testutils/createSection";
import { createPage } from "../../testutils/createPage";
import { renderConfig } from "../../testutils/renderConfig"; // registers custom components
import * as content from "../../../composables/content";
-import { Page, Dataset } from "fsxa-api";
describe("Section", () => {
const mockedContent = {
diff --git a/tests/testutils/nuxtMocks.ts b/tests/testutils/nuxtMocks.ts
index ff823ba8..fdf59246 100644
--- a/tests/testutils/nuxtMocks.ts
+++ b/tests/testutils/nuxtMocks.ts
@@ -1,4 +1,4 @@
-import { FetchElementParams } from "fsxa-api/dist/types";
+import { FetchByFilterParams, FetchElementParams } from "fsxa-api";
import appConfig from "../fixtures/appConfig.json";
import runtimeConfig from "../fixtures/runtimeConfig.json";
import toplevelDE from "../fixtures/toplevelNavigation_de_DE.json";
@@ -13,6 +13,7 @@ import {
fetchTopLevelNavigation,
fetchNavigationItemFromRoute,
fetchPageFromNavigationItem,
+ fetchProducts,
getLocaleFromNavigationItem,
} from "../../utils/fsxa";
@@ -51,6 +52,9 @@ export function useNuxtApp() {
fetchProjectProperties: (_config: { locale: string }) =>
projectProperties,
fetchElement: (_config: FetchElementParams) => page,
+ fetchByFilter: (_config: FetchByFilterParams) => ({
+ items: [],
+ }),
},
};
}
@@ -99,6 +103,7 @@ export {
fetchTopLevelNavigation,
fetchNavigationItemFromRoute,
fetchPageFromNavigationItem,
+ fetchProducts,
useContent,
useNavigationData,
useProjectProperties,
diff --git a/utils/fsxa.ts b/utils/fsxa.ts
index d86740b0..fdf8e8f2 100644
--- a/utils/fsxa.ts
+++ b/utils/fsxa.ts
@@ -5,6 +5,7 @@ import {
LogicalQueryOperatorEnum,
Dataset,
Page,
+ QueryBuilderQuery,
} from "fsxa-api";
export const fetchDatasetByRoute = async (
@@ -169,3 +170,38 @@ export const getTranslatedRouteFromNavItem = async (
return { route, dataset };
};
+
+export const fetchProducts = async (
+ api: FSXAProxyApi,
+ locale: string,
+ category?: string
+) => {
+ const filters: QueryBuilderQuery[] = [
+ {
+ field: "entityType",
+ operator: ComparisonQueryOperatorEnum.EQUALS,
+ value: "product",
+ },
+ {
+ field: "schema",
+ operator: ComparisonQueryOperatorEnum.EQUALS,
+ value: "products",
+ },
+ ];
+
+ if (category) {
+ filters.push({
+ field: "formData.tt_categories.value.identifier",
+ operator: ComparisonQueryOperatorEnum.EQUALS,
+ value: category,
+ });
+ }
+
+ const { items } = await api.fetchByFilter({
+ filters,
+ locale,
+ pagesize: 10,
+ });
+
+ return items as Dataset[];
+};
diff --git a/vitest.config.ts b/vitest.config.ts
index d024b771..8dc5884c 100644
--- a/vitest.config.ts
+++ b/vitest.config.ts
@@ -32,6 +32,7 @@ export default defineConfig({
"fetchTopLevelNavigation",
"fetchNavigationItemFromRoute",
"fetchPageFromNavigationItem",
+ "fetchProducts",
"getLocaleFromNavigationItem",
],
},