Hooks

useDocyrusLogActivity

Docyrus data engine for LogActivityForm. Fetches comments, users, task and event options and the record's status field, and runs the comment, task, event and two-call status mutations.

iOSAndroidExpo Go

Installation

pnpm dlx @docyrus/cli add @docyrus/rn-hooks-use-docyrus-log-activity
Required Packages(2 packages)
pnpm add @tanstack/react-query @docyrus/api-client

The hook owns all network I/O for the presentational LogActivityForm and returns a logActivityProps bag to spread onto it. It needs a QueryClientProvider above it.

Usage

import { useDocyrusClient } from '@docyrus/signin/react-native';

import { LogActivityForm } from '@/components/docyrus-native/log-activity-form';
import { useDocyrusLogActivity } from '@/hooks/docyrus-native/use-docyrus-log-activity';

export function ContactLogActivity({ contactId, meId }: { contactId: string; meId: string }) {
  const client = useDocyrusClient();

  const { logActivityProps } = useDocyrusLogActivity({
    client,
    appSlug: 'base',
    dataSourceSlug: 'contact',
    recordId: contactId,
    relationSlug: 'contact',
    currentUserId: meId,
    callEventTypeName: 'Call',
    meetingEventTypeName: 'Meeting'
  });

  return <LogActivityForm {...logActivityProps} />;
}

What it calls

TabRequests
CommentGET {record}/comments, POST {record}/comments, DELETE {record}/comments/:id, users from /v1/users
TaskGET /v1/apps/{taskApp}/data-sources/{taskDs}?expand=fields,enums (status + priority enums), POST …/{taskDs}/items linked through taskRelationSlug ?? relationSlug
Call / MeetingGET /v1/apps/{eventTypeApp}/data-sources/{eventTypeDs}/items (event types), POST /v1/apps/{eventApp}/data-sources/{eventDs}/items linked through eventRelationSlug ?? relationSlug
StatusGET {dataSource}?expand=fields,enums (status field), GET {record}?columns=… (current value), then PATCH {record} followed by POST {dataSource}/status-update/:slug

{record} is /v1/apps/:appSlug/data-sources/:dataSourceSlug/items/:recordId. Queries for tabs that are not in activityTypes never run.

If the PATCH succeeds but logging the status update fails, the mutation rejects with an error carrying partial: true. The status was still changed.

Every successful mutation invalidates the record-scoped ['docyrus-contact-activity', {record}] prefix. A mounted useDocyrusContactActivity timeline for the same record refreshes automatically.

Email tab

Like web, the hook embeds useDocyrusEmailComposer: sender accounts, @ mention users and the send mutation, with recipients seeded from emailTo. Its queries only run while the email tab is enabled. Native-only: pass emailComposerProps, onSendEmail and isSendingEmail to replace it with your own email wiring. The embedded composer then stays idle.

API Reference

UseDocyrusLogActivityOptions

OptionTypeDefaultDescription
clientRestApiClient-Authenticated Docyrus REST client (required)
appSlugstring-Owning record's app (required)
dataSourceSlugstring-Owning record's data source (required)
recordIdstring-Owning record id (required). Queries wait until it is set
relationSlugstring-Back-relation slug linking new tasks and events to the record
eventRelationSlugstringrelationSlugEvent back-relation override
taskRelationSlugstringrelationSlugTask back-relation override
statusFieldSlugstringfirst field-statusStatus field on the record's data source
activityTypesLoggableActivityType[]all sixTabs shown. Also gates the queries
taskAppSlugstring'base'Tasks app
taskDataSourceSlugstring'task'Tasks data source
taskStatusFieldSlugstring'status'Task status field
taskPriorityFieldSlugstring'priority'Task priority field
eventAppSlugstring'base'Events app
eventDataSourceSlugstring'event'Events data source
eventTypeAppSlugstring'base'Event type (calendar) app
eventTypeDataSourceSlugstring'calendar'Event type (calendar) data source
callEventTypeIdstring-Preset event type for Call
meetingEventTypeIdstring-Preset event type for Meeting
callEventTypeNamestring-Resolve the Call event type by name (case-insensitive) when no id is given
meetingEventTypeNamestring-Resolve the Meeting event type by name when no id is given
usersCommentUser[]-Users to use instead of fetching /v1/users
currentUserIdstring-Current user id (own comments)
usersLimitnumber1000Max users fetched
listUsersEndpointstring'/v1/users'Users endpoint override
emailTostring[]-Seed the Email tab recipients
emailComposerPropsPartial<LogActivityEmailComposerProps>-Native-only: overrides the embedded useDocyrusEmailComposer props
onSendEmail() => void | Promise<void>-Native-only: overrides the embedded send
isSendingEmailbooleanfalseNative-only: pending send state when you override the email wiring
enabledbooleantrueToggle every query

UseDocyrusLogActivityResult

FieldTypeDescription
logActivityPropsDocyrusLogActivityPropsSpread onto <LogActivityForm />
createComment(payload: LogActivityCommentPayload) => Promise<void>Post a comment or reply
deleteComment(commentId: string) => Promise<void>Delete a comment
createTask(input: LogTaskInput) => Promise<void>Create a linked task
createEvent(input: LogEventInput, kind: 'call' | 'meeting') => Promise<void>Create a linked event
updateStatus(input: LogStatusInput) => Promise<void>Two-call status change
isCreatingCommentbooleanComment mutation pending
isCreatingTaskbooleanTask mutation pending
isCreatingEventbooleanEvent mutation pending
isUpdatingStatusbooleanStatus mutation pending
refetch() => Promise<unknown>Invalidate the record-scoped activity cache

Type Exports

TypeDescription
UseDocyrusLogActivityOptionsHook options
UseDocyrusLogActivityResultHook result
DocyrusLogActivityPropsThe subset of LogActivityFormProps the hook fills

On this page