"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.usePendingFollowRequest = usePendingFollowRequest;
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");
function usePendingFollowRequest() {
  const {
    showToast
  } = (0, _toastSlice.useToast)();
  const {
    mutate: acceptMutate,
    isPending: isAcceptPending
  } = (0, _reactQuery.useMutation)({
    mutationFn: _tsSdkReactNative.UserRepository.Relationship.acceptMyFollower
  });
  const {
    mutate: declineMutate,
    isPending: isDeclinePending
  } = (0, _reactQuery.useMutation)({
    mutationFn: _tsSdkReactNative.UserRepository.Relationship.declineMyFollower
  });
  const acceptRequest = (userId, displayName) => {
    acceptMutate(userId, {
      onSuccess: () => {
        showToast({
          type: 'success',
          message: _constants.TOAST.USER.FOLLOW_REQUEST.ACCEPT.SUCCESS(displayName)
        });
      }
    });
  };
  const declineRequest = userId => {
    declineMutate(userId, {
      onSuccess: () => {
        showToast({
          type: 'success',
          message: _constants.TOAST.USER.FOLLOW_REQUEST.DECLINE.SUCCESS
        });
      }
    });
  };
  return {
    acceptRequest,
    declineRequest,
    isLoading: isAcceptPending || isDeclinePending
  };
}
//# sourceMappingURL=usePendingFollowRequest.js.map