"use client" /** * Switches list-hub view bodies by `DataListViewRenderKind`. * Hubs pass one renderer per kind they support; missing kinds show a clear empty state * (never silently fall through to dashboard). */ import * as React from "react" import type { DataListViewType } from "../../lib/data-list-view" import { dataListViewDefinition, dataListViewLabel, getDataListViewRenderKind, type DataListViewRenderKind, } from "../../lib/data-list-view-registry" export type ListPageConnectedViewRenderers = Partial< Record React.ReactNode)> > export interface ListPageConnectedViewBodyProps { view: DataListViewType /** Human-readable hub name for the not-configured state. */ hubLabel?: string renderers: ListPageConnectedViewRenderers } function resolveRenderer(node: React.ReactNode | (() => React.ReactNode) | undefined) { if (node == null) return null return typeof node === "function" ? node() : node } export function ListPageViewNotConfigured({ view, hubLabel = "This hub", }: { view: DataListViewType hubLabel?: string }) { const label = dataListViewLabel(view) return ( {hubLabel} does not implement {label}. Add a renderer for{" "} {dataListViewDefinition(view).renderKind}{" "} in this hub's table component, or remove the view from{" "} supportedViewTypes. ) } export function ListPageConnectedViewBody({ view, hubLabel, renderers, }: ListPageConnectedViewBodyProps) { const kind = getDataListViewRenderKind(view) const body = resolveRenderer(renderers[kind]) if (body == null) { return } return <>{body} }