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