import { Outlet } from "react-router-dom" import { JsonViewSection } from "../../../common/json-view-section" import { MetadataSection } from "../../../common/metadata-section" import { PageProps } from "../types" export const SingleColumnPage = ({ children, widgets, /** * Data of the page which is passed to Widgets, JSON view, and Metadata view. */ data, /** * Whether the page should render an outlet for children routes. Defaults to true. */ hasOutlet = true, /** * Whether to show JSON view of the data. Defaults to false. */ showJSON, /** * Whether to show metadata view of the data. Defaults to false. */ showMetadata, }: PageProps) => { const { before, after } = widgets const widgetProps = { data } if (showJSON && !data) { if (process.env.NODE_ENV === "development") { console.warn( "`showJSON` is true but no data is provided. To display JSON, provide data prop." ) } showJSON = false } if (showMetadata && !data) { if (process.env.NODE_ENV === "development") { console.warn( "`showMetadata` is true but no data is provided. To display metadata, provide data prop." ) } showMetadata = false } return (
{before.map((Component, i) => { return })} {children} {after.map((Component, i) => { return })} {showMetadata && } {showJSON && } {hasOutlet && }
) }