"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.usePendingPostQuery = void 0;
var _reactQuery = require("@tanstack/react-query");
var _toastSlice = require("../../core/stores/slices/toastSlice");
var _tsSdkReactNative = require("@amityco/ts-sdk-react-native");
const usePendingPostQuery = () => {
  const {
    showToast
  } = (0, _toastSlice.useToast)();
  const {
    mutate: deletePost
  } = (0, _reactQuery.useMutation)({
    mutationFn: postId => _tsSdkReactNative.PostRepository.deletePost(postId, false),
    onSuccess: () => {
      showToast({
        type: 'success',
        message: 'Post deleted.'
      });
    },
    onError: () => {
      showToast({
        type: 'informative',
        message: 'Failed to delete post.'
      });
    }
  });
  const {
    mutate: approvePost
  } = (0, _reactQuery.useMutation)({
    mutationFn: _tsSdkReactNative.PostRepository.approvePost,
    onSuccess: () => {
      showToast({
        type: 'success',
        message: 'Post accepted.'
      });
    },
    onError: () => {
      showToast({
        type: 'informative',
        message: 'Failed to accept post. This post has been reviewed by another moderator.'
      });
    }
  });
  const {
    mutate: declinePost
  } = (0, _reactQuery.useMutation)({
    mutationFn: _tsSdkReactNative.PostRepository.declinePost,
    onSuccess: () => {
      showToast({
        type: 'success',
        message: 'Post declined.'
      });
    },
    onError: () => {
      showToast({
        type: 'informative',
        message: 'Failed to decline post. This post has been reviewed by another moderator.'
      });
    }
  });
  return {
    deletePost,
    approvePost,
    declinePost
  };
};
exports.usePendingPostQuery = usePendingPostQuery;
//# sourceMappingURL=usePendingPostQuery.js.map