diff --git a/components/filters/filters-list.tsx b/components/filters/filters-list.tsx
index f3c5950c3..82ff8ec80 100644
--- a/components/filters/filters-list.tsx
+++ b/components/filters/filters-list.tsx
@@ -86,10 +86,10 @@ const FiltersList = ({ makes = [], menu, autoFocusField }: FiltersListProps) =>
setLoadingAttribute(undefined);
};
- if (make?.id && models.length === 0) {
+ if (models.length === 0) {
getModels();
}
- }, [make?.id, modelIdFromSearchParams, models.length]);
+ }, [modelIdFromSearchParams, models.length]);
useEffect(() => {
const getYears = async () => {
@@ -105,10 +105,10 @@ const FiltersList = ({ makes = [], menu, autoFocusField }: FiltersListProps) =>
setLoadingAttribute(undefined);
};
- if (model?.id && years.length === 0) {
+ if (years.length === 0) {
getYears();
}
- }, [model?.id, yearIdFromSearchParams, years.length]);
+ }, [yearIdFromSearchParams, years.length]);
const onChangeMake = async (value: Metaobject | null) => {
setMake(value);
diff --git a/components/page/rich-text-display.tsx b/components/page/rich-text-display.tsx
index a666be22e..4ec53cdcc 100644
--- a/components/page/rich-text-display.tsx
+++ b/components/page/rich-text-display.tsx
@@ -1,4 +1,5 @@
import clsx from 'clsx';
+import { cn } from 'lib/utils';
import Link from 'next/link';
type Text = {
@@ -16,14 +17,38 @@ type Content =
children: Array<{ type: 'listItem'; children: Text[] }>;
}
| { type: 'listItem'; children: Text[] }
- | { type: 'link'; children: Text[]; target: string; title: string; url: string };
+ | { type: 'link'; children: Text[]; target: string; title: string; url: string }
+ | {
+ type: 'heading';
+ level: number;
+ children: Text[];
+ };
-const RichTextBlock = ({ block }: { block: Content }) => {
+const RichTextBlock = ({ block, className }: { block: Content; className?: string }) => {
if (block.type === 'text') {
return block.bold ? (
{block.value}
) : (
- {block.value}
+ {block.value}
+ );
+ }
+
+ if (block.type === 'heading') {
+ const Heading = `h${block.level}` as keyof JSX.IntrinsicElements;
+ return (
+
+ {block.children.map((child, index) => (
+
+ ))}
+
);
}
diff --git a/components/plp/default-content.tsx b/components/plp/default-content.tsx
index 1cecb1900..da1032295 100644
--- a/components/plp/default-content.tsx
+++ b/components/plp/default-content.tsx
@@ -8,18 +8,18 @@ const DefaultContent = async () => {
handle: { handle: 'default-plp-content', type: 'plp_content' }
});
- if (!defaultPLPContent) return null;
+ if (!defaultPLPContent) {
+ return null;
+ }
- const sectionIds = defaultPLPContent.sections ? JSON.parse(defaultPLPContent.sections) : [];
+ const { id, type, title, ...fields } = defaultPLPContent;
return (
-
+
-
- {defaultPLPContent.title}
-
+ {title}
}>
-
+
);
diff --git a/components/plp/dynamic-content.tsx b/components/plp/dynamic-content.tsx
index d82e95920..92cf80b66 100644
--- a/components/plp/dynamic-content.tsx
+++ b/components/plp/dynamic-content.tsx
@@ -3,15 +3,17 @@ import { Metaobject } from 'lib/shopify/types';
import { Suspense } from 'react';
import Tabs, { TabsPlaceholder } from './tabs';
-const DynamicContent = async ({ content }: { content: Metaobject }) => {
- const sectionIds = content.sections ? JSON.parse(content.sections) : [];
+const DynamicContent = ({ content }: { content: Metaobject }) => {
+ const { id, type, title, ...fields } = content;
return (
-
+
-
{content.title}
+
+ {content.title}
+
}>
-
+
);
diff --git a/components/plp/tabs.tsx b/components/plp/tabs.tsx
index bd2025a41..59585f715 100644
--- a/components/plp/tabs.tsx
+++ b/components/plp/tabs.tsx
@@ -1,41 +1,30 @@
import { ChevronRightIcon } from '@heroicons/react/24/solid';
-import PageContent from 'components/page/page-content';
-import { getMetaobjectsByIds } from 'lib/shopify';
+import RichTextDisplay from 'components/page/rich-text-display';
+import startCase from 'lodash.startcase';
import { Tab, TabGroup, TabList, TabPanel, TabPanels } from './tab-components';
-const TabPanelContent = async ({ ids }: { ids: string[] }) => {
- const content = await getMetaobjectsByIds(ids);
-
- return (
-
- {content.map((block) => (
-
- ))}
-
- );
-};
-
-const Tabs = async ({ tabItemIds }: { tabItemIds: string[] }) => {
- const tabItems = await getMetaobjectsByIds(tabItemIds);
- if (!tabItems || tabItems.length === 0) return null;
+const Tabs = ({ fields }: { fields: { [key: string]: string } }) => {
+ const keys = Object.keys(fields);
return (
- {tabItems.map((item) => (
+ {keys.map((key) => (
- {item.title}
+ {startCase(key)}
))}
- {tabItems.map((item) => (
-
+ {keys.map((key) => (
+
+
+
))}