"use strict";

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