"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useBlockUser = void 0;
var _reactNative = require("react-native");
var _tsSdkReactNative = require("@amityco/ts-sdk-react-native");
var _reactQuery = require("@tanstack/react-query");
var _toastSlice = require("../../../core/stores/slices/toastSlice");
var _constants = require("../../../core/constants");
const useBlockUser = () => {
  const {
    showToast
  } = (0, _toastSlice.useToast)();
  const {
    mutate: blockUserMutate
  } = (0, _reactQuery.useMutation)({
    mutationFn: _tsSdkReactNative.UserRepository.Relationship.blockUser
  });
  const {
    mutate: unBlockUserMutate
  } = (0, _reactQuery.useMutation)({
    mutationFn: _tsSdkReactNative.UserRepository.Relationship.unBlockUser
  });
  const blockUser = (userId, displayName) => {
    _reactNative.Alert.alert(_constants.ALERT.USER.BLOCK.TITLE, _constants.ALERT.USER.BLOCK.MESSAGE(displayName), [{
      text: _constants.ALERT.ACTION.CANCEL,
      style: 'cancel'
    }, {
      text: _constants.ALERT.ACTION.BLOCK,
      style: 'destructive',
      onPress: () => {
        blockUserMutate(userId, {
          onSuccess: () => {
            showToast({
              type: 'success',
              message: _constants.TOAST.USER.BLOCK.SUCCESS
            });
          },
          onError: () => {
            showToast({
              type: 'informative',
              message: _constants.TOAST.USER.BLOCK.FAILED
            });
          }
        });
      }
    }]);
  };
  const unBlockUser = (userId, displayName) => {
    _reactNative.Alert.alert(_constants.ALERT.USER.UNBLOCK.TITLE, _constants.ALERT.USER.UNBLOCK.MESSAGE(displayName), [{
      text: _constants.ALERT.ACTION.CANCEL,
      style: 'cancel'
    }, {
      text: _constants.ALERT.ACTION.UNBLOCK,
      style: 'destructive',
      onPress: () => {
        unBlockUserMutate(userId, {
          onSuccess: () => {
            showToast({
              type: 'success',
              message: _constants.TOAST.USER.UNBLOCK.SUCCESS
            });
          },
          onError: () => {
            showToast({
              type: 'informative',
              message: _constants.TOAST.USER.UNBLOCK.FAILED
            });
          }
        });
      }
    }]);
  };
  return {
    blockUser,
    unBlockUser
  };
};
exports.useBlockUser = useBlockUser;
//# sourceMappingURL=useBlockUser.js.map