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.
Installation
pnpm dlx @docyrus/cli add @docyrus/rn-hooks-use-docyrus-contact-channelspnpm add @tanstack/react-queryA 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
| Option | Type | Default | Description |
|---|---|---|---|
client | ContactChannelsClient | - | REST client (required) |
appSlug / dataSourceSlug / recordId | string | - | Owning record (required) |
includeArchived | boolean | false | Include archived channels |
enabled | boolean | Boolean(recordId) | Toggle every query |
loadBrands | boolean | true | Fetch /v1/tenant/brands |
UseDocyrusContactChannelsResult
| Field | Type | Description |
|---|---|---|
channels / brands / consentHistory / validationHistory | arrays | Loaded data |
isLoading / error / isMutating / mutationError | State | |
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
| Type | Description |
|---|---|
ContactChannelsClient | { get, post, patch, delete } |
ContactChannelsPanelData | Read part of the result |
ConsentEntryWithChannel | ConsentEntryInput & { channelId } |
useDocyrusContactActivity
Merges a record's audit log, comments, related events and tasks, and status updates into one typed timeline for ContactActivityPanel, with upcoming items, a relationship summary and comment and status mutations.
useDocyrusDataExport
Server-side export of a Docyrus data source on React Native. POSTs the column list, filters and keyword to the query-export endpoint, writes the returned xlsx or csv file into the cache directory and opens the share sheet.