import { Alert } from 'react-native';
import { UserRepository } from '@amityco/ts-sdk-react-native';
import { useMutation } from '@tanstack/react-query';
import { useToast } from '../../../core/stores/slices/toastSlice';
import { ALERT, TOAST } from '../../../core/constants';
export const useBlockUser = () => {
  const {
    showToast
  } = useToast();
  const {
    mutate: blockUserMutate
  } = useMutation({
    mutationFn: UserRepository.Relationship.blockUser
  });
  const {
    mutate: unBlockUserMutate
  } = useMutation({
    mutationFn: UserRepository.Relationship.unBlockUser
  });
  const blockUser = (userId, displayName) => {
    Alert.alert(ALERT.USER.BLOCK.TITLE, ALERT.USER.BLOCK.MESSAGE(displayName), [{
      text: ALERT.ACTION.CANCEL,
      style: 'cancel'
    }, {
      text: ALERT.ACTION.BLOCK,
      style: 'destructive',
      onPress: () => {
        blockUserMutate(userId, {
          onSuccess: () => {
            showToast({
              type: 'success',
              message: TOAST.USER.BLOCK.SUCCESS
            });
          },
          onError: () => {
            showToast({
              type: 'informative',
              message: TOAST.USER.BLOCK.FAILED
            });
          }
        });
      }
    }]);
  };
  const unBlockUser = (userId, displayName) => {
    Alert.alert(ALERT.USER.UNBLOCK.TITLE, ALERT.USER.UNBLOCK.MESSAGE(displayName), [{
      text: ALERT.ACTION.CANCEL,
      style: 'cancel'
    }, {
      text: ALERT.ACTION.UNBLOCK,
      style: 'destructive',
      onPress: () => {
        unBlockUserMutate(userId, {
          onSuccess: () => {
            showToast({
              type: 'success',
              message: TOAST.USER.UNBLOCK.SUCCESS
            });
          },
          onError: () => {
            showToast({
              type: 'informative',
              message: TOAST.USER.UNBLOCK.FAILED
            });
          }
        });
      }
    }]);
  };
  return {
    blockUser,
    unBlockUser
  };
};
//# sourceMappingURL=useBlockUser.js.map