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.
Installation
pnpm dlx @docyrus/cli add @docyrus/rn-hooks-use-docyrus-log-activitypnpm add @tanstack/react-query @docyrus/api-clientThe 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
| Tab | Requests |
|---|---|
| Comment | GET {record}/comments, POST {record}/comments, DELETE {record}/comments/:id, users from /v1/users |
| Task | GET /v1/apps/{taskApp}/data-sources/{taskDs}?expand=fields,enums (status + priority enums), POST …/{taskDs}/items linked through taskRelationSlug ?? relationSlug |
| Call / Meeting | GET /v1/apps/{eventTypeApp}/data-sources/{eventTypeDs}/items (event types), POST /v1/apps/{eventApp}/data-sources/{eventDs}/items linked through eventRelationSlug ?? relationSlug |
| Status | GET {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
| Option | Type | Default | Description |
|---|---|---|---|
client | RestApiClient | - | Authenticated Docyrus REST client (required) |
appSlug | string | - | Owning record's app (required) |
dataSourceSlug | string | - | Owning record's data source (required) |
recordId | string | - | Owning record id (required). Queries wait until it is set |
relationSlug | string | - | Back-relation slug linking new tasks and events to the record |
eventRelationSlug | string | relationSlug | Event back-relation override |
taskRelationSlug | string | relationSlug | Task back-relation override |
statusFieldSlug | string | first field-status | Status field on the record's data source |
activityTypes | LoggableActivityType[] | all six | Tabs shown. Also gates the queries |
taskAppSlug | string | 'base' | Tasks app |
taskDataSourceSlug | string | 'task' | Tasks data source |
taskStatusFieldSlug | string | 'status' | Task status field |
taskPriorityFieldSlug | string | 'priority' | Task priority field |
eventAppSlug | string | 'base' | Events app |
eventDataSourceSlug | string | 'event' | Events data source |
eventTypeAppSlug | string | 'base' | Event type (calendar) app |
eventTypeDataSourceSlug | string | 'calendar' | Event type (calendar) data source |
callEventTypeId | string | - | Preset event type for Call |
meetingEventTypeId | string | - | Preset event type for Meeting |
callEventTypeName | string | - | Resolve the Call event type by name (case-insensitive) when no id is given |
meetingEventTypeName | string | - | Resolve the Meeting event type by name when no id is given |
users | CommentUser[] | - | Users to use instead of fetching /v1/users |
currentUserId | string | - | Current user id (own comments) |
usersLimit | number | 1000 | Max users fetched |
listUsersEndpoint | string | '/v1/users' | Users endpoint override |
emailTo | string[] | - | Seed the Email tab recipients |
emailComposerProps | Partial<LogActivityEmailComposerProps> | - | Native-only: overrides the embedded useDocyrusEmailComposer props |
onSendEmail | () => void | Promise<void> | - | Native-only: overrides the embedded send |
isSendingEmail | boolean | false | Native-only: pending send state when you override the email wiring |
enabled | boolean | true | Toggle every query |
UseDocyrusLogActivityResult
| Field | Type | Description |
|---|---|---|
logActivityProps | DocyrusLogActivityProps | Spread 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 |
isCreatingComment | boolean | Comment mutation pending |
isCreatingTask | boolean | Task mutation pending |
isCreatingEvent | boolean | Event mutation pending |
isUpdatingStatus | boolean | Status mutation pending |
refetch | () => Promise<unknown> | Invalidate the record-scoped activity cache |
Type Exports
| Type | Description |
|---|---|
UseDocyrusLogActivityOptions | Hook options |
UseDocyrusLogActivityResult | Hook result |
DocyrusLogActivityProps | The subset of LogActivityFormProps the hook fills |
useDocyrusKanban
Kanban board backed by a Docyrus data source. Groups records by an enum, user or date field, and saves a card's move to the API when it is dropped. Enum options marked final become drop zones.
useDocyrusMapView
Map backed by a Docyrus data source. Detects the location field and builds markers from logos, icons or the default pin, with clustering, a viewport filter, basemaps and drag-to-move with reverse geocoding.