Hooks

useDocyrusContactChannels

React Query wiring for the Contact Channels & Consent API — a record's channels, consent and validation ledgers, tenant brands and every channel / consent / validation mutation.

iOSAndroidExpo Go

Installation

pnpm dlx @docyrus/cli add @docyrus/rn-hooks-use-docyrus-contact-channels
Required Packages(1 package)
pnpm add @tanstack/react-query

A verbatim port of the web hook. It takes a structural ContactChannelsClient (get / post / patch / delete), which RestApiClient satisfies. Queries share the web keys (['docyrus-contact-channels', <recordBase>, …], ['docyrus-tenant-brands']) and every mutation invalidates the record's channel queries. Read endpoints need DS.Read.All, write endpoints DS.ReadWrite.All. ContactChannelsPanel uses it internally.

Usage

import { useDocyrusContactChannels } from '@/hooks/docyrus-native/use-docyrus-contact-channels';

const { channels, brands, createChannel, recordConsent, runValidation } = useDocyrusContactChannels({
  client,
  appSlug: 'base',
  dataSourceSlug: 'contact',
  recordId
});

await createChannel({ channelKind: 'email', channelType: 'email', value: 'erin@acme.com', isPrimary: true });
await recordConsent(channelId, { purpose: 'marketing', action: 'opt_in', consentStatus: 'opted_in', consentChannel: 'email' });

API Reference

UseDocyrusContactChannelsOptions

OptionTypeDefaultDescription
clientContactChannelsClient-REST client (required)
appSlug / dataSourceSlug / recordIdstring-Owning record (required)
includeArchivedbooleanfalseInclude archived channels
enabledbooleanBoolean(recordId)Toggle every query
loadBrandsbooleantrueFetch /v1/tenant/brands

UseDocyrusContactChannelsResult

FieldTypeDescription
channels / brands / consentHistory / validationHistoryarraysLoaded data
isLoading / error / isMutating / mutationErrorState
refetch() => Promise<unknown>Invalidate the record's queries
createChannel(input) / updateChannel(id, input)Promise<ContactChannel>POST / PATCH …/channels
makePrimary(id) / archiveChannel(id, reason?) / unarchiveChannel(id) / deleteChannel(id)Promise<ContactChannel>Channel actions
recordConsent(id, entry) / bulkRecordConsent(id, items) / bulkRecordRecordConsent(items)Promise<ConsentRecord | ConsentRecord[]>Consent ledger writes
listChannelConsent(id)Promise<ConsentRecord[]>Per-channel consent ledger
recordValidation(id, entry) / runValidation(id)Promise<ValidationRecord>Validation writes / engine run
listChannelValidations(id)Promise<ValidationRecord[]>Per-channel validation ledger

Types

TypeDescription
ContactChannelsClient{ get, post, patch, delete }
ContactChannelsPanelDataRead part of the result
ConsentEntryWithChannelConsentEntryInput & { channelId }

On this page