import React from 'react'; import { useIntl } from 'react-intl'; import PropTypes from 'prop-types'; import { Button, Flex } from '@strapi/design-system'; import { Check, Cross, PaperPlane, Pencil, Trash } from '@strapi/icons'; import { getTrad } from '../../../utils/getTrad'; const ActionButtons = ({ mode, isEditing, onEdit, onCreate, isCreating, executeAt, onDelete, onSave, canPublish, isLoading, }) => { const { formatMessage } = useIntl(); function handleEditChange() { if (onEdit) { onEdit(); } } function handleCreateChange() { if (onCreate) { onCreate(); } } function handleSaveChange() { if (onSave) { onSave(); } } function handleDeleteChange() { if (onDelete) { onDelete(); } } // do not show any mutate buttons if user cannot publish if ((isCreating || isEditing) && !canPublish) { return null; } if (isCreating) { return ( ); } if (isEditing) { return ( <> ); } return ( ); }; ActionButtons.propTypes = { mode: PropTypes.string.isRequired, executeAt: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]), isEditing: PropTypes.bool.isRequired, onEdit: PropTypes.func, onCreate: PropTypes.func, isCreating: PropTypes.bool.isRequired, isLoading: PropTypes.bool.isRequired, onDelete: PropTypes.func, onSave: PropTypes.func, canPublish: PropTypes.bool.isRequired, }; export default ActionButtons;