import { cn } from "@/lib/utils"; import SectionContainer from "@/components/ui/section-container"; import { PAGE_QUERY_RESULT } from "@/sanity.types"; import GridCard from "./grid-card"; import PricingCard from "./pricing-card"; import GridPost from "./grid-post"; type Block = NonNullable["blocks"]>[number]; type GridRow = Extract; type GridColumn = NonNullable[number]>; const componentMap: { [K in GridColumn["_type"]]: React.ComponentType< Extract >; } = { "grid-card": GridCard, "pricing-card": PricingCard, "grid-post": GridPost, }; export default function GridRow({ padding, colorVariant, gridColumns, columns, }: GridRow) { return ( {columns && columns?.length > 0 && (
{columns.map((column) => { const Component = componentMap[column._type]; if (!Component) { // Fallback for development/debugging of new component types console.warn( `No component implemented for grid column type: ${column._type}`, ); return
; } return ( ); })}
)} ); }