import { useState } from 'react';
import { CommunityRepository } from '@amityco/ts-sdk-react-native';
export const useJoinCommunity = ({
  onSuccess,
  onError
} = {}) => {
  const [isPending, setIsPending] = useState(false);
  const joinCommunity = async communityId => {
    setIsPending(true);
    try {
      await CommunityRepository.joinCommunity(communityId);
      setIsPending(false);
      if (onSuccess) {
        onSuccess();
      }
    } catch (error) {
      setIsPending(false);
      if (onError) {
        onError(error);
      }
    }
  };
  return {
    joinCommunity,
    isPending
  };
};
//# sourceMappingURL=useJoinCommunity.js.map