// This file is part of Shadcn Admin Kit (https://github.com/marmelab/shadcn-admin-kit)
import React from "react";
import { buttonVariants } from "@/components/ui/button";
import { Plus } from "lucide-react";
import { Translate, useCreatePath, useResourceContext } from "ra-core";
import { Link } from "react-router";
export type CreateButtonProps = {
label?: string;
resource?: string;
};
export const CreateButton = ({
label,
resource: targetResource,
}: CreateButtonProps) => {
const resource = useResourceContext();
const createPath = useCreatePath();
const link = createPath({
resource: targetResource ?? resource,
type: "create",
});
return (
{label ?? "Create"}
);
};
// useful to prevent click bubbling in a datagrid with rowClick
const stopPropagation = (e: React.MouseEvent) => e.stopPropagation();