"use client"; import { ReactNode } from "react"; import { OrderedListProps } from "./types"; import { Link } from "@shared/components/link"; import { Text } from "@shared/components/text"; import { DynamicTabs } from "@shared/contentful/blocks/dynamic-tabs"; export const OrderedList = ({ anchorId, backgroundColor = "white", title, description, tabs, }: OrderedListProps) => { const formatItemName = (name: string) => name .split(" ") .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) .join(" "); // Child rendering for a single list item (itemName / itemSlug). The tab // section UI and the column wrapper for these nodes live in DynamicTabs. const renderChild = ( item: OrderedListProps["tabs"][number]["items"]["tabContent"][number], index: number ): ReactNode => { if (!item.itemSlug) { return ( {formatItemName(item.itemName)} ); } return ( {formatItemName(item.itemName)} ); }; // Build the DynamicTabs `tabs` prop. Each tab's `tabContent` holds the list // of React nodes; DynamicTabs arranges them into columns in ordered mode. const dynamicTabs = { items: tabs.map((tab, index) => ({ tabName: tab.items.tabName, anchorId: `tab-${index}`, tabContent: tab.items.tabContent.map(renderChild), })), }; return ( {title} {description} {dynamicTabs.items.length > 0 ? ( ) : null} ); }; export default OrderedList;