import { Breadcrumb, BreadcrumbItem, BreadcrumbPage, } from "@/components/admin/breadcrumb"; import type { ShowBaseProps } from "ra-core"; import { ShowBase, Translate, useCreatePath, useHasDashboard, useShowContext, useGetRecordRepresentation, useGetResourceLabel, useResourceContext, useResourceDefinition, } from "ra-core"; import type { ReactNode } from "react"; import { Link } from "react-router"; import { cn } from "@/lib/utils"; import { EditButton } from "@/components/admin/edit-button"; export interface ShowProps extends ShowViewProps, Omit {} /** * A complete show page with breadcrumb, title, and default actions. * * Combines data fetching and UI layout for displaying record details. Inside, use * RecordField to display individual fields with labels. * * @see {@link https://marmelab.com/shadcn-admin-kit/docs/show/ Show documentation} * * @example * import { RecordField, NumberField, ReferenceField, Show } from "@/components/admin"; * * export const ProductShow = () => ( * *
* * * * * Intl.NumberFormat().format(record.price)} * /> * *
*
* ); */ export const Show = ({ actions, children, className, disableAuthentication, disableBreadcrumb, id, loading, queryOptions, render, resource, title, }: ShowProps) => ( {children} ); export interface ShowViewProps { actions?: ReactNode; disableBreadcrumb?: boolean; children: ReactNode; className?: string; emptyWhileLoading?: boolean; title?: ReactNode | string | false; } /** * The view component for Show pages with layout and UI. * * Renders breadcrumb, title, and default actions for show pages. Use Show instead unless you need * custom data fetching logic with ShowBase. * * @example * import { ShowBase, ShowView, SimpleShowLayout } from '@/components/admin'; * * export const PostShow = () => ( * * * ... * * * ); */ export const ShowView = ({ actions, children, className, disableBreadcrumb, emptyWhileLoading, title, }: ShowViewProps) => { const context = useShowContext(); const resource = useResourceContext(); if (!resource) { throw new Error( "The ShowView component must be used within a ResourceContextProvider", ); } const getResourceLabel = useGetResourceLabel(); const listLabel = getResourceLabel(resource, 2); const createPath = useCreatePath(); const listLink = createPath({ resource, type: "list", }); const getRecordRepresentation = useGetRecordRepresentation(resource); const recordRepresentation = getRecordRepresentation(context.record); const { hasEdit } = useResourceDefinition({ resource }); const hasDashboard = useHasDashboard(); if (context.isLoading || !context.record) { return null; } if (!context.record && emptyWhileLoading) { return null; } return ( <> {!disableBreadcrumb && ( {hasDashboard && ( Home )} {listLabel} {recordRepresentation} )}

{title !== undefined ? title : context.defaultTitle}

{actions ?? (
{hasEdit ? : null}
)}
{children}
); };