Capxul Docs
HooksAddress book

useCapxulHideAddressBookEntry

Mutation hook that hides an address-book entry from an actor's contact list without deleting the relationship.

Hides an address-book entry for an actor scope. Hiding is a display flag, not a delete: the relationship history stays, and useCapxulUnhideAddressBookEntry restores the entry. List entries (and read their hidden flag) with useCapxulAddressBook.

Import

import { capxulAccountScope, useCapxulHideAddressBookEntry } from "@capxul/sdk-react";

Usage

"use client";

import {
  capxulAccountScope,
  useCapxulHideAddressBookEntry,
} from "@capxul/sdk-react";

function HideContactButton({ entryId }: { entryId: string }) {
  const hideEntry = useCapxulHideAddressBookEntry(capxulAccountScope);

  return (
    <button
      type="button"
      disabled={hideEntry.isPending}
      onClick={() => hideEntry.mutate(entryId)}
    >
      {hideEntry.isPending ? "Hiding…" : "Hide contact"}
    </button>
  );
}

To hide an entry in an organization's address book, scope the hook with capxulOrgScope(orgId) instead.

Parameters

actor

CapxulActorScope | undefined — defaults to capxulAccountScope

Which actor's address book to write to. An explicit undefined also falls back to the personal scope — gate org-scoped controls on the org id being loaded. See Actor scopes.

Mutation input

The mutation takes the entry id (string), as returned by useCapxulAddressBook.

Return type

import { type UseCapxulHideAddressBookEntryReturn } from "@capxul/sdk-react";
// UseMutationResult<AddressBookEntry, CapxulError, string>

On success, data is the updated AddressBookEntry with hidden: true.

The hook returns TanStack Query's UseMutationResult. The most-used fields:

FieldDescription
mutateFire the mutation (fire-and-forget; pair with onSuccess/onError callbacks).
mutateAsyncFire the mutation and get a Promise of the result. Rejects with a CapxulError on failure.
dataThe mutation result (typed per hook, shown above). undefined until the first success.
errorA CapxulError when the last attempt failed, otherwise null.
isPendingtrue while the mutation is in flight. Use it to disable submit buttons.
resetClear the mutation state (data, error) back to idle.

Mutations do not retry by default. The full field list is in the TanStack Query useMutation reference; see also the TanStack Query integration guide.

Cache behavior

On success this mutation invalidates, for the acting scope only, the address book list and this entry's detail query.

Errors

Failures surface as a CapxulError on error / thrown from mutateAsync — for example when the id is not a valid address-book entry id.

Client method

This hook wraps client.account.addressBook.hide(entryId) for the personal scope, or client.org(orgId).addressBook.hide(entryId) for an org scope.

On this page