"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useWorkflowDefaultActionSuccessHandler = void 0;
var react_1 = require("react");
var WorkflowTasksContext_1 = require("../../../contexts/WorkflowTasksContext");
var MdmModuleContext_1 = require("../../../contexts/MdmModuleContext");
var useWorkflowDefaultActionSuccessHandler = function () {
    var loadTasks = ((0, react_1.useContext)(WorkflowTasksContext_1.WorkflowTasksContext) || {}).loadTasks;
    var loadEntity = (0, MdmModuleContext_1.useMdmAction)('loadEntity');
    var entityDeletionFinished = (0, MdmModuleContext_1.useMdmAction)('entityDeletionFinished');
    var entityUri = (0, MdmModuleContext_1.useMdmEntityUri)();
    return (0, react_1.useCallback)(function (action) {
        if (action === 'Delete') {
            entityDeletionFinished();
        }
        else {
            // entity refreshing
            loadEntity(entityUri);
            loadTasks === null || loadTasks === void 0 ? void 0 : loadTasks();
        }
    }, [entityUri, loadTasks, loadEntity, entityDeletionFinished]);
};
exports.useWorkflowDefaultActionSuccessHandler = useWorkflowDefaultActionSuccessHandler;
