import { isString } from "lodash"; import React from "react"; import PropTypes from "prop-types"; import Button from "antd/lib/button"; import Modal from "antd/lib/modal"; import Tooltip from "@/components/Tooltip"; import notification from "@/services/notification"; import Group from "@/services/group"; function deleteGroup(event, group, onGroupDeleted) { Modal.confirm({ title: "Delete Group", content: "Are you sure you want to delete this group?", okText: "Yes", okType: "danger", cancelText: "No", onOk: () => { Group.delete(group).then(() => { notification.success("Group deleted successfully."); onGroupDeleted(); }); }, }); } export default function DeleteGroupButton({ group, title, onClick, children, ...props }) { if (!group) { return null; } const button = ( ); if (isString(title) && title !== "") { return ( {button} ); } return button; } DeleteGroupButton.propTypes = { group: PropTypes.object, // eslint-disable-line react/forbid-prop-types title: PropTypes.string, onClick: PropTypes.func, children: PropTypes.node, }; DeleteGroupButton.defaultProps = { group: null, title: null, onClick: () => {}, children: null, };