// This file is part of Shadcn Admin Kit (https://github.com/marmelab/shadcn-admin-kit) 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 {} 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; } 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}
); };