Capxul Docs
HooksAddress book

useCapxulUnhideAddressBookEntry

Mutation hook that restores a hidden address-book entry to an actor's contact list.

Restores a hidden address-book entry for an actor scope — the counterpart of useCapxulHideAddressBookEntry. List entries (including hidden ones, flagged hidden: true) with useCapxulAddressBook.

Import

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

Usage

"use client";

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

function RestoreContactButton({ entryId }: { entryId: string }) {
  const unhideEntry = useCapxulUnhideAddressBookEntry(capxulAccountScope);

  return (
    <button
      type="button"
      disabled={unhideEntry.isPending}
      onClick={() => unhideEntry.mutate(entryId)}
    >
      {unhideEntry.isPending ? "Restoring…" : "Restore contact"}
    </button>
  );
}

To restore 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 UseCapxulUnhideAddressBookEntryReturn } from "@capxul/sdk-react";
// UseMutationResult<AddressBookEntry, CapxulError, string>

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

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.unhide(entryId) for the personal scope, or client.org(orgId).addressBook.unhide(entryId) for an org scope.

On this page