useDeleteButton
Usage
import { forwardRef } from "react";
import { Button, ButtonProps } from "@mui/material";
import { getLocalizedString } from "@olenbetong/appframe-core";
import { DeletePrompt, useDeleteButton } from "@olenbetong/appframe-react";
import Delete from "./icons/Delete.js";
export type DeleteButtonProps = ButtonProps & {
index?: number;
prompt?: DeletePrompt;
};
export const DeleteButton = forwardRef<HTMLButtonElement, DeleteButtonProps>(
function DeleteButton({ prompt, index, ...props }, ref) {
let { isDeleting, deleteRow } = useDeleteButton(prompt);
return (
<Button
loading={isDeleting}
onClick={() => deleteRow(index)}
loadingPosition="start"
startIcon={<Delete />}
{...props}
sx={{ ...props.sx, color: "crimson" }}
ref={ref}
>
{props.children ? props.children : getLocalizedString("Delete")}
</Button>
);
}
);API
Last updated
Was this helpful?