"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.catchUnauthorizedActionByBlockedUser = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_intl_1 = require("react-intl");
/**
 * Catch and display errors when an action is performed and
 * one user is blocked by the other
 * @param e (error)
 * @return boolean (true if catch errors 403)
 */
function catchUnauthorizedActionByBlockedUser(e, isBlockedByMe, enqueueSnackbar) {
    let _cathedErrors = false;
    if (e && e.response && e.response && e.response.status && e.response.status === 403) {
        if (isBlockedByMe) {
            enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.common.actionToUserBlockedByMe", defaultMessage: "ui.common.actionToUserBlockedByMe" }), {
                variant: 'warning',
                autoHideDuration: 3000
            });
        }
        else {
            enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.common.actionToUserHasBlockedMe", defaultMessage: "ui.common.actionToUserHasBlockedMe" }), {
                variant: 'warning',
                autoHideDuration: 3000
            });
        }
        _cathedErrors = true;
    }
    return _cathedErrors;
}
exports.catchUnauthorizedActionByBlockedUser = catchUnauthorizedActionByBlockedUser;
