import { Client } from '@amityco/ts-sdk-react-native';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
export function useCommunityNotificationSettingsQuery({
  communityId
}) {
  const queryClient = useQueryClient();
  const queryKey = ['communityNotificationSettings', communityId];
  const invalidate = () => {
    queryClient.invalidateQueries({
      queryKey
    });
  };
  const {
    data,
    isLoading
  } = useQuery({
    queryKey,
    queryFn: () => Client.notifications().community(communityId).getSettings(),
    enabled: !!communityId
  });
  const {
    mutateAsync: enableMutate,
    isPending: isEnablePending
  } = useMutation({
    mutationFn: ({
      communityId: id,
      events
    }) => Client.notifications().community(id).enable(events),
    onSuccess: invalidate
  });
  const {
    mutateAsync: disableMutate,
    isPending: isDisablePending
  } = useMutation({
    mutationFn: ({
      communityId: id
    }) => Client.notifications().community(id).disable(),
    onSuccess: invalidate
  });
  return {
    data,
    isLoading,
    enableNotifications: enableMutate,
    disableNotifications: disableMutate,
    isPending: isEnablePending || isDisablePending
  };
}
//# sourceMappingURL=useCommunityNotificationSettingsQuery.js.map