
* Add Delete button component * Add product / page type delete warning dialog * Replace old product types delete dialog with new one, add products total count query * Update schema, types and queries for pages, add use page count query and add warning delete dialog to page types * Move type delete warning dialog data to proper hooks, refactor * Remove unused components and stories * Add plural forms to messages for product / page type delete warning, refactor * Add type delete warning dialog stories * Move type delete hooks to proper directiories, fix imports * Fix imports * Remove countallproducts query and instead use useproductcountquery * Remove unnecessary types and imports
47 lines
1 KiB
TypeScript
47 lines
1 KiB
TypeScript
import Button from "@material-ui/core/Button";
|
|
import { buttonMessages } from "@saleor/intl";
|
|
import { makeStyles } from "@saleor/theme";
|
|
import React from "react";
|
|
import { useIntl } from "react-intl";
|
|
|
|
const useStyles = makeStyles(
|
|
theme => ({
|
|
button: {
|
|
"&:hover": {
|
|
backgroundColor: theme.palette.error.dark
|
|
},
|
|
backgroundColor: theme.palette.error.main,
|
|
color: theme.palette.error.contrastText
|
|
}
|
|
}),
|
|
{ name: "DeleteButton" }
|
|
);
|
|
|
|
interface DeleteButtonProps {
|
|
onClick: () => void;
|
|
label?: string | React.ReactNode;
|
|
disabled?: boolean;
|
|
}
|
|
|
|
const DeleteButton: React.FC<DeleteButtonProps> = ({
|
|
onClick,
|
|
label,
|
|
disabled = false
|
|
}) => {
|
|
const classes = useStyles({});
|
|
const intl = useIntl();
|
|
|
|
return (
|
|
<Button
|
|
variant="contained"
|
|
onClick={onClick}
|
|
className={classes.button}
|
|
data-test="button-bar-delete"
|
|
disabled={disabled}
|
|
>
|
|
{label || intl.formatMessage(buttonMessages.delete)}
|
|
</Button>
|
|
);
|
|
};
|
|
|
|
export default DeleteButton;
|