import React, { useState } from 'react';
import i18n from 'ui-i18n';
import Button from '@mui/material/Button';
import AddIcon from '@mui/icons-material/Add';
import { useWorkflowCheckPermission } from '../hooks/useWorkflowCheckPermission';
import { AddWorkflowDialog } from '../AddWorkflowDialog';
import { useStyles } from './styles';
export var AddWorkflowButton = function () {
    var styles = useStyles();
    var _a = useState(null), anchorEl = _a[0], setAnchorEl = _a[1];
    var checkWorkflowPermission = useWorkflowCheckPermission();
    var canStartProcess = checkWorkflowPermission('START_PROCESS_INSTANCE');
    var canViewProcessDefinitions = checkWorkflowPermission('VIEW_PROCESS_DEFINITIONS');
    var handleOpen = function (e) { return setAnchorEl(e.currentTarget); };
    var handleClose = function () { return setAnchorEl(null); };
    return canStartProcess && canViewProcessDefinitions ? (React.createElement(React.Fragment, null,
        React.createElement(Button, { color: "primary", className: styles.button, onClick: handleOpen },
            React.createElement(AddIcon, { className: styles.icon }),
            React.createElement("div", { className: styles.buttonLabel }, i18n.text('Add'))),
        React.createElement(AddWorkflowDialog, { anchorEl: anchorEl, onClose: handleClose }))) : null;
};
