"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useLeaveCommunity = void 0;
var _tsSdkReactNative = require("@amityco/ts-sdk-react-native");
var _react = require("react");
const useLeaveCommunity = ({
  onSuccess,
  onError
} = {}) => {
  const [isPending, setIsPending] = (0, _react.useState)(false);
  const leaveCommunity = async communityId => {
    setIsPending(true);
    try {
      await _tsSdkReactNative.CommunityRepository.leaveCommunity(communityId);
      setIsPending(false);
      if (onSuccess) {
        onSuccess();
      }
    } catch (error) {
      setIsPending(false);
      if (onError) {
        onError(error);
      }
    }
  };
  return {
    leaveCommunity,
    isPending
  };
};
exports.useLeaveCommunity = useLeaveCommunity;
//# sourceMappingURL=useLeaveCommunity.js.map