import { Breadcrumb, BreadcrumbItem, BreadcrumbPage, } from "@/components/admin/breadcrumb"; import type { CreateBaseProps } from "ra-core"; import { CreateBase, Translate, useCreateContext, useCreatePath, useGetResourceLabel, useHasDashboard, useResourceContext, } from "ra-core"; import type { ReactNode } from "react"; import { Link } from "react-router"; import { cn } from "@/lib/utils"; export type CreateProps = CreateViewProps & CreateBaseProps; /** * A complete create page with breadcrumb, title, and actions. * * Combines data fetching, form context, and UI layout for creating new records. Renders breadcrumb * navigation, page title, and wraps your form components. * * @see {@link https://marmelab.com/shadcn-admin-kit/docs/create/ Create documentation} * * @example * import { Create, SimpleForm, TextInput } from '@/components/admin'; * * export const PostCreate = () => ( * * * * * * * ); */ export const Create = ({ actions, children, className, disableBreadcrumb, title, ...rest }: CreateProps) => ( {children} ); export type CreateViewProps = { actions?: ReactNode; disableBreadcrumb?: boolean; children: ReactNode; className?: string; title?: ReactNode | string | false; }; /** * The view component for Create pages with layout and UI. * * @internal */ export const CreateView = ({ actions, disableBreadcrumb, title, children, className, }: CreateViewProps) => { const context = useCreateContext(); const resource = useResourceContext(); if (!resource) { throw new Error( "The CreateView 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 hasDashboard = useHasDashboard(); return ( <> {!disableBreadcrumb && ( {hasDashboard && ( Home )} {listLabel} Create )}

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

{actions}
{children}
); };