The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.
TypeScript b2b-marketplacecomposable-commerceecommerceenterpriseheadless-commercemarketplacemedusamedusajsmulti-vendortypescript
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 = <TData,>({
children,
/**
* 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<TData>) => {
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 (
<div className="flex flex-col gap-y-3">
{children}
{showMetadata && <MetadataSection data={data!} />}
{showJSON && <JsonViewSection data={data!} />}
{hasOutlet && <Outlet />}
</div>
)
}