diff --git a/components/page/rich-text-display.tsx b/components/page/rich-text-display.tsx index 3b79b197a..ea04a43a2 100644 --- a/components/page/rich-text-display.tsx +++ b/components/page/rich-text-display.tsx @@ -37,7 +37,7 @@ const RichTextBlock = ({ block, className }: { block: Content; className?: strin const Heading = `h${block.level}` as keyof JSX.IntrinsicElements; return ( >; + title: string; +}; + +const Table = ({ columns, data, title }: TableProps) => { + return ( +
+

{title}

+ + + + {columns.map((column, index) => ( + + ))} + + + + {data.map((row, index) => ( + + {columns.map((column, index) => ( + + ))} + + ))} + +
+ {column.title} +
+ {row[column.key]} +
+
+ ); +}; + +export default Table; diff --git a/components/plp/tabs.tsx b/components/plp/tabs.tsx index 1f4cd62a0..3104456dd 100644 --- a/components/plp/tabs.tsx +++ b/components/plp/tabs.tsx @@ -1,8 +1,27 @@ import { ChevronRightIcon } from '@heroicons/react/24/solid'; import RichTextDisplay from 'components/page/rich-text-display'; +import Table from 'components/page/table'; +import { getMetaobject } from 'lib/shopify'; import startCase from 'lodash.startcase'; import { Tab, TabGroup, TabList, TabPanel, TabPanels } from './tab-components'; +const TabContent = async ({ id }: { id?: string }) => { + if (!id) { + return null; + } + + const metaobject = await getMetaobject({ id }); + if (!metaobject || metaobject.type !== 'plp_content_tables') return null; + + return ( + + ); +}; + const Tabs = ({ fields }: { fields: { [key: string]: string } }) => { const keys = Object.keys(fields); @@ -10,6 +29,8 @@ const Tabs = ({ fields }: { fields: { [key: string]: string } }) => { return null; } + const isShopifyId = (value?: string) => value?.startsWith('gid://shopify'); + return (
@@ -27,7 +48,11 @@ const Tabs = ({ fields }: { fields: { [key: string]: string } }) => { {keys.map((key) => ( - + {isShopifyId(fields[key]) ? ( + + ) : ( + + )} ))}