@open-mercato/core 0.4.11-develop.1309.4b37381a7a → 0.4.11-develop.1347.c693e6dfee

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/modules/customers/api/companies/[id]/route.js +3 -2
  2. package/dist/modules/customers/api/companies/[id]/route.js.map +2 -2
  3. package/dist/modules/customers/api/dashboard/widgets/customer-todos/route.js +59 -91
  4. package/dist/modules/customers/api/dashboard/widgets/customer-todos/route.js.map +2 -2
  5. package/dist/modules/customers/api/interactions/tasks/route.js +115 -0
  6. package/dist/modules/customers/api/interactions/tasks/route.js.map +7 -0
  7. package/dist/modules/customers/api/people/[id]/route.js +3 -2
  8. package/dist/modules/customers/api/people/[id]/route.js.map +2 -2
  9. package/dist/modules/customers/api/todos/route.js +14 -134
  10. package/dist/modules/customers/api/todos/route.js.map +2 -2
  11. package/dist/modules/customers/backend/customer-tasks/page.js +10 -0
  12. package/dist/modules/customers/backend/customer-tasks/page.js.map +7 -0
  13. package/dist/modules/customers/backend/customer-tasks/page.meta.js +25 -0
  14. package/dist/modules/customers/backend/customer-tasks/page.meta.js.map +7 -0
  15. package/dist/modules/customers/commands/interactions.js +40 -4
  16. package/dist/modules/customers/commands/interactions.js.map +2 -2
  17. package/dist/modules/customers/components/CustomerTodosTable.js +77 -47
  18. package/dist/modules/customers/components/CustomerTodosTable.js.map +2 -2
  19. package/dist/modules/customers/components/detail/TasksSection.js +4 -4
  20. package/dist/modules/customers/components/detail/TasksSection.js.map +2 -2
  21. package/dist/modules/customers/components/detail/hooks/usePersonTasks.js +2 -1
  22. package/dist/modules/customers/components/detail/hooks/usePersonTasks.js.map +2 -2
  23. package/dist/modules/customers/components/detail/utils.js +3 -0
  24. package/dist/modules/customers/components/detail/utils.js.map +2 -2
  25. package/dist/modules/customers/data/entities.js +2 -2
  26. package/dist/modules/customers/data/entities.js.map +2 -2
  27. package/dist/modules/customers/data/validators.js +2 -2
  28. package/dist/modules/customers/data/validators.js.map +2 -2
  29. package/dist/modules/customers/lib/interactionCompatibility.js +12 -2
  30. package/dist/modules/customers/lib/interactionCompatibility.js.map +2 -2
  31. package/dist/modules/customers/lib/todoCompatibility.js +167 -4
  32. package/dist/modules/customers/lib/todoCompatibility.js.map +2 -2
  33. package/dist/modules/customers/migrations/Migration20260401172819.js +45 -0
  34. package/dist/modules/customers/migrations/Migration20260401172819.js.map +7 -0
  35. package/dist/modules/customers/search.js +3 -2
  36. package/dist/modules/customers/search.js.map +2 -2
  37. package/dist/modules/customers/widgets/dashboard/customer-todos/widget.client.js +10 -2
  38. package/dist/modules/customers/widgets/dashboard/customer-todos/widget.client.js.map +2 -2
  39. package/package.json +3 -3
  40. package/src/modules/customers/api/companies/[id]/route.ts +6 -5
  41. package/src/modules/customers/api/dashboard/widgets/customer-todos/route.ts +69 -126
  42. package/src/modules/customers/api/interactions/tasks/route.ts +122 -0
  43. package/src/modules/customers/api/people/[id]/route.ts +3 -2
  44. package/src/modules/customers/api/todos/route.ts +13 -181
  45. package/src/modules/customers/backend/customer-tasks/page.meta.ts +23 -0
  46. package/src/modules/customers/backend/customer-tasks/page.tsx +12 -0
  47. package/src/modules/customers/commands/interactions.ts +50 -2
  48. package/src/modules/customers/components/CustomerTodosTable.tsx +91 -66
  49. package/src/modules/customers/components/detail/TasksSection.tsx +8 -8
  50. package/src/modules/customers/components/detail/hooks/usePersonTasks.ts +2 -1
  51. package/src/modules/customers/components/detail/types.ts +6 -0
  52. package/src/modules/customers/components/detail/utils.ts +3 -0
  53. package/src/modules/customers/data/entities.ts +2 -2
  54. package/src/modules/customers/data/validators.ts +2 -2
  55. package/src/modules/customers/lib/interactionCompatibility.ts +16 -0
  56. package/src/modules/customers/lib/todoCompatibility.ts +229 -10
  57. package/src/modules/customers/migrations/.snapshot-open-mercato.json +1 -1
  58. package/src/modules/customers/migrations/Migration20260401172819.ts +45 -0
  59. package/src/modules/customers/search.ts +3 -2
  60. package/src/modules/customers/widgets/dashboard/customer-todos/widget.client.tsx +24 -23
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/modules/customers/components/detail/TasksSection.tsx"],
4
- "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { Loader2, Pencil, Trash2 } from 'lucide-react'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { LoadingMessage, TabEmptyState } from '@open-mercato/ui/backend/detail'\nimport { cn } from '@open-mercato/shared/lib/utils'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { InteractionSummary, SectionAction, TabEmptyStateConfig, TodoLinkSummary, Translator } from './types'\nimport { createTranslatorWithFallback } from '@open-mercato/shared/lib/i18n/translate'\nimport { formatDate, resolveTodoHref } from './utils'\nimport { formatDateTime } from '@open-mercato/shared/lib/time'\nimport { TimelineItemHeader } from './TimelineItemHeader'\nimport { TaskDialog } from './TaskDialog'\nimport { usePersonTasks, type TaskFormPayload } from './hooks/usePersonTasks'\nimport { useInteractions, type InteractionCreatePayload } from './hooks/useInteractions'\nimport { mapInteractionRecordToTodoSummary } from '../../lib/interactionCompatibility'\n\ntype GuardedMutationRunner = <T>(\n operation: () => Promise<T>,\n mutationPayload?: Record<string, unknown>,\n) => Promise<T>\n\ntype TasksSectionProps = {\n entityId: string | null\n initialTasks: TodoLinkSummary[]\n emptyLabel: string\n addActionLabel: string\n emptyState: TabEmptyStateConfig\n onActionChange?: (action: SectionAction | null) => void\n onLoadingChange?: (isLoading: boolean) => void\n onDataRefresh?: () => void\n translator?: Translator\n entityName?: string | null\n dialogContextKey?: string\n dialogContextFallback?: string\n /** When true, use the canonical interactions API instead of the legacy todos API. */\n useCanonicalInteractions?: boolean\n runGuardedMutation?: GuardedMutationRunner\n}\n\nconst RESERVED_TASK_CUSTOM_KEYS = new Set(['priority', 'description', 'due_at', 'dueAt'])\n\nfunction toTimestamp(value: string | null | undefined): number | null {\n if (!value) return null\n const timestamp = new Date(value).getTime()\n return Number.isNaN(timestamp) ? null : timestamp\n}\n\nfunction sortTaskSummaries(tasks: TodoLinkSummary[]): TodoLinkSummary[] {\n return [...tasks].sort((left, right) => {\n const leftDue = toTimestamp(left.dueAt)\n const rightDue = toTimestamp(right.dueAt)\n if (leftDue !== null || rightDue !== null) {\n if (leftDue === null) return 1\n if (rightDue === null) return -1\n if (leftDue !== rightDue) return leftDue - rightDue\n }\n const leftCreated = toTimestamp(left.createdAt) ?? 0\n const rightCreated = toTimestamp(right.createdAt) ?? 0\n if (leftCreated !== rightCreated) return rightCreated - leftCreated\n return left.id.localeCompare(right.id)\n })\n}\n\nfunction buildInitialFormValues(task: TodoLinkSummary | null): Record<string, unknown> | undefined {\n if (!task) return undefined\n const values: Record<string, unknown> = {\n title: task.title ?? '',\n is_done: task.isDone ?? false,\n description: task.description ?? '',\n priority: task.priority ?? '',\n scheduledAt: task.dueAt ?? '',\n }\n if (task.customValues) {\n for (const [key, value] of Object.entries(task.customValues)) {\n if (RESERVED_TASK_CUSTOM_KEYS.has(key)) continue\n const formKey = `cf_${key}`\n if (values[formKey] === undefined) values[formKey] = value\n }\n }\n return values\n}\n\nexport function TasksSection({\n entityId,\n initialTasks,\n emptyLabel,\n addActionLabel,\n emptyState,\n onActionChange,\n onLoadingChange,\n onDataRefresh,\n translator,\n entityName,\n dialogContextKey,\n dialogContextFallback,\n useCanonicalInteractions = false,\n runGuardedMutation,\n}: TasksSectionProps) {\n const tHook = useT()\n const fallbackTranslator = React.useMemo<Translator>(() => createTranslatorWithFallback(tHook), [tHook])\n const t: Translator = React.useMemo(() => translator ?? fallbackTranslator, [translator, fallbackTranslator])\n const runWriteMutation = React.useCallback(\n async <T,>(operation: () => Promise<T>, mutationPayload?: Record<string, unknown>): Promise<T> => {\n if (!runGuardedMutation) {\n return operation()\n }\n return runGuardedMutation(operation, mutationPayload)\n },\n [runGuardedMutation],\n )\n\n // Legacy path: usePersonTasks (default)\n const legacyResult = usePersonTasks({ entityId, initialTasks })\n\n // Canonical path: useInteractions with planned-status filter\n const canonicalResult = useInteractions({\n entityId: useCanonicalInteractions ? entityId : null,\n typeFilter: 'task',\n })\n\n // Map canonical interactions to the TodoLinkSummary shape used by the rendering below\n const canonicalTasks = React.useMemo<TodoLinkSummary[]>(\n () => (useCanonicalInteractions ? canonicalResult.interactions.map(mapInteractionRecordToTodoSummary) : []),\n [useCanonicalInteractions, canonicalResult.interactions],\n )\n\n const canonicalCreateTask = React.useCallback(\n async (payload: TaskFormPayload) => {\n if (!entityId) throw new Error('Task creation requires an entity id')\n const interactionPayload: InteractionCreatePayload = {\n entityId,\n interactionType: 'task',\n title: payload.base.title,\n status: payload.base.is_done ? 'done' : 'planned',\n priority: payload.base.priority ?? null,\n body: payload.base.description ?? null,\n scheduledAt: payload.base.scheduledAt ?? null,\n customValues: payload.custom,\n }\n await canonicalResult.createInteraction(interactionPayload)\n },\n [canonicalResult, entityId],\n )\n\n const canonicalUpdateTask = React.useCallback(\n async (task: TodoLinkSummary, payload: TaskFormPayload) => {\n await canonicalResult.updateInteraction(task.todoId, {\n title: payload.base.title,\n status: payload.base.is_done ? 'done' : 'planned',\n priority: payload.base.priority ?? null,\n body: payload.base.description ?? null,\n scheduledAt: payload.base.scheduledAt ?? null,\n customValues: payload.custom,\n })\n },\n [canonicalResult],\n )\n\n const canonicalToggleTask = React.useCallback(\n async (task: TodoLinkSummary, nextIsDone: boolean) => {\n if (nextIsDone) {\n await canonicalResult.completeInteraction(task.todoId)\n } else {\n // Reopen: set status back to planned via update\n await canonicalResult.updateInteraction(task.todoId, { status: 'planned' })\n }\n },\n [canonicalResult],\n )\n\n const canonicalUnlinkTask = React.useCallback(\n async (task: TodoLinkSummary) => {\n await canonicalResult.deleteInteraction(task.todoId)\n },\n [canonicalResult],\n )\n\n // Unified interface: pick the active data source based on the flag\n const tasks = useCanonicalInteractions ? canonicalTasks : legacyResult.tasks\n const isInitialLoading = useCanonicalInteractions ? canonicalResult.isInitialLoading : legacyResult.isInitialLoading\n const isLoadingMore = useCanonicalInteractions ? canonicalResult.isLoadingMore : legacyResult.isLoadingMore\n const isMutating = useCanonicalInteractions ? canonicalResult.isMutating : legacyResult.isMutating\n const hasMore = useCanonicalInteractions ? canonicalResult.hasMore : legacyResult.hasMore\n const loadMore = useCanonicalInteractions ? canonicalResult.loadMore : legacyResult.loadMore\n const refresh = useCanonicalInteractions ? canonicalResult.refresh : legacyResult.refresh\n const createTask = useCanonicalInteractions ? canonicalCreateTask : legacyResult.createTask\n const updateTask = useCanonicalInteractions ? canonicalUpdateTask : legacyResult.updateTask\n const toggleTask = useCanonicalInteractions ? canonicalToggleTask : legacyResult.toggleTask\n const unlinkTask = useCanonicalInteractions ? canonicalUnlinkTask : legacyResult.unlinkTask\n const pendingTaskId = useCanonicalInteractions ? canonicalResult.pendingId : legacyResult.pendingTaskId\n const error = useCanonicalInteractions ? canonicalResult.error : legacyResult.error\n const sortedTasks = React.useMemo(() => sortTaskSummaries(tasks), [tasks])\n\n const [dialogOpen, setDialogOpen] = React.useState(false)\n const [dialogMode, setDialogMode] = React.useState<'create' | 'edit'>('create')\n const [editingTask, setEditingTask] = React.useState<TodoLinkSummary | null>(null)\n const sentinelRef = React.useRef<HTMLDivElement | null>(null)\n\n const dialogContextMessage = React.useMemo(() => {\n if (!dialogContextKey || !entityName) return undefined\n return t(dialogContextKey, dialogContextFallback ?? 'This task will be linked to {{name}}', { name: entityName })\n }, [dialogContextFallback, dialogContextKey, entityName, t])\n\n const openCreateDialog = React.useCallback(() => {\n setEditingTask(null)\n setDialogMode('create')\n setDialogOpen(true)\n }, [])\n\n const openEditDialog = React.useCallback((task: TodoLinkSummary) => {\n setEditingTask(task)\n setDialogMode('edit')\n setDialogOpen(true)\n }, [])\n\n const closeDialog = React.useCallback(() => {\n setDialogOpen(false)\n setEditingTask(null)\n }, [])\n\n React.useEffect(() => {\n if (!onActionChange) return\n if (!entityId) {\n onActionChange(null)\n return\n }\n onActionChange({\n label: addActionLabel,\n onClick: openCreateDialog,\n disabled: isMutating,\n })\n return () => {\n onActionChange(null)\n }\n }, [addActionLabel, entityId, isMutating, onActionChange, openCreateDialog])\n\n React.useEffect(() => {\n if (!onLoadingChange) return\n onLoadingChange(isInitialLoading || isMutating)\n }, [isInitialLoading, isMutating, onLoadingChange])\n\n React.useEffect(() => {\n if (!hasMore) return\n if (typeof IntersectionObserver === 'undefined') return\n const el = sentinelRef.current\n if (!el) return\n\n const observer = new IntersectionObserver(\n (entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n loadMore().catch(() => {})\n }\n },\n { rootMargin: '200px 0px 200px 0px' },\n )\n observer.observe(el)\n return () => {\n observer.disconnect()\n }\n }, [hasMore, loadMore])\n\n const handleCreate = React.useCallback(\n async (payload: TaskFormPayload) => {\n try {\n await runWriteMutation(\n () => createTask(payload),\n {\n entityId,\n title: payload.base.title,\n isDone: payload.base.is_done ?? undefined,\n },\n )\n flash(t('customers.people.detail.tasks.createSuccess', 'Task created'), 'success')\n await Promise.resolve(onDataRefresh?.())\n } catch (err) {\n const message = err instanceof Error ? err.message : t('customers.people.detail.tasks.error', 'Failed to create task')\n flash(message, 'error')\n throw err\n }\n },\n [createTask, entityId, onDataRefresh, runWriteMutation, t],\n )\n\n const handleUpdate = React.useCallback(\n async (task: TodoLinkSummary, payload: TaskFormPayload) => {\n try {\n await runWriteMutation(\n () => updateTask(task, payload),\n {\n id: task.id,\n todoId: task.todoId,\n title: payload.base.title,\n isDone: payload.base.is_done ?? undefined,\n },\n )\n flash(t('customers.people.detail.tasks.updateSuccess', 'Task updated'), 'success')\n await Promise.resolve(onDataRefresh?.())\n } catch (err) {\n const message =\n err instanceof Error ? err.message : t('customers.people.detail.tasks.updateError', 'Failed to update task')\n flash(message, 'error')\n throw err\n }\n },\n [onDataRefresh, runWriteMutation, t, updateTask],\n )\n\n const handleToggle = React.useCallback(\n async (task: TodoLinkSummary, nextIsDone: boolean) => {\n try {\n await runWriteMutation(\n () => toggleTask(task, nextIsDone),\n {\n id: task.id,\n todoId: task.todoId,\n isDone: nextIsDone,\n },\n )\n flash(\n nextIsDone\n ? t('customers.people.detail.tasks.completeSuccess', 'Task marked as done')\n : t('customers.people.detail.tasks.reopenSuccess', 'Task reopened'),\n 'success',\n )\n await Promise.resolve(onDataRefresh?.())\n } catch (err) {\n const message =\n err instanceof Error ? err.message : t('customers.people.detail.tasks.toggleError', 'Failed to update task status')\n flash(message, 'error')\n }\n },\n [onDataRefresh, runWriteMutation, t, toggleTask],\n )\n\n const handleDelete = React.useCallback(\n async (task: TodoLinkSummary) => {\n try {\n await runWriteMutation(\n () => unlinkTask(task),\n {\n id: task.id,\n todoId: task.todoId,\n },\n )\n flash(t('customers.people.detail.tasks.deleteSuccess', 'Task removed'), 'success')\n await Promise.resolve(onDataRefresh?.())\n await refresh()\n } catch (err) {\n const message =\n err instanceof Error ? err.message : t('customers.people.detail.tasks.deleteError', 'Failed to remove task')\n flash(message, 'error')\n }\n },\n [onDataRefresh, refresh, runWriteMutation, t, unlinkTask],\n )\n\n const handleCancel = React.useCallback(\n async (task: TodoLinkSummary) => {\n if (!useCanonicalInteractions) return\n try {\n await runWriteMutation(\n () => canonicalResult.cancelInteraction(task.todoId),\n { id: task.todoId },\n )\n flash(t('customers.people.detail.tasks.cancelSuccess', 'Task canceled'), 'success')\n await Promise.resolve(onDataRefresh?.())\n } catch (err) {\n const message =\n err instanceof Error ? err.message : t('customers.people.detail.tasks.cancelError', 'Failed to cancel task')\n flash(message, 'error')\n }\n },\n [canonicalResult, onDataRefresh, runWriteMutation, t, useCanonicalInteractions],\n )\n\n const renderTaskMeta = React.useCallback(\n (task: TodoLinkSummary) => {\n const meta: string[] = []\n if (task.status === 'canceled') {\n meta.push(t('customers.people.detail.tasks.status.canceled', 'Canceled'))\n }\n if (typeof task.priority === 'number') {\n meta.push(t('customers.people.detail.tasks.priorityLabel', 'Priority {{priority}}', { priority: task.priority }))\n }\n if (task.severity) {\n meta.push(\n t(\n `customers.people.detail.tasks.severity.${task.severity}`,\n task.severity.charAt(0).toUpperCase() + task.severity.slice(1),\n ),\n )\n }\n if (task.dueAt) {\n const dueLabel =\n formatDate(task.dueAt) ??\n formatDateTime(task.dueAt) ??\n t('customers.people.detail.tasks.dueLabel', 'Due {{date}}', { date: task.dueAt })\n meta.push(t('customers.people.detail.tasks.dueLabel', 'Due {{date}}', { date: dueLabel }))\n }\n return meta\n },\n [t],\n )\n\n const handleDialogSubmit = React.useCallback(\n async (payload: TaskFormPayload) => {\n if (dialogMode === 'edit' && editingTask) {\n await handleUpdate(editingTask, payload)\n } else {\n await handleCreate(payload)\n }\n },\n [dialogMode, editingTask, handleCreate, handleUpdate],\n )\n\n const hasTasks = sortedTasks.length > 0\n\n return (\n <div className=\"mt-0 space-y-6\">\n <div className=\"space-y-4\">\n {isInitialLoading ? (\n <LoadingMessage\n label={t('customers.people.detail.tasks.loading', 'Loading tasks\u2026')}\n className=\"border-0 bg-transparent p-0 py-8 justify-center\"\n />\n ) : null}\n\n {!isInitialLoading && !hasTasks ? (\n <TabEmptyState\n title={emptyState.title}\n action={{\n label: emptyState.actionLabel,\n onClick: openCreateDialog,\n disabled: isMutating || !entityId,\n }}\n />\n ) : null}\n\n {!isInitialLoading && hasTasks ? (\n <div className=\"space-y-4\">\n {error ? (\n <div className=\"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive\">\n {error}\n </div>\n ) : null}\n {sortedTasks.map((task) => {\n const todoHref = resolveTodoHref(task.todoSource, task.todoId)\n const createdLabel = formatDateTime(task.createdAt) ?? emptyLabel\n const meta = renderTaskMeta(task)\n const title = task.title ?? t('customers.people.detail.tasks.untitled', 'Untitled task')\n const isDone = task.isDone === true\n const isCanceled = task.status === 'canceled'\n const checkboxId = `person-task-${task.id}`\n const isPendingToggle = pendingTaskId === task.todoId\n return (\n <article key={task.id} className=\"group space-y-3 rounded-lg border bg-card p-4 transition hover:border-border/80\">\n <div className=\"flex flex-wrap items-start justify-between gap-3\">\n <TimelineItemHeader\n title={\n <span className=\"inline-flex items-center gap-2\">\n <input\n id={checkboxId}\n type=\"checkbox\"\n checked={isDone}\n onChange={(event) => {\n const next = event.target.checked\n void handleToggle(task, next)\n }}\n disabled={isMutating || isPendingToggle || isCanceled}\n className=\"h-4 w-4 rounded border\"\n />\n <span\n className={cn(\n 'text-sm font-semibold',\n isDone ? 'line-through text-muted-foreground' : undefined,\n isCanceled ? 'text-muted-foreground' : undefined,\n )}\n >\n {title}\n </span>\n </span>\n }\n timestamp={task.createdAt}\n fallbackTimestampLabel={createdLabel}\n />\n <div className=\"flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100\">\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => openEditDialog(task)}\n disabled={isMutating}\n aria-label={t('ui.actions.edit', 'Edit')}\n >\n {isMutating && editingTask?.id === task.id && dialogMode === 'edit' ? (\n <Loader2 className=\"h-4 w-4 animate-spin\" />\n ) : (\n <Pencil className=\"h-4 w-4\" />\n )}\n </IconButton>\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => handleDelete(task)}\n disabled={isMutating}\n aria-label={t('ui.actions.delete', 'Delete')}\n >\n {isMutating ? <Loader2 className=\"h-4 w-4 animate-spin text-destructive\" /> : <Trash2 className=\"h-4 w-4\" />}\n </IconButton>\n </div>\n </div>\n {meta.length ? (\n <div className=\"flex flex-wrap items-center gap-3 text-xs text-muted-foreground\">\n {meta.map((entry) => (\n <span key={`${task.id}-${entry}`} className=\"rounded bg-muted px-2 py-1 text-xs font-medium text-muted-foreground\">\n {entry}\n </span>\n ))}\n </div>\n ) : null}\n {task.description ? (\n <p className=\"text-sm text-muted-foreground whitespace-pre-wrap\">{task.description}</p>\n ) : null}\n <div className=\"flex flex-wrap items-center gap-3 text-xs\">\n {useCanonicalInteractions && !isDone && !isCanceled ? (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"h-auto px-0 text-xs font-medium text-muted-foreground hover:bg-transparent hover:text-foreground\"\n onClick={() => void handleCancel(task)}\n disabled={isMutating || isPendingToggle}\n >\n {t('customers.people.detail.tasks.cancelAction', 'Cancel task')}\n </Button>\n ) : null}\n {todoHref ? (\n <Link href={todoHref} className=\"text-primary hover:underline\">\n {t('customers.people.detail.tasks.openTask', 'Open task')}\n </Link>\n ) : null}\n </div>\n </article>\n )\n })}\n <div ref={sentinelRef} />\n {hasMore ? (\n <div className=\"flex justify-center\">\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={() => loadMore().catch(() => {})} disabled={isLoadingMore}>\n {isLoadingMore ? (\n <>\n <Loader2 className=\"mr-2 h-4 w-4 animate-spin\" />\n {t('customers.people.detail.tasks.loadingMore', 'Loading\u2026')}\n </>\n ) : (\n t('customers.people.detail.tasks.loadMore', 'Load more')\n )}\n </Button>\n </div>\n ) : null}\n {isLoadingMore ? (\n <div className=\"flex justify-center text-xs text-muted-foreground\">\n <Loader2 className=\"mr-2 h-3 w-3 animate-spin\" />\n {t('customers.people.detail.tasks.loadingMore', 'Loading\u2026')}\n </div>\n ) : null}\n <div className=\"flex justify-center\">\n <Button asChild variant=\"outline\" size=\"sm\">\n <Link href=\"/backend/customer-tasks\">\n {t('customers.people.detail.tasks.viewAll', 'View all tasks')}\n </Link>\n </Button>\n </div>\n </div>\n ) : null}\n </div>\n\n <TaskDialog\n open={dialogOpen}\n mode={dialogMode}\n onOpenChange={(next) => {\n if (!next) closeDialog()\n else setDialogOpen(true)\n }}\n initialValues={buildInitialFormValues(editingTask)}\n onSubmit={handleDialogSubmit}\n isSubmitting={isMutating}\n contextMessage={dialogContextMessage}\n />\n </div>\n )\n}\n\nexport default TasksSection\n"],
5
- "mappings": ";AA0aU,SAkIU,UAlIV,KAsCc,YAtCd;AAxaV,YAAY,WAAW;AACvB,OAAO,UAAU;AACjB,SAAS,SAAS,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WAAU,gCAC7B,YAAE,0CAA0C,WAAW,GAC1D,IACE;AAAA,eACN;AAAA,eAvFY,KAAK,EAwFnB;AAAA,QAEJ,CAAC;AAAA,QACD,oBAAC,SAAI,KAAK,aAAa;AAAA,QACtB,UACC,oBAAC,SAAI,WAAU,uBACb,8BAAC,UAAO,MAAK,UAAS,SAAQ,WAAU,MAAK,MAAK,SAAS,MAAM,SAAS,EAAE,MAAM,MAAM;AAAA,QAAC,CAAC,GAAG,UAAU,eACpG,0BACC,iCACE;AAAA,8BAAC,WAAQ,WAAU,6BAA4B;AAAA,UAC9C,EAAE,6CAA6C,eAAU;AAAA,WAC5D,IAEA,EAAE,0CAA0C,WAAW,GAE3D,GACF,IACE;AAAA,QACH,gBACC,qBAAC,SAAI,WAAU,qDACb;AAAA,8BAAC,WAAQ,WAAU,6BAA4B;AAAA,UAC9C,EAAE,6CAA6C,eAAU;AAAA,WAC5D,IACE;AAAA,QACJ,oBAAC,SAAI,WAAU,uBACb,8BAAC,UAAO,SAAO,MAAC,SAAQ,WAAU,MAAK,MACrC,8BAAC,QAAK,MAAK,2BACR,YAAE,yCAAyC,gBAAgB,GAC9D,GACF,GACF;AAAA,SACF,IACE;AAAA,OACN;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc,CAAC,SAAS;AACtB,cAAI,CAAC,KAAM,aAAY;AAAA,cAClB,eAAc,IAAI;AAAA,QACzB;AAAA,QACA,eAAe,uBAAuB,WAAW;AAAA,QACjD,UAAU;AAAA,QACV,cAAc;AAAA,QACd,gBAAgB;AAAA;AAAA,IAClB;AAAA,KACF;AAEJ;AAEA,IAAO,uBAAQ;",
4
+ "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { Loader2, Pencil, Trash2 } from 'lucide-react'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { LoadingMessage, TabEmptyState } from '@open-mercato/ui/backend/detail'\nimport { cn } from '@open-mercato/shared/lib/utils'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { InteractionSummary, SectionAction, TabEmptyStateConfig, TodoLinkSummary, Translator } from './types'\nimport { createTranslatorWithFallback } from '@open-mercato/shared/lib/i18n/translate'\nimport { formatDate, resolveTodoHref } from './utils'\nimport { formatDateTime } from '@open-mercato/shared/lib/time'\nimport { TimelineItemHeader } from './TimelineItemHeader'\nimport { TaskDialog } from './TaskDialog'\nimport { usePersonTasks, type TaskFormPayload } from './hooks/usePersonTasks'\nimport { useInteractions, type InteractionCreatePayload } from './hooks/useInteractions'\nimport { mapInteractionRecordToTodoSummary } from '../../lib/interactionCompatibility'\n\ntype GuardedMutationRunner = <T>(\n operation: () => Promise<T>,\n mutationPayload?: Record<string, unknown>,\n) => Promise<T>\n\ntype TasksSectionProps = {\n entityId: string | null\n initialTasks: TodoLinkSummary[]\n emptyLabel: string\n addActionLabel: string\n emptyState: TabEmptyStateConfig\n onActionChange?: (action: SectionAction | null) => void\n onLoadingChange?: (isLoading: boolean) => void\n onDataRefresh?: () => void\n translator?: Translator\n entityName?: string | null\n dialogContextKey?: string\n dialogContextFallback?: string\n /** When true, use the canonical interactions API instead of the legacy todos API. */\n useCanonicalInteractions?: boolean\n runGuardedMutation?: GuardedMutationRunner\n}\n\nconst RESERVED_TASK_CUSTOM_KEYS = new Set(['priority', 'description', 'due_at', 'dueAt'])\n\nfunction toTimestamp(value: string | null | undefined): number | null {\n if (!value) return null\n const timestamp = new Date(value).getTime()\n return Number.isNaN(timestamp) ? null : timestamp\n}\n\nfunction sortTaskSummaries(tasks: TodoLinkSummary[]): TodoLinkSummary[] {\n return [...tasks].sort((left, right) => {\n const leftDue = toTimestamp(left.dueAt)\n const rightDue = toTimestamp(right.dueAt)\n if (leftDue !== null || rightDue !== null) {\n if (leftDue === null) return 1\n if (rightDue === null) return -1\n if (leftDue !== rightDue) return leftDue - rightDue\n }\n const leftCreated = toTimestamp(left.createdAt) ?? 0\n const rightCreated = toTimestamp(right.createdAt) ?? 0\n if (leftCreated !== rightCreated) return rightCreated - leftCreated\n return left.id.localeCompare(right.id)\n })\n}\n\nfunction buildInitialFormValues(task: TodoLinkSummary | null): Record<string, unknown> | undefined {\n if (!task) return undefined\n const values: Record<string, unknown> = {\n title: task.title ?? '',\n is_done: task.isDone ?? false,\n description: task.description ?? '',\n priority: task.priority ?? '',\n scheduledAt: task.dueAt ?? '',\n }\n if (task.customValues) {\n for (const [key, value] of Object.entries(task.customValues)) {\n if (RESERVED_TASK_CUSTOM_KEYS.has(key)) continue\n const formKey = `cf_${key}`\n if (values[formKey] === undefined) values[formKey] = value\n }\n }\n return values\n}\n\nexport function TasksSection({\n entityId,\n initialTasks,\n emptyLabel,\n addActionLabel,\n emptyState,\n onActionChange,\n onLoadingChange,\n onDataRefresh,\n translator,\n entityName,\n dialogContextKey,\n dialogContextFallback,\n useCanonicalInteractions = false,\n runGuardedMutation,\n}: TasksSectionProps) {\n const tHook = useT()\n const fallbackTranslator = React.useMemo<Translator>(() => createTranslatorWithFallback(tHook), [tHook])\n const t: Translator = React.useMemo(() => translator ?? fallbackTranslator, [translator, fallbackTranslator])\n const runWriteMutation = React.useCallback(\n async <T,>(operation: () => Promise<T>, mutationPayload?: Record<string, unknown>): Promise<T> => {\n if (!runGuardedMutation) {\n return operation()\n }\n return runGuardedMutation(operation, mutationPayload)\n },\n [runGuardedMutation],\n )\n\n // Legacy path: usePersonTasks (default)\n const legacyResult = usePersonTasks({ entityId, initialTasks })\n\n // Canonical path: useInteractions with planned-status filter\n const canonicalResult = useInteractions({\n entityId: useCanonicalInteractions ? entityId : null,\n typeFilter: 'task',\n })\n\n // Map canonical interactions to the TodoLinkSummary shape used by the rendering below\n const canonicalTasks = React.useMemo<TodoLinkSummary[]>(\n () => (useCanonicalInteractions ? canonicalResult.interactions.map(mapInteractionRecordToTodoSummary) : []),\n [useCanonicalInteractions, canonicalResult.interactions],\n )\n\n const canonicalCreateTask = React.useCallback(\n async (payload: TaskFormPayload) => {\n if (!entityId) throw new Error('Task creation requires an entity id')\n const interactionPayload: InteractionCreatePayload = {\n entityId,\n interactionType: 'task',\n title: payload.base.title,\n status: payload.base.is_done ? 'done' : 'planned',\n priority: payload.base.priority ?? null,\n body: payload.base.description ?? null,\n scheduledAt: payload.base.scheduledAt ?? null,\n customValues: payload.custom,\n }\n await canonicalResult.createInteraction(interactionPayload)\n },\n [canonicalResult, entityId],\n )\n\n const canonicalUpdateTask = React.useCallback(\n async (task: TodoLinkSummary, payload: TaskFormPayload) => {\n await canonicalResult.updateInteraction(task.todoId, {\n title: payload.base.title,\n status: payload.base.is_done ? 'done' : 'planned',\n priority: payload.base.priority ?? null,\n body: payload.base.description ?? null,\n scheduledAt: payload.base.scheduledAt ?? null,\n customValues: payload.custom,\n })\n },\n [canonicalResult],\n )\n\n const canonicalToggleTask = React.useCallback(\n async (task: TodoLinkSummary, nextIsDone: boolean) => {\n if (nextIsDone) {\n await canonicalResult.completeInteraction(task.todoId)\n } else {\n // Reopen: set status back to planned via update\n await canonicalResult.updateInteraction(task.todoId, { status: 'planned' })\n }\n },\n [canonicalResult],\n )\n\n const canonicalUnlinkTask = React.useCallback(\n async (task: TodoLinkSummary) => {\n await canonicalResult.deleteInteraction(task.todoId)\n },\n [canonicalResult],\n )\n\n // Unified interface: pick the active data source based on the flag\n const tasks = useCanonicalInteractions ? canonicalTasks : legacyResult.tasks\n const isInitialLoading = useCanonicalInteractions ? canonicalResult.isInitialLoading : legacyResult.isInitialLoading\n const isLoadingMore = useCanonicalInteractions ? canonicalResult.isLoadingMore : legacyResult.isLoadingMore\n const isMutating = useCanonicalInteractions ? canonicalResult.isMutating : legacyResult.isMutating\n const hasMore = useCanonicalInteractions ? canonicalResult.hasMore : legacyResult.hasMore\n const loadMore = useCanonicalInteractions ? canonicalResult.loadMore : legacyResult.loadMore\n const refresh = useCanonicalInteractions ? canonicalResult.refresh : legacyResult.refresh\n const createTask = useCanonicalInteractions ? canonicalCreateTask : legacyResult.createTask\n const updateTask = useCanonicalInteractions ? canonicalUpdateTask : legacyResult.updateTask\n const toggleTask = useCanonicalInteractions ? canonicalToggleTask : legacyResult.toggleTask\n const unlinkTask = useCanonicalInteractions ? canonicalUnlinkTask : legacyResult.unlinkTask\n const pendingTaskId = useCanonicalInteractions ? canonicalResult.pendingId : legacyResult.pendingTaskId\n const error = useCanonicalInteractions ? canonicalResult.error : legacyResult.error\n const sortedTasks = React.useMemo(() => sortTaskSummaries(tasks), [tasks])\n\n const [dialogOpen, setDialogOpen] = React.useState(false)\n const [dialogMode, setDialogMode] = React.useState<'create' | 'edit'>('create')\n const [editingTask, setEditingTask] = React.useState<TodoLinkSummary | null>(null)\n const sentinelRef = React.useRef<HTMLDivElement | null>(null)\n\n const dialogContextMessage = React.useMemo(() => {\n if (!dialogContextKey || !entityName) return undefined\n return t(dialogContextKey, dialogContextFallback ?? 'This task will be linked to {{name}}', { name: entityName })\n }, [dialogContextFallback, dialogContextKey, entityName, t])\n\n const openCreateDialog = React.useCallback(() => {\n setEditingTask(null)\n setDialogMode('create')\n setDialogOpen(true)\n }, [])\n\n const openEditDialog = React.useCallback((task: TodoLinkSummary) => {\n setEditingTask(task)\n setDialogMode('edit')\n setDialogOpen(true)\n }, [])\n\n const closeDialog = React.useCallback(() => {\n setDialogOpen(false)\n setEditingTask(null)\n }, [])\n\n React.useEffect(() => {\n if (!onActionChange) return\n if (!entityId) {\n onActionChange(null)\n return\n }\n onActionChange({\n label: addActionLabel,\n onClick: openCreateDialog,\n disabled: isMutating,\n })\n return () => {\n onActionChange(null)\n }\n }, [addActionLabel, entityId, isMutating, onActionChange, openCreateDialog])\n\n React.useEffect(() => {\n if (!onLoadingChange) return\n onLoadingChange(isInitialLoading || isMutating)\n }, [isInitialLoading, isMutating, onLoadingChange])\n\n React.useEffect(() => {\n if (!hasMore) return\n if (typeof IntersectionObserver === 'undefined') return\n const el = sentinelRef.current\n if (!el) return\n\n const observer = new IntersectionObserver(\n (entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n loadMore().catch(() => {})\n }\n },\n { rootMargin: '200px 0px 200px 0px' },\n )\n observer.observe(el)\n return () => {\n observer.disconnect()\n }\n }, [hasMore, loadMore])\n\n const handleCreate = React.useCallback(\n async (payload: TaskFormPayload) => {\n try {\n await runWriteMutation(\n () => createTask(payload),\n {\n entityId,\n title: payload.base.title,\n isDone: payload.base.is_done ?? undefined,\n },\n )\n flash(t('customers.people.detail.tasks.createSuccess', 'Task created'), 'success')\n await Promise.resolve(onDataRefresh?.())\n } catch (err) {\n const message = err instanceof Error ? err.message : t('customers.people.detail.tasks.error', 'Failed to create task')\n flash(message, 'error')\n throw err\n }\n },\n [createTask, entityId, onDataRefresh, runWriteMutation, t],\n )\n\n const handleUpdate = React.useCallback(\n async (task: TodoLinkSummary, payload: TaskFormPayload) => {\n try {\n await runWriteMutation(\n () => updateTask(task, payload),\n {\n id: task.id,\n todoId: task.todoId,\n title: payload.base.title,\n isDone: payload.base.is_done ?? undefined,\n },\n )\n flash(t('customers.people.detail.tasks.updateSuccess', 'Task updated'), 'success')\n await Promise.resolve(onDataRefresh?.())\n } catch (err) {\n const message =\n err instanceof Error ? err.message : t('customers.people.detail.tasks.updateError', 'Failed to update task')\n flash(message, 'error')\n throw err\n }\n },\n [onDataRefresh, runWriteMutation, t, updateTask],\n )\n\n const handleToggle = React.useCallback(\n async (task: TodoLinkSummary, nextIsDone: boolean) => {\n try {\n await runWriteMutation(\n () => toggleTask(task, nextIsDone),\n {\n id: task.id,\n todoId: task.todoId,\n isDone: nextIsDone,\n },\n )\n flash(\n nextIsDone\n ? t('customers.people.detail.tasks.completeSuccess', 'Task marked as done')\n : t('customers.people.detail.tasks.reopenSuccess', 'Task reopened'),\n 'success',\n )\n await Promise.resolve(onDataRefresh?.())\n } catch (err) {\n const message =\n err instanceof Error ? err.message : t('customers.people.detail.tasks.toggleError', 'Failed to update task status')\n flash(message, 'error')\n }\n },\n [onDataRefresh, runWriteMutation, t, toggleTask],\n )\n\n const handleDelete = React.useCallback(\n async (task: TodoLinkSummary) => {\n try {\n await runWriteMutation(\n () => unlinkTask(task),\n {\n id: task.id,\n todoId: task.todoId,\n },\n )\n flash(t('customers.people.detail.tasks.deleteSuccess', 'Task removed'), 'success')\n await Promise.resolve(onDataRefresh?.())\n await refresh()\n } catch (err) {\n const message =\n err instanceof Error ? err.message : t('customers.people.detail.tasks.deleteError', 'Failed to remove task')\n flash(message, 'error')\n }\n },\n [onDataRefresh, refresh, runWriteMutation, t, unlinkTask],\n )\n\n const handleCancel = React.useCallback(\n async (task: TodoLinkSummary) => {\n if (!useCanonicalInteractions) return\n try {\n await runWriteMutation(\n () => canonicalResult.cancelInteraction(task.todoId),\n { id: task.todoId },\n )\n flash(t('customers.people.detail.tasks.cancelSuccess', 'Task canceled'), 'success')\n await Promise.resolve(onDataRefresh?.())\n } catch (err) {\n const message =\n err instanceof Error ? err.message : t('customers.people.detail.tasks.cancelError', 'Failed to cancel task')\n flash(message, 'error')\n }\n },\n [canonicalResult, onDataRefresh, runWriteMutation, t, useCanonicalInteractions],\n )\n\n const renderTaskMeta = React.useCallback(\n (task: TodoLinkSummary) => {\n const meta: string[] = []\n if (task.status === 'canceled') {\n meta.push(t('customers.people.detail.tasks.status.canceled', 'Canceled'))\n }\n if (typeof task.priority === 'number') {\n meta.push(t('customers.people.detail.tasks.priorityLabel', 'Priority {{priority}}', { priority: task.priority }))\n }\n if (task.severity) {\n meta.push(\n t(\n `customers.people.detail.tasks.severity.${task.severity}`,\n task.severity.charAt(0).toUpperCase() + task.severity.slice(1),\n ),\n )\n }\n if (task.dueAt) {\n const dueLabel =\n formatDate(task.dueAt) ??\n formatDateTime(task.dueAt) ??\n t('customers.people.detail.tasks.dueLabel', 'Due {{date}}', { date: task.dueAt })\n meta.push(t('customers.people.detail.tasks.dueLabel', 'Due {{date}}', { date: dueLabel }))\n }\n return meta\n },\n [t],\n )\n\n const handleDialogSubmit = React.useCallback(\n async (payload: TaskFormPayload) => {\n if (dialogMode === 'edit' && editingTask) {\n await handleUpdate(editingTask, payload)\n } else {\n await handleCreate(payload)\n }\n },\n [dialogMode, editingTask, handleCreate, handleUpdate],\n )\n\n const hasTasks = sortedTasks.length > 0\n\n return (\n <div className=\"mt-0 space-y-6\">\n <div className=\"space-y-4\">\n {isInitialLoading ? (\n <LoadingMessage\n label={t('customers.people.detail.tasks.loading', 'Loading tasks\u2026')}\n className=\"border-0 bg-transparent p-0 py-8 justify-center\"\n />\n ) : null}\n\n {!isInitialLoading && !hasTasks ? (\n <TabEmptyState\n title={emptyState.title}\n action={{\n label: emptyState.actionLabel,\n onClick: openCreateDialog,\n disabled: isMutating || !entityId,\n }}\n />\n ) : null}\n\n {!isInitialLoading && hasTasks ? (\n <div className=\"space-y-4\">\n {error ? (\n <div className=\"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive\">\n {error}\n </div>\n ) : null}\n {sortedTasks.map((task) => {\n const todoHref = task.externalHref ?? resolveTodoHref(task.todoSource, task.todoId)\n const createdLabel = formatDateTime(task.createdAt) ?? emptyLabel\n const meta = renderTaskMeta(task)\n const title = task.title ?? t('customers.people.detail.tasks.untitled', 'Untitled task')\n const isDone = task.isDone === true\n const isCanceled = task.status === 'canceled'\n const checkboxId = `person-task-${task.id}`\n const isPendingToggle = pendingTaskId === task.todoId\n return (\n <article key={task.id} className=\"group space-y-3 rounded-lg border bg-card p-4 transition hover:border-border/80\">\n <div className=\"flex flex-wrap items-start justify-between gap-3\">\n <TimelineItemHeader\n title={\n <span className=\"inline-flex items-center gap-2\">\n <input\n id={checkboxId}\n type=\"checkbox\"\n checked={isDone}\n onChange={(event) => {\n const next = event.target.checked\n void handleToggle(task, next)\n }}\n disabled={isMutating || isPendingToggle || isCanceled}\n className=\"h-4 w-4 rounded border\"\n />\n <span\n className={cn(\n 'text-sm font-semibold',\n isDone ? 'line-through text-muted-foreground' : undefined,\n isCanceled ? 'text-muted-foreground' : undefined,\n )}\n >\n {title}\n </span>\n </span>\n }\n timestamp={task.createdAt}\n fallbackTimestampLabel={createdLabel}\n />\n <div className=\"flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100\">\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => openEditDialog(task)}\n disabled={isMutating}\n aria-label={t('ui.actions.edit', 'Edit')}\n >\n {isMutating && editingTask?.id === task.id && dialogMode === 'edit' ? (\n <Loader2 className=\"h-4 w-4 animate-spin\" />\n ) : (\n <Pencil className=\"h-4 w-4\" />\n )}\n </IconButton>\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => handleDelete(task)}\n disabled={isMutating}\n aria-label={t('ui.actions.delete', 'Delete')}\n >\n {isMutating ? <Loader2 className=\"h-4 w-4 animate-spin text-destructive\" /> : <Trash2 className=\"h-4 w-4\" />}\n </IconButton>\n </div>\n </div>\n {meta.length ? (\n <div className=\"flex flex-wrap items-center gap-3 text-xs text-muted-foreground\">\n {meta.map((entry) => (\n <span key={`${task.id}-${entry}`} className=\"rounded bg-muted px-2 py-1 text-xs font-medium text-muted-foreground\">\n {entry}\n </span>\n ))}\n </div>\n ) : null}\n {task.description ? (\n <p className=\"text-sm text-muted-foreground whitespace-pre-wrap\">{task.description}</p>\n ) : null}\n <div className=\"flex flex-wrap items-center gap-3 text-xs\">\n {useCanonicalInteractions && !isDone && !isCanceled ? (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"h-auto px-0 text-xs font-medium text-muted-foreground hover:bg-transparent hover:text-foreground\"\n onClick={() => void handleCancel(task)}\n disabled={isMutating || isPendingToggle}\n >\n {t('customers.people.detail.tasks.cancelAction', 'Cancel task')}\n </Button>\n ) : null}\n {todoHref ? (\n <Link href={todoHref} className=\"text-primary hover:underline\">\n {t('customers.people.detail.tasks.openTask', 'Open task')}\n </Link>\n ) : null}\n </div>\n </article>\n )\n })}\n <div ref={sentinelRef} />\n {hasMore ? (\n <div className=\"flex justify-center\">\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={() => loadMore().catch(() => {})} disabled={isLoadingMore}>\n {isLoadingMore ? (\n <>\n <Loader2 className=\"mr-2 h-4 w-4 animate-spin\" />\n {t('customers.people.detail.tasks.loadingMore', 'Loading\u2026')}\n </>\n ) : (\n t('customers.people.detail.tasks.loadMore', 'Load more')\n )}\n </Button>\n </div>\n ) : null}\n {isLoadingMore ? (\n <div className=\"flex justify-center text-xs text-muted-foreground\">\n <Loader2 className=\"mr-2 h-3 w-3 animate-spin\" />\n {t('customers.people.detail.tasks.loadingMore', 'Loading\u2026')}\n </div>\n ) : null}\n </div>\n ) : null}\n <div className=\"flex justify-center\">\n <Button asChild variant=\"outline\" size=\"sm\">\n <Link href=\"/backend/customer-tasks\">\n {t('customers.people.detail.tasks.viewAll', 'View all tasks')}\n </Link>\n </Button>\n </div>\n </div>\n\n <TaskDialog\n open={dialogOpen}\n mode={dialogMode}\n onOpenChange={(next) => {\n if (!next) closeDialog()\n else setDialogOpen(true)\n }}\n initialValues={buildInitialFormValues(editingTask)}\n onSubmit={handleDialogSubmit}\n isSubmitting={isMutating}\n contextMessage={dialogContextMessage}\n />\n </div>\n )\n}\n\nexport default TasksSection\n"],
5
+ "mappings": ";AA0aU,SAkIU,UAlIV,KAsCc,YAtCd;AAxaV,YAAY,WAAW;AACvB,OAAO,UAAU;AACjB,SAAS,SAAS,QAAQ,cAAc;AACxC,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AACtB,SAAS,gBAAgB,qBAAqB;AAC9C,SAAS,UAAU;AACnB,SAAS,YAAY;AAErB,SAAS,oCAAoC;AAC7C,SAAS,YAAY,uBAAuB;AAC5C,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AACnC,SAAS,kBAAkB;AAC3B,SAAS,sBAA4C;AACrD,SAAS,uBAA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,QAAC,CAAC,GAAG,UAAU,eACpG,0BACC,iCACE;AAAA,8BAAC,WAAQ,WAAU,6BAA4B;AAAA,UAC9C,EAAE,6CAA6C,eAAU;AAAA,WAC5D,IAEA,EAAE,0CAA0C,WAAW,GAE3D,GACF,IACE;AAAA,QACH,gBACC,qBAAC,SAAI,WAAU,qDACb;AAAA,8BAAC,WAAQ,WAAU,6BAA4B;AAAA,UAC9C,EAAE,6CAA6C,eAAU;AAAA,WAC5D,IACE;AAAA,SACN,IACE;AAAA,MACJ,oBAAC,SAAI,WAAU,uBACb,8BAAC,UAAO,SAAO,MAAC,SAAQ,WAAU,MAAK,MACrC,8BAAC,QAAK,MAAK,2BACR,YAAE,yCAAyC,gBAAgB,GAC9D,GACF,GACF;AAAA,OACF;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc,CAAC,SAAS;AACtB,cAAI,CAAC,KAAM,aAAY;AAAA,cAClB,eAAc,IAAI;AAAA,QACzB;AAAA,QACA,eAAe,uBAAuB,WAAW;AAAA,QACjD,UAAU;AAAA,QACV,cAAc;AAAA,QACd,gBAAgB;AAAA;AAAA,IAClB;AAAA,KACF;AAEJ;AAEA,IAAO,uBAAQ;",
6
6
  "names": []
7
7
  }
@@ -4,7 +4,8 @@ import { apiCallOrThrow, readApiResultOrThrow } from "@open-mercato/ui/backend/u
4
4
  import { resolveTodoApiPath } from "../utils.js";
5
5
  import { generateTempId } from "@open-mercato/core/modules/customers/lib/detailHelpers";
6
6
  import { parseBooleanToken } from "@open-mercato/shared/lib/boolean";
7
- const DEFAULT_TODO_SOURCE = "example:todo";
7
+ import { CUSTOMER_INTERACTION_TASK_SOURCE } from "../../../lib/interactionCompatibility.js";
8
+ const DEFAULT_TODO_SOURCE = CUSTOMER_INTERACTION_TASK_SOURCE;
8
9
  function mapRowToSummary(row) {
9
10
  return {
10
11
  id: row.id,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/modules/customers/components/detail/hooks/usePersonTasks.ts"],
4
- "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { apiCallOrThrow, readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { resolveTodoApiPath } from '../utils'\nimport type { TodoLinkSummary } from '../types'\nimport { generateTempId } from '@open-mercato/core/modules/customers/lib/detailHelpers'\nimport { parseBooleanToken } from '@open-mercato/shared/lib/boolean'\n\nconst DEFAULT_TODO_SOURCE = 'example:todo'\n\ntype CustomerTodoRow = {\n id: string\n todoId: string\n todoSource: string\n todoTitle: string | null\n todoIsDone: boolean | null\n todoPriority: number | null\n todoSeverity: string | null\n todoDescription: string | null\n todoDueAt: string | null\n todoCustomValues: Record<string, unknown> | null\n todoOrganizationId: string | null\n organizationId: string\n tenantId: string\n createdAt: string\n}\n\ntype CustomerTodosResponse = {\n items: CustomerTodoRow[]\n total: number\n page: number\n pageSize: number\n totalPages: number\n}\n\nexport type TaskFormPayload = {\n base: {\n title: string\n is_done?: boolean\n description?: string | null\n priority?: number | null\n scheduledAt?: string | null\n }\n custom: Record<string, unknown>\n}\n\nexport type UsePersonTasksOptions = {\n entityId: string | null\n initialTasks?: TodoLinkSummary[]\n pageSize?: number\n}\n\nexport type UsePersonTasksResult = {\n tasks: TodoLinkSummary[]\n isInitialLoading: boolean\n isLoadingMore: boolean\n isMutating: boolean\n hasMore: boolean\n loadMore: () => Promise<void>\n refresh: () => Promise<void>\n createTask: (payload: TaskFormPayload) => Promise<void>\n updateTask: (task: TodoLinkSummary, payload: TaskFormPayload) => Promise<void>\n toggleTask: (task: TodoLinkSummary, nextIsDone: boolean) => Promise<void>\n unlinkTask: (task: TodoLinkSummary) => Promise<void>\n pendingTaskId: string | null\n totalCount: number\n error: string | null\n}\n\nfunction mapRowToSummary(row: CustomerTodoRow): TodoLinkSummary {\n return {\n id: row.id,\n todoId: row.todoId,\n todoSource: row.todoSource || DEFAULT_TODO_SOURCE,\n createdAt: row.createdAt,\n title: row.todoTitle ?? null,\n isDone: row.todoIsDone ?? null,\n status: row.todoIsDone ? 'done' : 'planned',\n priority: row.todoPriority ?? null,\n severity: row.todoSeverity ?? null,\n description: row.todoDescription ?? null,\n dueAt: row.todoDueAt ?? null,\n todoOrganizationId: row.todoOrganizationId ?? null,\n customValues: row.todoCustomValues ?? null,\n }\n}\n\nfunction mergeUnique(existing: TodoLinkSummary[], incoming: TodoLinkSummary[]): TodoLinkSummary[] {\n if (!existing.length) return incoming\n if (!incoming.length) return existing\n const byId = new Map<string, TodoLinkSummary>()\n const result: TodoLinkSummary[] = []\n for (const item of existing) {\n byId.set(item.id, item)\n result.push(item)\n }\n for (const item of incoming) {\n if (byId.has(item.id)) {\n const index = result.findIndex((entry) => entry.id === item.id)\n if (index !== -1) result[index] = item\n } else {\n byId.set(item.id, item)\n result.push(item)\n }\n }\n return result\n}\n\nfunction normalizeBoolean(value: unknown): boolean | undefined {\n if (value === null || value === undefined) return undefined\n if (typeof value === 'boolean') return value\n if (typeof value === 'string') {\n const parsed = parseBooleanToken(value)\n return parsed === null ? undefined : parsed\n }\n return undefined\n}\n\nfunction normalizeNumber(value: unknown): number | null | undefined {\n if (value === null || value === undefined || value === '') return undefined\n if (typeof value === 'number' && Number.isFinite(value)) return value\n if (typeof value === 'string') {\n const trimmed = value.trim()\n if (!trimmed.length) return undefined\n const parsed = Number(trimmed)\n if (!Number.isNaN(parsed)) return parsed\n }\n return null\n}\n\nfunction normalizeString(value: unknown): string | null | undefined {\n if (value === null || value === undefined) return undefined\n if (typeof value === 'string') {\n const trimmed = value.trim()\n return trimmed.length ? trimmed : null\n }\n return String(value)\n}\n\nfunction buildLegacyTaskCustomValues(\n payload: TaskFormPayload,\n options?: { includeEmptyFields?: boolean },\n): Record<string, unknown> {\n const includeEmptyFields = options?.includeEmptyFields === true\n const custom = { ...payload.custom }\n\n const assignValue = (key: string, value: unknown) => {\n if (value === undefined) return\n if (value === null) {\n if (includeEmptyFields) custom[key] = null\n return\n }\n custom[key] = value\n }\n\n assignValue('priority', payload.base.priority ?? null)\n assignValue('description', payload.base.description ?? null)\n assignValue('due_at', payload.base.scheduledAt ?? null)\n\n return custom\n}\n\nexport function usePersonTasks({\n entityId,\n initialTasks = [],\n pageSize = 20,\n}: UsePersonTasksOptions): UsePersonTasksResult {\n const [tasks, setTasks] = React.useState<TodoLinkSummary[]>(initialTasks)\n const [pageInfo, setPageInfo] = React.useState<{ page: number; totalPages: number; total: number }>({\n page: 1,\n totalPages: 1,\n total: initialTasks.length,\n })\n const [isInitialLoading, setIsInitialLoading] = React.useState<boolean>(() => Boolean(entityId))\n const [isLoadingMore, setIsLoadingMore] = React.useState(false)\n const [isMutating, setIsMutating] = React.useState(false)\n const [pendingTaskId, setPendingTaskId] = React.useState<string | null>(null)\n const [error, setError] = React.useState<string | null>(null)\n\n const mapResponse = React.useCallback((payload: CustomerTodosResponse) => {\n const mapped = Array.isArray(payload.items) ? payload.items.map(mapRowToSummary) : []\n setPageInfo({\n page: payload.page ?? 1,\n totalPages: payload.totalPages ?? 0,\n total: payload.total ?? mapped.length,\n })\n setError(null)\n return mapped\n }, [])\n\n const fetchPage = React.useCallback(\n async (page: number): Promise<CustomerTodosResponse> => {\n if (!entityId) {\n return {\n items: [],\n total: 0,\n page: 1,\n pageSize,\n totalPages: 1,\n }\n }\n const params = new URLSearchParams({\n page: String(page),\n pageSize: String(pageSize),\n entityId,\n })\n return readApiResultOrThrow<CustomerTodosResponse>(\n `/api/customers/todos?${params.toString()}`,\n undefined,\n { errorMessage: 'Failed to load tasks.' },\n )\n },\n [entityId, pageSize],\n )\n\n const refresh = React.useCallback(async () => {\n if (!entityId) {\n setTasks([])\n setPageInfo({ page: 1, totalPages: 1, total: 0 })\n return\n }\n setIsInitialLoading(true)\n try {\n const payload = await fetchPage(1)\n const mapped = mapResponse(payload)\n setTasks(mapped)\n } catch (err) {\n const message = err instanceof Error ? err.message : 'Failed to load tasks.'\n setError(message)\n throw err\n } finally {\n setIsInitialLoading(false)\n }\n }, [entityId, fetchPage, mapResponse])\n\n const loadMore = React.useCallback(async () => {\n if (!entityId) return\n if (isLoadingMore) return\n if (pageInfo.page >= pageInfo.totalPages) return\n setIsLoadingMore(true)\n try {\n const payload = await fetchPage(pageInfo.page + 1)\n const mapped = mapResponse(payload)\n setTasks((prev) => mergeUnique(prev, mapped))\n } catch (err) {\n const message = err instanceof Error ? err.message : 'Failed to load tasks.'\n setError(message)\n throw err\n } finally {\n setIsLoadingMore(false)\n }\n }, [entityId, fetchPage, isLoadingMore, mapResponse, pageInfo.page, pageInfo.totalPages])\n\n React.useEffect(() => {\n if (!entityId) {\n setTasks([])\n setPageInfo({ page: 1, totalPages: 1, total: 0 })\n setError(null)\n setIsInitialLoading(false)\n return\n }\n setTasks(initialTasks)\n setPageInfo({\n page: 1,\n totalPages: 1,\n total: initialTasks.length,\n })\n setError(null)\n let cancelled = false\n setIsInitialLoading(true)\n fetchPage(1)\n .then((payload) => {\n if (cancelled) return\n const mapped = mapResponse(payload)\n setTasks(mapped)\n })\n .catch((err) => {\n if (cancelled) return\n const message = err instanceof Error ? err.message : 'Failed to load tasks.'\n setError(message)\n })\n .finally(() => {\n if (!cancelled) setIsInitialLoading(false)\n })\n return () => {\n cancelled = true\n }\n }, [entityId, initialTasks, fetchPage, mapResponse])\n\n const createTask = React.useCallback(\n async ({ base, custom }: TaskFormPayload) => {\n if (!entityId) throw new Error('Task creation requires an entity id')\n setIsMutating(true)\n try {\n const customValues = buildLegacyTaskCustomValues({ base, custom })\n const payload: Record<string, unknown> = {\n entityId,\n title: base.title,\n }\n const normalizedDone = normalizeBoolean(base.is_done)\n if (normalizedDone !== undefined) payload.isDone = normalizedDone\n if (Object.keys(customValues).length) payload.todoCustom = customValues\n\n const response = await apiCallOrThrow<{ linkId?: string; todoId?: string }>(\n '/api/customers/todos',\n {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(payload),\n },\n { errorMessage: 'Failed to create task.' },\n )\n const body = response.result ?? {}\n const linkId = typeof body.linkId === 'string' && body.linkId.length ? body.linkId : generateTempId()\n const todoId = typeof body.todoId === 'string' && body.todoId.length ? body.todoId : generateTempId()\n const createdAt = new Date().toISOString()\n const persistedCustomValues = Object.keys(customValues).length ? { ...customValues } : null\n const priority = normalizeNumber(base.priority ?? customValues.priority)\n const severity = normalizeString(customValues.severity) ?? null\n const description = normalizeString(base.description ?? customValues.description) ?? null\n const newTask: TodoLinkSummary = {\n id: linkId,\n todoId,\n todoSource: DEFAULT_TODO_SOURCE,\n createdAt,\n title: base.title,\n isDone: normalizedDone ?? false,\n status: normalizedDone ? 'done' : 'planned',\n priority: priority === undefined ? null : priority,\n severity,\n description,\n dueAt: normalizeString(base.scheduledAt ?? customValues.due_at) ?? normalizeString(customValues.dueAt) ?? null,\n todoOrganizationId: null,\n customValues: persistedCustomValues,\n }\n setTasks((prev) => [newTask, ...prev])\n setPageInfo((prev) => ({\n page: 1,\n totalPages: prev.totalPages,\n total: prev.total + 1,\n }))\n await refresh()\n } finally {\n setIsMutating(false)\n }\n },\n [entityId, refresh],\n )\n\n const updateTask = React.useCallback(\n async (task: TodoLinkSummary, { base, custom }: TaskFormPayload) => {\n if (!task.todoId) throw new Error('Task is missing todo id')\n const apiPath = resolveTodoApiPath(task.todoSource || DEFAULT_TODO_SOURCE)\n if (!apiPath) throw new Error('Unsupported task source')\n setIsMutating(true)\n try {\n const customValues = buildLegacyTaskCustomValues({ base, custom }, { includeEmptyFields: true })\n const body: Record<string, unknown> = {\n id: task.todoId,\n linkId: task.id,\n }\n if (typeof base.title === 'string' && base.title.trim().length) {\n body.title = base.title.trim()\n }\n const normalizedDone = normalizeBoolean(base.is_done)\n if (normalizedDone !== undefined) body.is_done = normalizedDone\n if (Object.keys(customValues).length) {\n body.customFields = customValues\n }\n await apiCallOrThrow(\n apiPath,\n {\n method: 'PUT',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(body),\n },\n { errorMessage: 'Failed to update task.' },\n )\n setTasks((prev) =>\n prev.map((item) => {\n if (item.id !== task.id) return item\n const nextCustomValues = { ...(item.customValues ?? {}) }\n for (const [key, value] of Object.entries(customValues)) {\n nextCustomValues[key] = value === undefined ? null : value\n }\n return {\n ...item,\n title: typeof base.title === 'string' && base.title.trim().length ? base.title.trim() : item.title,\n isDone: normalizedDone !== undefined ? normalizedDone : item.isDone,\n status: normalizedDone !== undefined ? (normalizedDone ? 'done' : 'planned') : item.status ?? null,\n priority:\n normalizeNumber(base.priority ?? customValues.priority) ??\n (base.priority === undefined && customValues.priority === undefined ? item.priority ?? null : null),\n severity:\n normalizeString(customValues.severity) ??\n (customValues.severity === undefined ? item.severity ?? null : null),\n description:\n normalizeString(base.description ?? customValues.description) ??\n (base.description === undefined && customValues.description === undefined ? item.description ?? null : null),\n dueAt:\n normalizeString(base.scheduledAt ?? customValues.due_at) ??\n normalizeString(customValues.dueAt) ??\n (base.scheduledAt === undefined && customValues.due_at === undefined && customValues.dueAt === undefined\n ? item.dueAt ?? null\n : null),\n customValues: Object.keys(nextCustomValues).length ? nextCustomValues : null,\n }\n }),\n )\n } finally {\n setIsMutating(false)\n }\n },\n [],\n )\n\n const toggleTask = React.useCallback(\n async (task: TodoLinkSummary, nextIsDone: boolean) => {\n if (!task.todoId) {\n throw new Error('Task is missing todo id')\n }\n const apiPath = resolveTodoApiPath(task.todoSource || DEFAULT_TODO_SOURCE)\n if (!apiPath) {\n throw new Error('Unsupported task source')\n }\n setPendingTaskId(task.todoId)\n try {\n await updateTask(task, { base: { title: task.title ?? '', is_done: nextIsDone }, custom: {} })\n } finally {\n setPendingTaskId(null)\n }\n },\n [updateTask],\n )\n\n const unlinkTask = React.useCallback(\n async (task: TodoLinkSummary) => {\n if (!task.id) throw new Error('Task link id missing')\n setIsMutating(true)\n try {\n await apiCallOrThrow(\n '/api/customers/todos',\n {\n method: 'DELETE',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ id: task.id }),\n },\n { errorMessage: 'Failed to remove task.' },\n )\n setTasks((prev) => prev.filter((item) => item.id !== task.id))\n setPageInfo((prev) => ({\n page: prev.page,\n totalPages: prev.totalPages,\n total: Math.max(0, prev.total - 1),\n }))\n } finally {\n setIsMutating(false)\n }\n },\n [],\n )\n\n const hasMore = entityId != null && pageInfo.page < pageInfo.totalPages\n\n return {\n tasks,\n isInitialLoading,\n isLoadingMore,\n isMutating,\n hasMore,\n loadMore,\n refresh,\n createTask,\n updateTask,\n toggleTask,\n unlinkTask,\n pendingTaskId,\n totalCount: pageInfo.total,\n error,\n }\n}\n"],
5
- "mappings": ";AAEA,YAAY,WAAW;AACvB,SAAS,gBAAgB,4BAA4B;AACrD,SAAS,0BAA0B;AAEnC,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAElC,MAAM,sBAAsB;AA6D5B,SAAS,gBAAgB,KAAuC;AAC9D,SAAO;AAAA,IACL,IAAI,IAAI;AAAA,IACR,QAAQ,IAAI;AAAA,IACZ,YAAY,IAAI,cAAc;AAAA,IAC9B,WAAW,IAAI;AAAA,IACf,OAAO,IAAI,aAAa;AAAA,IACxB,QAAQ,IAAI,cAAc;AAAA,IAC1B,QAAQ,IAAI,aAAa,SAAS;AAAA,IAClC,UAAU,IAAI,gBAAgB;AAAA,IAC9B,UAAU,IAAI,gBAAgB;AAAA,IAC9B,aAAa,IAAI,mBAAmB;AAAA,IACpC,OAAO,IAAI,aAAa;AAAA,IACxB,oBAAoB,IAAI,sBAAsB;AAAA,IAC9C,cAAc,IAAI,oBAAoB;AAAA,EACxC;AACF;AAEA,SAAS,YAAY,UAA6B,UAAgD;AAChG,MAAI,CAAC,SAAS,OAAQ,QAAO;AAC7B,MAAI,CAAC,SAAS,OAAQ,QAAO;AAC7B,QAAM,OAAO,oBAAI,IAA6B;AAC9C,QAAM,SAA4B,CAAC;AACnC,aAAW,QAAQ,UAAU;AAC3B,SAAK,IAAI,KAAK,IAAI,IAAI;AACtB,WAAO,KAAK,IAAI;AAAA,EAClB;AACA,aAAW,Q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AC5B,UAAI;AACF,cAAM,WAAW,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,SAAS,IAAI,SAAS,WAAW,GAAG,QAAQ,CAAC,EAAE,CAAC;AAAA,MAC/F,UAAE;AACA,yBAAiB,IAAI;AAAA,MACvB;AAAA,IACF;AAAA,IACA,CAAC,UAAU;AAAA,EACb;AAEA,QAAM,aAAa,MAAM;AAAA,IACvB,OAAO,SAA0B;AAC/B,UAAI,CAAC,KAAK,GAAI,OAAM,IAAI,MAAM,sBAAsB;AACpD,oBAAc,IAAI;AACpB,UAAI;AACF,cAAM;AAAA,UACJ;AAAA,UACA;AAAA,YACE,QAAQ;AAAA,YACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,YAC9C,MAAM,KAAK,UAAU,EAAE,IAAI,KAAK,GAAG,CAAC;AAAA,UACtC;AAAA,UACA,EAAE,cAAc,yBAAyB;AAAA,QAC3C;AACE,iBAAS,CAAC,SAAS,KAAK,OAAO,CAAC,SAAS,KAAK,OAAO,KAAK,EAAE,CAAC;AAC7D,oBAAY,CAAC,UAAU;AAAA,UACrB,MAAM,KAAK;AAAA,UACX,YAAY,KAAK;AAAA,UACjB,OAAO,KAAK,IAAI,GAAG,KAAK,QAAQ,CAAC;AAAA,QACnC,EAAE;AAAA,MACJ,UAAE;AACA,sBAAc,KAAK;AAAA,MACrB;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AAEA,QAAM,UAAU,YAAY,QAAQ,SAAS,OAAO,SAAS;AAE7D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY,SAAS;AAAA,IACrB;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { apiCallOrThrow, readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { resolveTodoApiPath } from '../utils'\nimport type { TodoLinkSummary } from '../types'\nimport { generateTempId } from '@open-mercato/core/modules/customers/lib/detailHelpers'\nimport { parseBooleanToken } from '@open-mercato/shared/lib/boolean'\nimport { CUSTOMER_INTERACTION_TASK_SOURCE } from '../../../lib/interactionCompatibility'\n\nconst DEFAULT_TODO_SOURCE = CUSTOMER_INTERACTION_TASK_SOURCE\n\ntype CustomerTodoRow = {\n id: string\n todoId: string\n todoSource: string\n todoTitle: string | null\n todoIsDone: boolean | null\n todoPriority: number | null\n todoSeverity: string | null\n todoDescription: string | null\n todoDueAt: string | null\n todoCustomValues: Record<string, unknown> | null\n todoOrganizationId: string | null\n organizationId: string\n tenantId: string\n createdAt: string\n}\n\ntype CustomerTodosResponse = {\n items: CustomerTodoRow[]\n total: number\n page: number\n pageSize: number\n totalPages: number\n}\n\nexport type TaskFormPayload = {\n base: {\n title: string\n is_done?: boolean\n description?: string | null\n priority?: number | null\n scheduledAt?: string | null\n }\n custom: Record<string, unknown>\n}\n\nexport type UsePersonTasksOptions = {\n entityId: string | null\n initialTasks?: TodoLinkSummary[]\n pageSize?: number\n}\n\nexport type UsePersonTasksResult = {\n tasks: TodoLinkSummary[]\n isInitialLoading: boolean\n isLoadingMore: boolean\n isMutating: boolean\n hasMore: boolean\n loadMore: () => Promise<void>\n refresh: () => Promise<void>\n createTask: (payload: TaskFormPayload) => Promise<void>\n updateTask: (task: TodoLinkSummary, payload: TaskFormPayload) => Promise<void>\n toggleTask: (task: TodoLinkSummary, nextIsDone: boolean) => Promise<void>\n unlinkTask: (task: TodoLinkSummary) => Promise<void>\n pendingTaskId: string | null\n totalCount: number\n error: string | null\n}\n\nfunction mapRowToSummary(row: CustomerTodoRow): TodoLinkSummary {\n return {\n id: row.id,\n todoId: row.todoId,\n todoSource: row.todoSource || DEFAULT_TODO_SOURCE,\n createdAt: row.createdAt,\n title: row.todoTitle ?? null,\n isDone: row.todoIsDone ?? null,\n status: row.todoIsDone ? 'done' : 'planned',\n priority: row.todoPriority ?? null,\n severity: row.todoSeverity ?? null,\n description: row.todoDescription ?? null,\n dueAt: row.todoDueAt ?? null,\n todoOrganizationId: row.todoOrganizationId ?? null,\n customValues: row.todoCustomValues ?? null,\n }\n}\n\nfunction mergeUnique(existing: TodoLinkSummary[], incoming: TodoLinkSummary[]): TodoLinkSummary[] {\n if (!existing.length) return incoming\n if (!incoming.length) return existing\n const byId = new Map<string, TodoLinkSummary>()\n const result: TodoLinkSummary[] = []\n for (const item of existing) {\n byId.set(item.id, item)\n result.push(item)\n }\n for (const item of incoming) {\n if (byId.has(item.id)) {\n const index = result.findIndex((entry) => entry.id === item.id)\n if (index !== -1) result[index] = item\n } else {\n byId.set(item.id, item)\n result.push(item)\n }\n }\n return result\n}\n\nfunction normalizeBoolean(value: unknown): boolean | undefined {\n if (value === null || value === undefined) return undefined\n if (typeof value === 'boolean') return value\n if (typeof value === 'string') {\n const parsed = parseBooleanToken(value)\n return parsed === null ? undefined : parsed\n }\n return undefined\n}\n\nfunction normalizeNumber(value: unknown): number | null | undefined {\n if (value === null || value === undefined || value === '') return undefined\n if (typeof value === 'number' && Number.isFinite(value)) return value\n if (typeof value === 'string') {\n const trimmed = value.trim()\n if (!trimmed.length) return undefined\n const parsed = Number(trimmed)\n if (!Number.isNaN(parsed)) return parsed\n }\n return null\n}\n\nfunction normalizeString(value: unknown): string | null | undefined {\n if (value === null || value === undefined) return undefined\n if (typeof value === 'string') {\n const trimmed = value.trim()\n return trimmed.length ? trimmed : null\n }\n return String(value)\n}\n\nfunction buildLegacyTaskCustomValues(\n payload: TaskFormPayload,\n options?: { includeEmptyFields?: boolean },\n): Record<string, unknown> {\n const includeEmptyFields = options?.includeEmptyFields === true\n const custom = { ...payload.custom }\n\n const assignValue = (key: string, value: unknown) => {\n if (value === undefined) return\n if (value === null) {\n if (includeEmptyFields) custom[key] = null\n return\n }\n custom[key] = value\n }\n\n assignValue('priority', payload.base.priority ?? null)\n assignValue('description', payload.base.description ?? null)\n assignValue('due_at', payload.base.scheduledAt ?? null)\n\n return custom\n}\n\nexport function usePersonTasks({\n entityId,\n initialTasks = [],\n pageSize = 20,\n}: UsePersonTasksOptions): UsePersonTasksResult {\n const [tasks, setTasks] = React.useState<TodoLinkSummary[]>(initialTasks)\n const [pageInfo, setPageInfo] = React.useState<{ page: number; totalPages: number; total: number }>({\n page: 1,\n totalPages: 1,\n total: initialTasks.length,\n })\n const [isInitialLoading, setIsInitialLoading] = React.useState<boolean>(() => Boolean(entityId))\n const [isLoadingMore, setIsLoadingMore] = React.useState(false)\n const [isMutating, setIsMutating] = React.useState(false)\n const [pendingTaskId, setPendingTaskId] = React.useState<string | null>(null)\n const [error, setError] = React.useState<string | null>(null)\n\n const mapResponse = React.useCallback((payload: CustomerTodosResponse) => {\n const mapped = Array.isArray(payload.items) ? payload.items.map(mapRowToSummary) : []\n setPageInfo({\n page: payload.page ?? 1,\n totalPages: payload.totalPages ?? 0,\n total: payload.total ?? mapped.length,\n })\n setError(null)\n return mapped\n }, [])\n\n const fetchPage = React.useCallback(\n async (page: number): Promise<CustomerTodosResponse> => {\n if (!entityId) {\n return {\n items: [],\n total: 0,\n page: 1,\n pageSize,\n totalPages: 1,\n }\n }\n const params = new URLSearchParams({\n page: String(page),\n pageSize: String(pageSize),\n entityId,\n })\n return readApiResultOrThrow<CustomerTodosResponse>(\n `/api/customers/todos?${params.toString()}`,\n undefined,\n { errorMessage: 'Failed to load tasks.' },\n )\n },\n [entityId, pageSize],\n )\n\n const refresh = React.useCallback(async () => {\n if (!entityId) {\n setTasks([])\n setPageInfo({ page: 1, totalPages: 1, total: 0 })\n return\n }\n setIsInitialLoading(true)\n try {\n const payload = await fetchPage(1)\n const mapped = mapResponse(payload)\n setTasks(mapped)\n } catch (err) {\n const message = err instanceof Error ? err.message : 'Failed to load tasks.'\n setError(message)\n throw err\n } finally {\n setIsInitialLoading(false)\n }\n }, [entityId, fetchPage, mapResponse])\n\n const loadMore = React.useCallback(async () => {\n if (!entityId) return\n if (isLoadingMore) return\n if (pageInfo.page >= pageInfo.totalPages) return\n setIsLoadingMore(true)\n try {\n const payload = await fetchPage(pageInfo.page + 1)\n const mapped = mapResponse(payload)\n setTasks((prev) => mergeUnique(prev, mapped))\n } catch (err) {\n const message = err instanceof Error ? err.message : 'Failed to load tasks.'\n setError(message)\n throw err\n } finally {\n setIsLoadingMore(false)\n }\n }, [entityId, fetchPage, isLoadingMore, mapResponse, pageInfo.page, pageInfo.totalPages])\n\n React.useEffect(() => {\n if (!entityId) {\n setTasks([])\n setPageInfo({ page: 1, totalPages: 1, total: 0 })\n setError(null)\n setIsInitialLoading(false)\n return\n }\n setTasks(initialTasks)\n setPageInfo({\n page: 1,\n totalPages: 1,\n total: initialTasks.length,\n })\n setError(null)\n let cancelled = false\n setIsInitialLoading(true)\n fetchPage(1)\n .then((payload) => {\n if (cancelled) return\n const mapped = mapResponse(payload)\n setTasks(mapped)\n })\n .catch((err) => {\n if (cancelled) return\n const message = err instanceof Error ? err.message : 'Failed to load tasks.'\n setError(message)\n })\n .finally(() => {\n if (!cancelled) setIsInitialLoading(false)\n })\n return () => {\n cancelled = true\n }\n }, [entityId, initialTasks, fetchPage, mapResponse])\n\n const createTask = React.useCallback(\n async ({ base, custom }: TaskFormPayload) => {\n if (!entityId) throw new Error('Task creation requires an entity id')\n setIsMutating(true)\n try {\n const customValues = buildLegacyTaskCustomValues({ base, custom })\n const payload: Record<string, unknown> = {\n entityId,\n title: base.title,\n }\n const normalizedDone = normalizeBoolean(base.is_done)\n if (normalizedDone !== undefined) payload.isDone = normalizedDone\n if (Object.keys(customValues).length) payload.todoCustom = customValues\n\n const response = await apiCallOrThrow<{ linkId?: string; todoId?: string }>(\n '/api/customers/todos',\n {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(payload),\n },\n { errorMessage: 'Failed to create task.' },\n )\n const body = response.result ?? {}\n const linkId = typeof body.linkId === 'string' && body.linkId.length ? body.linkId : generateTempId()\n const todoId = typeof body.todoId === 'string' && body.todoId.length ? body.todoId : generateTempId()\n const createdAt = new Date().toISOString()\n const persistedCustomValues = Object.keys(customValues).length ? { ...customValues } : null\n const priority = normalizeNumber(base.priority ?? customValues.priority)\n const severity = normalizeString(customValues.severity) ?? null\n const description = normalizeString(base.description ?? customValues.description) ?? null\n const newTask: TodoLinkSummary = {\n id: linkId,\n todoId,\n todoSource: DEFAULT_TODO_SOURCE,\n createdAt,\n title: base.title,\n isDone: normalizedDone ?? false,\n status: normalizedDone ? 'done' : 'planned',\n priority: priority === undefined ? null : priority,\n severity,\n description,\n dueAt: normalizeString(base.scheduledAt ?? customValues.due_at) ?? normalizeString(customValues.dueAt) ?? null,\n todoOrganizationId: null,\n customValues: persistedCustomValues,\n }\n setTasks((prev) => [newTask, ...prev])\n setPageInfo((prev) => ({\n page: 1,\n totalPages: prev.totalPages,\n total: prev.total + 1,\n }))\n await refresh()\n } finally {\n setIsMutating(false)\n }\n },\n [entityId, refresh],\n )\n\n const updateTask = React.useCallback(\n async (task: TodoLinkSummary, { base, custom }: TaskFormPayload) => {\n if (!task.todoId) throw new Error('Task is missing todo id')\n const apiPath = resolveTodoApiPath(task.todoSource || DEFAULT_TODO_SOURCE)\n if (!apiPath) throw new Error('Unsupported task source')\n setIsMutating(true)\n try {\n const customValues = buildLegacyTaskCustomValues({ base, custom }, { includeEmptyFields: true })\n const body: Record<string, unknown> = {\n id: task.todoId,\n linkId: task.id,\n }\n if (typeof base.title === 'string' && base.title.trim().length) {\n body.title = base.title.trim()\n }\n const normalizedDone = normalizeBoolean(base.is_done)\n if (normalizedDone !== undefined) body.is_done = normalizedDone\n if (Object.keys(customValues).length) {\n body.customFields = customValues\n }\n await apiCallOrThrow(\n apiPath,\n {\n method: 'PUT',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(body),\n },\n { errorMessage: 'Failed to update task.' },\n )\n setTasks((prev) =>\n prev.map((item) => {\n if (item.id !== task.id) return item\n const nextCustomValues = { ...(item.customValues ?? {}) }\n for (const [key, value] of Object.entries(customValues)) {\n nextCustomValues[key] = value === undefined ? null : value\n }\n return {\n ...item,\n title: typeof base.title === 'string' && base.title.trim().length ? base.title.trim() : item.title,\n isDone: normalizedDone !== undefined ? normalizedDone : item.isDone,\n status: normalizedDone !== undefined ? (normalizedDone ? 'done' : 'planned') : item.status ?? null,\n priority:\n normalizeNumber(base.priority ?? customValues.priority) ??\n (base.priority === undefined && customValues.priority === undefined ? item.priority ?? null : null),\n severity:\n normalizeString(customValues.severity) ??\n (customValues.severity === undefined ? item.severity ?? null : null),\n description:\n normalizeString(base.description ?? customValues.description) ??\n (base.description === undefined && customValues.description === undefined ? item.description ?? null : null),\n dueAt:\n normalizeString(base.scheduledAt ?? customValues.due_at) ??\n normalizeString(customValues.dueAt) ??\n (base.scheduledAt === undefined && customValues.due_at === undefined && customValues.dueAt === undefined\n ? item.dueAt ?? null\n : null),\n customValues: Object.keys(nextCustomValues).length ? nextCustomValues : null,\n }\n }),\n )\n } finally {\n setIsMutating(false)\n }\n },\n [],\n )\n\n const toggleTask = React.useCallback(\n async (task: TodoLinkSummary, nextIsDone: boolean) => {\n if (!task.todoId) {\n throw new Error('Task is missing todo id')\n }\n const apiPath = resolveTodoApiPath(task.todoSource || DEFAULT_TODO_SOURCE)\n if (!apiPath) {\n throw new Error('Unsupported task source')\n }\n setPendingTaskId(task.todoId)\n try {\n await updateTask(task, { base: { title: task.title ?? '', is_done: nextIsDone }, custom: {} })\n } finally {\n setPendingTaskId(null)\n }\n },\n [updateTask],\n )\n\n const unlinkTask = React.useCallback(\n async (task: TodoLinkSummary) => {\n if (!task.id) throw new Error('Task link id missing')\n setIsMutating(true)\n try {\n await apiCallOrThrow(\n '/api/customers/todos',\n {\n method: 'DELETE',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ id: task.id }),\n },\n { errorMessage: 'Failed to remove task.' },\n )\n setTasks((prev) => prev.filter((item) => item.id !== task.id))\n setPageInfo((prev) => ({\n page: prev.page,\n totalPages: prev.totalPages,\n total: Math.max(0, prev.total - 1),\n }))\n } finally {\n setIsMutating(false)\n }\n },\n [],\n )\n\n const hasMore = entityId != null && pageInfo.page < pageInfo.totalPages\n\n return {\n tasks,\n isInitialLoading,\n isLoadingMore,\n isMutating,\n hasMore,\n loadMore,\n refresh,\n createTask,\n updateTask,\n toggleTask,\n unlinkTask,\n pendingTaskId,\n totalCount: pageInfo.total,\n error,\n }\n}\n"],
5
+ "mappings": ";AAEA,YAAY,WAAW;AACvB,SAAS,gBAAgB,4BAA4B;AACrD,SAAS,0BAA0B;AAEnC,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAClC,SAAS,wCAAwC;AAEjD,MAAM,sBAAsB;AA6D5B,SAAS,gBAAgB,KAAuC;AAC9D,SAAO;AAAA,IACL,IAAI,IAAI;AAAA,IACR,QAAQ,IAAI;AAAA,IACZ,YAAY,IAAI,cAAc;AAAA,IAC9B,WAAW,IAAI;AAAA,IACf,OAAO,IAAI,aAAa;AAAA,IACxB,QAAQ,IAAI,cAAc;AAAA,IAC1B,QAAQ,IAAI,aAAa,SAAS;AAAA,IAClC,UAAU,IAAI,gBAAgB;AAAA,IAC9B,UAAU,IAAI,gBAAgB;AAAA,IAC9B,aAAa,IAAI,mBAAmB;AAAA,IACpC,OAAO,IAAI,aAAa;AAAA,IACxB,oBAAoB,IAAI,sBAAsB;AAAA,IAC9C,cAAc,IAAI,oBAAoB;AAAA,EACxC;AACF;AAEA,SAAS,YAAY,UAA6B,UAAgD;AAChG,MAAI,CAAC,SAAS,OAAQ,QAAO;AAC7B,MAAI,CAAC,SAAS,OAAQ,QAAO;AAC7B,QAAM,OAAO,oBAAI,IAA6B;AAC9C,QAAM,SAA4B,CAAC;AACnC,aAAW,QAAQ,UAAU;AAC3B,SAAK,IAAI,KAAK,IAAI,IAAI;AACtB,WAAO,KAAK,IAAI;AAAA,EAClB;AACA,aAAW,QAAQ,UAAU;AAC3B,QAAI,KAAK,IAAI,KAAK,EAAE,GAAG;AACrB,YAAM,QA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,IAAI,SAAS,WAAW,GAAG,QAAQ,CAAC,EAAE,CAAC;AAAA,MAC/F,UAAE;AACA,yBAAiB,IAAI;AAAA,MACvB;AAAA,IACF;AAAA,IACA,CAAC,UAAU;AAAA,EACb;AAEA,QAAM,aAAa,MAAM;AAAA,IACvB,OAAO,SAA0B;AAC/B,UAAI,CAAC,KAAK,GAAI,OAAM,IAAI,MAAM,sBAAsB;AACpD,oBAAc,IAAI;AACpB,UAAI;AACF,cAAM;AAAA,UACJ;AAAA,UACA;AAAA,YACE,QAAQ;AAAA,YACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,YAC9C,MAAM,KAAK,UAAU,EAAE,IAAI,KAAK,GAAG,CAAC;AAAA,UACtC;AAAA,UACA,EAAE,cAAc,yBAAyB;AAAA,QAC3C;AACE,iBAAS,CAAC,SAAS,KAAK,OAAO,CAAC,SAAS,KAAK,OAAO,KAAK,EAAE,CAAC;AAC7D,oBAAY,CAAC,UAAU;AAAA,UACrB,MAAM,KAAK;AAAA,UACX,YAAY,KAAK;AAAA,UACjB,OAAO,KAAK,IAAI,GAAG,KAAK,QAAQ,CAAC;AAAA,QACnC,EAAE;AAAA,MACJ,UAAE;AACA,sBAAc,KAAK;AAAA,MACrB;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AAEA,QAAM,UAAU,YAAY,QAAQ,SAAS,OAAO,SAAS;AAE7D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY,SAAS;AAAA,IACrB;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -31,6 +31,9 @@ function resolveTodoHref(source, todoId) {
31
31
  if (source === CUSTOMER_INTERACTION_TASK_SOURCE || source === CUSTOMER_INTERACTION_TASK_TYPE) return null;
32
32
  const [module] = source.split(":");
33
33
  if (!module) return null;
34
+ if (module === "example") {
35
+ return `/backend/todos/${encodeURIComponent(todoId)}/edit`;
36
+ }
34
37
  return `/backend/${module}/todos/${encodeURIComponent(todoId)}/edit`;
35
38
  }
36
39
  function resolveTodoApiPath(source) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/modules/customers/components/detail/utils.ts"],
4
- "sourcesContent": ["\"use client\"\n\nimport type { DictionarySelectLabels } from '@open-mercato/core/modules/dictionaries/components/DictionaryEntrySelect'\nimport type { CustomerDictionaryKind } from '../../lib/dictionaries'\nimport { CUSTOMER_INTERACTION_TASK_SOURCE, CUSTOMER_INTERACTION_TASK_TYPE } from '../../lib/interactionCompatibility'\n\n\nexport function formatDate(value?: string | null): string | null {\n if (!value) return null\n const date = new Date(value)\n if (Number.isNaN(date.getTime())) return null\n return date.toLocaleDateString()\n}\n\nexport function formatTemplate(template: string, params?: Record<string, string | number>): string {\n if (!template) return template\n if (!params) return template\n return template.replace(/\\{\\{(\\w+)\\}\\}|\\{(\\w+)\\}/g, (match, doubleKey, singleKey) => {\n const key = doubleKey ?? singleKey\n if (!key) return match\n const value = params[key]\n return value === undefined ? match : String(value)\n })\n}\n\nexport function toLocalDateTimeInput(value?: string | null): string {\n if (!value) return ''\n const date = new Date(value)\n if (Number.isNaN(date.getTime())) return ''\n const pad = (input: number) => `${input}`.padStart(2, '0')\n return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(\n date.getMinutes(),\n )}`\n}\n\nexport function resolveTodoHref(source: string, todoId: string | null | undefined): string | null {\n if (!todoId) return null\n if (!source) return null\n if (source === CUSTOMER_INTERACTION_TASK_SOURCE || source === CUSTOMER_INTERACTION_TASK_TYPE) return null\n const [module] = source.split(':')\n if (!module) return null\n return `/backend/${module}/todos/${encodeURIComponent(todoId)}/edit`\n}\n\nexport function resolveTodoApiPath(source: string): string | null {\n if (!source) return null\n if (source === CUSTOMER_INTERACTION_TASK_SOURCE || source === CUSTOMER_INTERACTION_TASK_TYPE) {\n return '/api/customers/todos'\n }\n const [module] = source.split(':')\n if (!module) return null\n return `/api/${module}/todos`\n}\n\nexport function createDictionarySelectLabels(\n kind: CustomerDictionaryKind,\n translate: (key: string, fallback: string) => string,\n): DictionarySelectLabels {\n const base = {\n valueLabel: translate('customers.people.form.dictionary.valueLabel', 'Name'),\n valuePlaceholder: translate('customers.people.form.dictionary.valuePlaceholder', 'Name'),\n labelLabel: translate('customers.people.form.dictionary.labelLabel', 'Label'),\n labelPlaceholder: translate('customers.people.form.dictionary.labelPlaceholder', 'Display name shown in UI'),\n emptyError: translate('customers.people.form.dictionary.errorRequired', 'Please enter a name'),\n cancelLabel: translate('customers.people.form.dictionary.cancel', 'Cancel'),\n saveLabel: translate('customers.people.form.dictionary.save', 'Save'),\n saveShortcutHint: translate('customers.people.form.dictionary.saveShortcut', '\u2318/Ctrl + Enter'),\n errorLoad: translate('customers.people.form.dictionary.errorLoad', 'Failed to load options'),\n errorSave: translate('customers.people.form.dictionary.error', 'Failed to save option'),\n loadingLabel: translate('customers.people.form.dictionary.loading', 'Loading\u2026'),\n manageTitle: translate('customers.people.form.dictionary.manage', 'Manage dictionary'),\n placeholder: translate('customers.people.form.dictionary.placeholder', 'Select an option'),\n addLabel: translate('customers.people.form.dictionary.add', 'Add option'),\n addPrompt: translate('customers.people.form.dictionary.prompt', 'Name your option'),\n dialogTitle: translate('customers.people.form.dictionary.dialogTitle', 'Add option'),\n } satisfies DictionarySelectLabels\n\n switch (kind) {\n case 'statuses':\n return {\n ...base,\n placeholder: translate('customers.people.form.status.placeholder', 'Select a status'),\n addLabel: translate('customers.people.form.dictionary.addStatus', 'Add status'),\n addPrompt: translate('customers.people.form.dictionary.promptStatus', 'Name the status'),\n dialogTitle: translate('customers.people.form.dictionary.dialogTitleStatus', 'Add status'),\n }\n case 'lifecycle-stages':\n return {\n ...base,\n placeholder: translate('customers.people.form.lifecycleStage.placeholder', 'Select a lifecycle stage'),\n addLabel: translate('customers.people.form.dictionary.addLifecycleStage', 'Add lifecycle stage'),\n addPrompt: translate('customers.people.form.dictionary.promptLifecycleStage', 'Name the lifecycle stage'),\n dialogTitle: translate('customers.people.form.dictionary.dialogTitleLifecycleStage', 'Add lifecycle stage'),\n }\n case 'sources':\n return {\n ...base,\n placeholder: translate('customers.people.form.source.placeholder', 'Select a source'),\n addLabel: translate('customers.people.form.dictionary.addSource', 'Add source'),\n addPrompt: translate('customers.people.form.dictionary.promptSource', 'Name the source'),\n dialogTitle: translate('customers.people.form.dictionary.dialogTitleSource', 'Add source'),\n }\n case 'activity-types':\n return {\n ...base,\n placeholder: translate('customers.people.form.activityType.placeholder', 'Select an activity type'),\n addLabel: translate('customers.people.form.dictionary.addActivityType', 'Add activity type'),\n addPrompt: translate('customers.people.form.dictionary.promptActivityType', 'Name the activity type'),\n dialogTitle: translate('customers.people.form.dictionary.dialogTitleActivityType', 'Add activity type'),\n }\n case 'deal-statuses':\n return {\n ...base,\n placeholder: translate('customers.deals.form.status.placeholder', 'Select a deal status'),\n addLabel: translate('customers.deals.form.dictionary.addStatus', 'Add deal status'),\n addPrompt: translate('customers.deals.form.dictionary.promptStatus', 'Name the deal status'),\n dialogTitle: translate('customers.deals.form.dictionary.dialogTitleStatus', 'Add deal status'),\n }\n case 'pipeline-stages':\n return {\n ...base,\n placeholder: translate('customers.deals.form.pipeline.placeholder', 'Select a pipeline stage'),\n addLabel: translate('customers.deals.form.dictionary.addPipelineStage', 'Add pipeline stage'),\n addPrompt: translate('customers.deals.form.dictionary.promptPipelineStage', 'Name the pipeline stage'),\n dialogTitle: translate('customers.deals.form.dictionary.dialogTitlePipelineStage', 'Add pipeline stage'),\n }\n case 'job-titles':\n return {\n ...base,\n placeholder: translate('customers.people.form.jobTitle.placeholder', 'Select a job title'),\n addLabel: translate('customers.people.form.dictionary.addJobTitle', 'Add job title'),\n addPrompt: translate('customers.people.form.dictionary.promptJobTitle', 'Name the job title'),\n dialogTitle: translate('customers.people.form.dictionary.dialogTitleJobTitle', 'Add job title'),\n }\n case 'address-types':\n return {\n ...base,\n placeholder: translate('customers.people.form.addressType.placeholder', 'Select an address type'),\n addLabel: translate('customers.people.form.dictionary.addAddressType', 'Add address type'),\n addPrompt: translate('customers.people.form.dictionary.promptAddressType', 'Name the address type'),\n dialogTitle: translate('customers.people.form.dictionary.dialogTitleAddressType', 'Add address type'),\n }\n default:\n return base\n }\n}\n"],
5
- "mappings": ";AAIA,SAAS,kCAAkC,sCAAsC;AAG1E,SAAS,WAAW,OAAsC;AAC/D,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,MAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,EAAG,QAAO;AACzC,SAAO,KAAK,mBAAmB;AACjC;AAEO,SAAS,eAAe,UAAkB,QAAkD;AACjG,MAAI,CAAC,SAAU,QAAO;AACtB,MAAI,CAAC,OAAQ,QAAO;AACpB,SAAO,SAAS,QAAQ,4BAA4B,CAAC,OAAO,WAAW,cAAc;AACnF,UAAM,MAAM,aAAa;AACzB,QAAI,CAAC,IAAK,QAAO;AACjB,UAAM,QAAQ,OAAO,GAAG;AACxB,WAAO,UAAU,SAAY,QAAQ,OAAO,KAAK;AAAA,EACnD,CAAC;AACH;AAEO,SAAS,qBAAqB,OAA+B;AAClE,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,MAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,EAAG,QAAO;AACzC,QAAM,MAAM,CAAC,UAAkB,GAAG,KAAK,GAAG,SAAS,GAAG,GAAG;AACzD,SAAO,GAAG,KAAK,YAAY,CAAC,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,IAAI,IAAI,KAAK,QAAQ,CAAC,CAAC,IAAI,IAAI,KAAK,SAAS,CAAC,CAAC,IAAI;AAAA,IACzG,KAAK,WAAW;AAAA,EAClB,CAAC;AACH;AAEO,SAAS,gB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5F,WAAW,UAAU,uDAAuD,yBAAyB;AAAA,QACrG,aAAa,UAAU,4DAA4D,oBAAoB;AAAA,MACzG;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,aAAa,UAAU,8CAA8C,oBAAoB;AAAA,QACzF,UAAU,UAAU,gDAAgD,eAAe;AAAA,QACnF,WAAW,UAAU,mDAAmD,oBAAoB;AAAA,QAC5F,aAAa,UAAU,wDAAwD,eAAe;AAAA,MAChG;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,aAAa,UAAU,iDAAiD,wBAAwB;AAAA,QAChG,UAAU,UAAU,mDAAmD,kBAAkB;AAAA,QACzF,WAAW,UAAU,sDAAsD,uBAAuB;AAAA,QAClG,aAAa,UAAU,2DAA2D,kBAAkB;AAAA,MACtG;AAAA,IACF;AACE,aAAO;AAAA,EACX;AACF;",
4
+ "sourcesContent": ["\"use client\"\n\nimport type { DictionarySelectLabels } from '@open-mercato/core/modules/dictionaries/components/DictionaryEntrySelect'\nimport type { CustomerDictionaryKind } from '../../lib/dictionaries'\nimport { CUSTOMER_INTERACTION_TASK_SOURCE, CUSTOMER_INTERACTION_TASK_TYPE } from '../../lib/interactionCompatibility'\n\n\nexport function formatDate(value?: string | null): string | null {\n if (!value) return null\n const date = new Date(value)\n if (Number.isNaN(date.getTime())) return null\n return date.toLocaleDateString()\n}\n\nexport function formatTemplate(template: string, params?: Record<string, string | number>): string {\n if (!template) return template\n if (!params) return template\n return template.replace(/\\{\\{(\\w+)\\}\\}|\\{(\\w+)\\}/g, (match, doubleKey, singleKey) => {\n const key = doubleKey ?? singleKey\n if (!key) return match\n const value = params[key]\n return value === undefined ? match : String(value)\n })\n}\n\nexport function toLocalDateTimeInput(value?: string | null): string {\n if (!value) return ''\n const date = new Date(value)\n if (Number.isNaN(date.getTime())) return ''\n const pad = (input: number) => `${input}`.padStart(2, '0')\n return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(\n date.getMinutes(),\n )}`\n}\n\nexport function resolveTodoHref(source: string, todoId: string | null | undefined): string | null {\n if (!todoId) return null\n if (!source) return null\n if (source === CUSTOMER_INTERACTION_TASK_SOURCE || source === CUSTOMER_INTERACTION_TASK_TYPE) return null\n const [module] = source.split(':')\n if (!module) return null\n if (module === 'example') {\n return `/backend/todos/${encodeURIComponent(todoId)}/edit`\n }\n return `/backend/${module}/todos/${encodeURIComponent(todoId)}/edit`\n}\n\nexport function resolveTodoApiPath(source: string): string | null {\n if (!source) return null\n if (source === CUSTOMER_INTERACTION_TASK_SOURCE || source === CUSTOMER_INTERACTION_TASK_TYPE) {\n return '/api/customers/todos'\n }\n const [module] = source.split(':')\n if (!module) return null\n return `/api/${module}/todos`\n}\n\nexport function createDictionarySelectLabels(\n kind: CustomerDictionaryKind,\n translate: (key: string, fallback: string) => string,\n): DictionarySelectLabels {\n const base = {\n valueLabel: translate('customers.people.form.dictionary.valueLabel', 'Name'),\n valuePlaceholder: translate('customers.people.form.dictionary.valuePlaceholder', 'Name'),\n labelLabel: translate('customers.people.form.dictionary.labelLabel', 'Label'),\n labelPlaceholder: translate('customers.people.form.dictionary.labelPlaceholder', 'Display name shown in UI'),\n emptyError: translate('customers.people.form.dictionary.errorRequired', 'Please enter a name'),\n cancelLabel: translate('customers.people.form.dictionary.cancel', 'Cancel'),\n saveLabel: translate('customers.people.form.dictionary.save', 'Save'),\n saveShortcutHint: translate('customers.people.form.dictionary.saveShortcut', '\u2318/Ctrl + Enter'),\n errorLoad: translate('customers.people.form.dictionary.errorLoad', 'Failed to load options'),\n errorSave: translate('customers.people.form.dictionary.error', 'Failed to save option'),\n loadingLabel: translate('customers.people.form.dictionary.loading', 'Loading\u2026'),\n manageTitle: translate('customers.people.form.dictionary.manage', 'Manage dictionary'),\n placeholder: translate('customers.people.form.dictionary.placeholder', 'Select an option'),\n addLabel: translate('customers.people.form.dictionary.add', 'Add option'),\n addPrompt: translate('customers.people.form.dictionary.prompt', 'Name your option'),\n dialogTitle: translate('customers.people.form.dictionary.dialogTitle', 'Add option'),\n } satisfies DictionarySelectLabels\n\n switch (kind) {\n case 'statuses':\n return {\n ...base,\n placeholder: translate('customers.people.form.status.placeholder', 'Select a status'),\n addLabel: translate('customers.people.form.dictionary.addStatus', 'Add status'),\n addPrompt: translate('customers.people.form.dictionary.promptStatus', 'Name the status'),\n dialogTitle: translate('customers.people.form.dictionary.dialogTitleStatus', 'Add status'),\n }\n case 'lifecycle-stages':\n return {\n ...base,\n placeholder: translate('customers.people.form.lifecycleStage.placeholder', 'Select a lifecycle stage'),\n addLabel: translate('customers.people.form.dictionary.addLifecycleStage', 'Add lifecycle stage'),\n addPrompt: translate('customers.people.form.dictionary.promptLifecycleStage', 'Name the lifecycle stage'),\n dialogTitle: translate('customers.people.form.dictionary.dialogTitleLifecycleStage', 'Add lifecycle stage'),\n }\n case 'sources':\n return {\n ...base,\n placeholder: translate('customers.people.form.source.placeholder', 'Select a source'),\n addLabel: translate('customers.people.form.dictionary.addSource', 'Add source'),\n addPrompt: translate('customers.people.form.dictionary.promptSource', 'Name the source'),\n dialogTitle: translate('customers.people.form.dictionary.dialogTitleSource', 'Add source'),\n }\n case 'activity-types':\n return {\n ...base,\n placeholder: translate('customers.people.form.activityType.placeholder', 'Select an activity type'),\n addLabel: translate('customers.people.form.dictionary.addActivityType', 'Add activity type'),\n addPrompt: translate('customers.people.form.dictionary.promptActivityType', 'Name the activity type'),\n dialogTitle: translate('customers.people.form.dictionary.dialogTitleActivityType', 'Add activity type'),\n }\n case 'deal-statuses':\n return {\n ...base,\n placeholder: translate('customers.deals.form.status.placeholder', 'Select a deal status'),\n addLabel: translate('customers.deals.form.dictionary.addStatus', 'Add deal status'),\n addPrompt: translate('customers.deals.form.dictionary.promptStatus', 'Name the deal status'),\n dialogTitle: translate('customers.deals.form.dictionary.dialogTitleStatus', 'Add deal status'),\n }\n case 'pipeline-stages':\n return {\n ...base,\n placeholder: translate('customers.deals.form.pipeline.placeholder', 'Select a pipeline stage'),\n addLabel: translate('customers.deals.form.dictionary.addPipelineStage', 'Add pipeline stage'),\n addPrompt: translate('customers.deals.form.dictionary.promptPipelineStage', 'Name the pipeline stage'),\n dialogTitle: translate('customers.deals.form.dictionary.dialogTitlePipelineStage', 'Add pipeline stage'),\n }\n case 'job-titles':\n return {\n ...base,\n placeholder: translate('customers.people.form.jobTitle.placeholder', 'Select a job title'),\n addLabel: translate('customers.people.form.dictionary.addJobTitle', 'Add job title'),\n addPrompt: translate('customers.people.form.dictionary.promptJobTitle', 'Name the job title'),\n dialogTitle: translate('customers.people.form.dictionary.dialogTitleJobTitle', 'Add job title'),\n }\n case 'address-types':\n return {\n ...base,\n placeholder: translate('customers.people.form.addressType.placeholder', 'Select an address type'),\n addLabel: translate('customers.people.form.dictionary.addAddressType', 'Add address type'),\n addPrompt: translate('customers.people.form.dictionary.promptAddressType', 'Name the address type'),\n dialogTitle: translate('customers.people.form.dictionary.dialogTitleAddressType', 'Add address type'),\n }\n default:\n return base\n }\n}\n"],
5
+ "mappings": ";AAIA,SAAS,kCAAkC,sCAAsC;AAG1E,SAAS,WAAW,OAAsC;AAC/D,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,MAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,EAAG,QAAO;AACzC,SAAO,KAAK,mBAAmB;AACjC;AAEO,SAAS,eAAe,UAAkB,QAAkD;AACjG,MAAI,CAAC,SAAU,QAAO;AACtB,MAAI,CAAC,OAAQ,QAAO;AACpB,SAAO,SAAS,QAAQ,4BAA4B,CAAC,OAAO,WAAW,cAAc;AACnF,UAAM,MAAM,aAAa;AACzB,QAAI,CAAC,IAAK,QAAO;AACjB,UAAM,QAAQ,OAAO,GAAG;AACxB,WAAO,UAAU,SAAY,QAAQ,OAAO,KAAK;AAAA,EACnD,CAAC;AACH;AAEO,SAAS,qBAAqB,OAA+B;AAClE,MAAI,CAAC,M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AoD,mBAAmB;AAAA,QAC3F,WAAW,UAAU,uDAAuD,wBAAwB;AAAA,QACpG,aAAa,UAAU,4DAA4D,mBAAmB;AAAA,MACxG;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,aAAa,UAAU,2CAA2C,sBAAsB;AAAA,QACxF,UAAU,UAAU,6CAA6C,iBAAiB;AAAA,QAClF,WAAW,UAAU,gDAAgD,sBAAsB;AAAA,QAC3F,aAAa,UAAU,qDAAqD,iBAAiB;AAAA,MAC/F;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,aAAa,UAAU,6CAA6C,yBAAyB;AAAA,QAC7F,UAAU,UAAU,oDAAoD,oBAAoB;AAAA,QAC5F,WAAW,UAAU,uDAAuD,yBAAyB;AAAA,QACrG,aAAa,UAAU,4DAA4D,oBAAoB;AAAA,MACzG;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,aAAa,UAAU,8CAA8C,oBAAoB;AAAA,QACzF,UAAU,UAAU,gDAAgD,eAAe;AAAA,QACnF,WAAW,UAAU,mDAAmD,oBAAoB;AAAA,QAC5F,aAAa,UAAU,wDAAwD,eAAe;AAAA,MAChG;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,aAAa,UAAU,iDAAiD,wBAAwB;AAAA,QAChG,UAAU,UAAU,mDAAmD,kBAAkB;AAAA,QACzF,WAAW,UAAU,sDAAsD,uBAAuB;AAAA,QAClG,aAAa,UAAU,2DAA2D,kBAAkB;AAAA,MACtG;AAAA,IACF;AACE,aAAO;AAAA,EACX;AACF;",
6
6
  "names": []
7
7
  }
@@ -890,7 +890,7 @@ CustomerPipelineStage = __decorateClass([
890
890
  OptionalProps;
891
891
  let CustomerTodoLink = class {
892
892
  constructor() {
893
- this.todoSource = "example:todo";
893
+ this.todoSource = "customers:interaction";
894
894
  this.createdAt = /* @__PURE__ */ new Date();
895
895
  }
896
896
  };
@@ -907,7 +907,7 @@ __decorateClass([
907
907
  Property({ name: "todo_id", type: "uuid" })
908
908
  ], CustomerTodoLink.prototype, "todoId", 2);
909
909
  __decorateClass([
910
- Property({ name: "todo_source", type: "text", default: "example:todo" })
910
+ Property({ name: "todo_source", type: "text", default: "customers:interaction" })
911
911
  ], CustomerTodoLink.prototype, "todoSource", 2);
912
912
  __decorateClass([
913
913
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })