@open-mercato/core 0.4.5-develop-0f0e676c72 → 0.4.5-develop-e694581d9f

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 (113) hide show
  1. package/dist/generated/entities/customer_deal/index.js +4 -0
  2. package/dist/generated/entities/customer_deal/index.js.map +2 -2
  3. package/dist/generated/entities/customer_pipeline/index.js +17 -0
  4. package/dist/generated/entities/customer_pipeline/index.js.map +7 -0
  5. package/dist/generated/entities/customer_pipeline_stage/index.js +19 -0
  6. package/dist/generated/entities/customer_pipeline_stage/index.js.map +7 -0
  7. package/dist/generated/entities.ids.generated.js +2 -0
  8. package/dist/generated/entities.ids.generated.js.map +2 -2
  9. package/dist/generated/entity-fields-registry.js +4 -0
  10. package/dist/generated/entity-fields-registry.js.map +2 -2
  11. package/dist/modules/customers/acl.js +2 -0
  12. package/dist/modules/customers/acl.js.map +2 -2
  13. package/dist/modules/customers/api/deals/[id]/route.js +4 -0
  14. package/dist/modules/customers/api/deals/[id]/route.js.map +2 -2
  15. package/dist/modules/customers/api/deals/route.js +12 -0
  16. package/dist/modules/customers/api/deals/route.js.map +2 -2
  17. package/dist/modules/customers/api/dictionaries/[kind]/route.js +20 -1
  18. package/dist/modules/customers/api/dictionaries/[kind]/route.js.map +2 -2
  19. package/dist/modules/customers/api/pipeline-stages/reorder/route.js +69 -0
  20. package/dist/modules/customers/api/pipeline-stages/reorder/route.js.map +7 -0
  21. package/dist/modules/customers/api/pipeline-stages/route.js +275 -0
  22. package/dist/modules/customers/api/pipeline-stages/route.js.map +7 -0
  23. package/dist/modules/customers/api/pipelines/route.js +245 -0
  24. package/dist/modules/customers/api/pipelines/route.js.map +7 -0
  25. package/dist/modules/customers/backend/config/customers/page.js +2 -0
  26. package/dist/modules/customers/backend/config/customers/page.js.map +2 -2
  27. package/dist/modules/customers/backend/config/customers/pipeline-stages/page.js +439 -0
  28. package/dist/modules/customers/backend/config/customers/pipeline-stages/page.js.map +7 -0
  29. package/dist/modules/customers/backend/config/customers/pipeline-stages/page.meta.js +17 -0
  30. package/dist/modules/customers/backend/config/customers/pipeline-stages/page.meta.js.map +7 -0
  31. package/dist/modules/customers/backend/customers/deals/[id]/page.js +19 -1
  32. package/dist/modules/customers/backend/customers/deals/[id]/page.js.map +2 -2
  33. package/dist/modules/customers/backend/customers/deals/page.js +35 -1
  34. package/dist/modules/customers/backend/customers/deals/page.js.map +2 -2
  35. package/dist/modules/customers/backend/customers/deals/pipeline/page.js +102 -74
  36. package/dist/modules/customers/backend/customers/deals/pipeline/page.js.map +2 -2
  37. package/dist/modules/customers/cli.js +28 -2
  38. package/dist/modules/customers/cli.js.map +2 -2
  39. package/dist/modules/customers/commands/deals.js +34 -2
  40. package/dist/modules/customers/commands/deals.js.map +2 -2
  41. package/dist/modules/customers/commands/index.js +2 -0
  42. package/dist/modules/customers/commands/index.js.map +2 -2
  43. package/dist/modules/customers/commands/pipeline-stages.js +126 -0
  44. package/dist/modules/customers/commands/pipeline-stages.js.map +7 -0
  45. package/dist/modules/customers/commands/pipelines.js +87 -0
  46. package/dist/modules/customers/commands/pipelines.js.map +7 -0
  47. package/dist/modules/customers/components/DictionarySettings.js +0 -5
  48. package/dist/modules/customers/components/DictionarySettings.js.map +2 -2
  49. package/dist/modules/customers/components/PipelineSettings.js +474 -0
  50. package/dist/modules/customers/components/PipelineSettings.js.map +7 -0
  51. package/dist/modules/customers/components/detail/DealForm.js +84 -12
  52. package/dist/modules/customers/components/detail/DealForm.js.map +2 -2
  53. package/dist/modules/customers/data/entities.js +78 -0
  54. package/dist/modules/customers/data/entities.js.map +2 -2
  55. package/dist/modules/customers/data/validators.js +44 -0
  56. package/dist/modules/customers/data/validators.js.map +2 -2
  57. package/dist/modules/customers/migrations/Migration20260218191730.js +77 -0
  58. package/dist/modules/customers/migrations/Migration20260218191730.js.map +7 -0
  59. package/dist/modules/customers/setup.js +7 -3
  60. package/dist/modules/customers/setup.js.map +2 -2
  61. package/dist/modules/translations/api/[entityType]/[entityId]/route.js +46 -44
  62. package/dist/modules/translations/api/[entityType]/[entityId]/route.js.map +2 -2
  63. package/dist/modules/translations/api/context.js +10 -1
  64. package/dist/modules/translations/api/context.js.map +2 -2
  65. package/dist/modules/translations/commands/index.js +2 -0
  66. package/dist/modules/translations/commands/index.js.map +7 -0
  67. package/dist/modules/translations/commands/translations.js +160 -0
  68. package/dist/modules/translations/commands/translations.js.map +7 -0
  69. package/dist/modules/translations/index.js +1 -0
  70. package/dist/modules/translations/index.js.map +2 -2
  71. package/dist/modules/workflows/migrations/Migration20260222205305.js +14 -0
  72. package/dist/modules/workflows/migrations/Migration20260222205305.js.map +7 -0
  73. package/generated/entities/customer_deal/index.ts +2 -0
  74. package/generated/entities/customer_pipeline/index.ts +7 -0
  75. package/generated/entities/customer_pipeline_stage/index.ts +8 -0
  76. package/generated/entities.ids.generated.ts +2 -0
  77. package/generated/entity-fields-registry.ts +4 -0
  78. package/package.json +2 -2
  79. package/src/modules/customers/acl.ts +2 -0
  80. package/src/modules/customers/api/deals/[id]/route.ts +4 -0
  81. package/src/modules/customers/api/deals/route.ts +12 -0
  82. package/src/modules/customers/api/dictionaries/[kind]/route.ts +21 -1
  83. package/src/modules/customers/api/pipeline-stages/reorder/route.ts +71 -0
  84. package/src/modules/customers/api/pipeline-stages/route.ts +296 -0
  85. package/src/modules/customers/api/pipelines/route.ts +261 -0
  86. package/src/modules/customers/backend/config/customers/page.tsx +2 -0
  87. package/src/modules/customers/backend/config/customers/pipeline-stages/page.meta.ts +13 -0
  88. package/src/modules/customers/backend/config/customers/pipeline-stages/page.tsx +512 -0
  89. package/src/modules/customers/backend/customers/deals/[id]/page.tsx +21 -1
  90. package/src/modules/customers/backend/customers/deals/page.tsx +33 -1
  91. package/src/modules/customers/backend/customers/deals/pipeline/page.tsx +119 -79
  92. package/src/modules/customers/cli.ts +29 -1
  93. package/src/modules/customers/commands/deals.ts +44 -1
  94. package/src/modules/customers/commands/index.ts +2 -0
  95. package/src/modules/customers/commands/pipeline-stages.ts +156 -0
  96. package/src/modules/customers/commands/pipelines.ts +105 -0
  97. package/src/modules/customers/components/DictionarySettings.tsx +0 -5
  98. package/src/modules/customers/components/PipelineSettings.tsx +570 -0
  99. package/src/modules/customers/components/detail/DealForm.tsx +89 -11
  100. package/src/modules/customers/data/entities.ts +64 -0
  101. package/src/modules/customers/data/validators.ts +57 -0
  102. package/src/modules/customers/i18n/de.json +4 -0
  103. package/src/modules/customers/i18n/en.json +4 -0
  104. package/src/modules/customers/i18n/es.json +4 -0
  105. package/src/modules/customers/i18n/pl.json +5 -1
  106. package/src/modules/customers/migrations/Migration20260218191730.ts +84 -0
  107. package/src/modules/customers/setup.ts +5 -1
  108. package/src/modules/translations/api/[entityType]/[entityId]/route.ts +65 -60
  109. package/src/modules/translations/api/context.ts +12 -0
  110. package/src/modules/translations/commands/index.ts +1 -0
  111. package/src/modules/translations/commands/translations.ts +253 -0
  112. package/src/modules/translations/index.ts +1 -0
  113. package/src/modules/workflows/migrations/Migration20260222205305.ts +13 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/customers/components/PipelineSettings.tsx"],
4
+ "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Label } from '@open-mercato/ui/primitives/label'\nimport { Checkbox } from '@open-mercato/ui/primitives/checkbox'\nimport {\n Dialog,\n DialogContent,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from '@open-mercato/ui/primitives/dialog'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { apiCall, readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { raiseCrudError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { Spinner } from '@open-mercato/ui/primitives/spinner'\nimport {\n AppearanceSelector,\n type AppearanceSelectorLabels,\n} from '@open-mercato/core/modules/dictionaries/components/AppearanceSelector'\nimport {\n renderDictionaryColor,\n renderDictionaryIcon,\n} from '@open-mercato/core/modules/dictionaries/components/dictionaryAppearance'\n\ntype Pipeline = {\n id: string\n name: string\n isDefault: boolean\n organizationId: string\n tenantId: string\n}\n\ntype PipelineStage = {\n id: string\n pipelineId: string\n label: string\n order: number\n color: string | null\n icon: string | null\n}\n\ntype PipelineDialogState =\n | { mode: 'create' }\n | { mode: 'edit'; entry: Pipeline }\n\ntype StageDialogState =\n | { mode: 'create'; pipelineId: string }\n | { mode: 'edit'; entry: PipelineStage }\n\nfunction normalizePipeline(raw: Record<string, unknown>): Pipeline {\n return {\n id: typeof raw.id === 'string' ? raw.id : '',\n name: typeof raw.name === 'string' ? raw.name : '',\n isDefault: raw.isDefault === true || raw.is_default === true,\n organizationId: typeof raw.organizationId === 'string' ? raw.organizationId : (typeof raw.organization_id === 'string' ? raw.organization_id : ''),\n tenantId: typeof raw.tenantId === 'string' ? raw.tenantId : (typeof raw.tenant_id === 'string' ? raw.tenant_id : ''),\n }\n}\n\nfunction normalizeStage(raw: Record<string, unknown>): PipelineStage {\n return {\n id: typeof raw.id === 'string' ? raw.id : '',\n pipelineId: typeof raw.pipelineId === 'string' ? raw.pipelineId : (typeof raw.pipeline_id === 'string' ? raw.pipeline_id : ''),\n label: typeof raw.label === 'string' ? raw.label : '',\n order: typeof raw.order === 'number' ? raw.order : 0,\n color: typeof raw.color === 'string' && raw.color.trim().length ? raw.color.trim() : null,\n icon: typeof raw.icon === 'string' && raw.icon.trim().length ? raw.icon.trim() : null,\n }\n}\n\nexport default function PipelineSettings(): React.ReactElement {\n const t = useT()\n const scopeVersion = useOrganizationScopeVersion()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n\n const [pipelines, setPipelines] = React.useState<Pipeline[]>([])\n const [loadingPipelines, setLoadingPipelines] = React.useState(false)\n const [pipelineDialog, setPipelineDialog] = React.useState<PipelineDialogState | null>(null)\n const [pipelineForm, setPipelineForm] = React.useState({ name: '', isDefault: false })\n const [submittingPipeline, setSubmittingPipeline] = React.useState(false)\n\n const [expandedPipelineId, setExpandedPipelineId] = React.useState<string | null>(null)\n const [stages, setStages] = React.useState<Record<string, PipelineStage[]>>({})\n const [loadingStages, setLoadingStages] = React.useState<Record<string, boolean>>({})\n const [stageDialog, setStageDialog] = React.useState<StageDialogState | null>(null)\n const [stageForm, setStageForm] = React.useState({ label: '', color: null as string | null, icon: null as string | null })\n const [submittingStage, setSubmittingStage] = React.useState(false)\n\n const loadPipelines = React.useCallback(async () => {\n setLoadingPipelines(true)\n try {\n const data = await readApiResultOrThrow<{ items?: unknown[] }>(\n '/api/customers/pipelines',\n undefined,\n { errorMessage: t('customers.pipelines.errors.loadFailed', 'Failed to load pipelines'), fallback: { items: [] } },\n )\n const items = Array.isArray(data?.items) ? data.items : []\n setPipelines(items.map((item) => normalizePipeline(item as Record<string, unknown>)))\n } finally {\n setLoadingPipelines(false)\n }\n }, [t])\n\n const loadStages = React.useCallback(async (pipelineId: string) => {\n setLoadingStages((prev) => ({ ...prev, [pipelineId]: true }))\n try {\n const data = await readApiResultOrThrow<{ items?: unknown[] }>(\n `/api/customers/pipeline-stages?pipelineId=${encodeURIComponent(pipelineId)}`,\n undefined,\n { errorMessage: t('customers.pipelines.errors.stagesLoadFailed', 'Failed to load stages'), fallback: { items: [] } },\n )\n const items = Array.isArray(data?.items) ? data.items : []\n setStages((prev) => ({\n ...prev,\n [pipelineId]: items.map((item) => normalizeStage(item as Record<string, unknown>)),\n }))\n } finally {\n setLoadingStages((prev) => ({ ...prev, [pipelineId]: false }))\n }\n }, [t])\n\n React.useEffect(() => {\n void loadPipelines()\n }, [loadPipelines, scopeVersion])\n\n React.useEffect(() => {\n if (expandedPipelineId) {\n void loadStages(expandedPipelineId)\n }\n }, [expandedPipelineId, loadStages])\n\n const openCreatePipeline = React.useCallback(() => {\n setPipelineForm({ name: '', isDefault: false })\n setPipelineDialog({ mode: 'create' })\n }, [])\n\n const openEditPipeline = React.useCallback((pipeline: Pipeline) => {\n setPipelineForm({ name: pipeline.name, isDefault: pipeline.isDefault })\n setPipelineDialog({ mode: 'edit', entry: pipeline })\n }, [])\n\n const closePipelineDialog = React.useCallback(() => {\n setPipelineDialog(null)\n }, [])\n\n const handlePipelineSubmit = React.useCallback(async () => {\n if (!pipelineForm.name.trim()) return\n setSubmittingPipeline(true)\n try {\n if (pipelineDialog?.mode === 'create') {\n const res = await apiCall('/api/customers/pipelines', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ name: pipelineForm.name.trim(), isDefault: pipelineForm.isDefault }),\n })\n if (!res.ok) {\n await raiseCrudError(res.response, t('customers.pipelines.errors.createFailed', 'Failed to create pipeline'))\n return\n }\n flash(t('customers.pipelines.flash.created', 'Pipeline created'), 'success')\n } else if (pipelineDialog?.mode === 'edit') {\n const res = await apiCall('/api/customers/pipelines', {\n method: 'PUT',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ id: pipelineDialog.entry.id, name: pipelineForm.name.trim(), isDefault: pipelineForm.isDefault }),\n })\n if (!res.ok) {\n await raiseCrudError(res.response, t('customers.pipelines.errors.updateFailed', 'Failed to update pipeline'))\n return\n }\n flash(t('customers.pipelines.flash.updated', 'Pipeline updated'), 'success')\n }\n setPipelineDialog(null)\n await loadPipelines()\n } finally {\n setSubmittingPipeline(false)\n }\n }, [pipelineDialog, pipelineForm, loadPipelines, t])\n\n const handleDeletePipeline = React.useCallback(async (pipeline: Pipeline) => {\n const confirmed = await confirm({\n title: t('customers.pipelines.confirm.deleteTitle', 'Delete pipeline'),\n text: t('customers.pipelines.confirm.deleteDesc', 'Are you sure you want to delete this pipeline? This cannot be undone.'),\n confirmText: t('customers.pipelines.confirm.deleteConfirm', 'Delete'),\n variant: 'destructive',\n })\n if (!confirmed) return\n const res = await apiCall('/api/customers/pipelines', {\n method: 'DELETE',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ id: pipeline.id }),\n })\n if (!res.ok) {\n const body = (res.result ?? {}) as Record<string, unknown>\n const msg = typeof body.error === 'string' ? body.error : t('customers.pipelines.errors.deleteFailed', 'Failed to delete pipeline')\n flash(msg, 'error')\n return\n }\n flash(t('customers.pipelines.flash.deleted', 'Pipeline deleted'), 'success')\n if (expandedPipelineId === pipeline.id) setExpandedPipelineId(null)\n await loadPipelines()\n }, [confirm, expandedPipelineId, loadPipelines, t])\n\n const toggleExpand = React.useCallback((pipelineId: string) => {\n setExpandedPipelineId((prev) => (prev === pipelineId ? null : pipelineId))\n }, [])\n\n const openCreateStage = React.useCallback((pipelineId: string) => {\n setStageForm({ label: '', color: null, icon: null })\n setStageDialog({ mode: 'create', pipelineId })\n }, [])\n\n const openEditStage = React.useCallback((stage: PipelineStage) => {\n setStageForm({ label: stage.label, color: stage.color, icon: stage.icon })\n setStageDialog({ mode: 'edit', entry: stage })\n }, [])\n\n const closeStageDialog = React.useCallback(() => {\n setStageDialog(null)\n }, [])\n\n const handleStageSubmit = React.useCallback(async () => {\n if (!stageForm.label.trim()) return\n setSubmittingStage(true)\n try {\n const appearance: Record<string, unknown> = {}\n if (stageForm.color) appearance.color = stageForm.color\n if (stageForm.icon) appearance.icon = stageForm.icon\n\n if (stageDialog?.mode === 'create') {\n const res = await apiCall('/api/customers/pipeline-stages', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ pipelineId: stageDialog.pipelineId, label: stageForm.label.trim(), ...appearance }),\n })\n if (!res.ok) {\n await raiseCrudError(res.response, t('customers.pipelines.errors.stageCreateFailed', 'Failed to create stage'))\n return\n }\n flash(t('customers.pipelines.flash.stageCreated', 'Stage created'), 'success')\n await loadStages(stageDialog.pipelineId)\n } else if (stageDialog?.mode === 'edit') {\n const res = await apiCall('/api/customers/pipeline-stages', {\n method: 'PUT',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ id: stageDialog.entry.id, label: stageForm.label.trim(), ...appearance }),\n })\n if (!res.ok) {\n await raiseCrudError(res.response, t('customers.pipelines.errors.stageUpdateFailed', 'Failed to update stage'))\n return\n }\n flash(t('customers.pipelines.flash.stageUpdated', 'Stage updated'), 'success')\n await loadStages(stageDialog.entry.pipelineId)\n }\n setStageDialog(null)\n } finally {\n setSubmittingStage(false)\n }\n }, [stageDialog, stageForm, loadStages, t])\n\n const handleDeleteStage = React.useCallback(async (stage: PipelineStage) => {\n const confirmed = await confirm({\n title: t('customers.pipelines.confirm.stageDeleteTitle', 'Delete stage'),\n text: t('customers.pipelines.confirm.stageDeleteDesc', 'Are you sure you want to delete this stage?'),\n confirmText: t('customers.pipelines.confirm.stageDeleteConfirm', 'Delete'),\n variant: 'destructive',\n })\n if (!confirmed) return\n const res = await apiCall('/api/customers/pipeline-stages', {\n method: 'DELETE',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ id: stage.id }),\n })\n if (!res.ok) {\n const body = (res.result ?? {}) as Record<string, unknown>\n const msg = typeof body.error === 'string' ? body.error : t('customers.pipelines.errors.stageDeleteFailed', 'Failed to delete stage')\n flash(msg, 'error')\n return\n }\n flash(t('customers.pipelines.flash.stageDeleted', 'Stage deleted'), 'success')\n await loadStages(stage.pipelineId)\n }, [confirm, loadStages, t])\n\n const handleMoveStage = React.useCallback(async (stage: PipelineStage, direction: 'up' | 'down') => {\n const pipelineStages = stages[stage.pipelineId] ?? []\n const idx = pipelineStages.findIndex((s) => s.id === stage.id)\n if (idx < 0) return\n const swapIdx = direction === 'up' ? idx - 1 : idx + 1\n if (swapIdx < 0 || swapIdx >= pipelineStages.length) return\n\n const reordered = [...pipelineStages]\n const temp = reordered[idx]\n reordered[idx] = reordered[swapIdx]\n reordered[swapIdx] = temp\n\n const orderedStages = reordered.map((s, i) => ({ id: s.id, order: i }))\n const res = await apiCall('/api/customers/pipeline-stages/reorder', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ stages: orderedStages }),\n })\n if (!res.ok) {\n flash(t('customers.pipelines.errors.reorderFailed', 'Failed to reorder stages'), 'error')\n return\n }\n await loadStages(stage.pipelineId)\n }, [stages, loadStages, t])\n\n const handleKeyDown = React.useCallback(\n (handler: () => void) => (e: React.KeyboardEvent) => {\n if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {\n e.preventDefault()\n handler()\n }\n },\n [],\n )\n\n const appearanceLabels = React.useMemo<AppearanceSelectorLabels>(() => ({\n colorLabel: t('customers.pipelines.stageForm.color', 'Color'),\n colorClearLabel: t('customers.pipelines.stageForm.colorClear', 'Remove color'),\n iconLabel: t('customers.pipelines.stageForm.icon', 'Icon'),\n iconPlaceholder: t('customers.pipelines.stageForm.iconPlaceholder', 'e.g. lucide:star'),\n iconPickerTriggerLabel: t('customers.pipelines.stageForm.iconPicker', 'Pick icon'),\n iconSearchPlaceholder: t('customers.pipelines.stageForm.iconSearch', 'Search icons\u2026'),\n iconSearchEmptyLabel: t('customers.pipelines.stageForm.iconSearchEmpty', 'No icons found'),\n iconSuggestionsLabel: t('customers.pipelines.stageForm.iconSuggestions', 'Suggestions'),\n iconClearLabel: t('customers.pipelines.stageForm.iconClear', 'Remove icon'),\n previewEmptyLabel: t('customers.pipelines.stageForm.previewEmpty', 'No appearance set'),\n }), [t])\n\n return (\n <div className=\"space-y-4\">\n <div className=\"flex items-center justify-between\">\n <div>\n <h3 className=\"text-base font-semibold\">{t('customers.pipelines.title', 'Sales Pipelines')}</h3>\n <p className=\"text-sm text-muted-foreground\">\n {t('customers.pipelines.description', 'Manage sales pipelines and their stages.')}\n </p>\n </div>\n <Button size=\"sm\" onClick={openCreatePipeline}>\n {t('customers.pipelines.actions.create', 'Add pipeline')}\n </Button>\n </div>\n\n {loadingPipelines ? (\n <div className=\"flex items-center gap-2 text-sm text-muted-foreground\">\n <Spinner className=\"h-4 w-4\" />\n {t('customers.pipelines.loading', 'Loading pipelines\u2026')}\n </div>\n ) : pipelines.length === 0 ? (\n <p className=\"text-sm text-muted-foreground\">\n {t('customers.pipelines.empty', 'No pipelines yet. Create one to get started.')}\n </p>\n ) : (\n <div className=\"divide-y divide-border rounded-md border\">\n {pipelines.map((pipeline) => {\n const isExpanded = expandedPipelineId === pipeline.id\n const pipelineStages = stages[pipeline.id] ?? []\n const isLoadingStages = loadingStages[pipeline.id] ?? false\n\n return (\n <div key={pipeline.id}>\n <div className=\"flex items-center justify-between gap-3 px-4 py-3\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-sm font-medium\">{pipeline.name}</span>\n {pipeline.isDefault ? (\n <span className=\"rounded-full bg-primary/10 px-2 py-0.5 text-xs text-primary\">\n {t('customers.pipelines.defaultBadge', 'Default')}\n </span>\n ) : null}\n </div>\n <div className=\"flex items-center gap-2\">\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => toggleExpand(pipeline.id)}\n >\n {isExpanded\n ? t('customers.pipelines.actions.hideStages', 'Hide stages')\n : t('customers.pipelines.actions.manageStages', 'Manage stages')}\n </Button>\n <Button variant=\"ghost\" size=\"sm\" onClick={() => openEditPipeline(pipeline)}>\n {t('customers.pipelines.actions.edit', 'Edit')}\n </Button>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n className=\"text-destructive hover:text-destructive\"\n onClick={() => void handleDeletePipeline(pipeline)}\n >\n {t('customers.pipelines.actions.delete', 'Delete')}\n </Button>\n </div>\n </div>\n\n {isExpanded ? (\n <div className=\"border-t border-border bg-muted/30 px-4 py-3\">\n <div className=\"mb-3 flex items-center justify-between\">\n <span className=\"text-xs font-medium text-muted-foreground uppercase tracking-wide\">\n {t('customers.pipelines.stages.title', 'Stages')}\n </span>\n <Button size=\"sm\" variant=\"outline\" onClick={() => openCreateStage(pipeline.id)}>\n {t('customers.pipelines.stages.add', 'Add stage')}\n </Button>\n </div>\n\n {isLoadingStages ? (\n <div className=\"flex items-center gap-2 text-sm text-muted-foreground\">\n <Spinner className=\"h-3 w-3\" />\n {t('customers.pipelines.stages.loading', 'Loading\u2026')}\n </div>\n ) : pipelineStages.length === 0 ? (\n <p className=\"text-sm text-muted-foreground\">\n {t('customers.pipelines.stages.empty', 'No stages yet.')}\n </p>\n ) : (\n <div className=\"divide-y divide-border rounded-md border bg-background\">\n {pipelineStages.map((stage, idx) => (\n <div key={stage.id} className=\"flex items-center justify-between gap-3 px-3 py-2\">\n <div className=\"flex items-center gap-2\">\n <span className=\"w-5 text-center text-xs text-muted-foreground\">{idx + 1}</span>\n {stage.color ? renderDictionaryColor(stage.color, 'h-3 w-3 rounded-full') : null}\n {stage.icon ? renderDictionaryIcon(stage.icon, 'h-4 w-4') : null}\n <span className=\"text-sm\">{stage.label}</span>\n </div>\n <div className=\"flex items-center gap-1\">\n <Button\n variant=\"ghost\"\n size=\"icon\"\n className=\"h-7 w-7\"\n disabled={idx === 0}\n onClick={() => void handleMoveStage(stage, 'up')}\n title={t('customers.pipelines.stages.moveUp', 'Move up')}\n >\n \u2191\n </Button>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n className=\"h-7 w-7\"\n disabled={idx === pipelineStages.length - 1}\n onClick={() => void handleMoveStage(stage, 'down')}\n title={t('customers.pipelines.stages.moveDown', 'Move down')}\n >\n \u2193\n </Button>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => openEditStage(stage)}\n >\n {t('customers.pipelines.stages.edit', 'Edit')}\n </Button>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n className=\"text-destructive hover:text-destructive\"\n onClick={() => void handleDeleteStage(stage)}\n >\n {t('customers.pipelines.stages.delete', 'Delete')}\n </Button>\n </div>\n </div>\n ))}\n </div>\n )}\n </div>\n ) : null}\n </div>\n )\n })}\n </div>\n )}\n\n {/* Pipeline Dialog */}\n <Dialog open={pipelineDialog !== null} onOpenChange={(open) => { if (!open) closePipelineDialog() }}>\n <DialogContent onKeyDown={handleKeyDown(handlePipelineSubmit)}>\n <DialogHeader>\n <DialogTitle>\n {pipelineDialog?.mode === 'create'\n ? t('customers.pipelines.dialog.createTitle', 'Create pipeline')\n : t('customers.pipelines.dialog.editTitle', 'Edit pipeline')}\n </DialogTitle>\n </DialogHeader>\n <div className=\"space-y-4 py-2\">\n <div className=\"space-y-2\">\n <Label htmlFor=\"pipeline-name\">{t('customers.pipelines.form.name', 'Name')}</Label>\n <Input\n id=\"pipeline-name\"\n value={pipelineForm.name}\n onChange={(e) => setPipelineForm((prev) => ({ ...prev, name: e.target.value }))}\n placeholder={t('customers.pipelines.form.namePlaceholder', 'e.g. New Business')}\n autoFocus\n />\n </div>\n <div className=\"flex items-center gap-2\">\n <Checkbox\n id=\"pipeline-default\"\n checked={pipelineForm.isDefault}\n onCheckedChange={(checked) => setPipelineForm((prev) => ({ ...prev, isDefault: checked === true }))}\n />\n <Label htmlFor=\"pipeline-default\" className=\"cursor-pointer\">\n {t('customers.pipelines.form.isDefault', 'Set as default pipeline')}\n </Label>\n </div>\n </div>\n <DialogFooter>\n <Button variant=\"outline\" onClick={closePipelineDialog} disabled={submittingPipeline}>\n {t('customers.pipelines.dialog.cancel', 'Cancel')}\n </Button>\n <Button onClick={() => void handlePipelineSubmit()} disabled={submittingPipeline || !pipelineForm.name.trim()}>\n {submittingPipeline ? <Spinner className=\"mr-2 h-4 w-4\" /> : null}\n {t('customers.pipelines.dialog.save', 'Save')}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n\n {ConfirmDialogElement}\n\n {/* Stage Dialog */}\n <Dialog open={stageDialog !== null} onOpenChange={(open) => { if (!open) closeStageDialog() }}>\n <DialogContent onKeyDown={handleKeyDown(handleStageSubmit)}>\n <DialogHeader>\n <DialogTitle>\n {stageDialog?.mode === 'create'\n ? t('customers.pipelines.stageDialog.createTitle', 'Add stage')\n : t('customers.pipelines.stageDialog.editTitle', 'Edit stage')}\n </DialogTitle>\n </DialogHeader>\n <div className=\"space-y-4 py-2\">\n <div className=\"space-y-2\">\n <Label htmlFor=\"stage-label\">{t('customers.pipelines.stageForm.label', 'Label')}</Label>\n <Input\n id=\"stage-label\"\n value={stageForm.label}\n onChange={(e) => setStageForm((prev) => ({ ...prev, label: e.target.value }))}\n placeholder={t('customers.pipelines.stageForm.labelPlaceholder', 'e.g. Discovery')}\n autoFocus\n />\n </div>\n <AppearanceSelector\n color={stageForm.color}\n icon={stageForm.icon}\n onColorChange={(next) => setStageForm((prev) => ({ ...prev, color: next }))}\n onIconChange={(next) => setStageForm((prev) => ({ ...prev, icon: next }))}\n labels={appearanceLabels}\n />\n </div>\n <DialogFooter>\n <Button variant=\"outline\" onClick={closeStageDialog} disabled={submittingStage}>\n {t('customers.pipelines.stageDialog.cancel', 'Cancel')}\n </Button>\n <Button onClick={() => void handleStageSubmit()} disabled={submittingStage || !stageForm.label.trim()}>\n {submittingStage ? <Spinner className=\"mr-2 h-4 w-4\" /> : null}\n {t('customers.pipelines.stageDialog.save', 'Save')}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </div>\n )\n}\n"],
5
+ "mappings": ";AAoVQ,SACE,KADF;AAlVR,YAAY,WAAW;AACvB,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa;AACtB,SAAS,SAAS,4BAA4B;AAC9C,SAAS,sBAAsB;AAC/B,SAAS,mCAAmC;AAC5C,SAAS,YAAY;AACrB,SAAS,wBAAwB;AACjC,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AA2BP,SAAS,kBAAkB,KAAwC;AACjE,SAAO;AAAA,IACL,IAAI,OAAO,IAAI,OAAO,WAAW,IAAI,KAAK;AAAA,IAC1C,MAAM,OAAO,IAAI,SAAS,WAAW,IAAI,OAAO;AAAA,IAChD,WAAW,IAAI,cAAc,QAAQ,IAAI,eAAe;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AAA,YACxE,QAAQ;AAAA;AAAA,QACV;AAAA,SACF;AAAA,MACA,qBAAC,gBACC;AAAA,4BAAC,UAAO,SAAQ,WAAU,SAAS,kBAAkB,UAAU,iBAC5D,YAAE,0CAA0C,QAAQ,GACvD;AAAA,QACA,qBAAC,UAAO,SAAS,MAAM,KAAK,kBAAkB,GAAG,UAAU,mBAAmB,CAAC,UAAU,MAAM,KAAK,GACjG;AAAA,4BAAkB,oBAAC,WAAQ,WAAU,gBAAe,IAAK;AAAA,UACzD,EAAE,wCAAwC,MAAM;AAAA,WACnD;AAAA,SACF;AAAA,OACF,GACF;AAAA,KACF;AAEJ;",
6
+ "names": []
7
+ }
@@ -21,6 +21,8 @@ const schema = z.object({
21
21
  title: z.string().trim().min(1, "customers.people.detail.deals.titleRequired").max(200, "customers.people.detail.deals.titleTooLong"),
22
22
  status: z.string().trim().max(50, "customers.people.detail.deals.statusTooLong").optional(),
23
23
  pipelineStage: z.string().trim().max(100, "customers.people.detail.deals.pipelineTooLong").optional(),
24
+ pipelineId: z.string().uuid().optional(),
25
+ pipelineStageId: z.string().uuid().optional(),
24
26
  valueAmount: z.preprocess((value) => {
25
27
  if (value === "" || value === null || value === void 0) return void 0;
26
28
  if (typeof value === "number") return value;
@@ -305,8 +307,7 @@ function DealForm({
305
307
  [t]
306
308
  );
307
309
  const dictionaryLabels = React.useMemo(() => ({
308
- status: createDictionarySelectLabels("deal-statuses", translate),
309
- pipeline: createDictionarySelectLabels("pipeline-stages", translate)
310
+ status: createDictionarySelectLabels("deal-statuses", translate)
310
311
  }), [translate]);
311
312
  const resolvedCurrencyError = React.useMemo(() => {
312
313
  if (currencyDictionaryError) return currencyDictionaryError;
@@ -425,6 +426,47 @@ function DealForm({
425
426
  }, []);
426
427
  const disabled = pending || isSubmitting;
427
428
  const canDelete = mode === "edit" && typeof onDelete === "function";
429
+ const [pipelines, setPipelines] = React.useState([]);
430
+ const [pipelineStages, setPipelineStages] = React.useState([]);
431
+ const loadStagesForPipeline = React.useCallback(async (pipelineId) => {
432
+ if (!pipelineId) {
433
+ setPipelineStages([]);
434
+ return;
435
+ }
436
+ try {
437
+ const call = await apiCall(`/api/customers/pipeline-stages?pipelineId=${encodeURIComponent(pipelineId)}`);
438
+ if (call.ok && call.result?.items) {
439
+ const sorted = [...call.result.items].sort((a, b) => a.order - b.order);
440
+ setPipelineStages(sorted);
441
+ }
442
+ } catch {
443
+ setPipelineStages([]);
444
+ }
445
+ }, []);
446
+ React.useEffect(() => {
447
+ let cancelled = false;
448
+ (async () => {
449
+ try {
450
+ const call = await apiCall("/api/customers/pipelines");
451
+ if (cancelled) return;
452
+ if (call.ok && call.result?.items) {
453
+ setPipelines(call.result.items);
454
+ }
455
+ } catch {
456
+ }
457
+ })().catch(() => {
458
+ });
459
+ return () => {
460
+ cancelled = true;
461
+ };
462
+ }, []);
463
+ React.useEffect(() => {
464
+ const pid = initialValues?.pipelineId;
465
+ if (typeof pid === "string" && pid.length) {
466
+ loadStagesForPipeline(pid).catch(() => {
467
+ });
468
+ }
469
+ }, [initialValues?.pipelineId, loadStagesForPipeline]);
428
470
  const baseFields = React.useMemo(() => [
429
471
  {
430
472
  id: "title",
@@ -449,18 +491,44 @@ function DealForm({
449
491
  )
450
492
  },
451
493
  {
452
- id: "pipelineStage",
494
+ id: "pipelineId",
495
+ label: t("customers.people.detail.deals.fields.pipeline", "Pipeline"),
496
+ type: "custom",
497
+ layout: "half",
498
+ component: ({ value, setValue }) => /* @__PURE__ */ jsxs(
499
+ "select",
500
+ {
501
+ className: "w-full rounded border px-2 py-1.5 text-sm",
502
+ value: typeof value === "string" ? value : "",
503
+ onChange: (e) => {
504
+ setValue(e.target.value);
505
+ loadStagesForPipeline(e.target.value).catch(() => {
506
+ });
507
+ },
508
+ disabled,
509
+ children: [
510
+ /* @__PURE__ */ jsx("option", { value: "", children: t("customers.deals.form.pipeline.placeholder", "Select pipeline\u2026") }),
511
+ pipelines.map((p) => /* @__PURE__ */ jsx("option", { value: p.id, children: p.name }, p.id))
512
+ ]
513
+ }
514
+ )
515
+ },
516
+ {
517
+ id: "pipelineStageId",
453
518
  label: t("customers.people.detail.deals.fields.pipelineStage", "Pipeline stage"),
454
519
  type: "custom",
455
520
  layout: "half",
456
- component: ({ value, setValue }) => /* @__PURE__ */ jsx(
457
- DictionarySelectField,
521
+ component: ({ value, setValue }) => /* @__PURE__ */ jsxs(
522
+ "select",
458
523
  {
459
- kind: "pipeline-stages",
460
- value: typeof value === "string" ? value : void 0,
461
- onChange: (next) => setValue(next ?? ""),
462
- labels: dictionaryLabels.pipeline,
463
- selectClassName: "w-full"
524
+ className: "w-full rounded border px-2 py-1.5 text-sm",
525
+ value: typeof value === "string" ? value : "",
526
+ onChange: (e) => setValue(e.target.value),
527
+ disabled: disabled || !pipelineStages.length,
528
+ children: [
529
+ /* @__PURE__ */ jsx("option", { value: "", children: t("customers.deals.form.pipelineStage.placeholder", "Select stage\u2026") }),
530
+ pipelineStages.map((s) => /* @__PURE__ */ jsx("option", { value: s.id, children: s.label }, s.id))
531
+ ]
464
532
  }
465
533
  )
466
534
  },
@@ -554,13 +622,13 @@ function DealForm({
554
622
  }
555
623
  )
556
624
  }
557
- ], [currencyDictionaryLabels, fetchCurrencyOptions, resolvedCurrencyError, dictionaryLabels.pipeline, dictionaryLabels.status, disabled, fetchCompaniesByIds, fetchPeopleByIds, searchCompanies, searchPeople, t]);
625
+ ], [currencyDictionaryLabels, fetchCurrencyOptions, resolvedCurrencyError, pipelines, pipelineStages, loadStagesForPipeline, dictionaryLabels.status, disabled, fetchCompaniesByIds, fetchPeopleByIds, searchCompanies, searchPeople, t]);
558
626
  const groups = React.useMemo(() => [
559
627
  {
560
628
  id: "details",
561
629
  title: t("customers.people.detail.deals.form.details", "Deal details"),
562
630
  column: 1,
563
- fields: ["title", "status", "pipelineStage", "valueAmount", "valueCurrency", "probability", "expectedCloseAt", "description"]
631
+ fields: ["title", "status", "pipelineId", "pipelineStageId", "valueAmount", "valueCurrency", "probability", "expectedCloseAt", "description"]
564
632
  },
565
633
  {
566
634
  id: "associations",
@@ -603,6 +671,8 @@ function DealForm({
603
671
  title: initialValues?.title ?? "",
604
672
  status: initialValues?.status ?? "",
605
673
  pipelineStage: initialValues?.pipelineStage ?? "",
674
+ pipelineId: initialValues?.pipelineId ?? (typeof initialValues?.pipeline_id === "string" ? initialValues.pipeline_id : ""),
675
+ pipelineStageId: initialValues?.pipelineStageId ?? (typeof initialValues?.pipeline_stage_id === "string" ? initialValues.pipeline_stage_id : ""),
606
676
  valueAmount: normalizeNumber(initialValues?.valueAmount ?? null),
607
677
  valueCurrency: normalizeCurrency(initialValues?.valueCurrency ?? null),
608
678
  probability: normalizeNumber(initialValues?.probability ?? null),
@@ -631,6 +701,8 @@ function DealForm({
631
701
  title: parsed.data.title,
632
702
  status: parsed.data.status || void 0,
633
703
  pipelineStage: parsed.data.pipelineStage || void 0,
704
+ pipelineId: parsed.data.pipelineId || void 0,
705
+ pipelineStageId: parsed.data.pipelineStageId || void 0,
634
706
  valueAmount: typeof parsed.data.valueAmount === "number" ? parsed.data.valueAmount : void 0,
635
707
  valueCurrency: parsed.data.valueCurrency || void 0,
636
708
  probability: typeof parsed.data.probability === "number" ? parsed.data.probability : void 0,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/modules/customers/components/detail/DealForm.tsx"],
4
- "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { z } from 'zod'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { CrudForm, type CrudField, type CrudFormGroup } from '@open-mercato/ui/backend/CrudForm'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { createCrudFormError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { DictionarySelectField } from '../formConfig'\nimport { createDictionarySelectLabels } from './utils'\nimport { E } from '#generated/entities.ids.generated'\nimport { collectCustomFieldValues } from '@open-mercato/ui/backend/utils/customFieldValues'\nimport { useCurrencyDictionary } from './hooks/useCurrencyDictionary'\nimport { DictionaryEntrySelect } from '@open-mercato/core/modules/dictionaries/components/DictionaryEntrySelect'\nimport { normalizeCustomFieldSubmitValue } from './customFieldUtils'\n\nexport type DealFormBaseValues = {\n title: string\n status?: string | null\n pipelineStage?: string | null\n valueAmount?: number | null\n valueCurrency?: string | null\n probability?: number | null\n expectedCloseAt?: string | null\n description?: string | null\n personIds?: string[]\n companyIds?: string[]\n}\n\nexport type DealFormSubmitPayload = {\n base: DealFormBaseValues\n custom: Record<string, unknown>\n}\n\nexport type DealFormProps = {\n mode: 'create' | 'edit'\n initialValues?: Partial<DealFormBaseValues & Record<string, unknown>>\n onSubmit: (payload: DealFormSubmitPayload) => Promise<void>\n onCancel: () => void\n onDelete?: () => Promise<void> | void\n submitLabel?: string\n cancelLabel?: string\n isSubmitting?: boolean\n embedded?: boolean\n title?: string\n backHref?: string\n}\n\ntype EntityOption = {\n id: string\n label: string\n subtitle?: string | null\n}\n\ntype EntityMultiSelectProps = {\n value: string[]\n onChange: (next: string[]) => void\n placeholder: string\n emptyLabel: string\n loadingLabel: string\n noResultsLabel: string\n removeLabel: string\n errorLabel: string\n search: (query: string) => Promise<EntityOption[]>\n fetchByIds: (ids: string[]) => Promise<EntityOption[]>\n disabled?: boolean\n autoFocus?: boolean\n}\n\nconst DEAL_ENTITY_IDS = [E.customers.customer_deal]\nconst CURRENCY_PRIORITY = ['EUR', 'USD', 'GBP', 'PLN'] as const\n\nconst schema = z.object({\n title: z\n .string()\n .trim()\n .min(1, 'customers.people.detail.deals.titleRequired')\n .max(200, 'customers.people.detail.deals.titleTooLong'),\n status: z\n .string()\n .trim()\n .max(50, 'customers.people.detail.deals.statusTooLong')\n .optional(),\n pipelineStage: z\n .string()\n .trim()\n .max(100, 'customers.people.detail.deals.pipelineTooLong')\n .optional(),\n valueAmount: z\n .preprocess((value) => {\n if (value === '' || value === null || value === undefined) return undefined\n if (typeof value === 'number') return value\n if (typeof value === 'string') {\n const trimmed = value.trim()\n if (!trimmed) return undefined\n const parsed = Number(trimmed)\n if (Number.isNaN(parsed)) return value\n return parsed\n }\n return value\n }, z\n .number()\n .min(0, 'customers.people.detail.deals.valueInvalid')\n .optional())\n .optional(),\n valueCurrency: z\n .string()\n .transform((value) => value.trim().toUpperCase())\n .refine(\n (value) => !value || /^[A-Z]{3}$/.test(value),\n 'customers.people.detail.deals.currencyInvalid',\n )\n .optional(),\n probability: z\n .preprocess((value) => {\n if (value === '' || value === null || value === undefined) return undefined\n if (typeof value === 'number') return value\n if (typeof value === 'string') {\n const trimmed = value.trim()\n if (!trimmed) return undefined\n const parsed = Number(trimmed)\n if (Number.isNaN(parsed)) return value\n return parsed\n }\n return value\n }, z\n .number()\n .min(0, 'customers.people.detail.deals.probabilityInvalid')\n .max(100, 'customers.people.detail.deals.probabilityInvalid')\n .optional())\n .optional(),\n expectedCloseAt: z\n .string()\n .transform((value) => value.trim())\n .refine(\n (value) => {\n if (!value) return true\n const parsed = new Date(value)\n return !Number.isNaN(parsed.getTime())\n },\n 'customers.people.detail.deals.expectedCloseInvalid',\n )\n .optional(),\n description: z.string().max(4000, 'customers.people.detail.deals.descriptionTooLong').optional(),\n personIds: z.array(z.string().trim().min(1)).optional(),\n companyIds: z.array(z.string().trim().min(1)).optional(),\n}).passthrough()\n\nfunction toDateInputValue(value: string | null | undefined): string {\n if (!value) return ''\n const parsed = new Date(value)\n if (Number.isNaN(parsed.getTime())) return ''\n const year = parsed.getUTCFullYear()\n const month = String(parsed.getUTCMonth() + 1).padStart(2, '0')\n const day = String(parsed.getUTCDate()).padStart(2, '0')\n return `${year}-${month}-${day}`\n}\n\nfunction normalizeCurrency(value: string | null | undefined): string {\n if (!value) return ''\n return value.trim().slice(0, 3).toUpperCase()\n}\n\nfunction sanitizeIdList(input: unknown): string[] {\n if (!Array.isArray(input)) return []\n const set = new Set<string>()\n input.forEach((candidate) => {\n if (typeof candidate !== 'string') return\n const trimmed = candidate.trim()\n if (!trimmed.length) return\n set.add(trimmed)\n })\n return Array.from(set)\n}\n\nfunction extractPersonOption(record: Record<string, unknown>): EntityOption | null {\n const id = typeof record.id === 'string' ? record.id : null\n if (!id) return null\n const displayName =\n typeof record.displayName === 'string' && record.displayName.trim().length\n ? record.displayName.trim()\n : typeof record.display_name === 'string' && record.display_name.trim().length\n ? (record.display_name as string).trim()\n : null\n const email =\n typeof record.primaryEmail === 'string' && record.primaryEmail.trim().length\n ? record.primaryEmail.trim()\n : typeof record.primary_email === 'string' && record.primary_email.trim().length\n ? (record.primary_email as string).trim()\n : null\n const label = displayName ?? email ?? id\n const subtitle = email && email !== label ? email : null\n return { id, label, subtitle }\n}\n\nfunction extractCompanyOption(record: Record<string, unknown>): EntityOption | null {\n const id = typeof record.id === 'string' ? record.id : null\n if (!id) return null\n const displayName =\n typeof record.displayName === 'string' && record.displayName.trim().length\n ? record.displayName.trim()\n : typeof record.display_name === 'string' && record.display_name.trim().length\n ? (record.display_name as string).trim()\n : null\n const domain =\n typeof record.domain === 'string' && record.domain.trim().length\n ? record.domain.trim()\n : typeof record.websiteUrl === 'string' && record.websiteUrl.trim().length\n ? record.websiteUrl.trim()\n : typeof record.website_url === 'string' && record.website_url.trim().length\n ? (record.website_url as string).trim()\n : null\n const label = displayName ?? domain ?? id\n const subtitle = domain && domain !== label ? domain : null\n return { id, label, subtitle }\n}\n\nfunction EntityMultiSelect({\n value,\n onChange,\n placeholder,\n emptyLabel,\n loadingLabel,\n noResultsLabel,\n removeLabel,\n errorLabel,\n search,\n fetchByIds,\n disabled = false,\n autoFocus = false,\n}: EntityMultiSelectProps) {\n const [input, setInput] = React.useState('')\n const [suggestions, setSuggestions] = React.useState<EntityOption[]>([])\n const [cache, setCache] = React.useState<Map<string, EntityOption>>(() => new Map())\n const [loading, setLoading] = React.useState(false)\n const [error, setError] = React.useState<string | null>(null)\n\n const normalizedValue = React.useMemo(() => sanitizeIdList(value), [value])\n\n React.useEffect(() => {\n if (!normalizedValue.length) return\n const missing = normalizedValue.filter((id) => !cache.has(id))\n if (!missing.length) return\n let cancelled = false\n ;(async () => {\n try {\n const entries = await fetchByIds(missing)\n if (cancelled) return\n setCache((prev) => {\n const next = new Map(prev)\n entries.forEach((entry) => {\n if (entry?.id) next.set(entry.id, entry)\n })\n return next\n })\n } catch {\n if (!cancelled) setError(errorLabel)\n }\n })().catch(() => {})\n return () => { cancelled = true }\n }, [cache, errorLabel, fetchByIds, normalizedValue])\n\n React.useEffect(() => {\n if (disabled) {\n setLoading(false)\n return\n }\n let cancelled = false\n const handler = window.setTimeout(async () => {\n setLoading(true)\n try {\n const results = await search(input.trim())\n if (cancelled) return\n setSuggestions(results)\n setCache((prev) => {\n const next = new Map(prev)\n results.forEach((entry) => {\n if (entry?.id) next.set(entry.id, entry)\n })\n return next\n })\n setError(null)\n } catch {\n if (!cancelled) {\n setError(errorLabel)\n setSuggestions([])\n }\n } finally {\n if (!cancelled) setLoading(false)\n }\n }, 200)\n return () => {\n cancelled = true\n window.clearTimeout(handler)\n }\n }, [disabled, errorLabel, input, search])\n\n const filteredSuggestions = React.useMemo(\n () => suggestions.filter((option) => !normalizedValue.includes(option.id)),\n [normalizedValue, suggestions],\n )\n\n const selectedOptions = React.useMemo(\n () => normalizedValue.map((id) => cache.get(id) ?? { id, label: id }),\n [cache, normalizedValue],\n )\n\n const addOption = React.useCallback(\n (option: EntityOption) => {\n if (!option?.id) return\n if (normalizedValue.includes(option.id)) return\n const next = [...normalizedValue, option.id]\n onChange(next)\n setCache((prev) => {\n const nextCache = new Map(prev)\n nextCache.set(option.id, option)\n return nextCache\n })\n setInput('')\n setSuggestions([])\n },\n [normalizedValue, onChange],\n )\n\n const removeOption = React.useCallback(\n (id: string) => {\n const next = normalizedValue.filter((candidate) => candidate !== id)\n onChange(next)\n },\n [normalizedValue, onChange],\n )\n\n return (\n <div className=\"space-y-2\">\n <div className=\"flex flex-wrap items-center gap-2 rounded border px-2 py-1\">\n {selectedOptions.map((option) => (\n <span key={option.id} className=\"inline-flex items-center gap-1 rounded bg-muted px-2 py-0.5 text-xs\">\n {option.label}\n <IconButton\n variant=\"ghost\"\n size=\"xs\"\n className=\"opacity-60 hover:opacity-100\"\n onClick={() => removeOption(option.id)}\n aria-label={`${removeLabel} ${option.label}`}\n disabled={disabled}\n >\n \u00D7\n </IconButton>\n </span>\n ))}\n <input\n type=\"text\"\n className=\"flex-1 min-w-[160px] border-0 bg-transparent py-1 text-sm outline-none\"\n value={input}\n placeholder={placeholder}\n onChange={(event) => setInput(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === 'Enter') {\n event.preventDefault()\n const nextOption = filteredSuggestions[0]\n if (nextOption) addOption(nextOption)\n } else if (event.key === 'Backspace' && !input.length && normalizedValue.length) {\n removeOption(normalizedValue[normalizedValue.length - 1])\n }\n }}\n disabled={disabled}\n autoFocus={autoFocus}\n data-crud-focus-target=\"\"\n />\n </div>\n {loading ? <div className=\"text-xs text-muted-foreground\">{loadingLabel}</div> : null}\n {!loading && filteredSuggestions.length ? (\n <div className=\"flex flex-wrap gap-2\">\n {filteredSuggestions.slice(0, 10).map((option) => (\n <Button\n key={option.id}\n variant=\"outline\"\n size=\"sm\"\n className=\"h-auto px-2 py-1 text-xs font-normal\"\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => addOption(option)}\n disabled={disabled}\n >\n <span className=\"flex flex-col items-start\">\n <span>{option.label}</span>\n {option.subtitle ? (\n <span className=\"text-[10px] text-muted-foreground\">{option.subtitle}</span>\n ) : null}\n </span>\n </Button>\n ))}\n </div>\n ) : null}\n {!loading && !filteredSuggestions.length && input.trim().length ? (\n <div className=\"text-xs text-muted-foreground\">{noResultsLabel}</div>\n ) : null}\n {error ? <div className=\"text-xs text-red-600\">{error}</div> : null}\n {!normalizedValue.length && !input.trim().length ? (\n <div className=\"text-xs text-muted-foreground\">{emptyLabel}</div>\n ) : null}\n </div>\n )\n}\n\nexport function DealForm({\n mode,\n initialValues,\n onSubmit,\n onCancel,\n onDelete,\n submitLabel,\n cancelLabel,\n isSubmitting = false,\n embedded = true,\n title,\n backHref,\n}: DealFormProps) {\n const t = useT()\n const [pending, setPending] = React.useState(false)\n const {\n data: currencyDictionaryData,\n error: currencyDictionaryErrorRaw,\n isLoading: currencyDictionaryLoading,\n refetch: refetchCurrencyDictionary,\n } = useCurrencyDictionary()\n const currencyDictionaryError = currencyDictionaryErrorRaw\n ? currencyDictionaryErrorRaw instanceof Error\n ? currencyDictionaryErrorRaw.message\n : String(currencyDictionaryErrorRaw)\n : null\n\n const translate = React.useCallback(\n (key: string, fallback: string) => {\n const value = t(key)\n return value === key ? fallback : value\n },\n [t],\n )\n\n const dictionaryLabels = React.useMemo(() => ({\n status: createDictionarySelectLabels('deal-statuses', translate),\n pipeline: createDictionarySelectLabels('pipeline-stages', translate),\n }), [translate])\n\n const resolvedCurrencyError = React.useMemo(() => {\n if (currencyDictionaryError) return currencyDictionaryError\n if (!currencyDictionaryLoading && !currencyDictionaryData) {\n return t('customers.deals.form.currency.missing', 'Currency dictionary is not configured yet.')\n }\n return null\n }, [currencyDictionaryData, currencyDictionaryError, currencyDictionaryLoading, t])\n\n const fetchCurrencyOptions = React.useCallback(async () => {\n let payload = currencyDictionaryData ?? null\n if (!payload) {\n try {\n payload = await refetchCurrencyDictionary()\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err ?? '')\n throw new Error(message || t('customers.deals.form.currency.error', 'Failed to load currency dictionary.'))\n }\n }\n if (!payload) {\n throw new Error(t('customers.deals.form.currency.missing', 'Currency dictionary is not configured yet.'))\n }\n const priorityOrder = new Map<string, number>()\n CURRENCY_PRIORITY.forEach((code, index) => priorityOrder.set(code, index))\n const prioritized: { value: string; label: string; color: string | null; icon: string | null }[] = []\n const remainder: { value: string; label: string; color: string | null; icon: string | null }[] = []\n payload.entries.forEach((entry) => {\n const value = entry.value.toUpperCase()\n const label = entry.label && entry.label.length ? `${value} \u2013 ${entry.label}` : value\n const option = { value, label, color: null, icon: null }\n if (priorityOrder.has(value)) prioritized.push(option)\n else remainder.push(option)\n })\n prioritized.sort((a, b) => (priorityOrder.get(a.value)! - priorityOrder.get(b.value)!))\n remainder.sort((a, b) => a.label.localeCompare(b.label, undefined, { sensitivity: 'base' }))\n return [...prioritized, ...remainder]\n }, [currencyDictionaryData, refetchCurrencyDictionary, t])\n\n const currencyDictionaryLabels = React.useMemo(() => ({\n placeholder: t('customers.deals.form.currency.placeholder', 'Select currency\u2026'),\n addLabel: t('customers.deals.form.currency.add', 'Add currency'),\n dialogTitle: t('customers.deals.form.currency.dialogTitle', 'Add currency'),\n valueLabel: t('customers.deals.form.currency.valueLabel', 'Currency code'),\n valuePlaceholder: t('customers.deals.form.currency.valuePlaceholder', 'e.g. USD'),\n labelLabel: t('customers.deals.form.currency.labelLabel', 'Label'),\n labelPlaceholder: t('customers.deals.form.currency.labelPlaceholder', 'Display name shown in UI'),\n emptyError: t('customers.deals.form.currency.error.required', 'Currency code is required.'),\n cancelLabel: t('customers.deals.form.currency.cancel', 'Cancel'),\n saveLabel: t('customers.deals.form.currency.save', 'Save'),\n errorLoad: t('customers.deals.form.currency.error', 'Failed to load currency dictionary.'),\n errorSave: t('customers.deals.form.currency.error', 'Failed to load currency dictionary.'),\n loadingLabel: t('customers.deals.form.currency.loading', 'Loading currencies\u2026'),\n manageTitle: t('customers.deals.form.currency.manage', 'Manage currency dictionary'),\n }), [t])\n\n const searchPeople = React.useCallback(async (query: string): Promise<EntityOption[]> => {\n const params = new URLSearchParams({\n pageSize: '20',\n sortField: 'name',\n sortDir: 'asc',\n })\n if (query.trim().length) params.set('search', query.trim())\n const call = await apiCall<Record<string, unknown>>(`/api/customers/people?${params.toString()}`)\n if (!call.ok) {\n throw new Error(typeof call.result?.error === 'string' ? String(call.result?.error) : 'Failed to search people')\n }\n const payload = call.result ?? {}\n const items = Array.isArray(payload.items) ? payload.items : []\n return items\n .map((item: unknown) => (item && typeof item === 'object' ? extractPersonOption(item as Record<string, unknown>) : null))\n .filter((entry: EntityOption | null): entry is EntityOption => entry !== null)\n }, [])\n\n const fetchPeopleByIds = React.useCallback(async (ids: string[]): Promise<EntityOption[]> => {\n const unique = sanitizeIdList(ids)\n if (!unique.length) return []\n const results = await Promise.all(unique.map(async (id) => {\n try {\n const call = await apiCall<Record<string, unknown>>(`/api/customers/people?id=${encodeURIComponent(id)}&pageSize=1`)\n if (!call.ok) throw new Error()\n const payload = call.result ?? {}\n const items = Array.isArray(payload.items) ? payload.items : []\n const option = items\n .map((item: unknown) => (item && typeof item === 'object' ? extractPersonOption(item as Record<string, unknown>) : null))\n .find((candidate: EntityOption | null): candidate is EntityOption => candidate !== null)\n return option ?? { id, label: id }\n } catch {\n return { id, label: id }\n }\n }))\n return results\n }, [])\n\n const searchCompanies = React.useCallback(async (query: string): Promise<EntityOption[]> => {\n const params = new URLSearchParams({\n pageSize: '20',\n sortField: 'name',\n sortDir: 'asc',\n })\n if (query.trim().length) params.set('search', query.trim())\n const call = await apiCall<Record<string, unknown>>(`/api/customers/companies?${params.toString()}`)\n if (!call.ok) {\n throw new Error(typeof call.result?.error === 'string' ? String(call.result?.error) : 'Failed to search companies')\n }\n const payload = call.result ?? {}\n const items = Array.isArray(payload.items) ? payload.items : []\n return items\n .map((item: unknown) => (item && typeof item === 'object' ? extractCompanyOption(item as Record<string, unknown>) : null))\n .filter((entry: EntityOption | null): entry is EntityOption => entry !== null)\n }, [])\n\n const fetchCompaniesByIds = React.useCallback(async (ids: string[]): Promise<EntityOption[]> => {\n const unique = sanitizeIdList(ids)\n if (!unique.length) return []\n const results = await Promise.all(unique.map(async (id) => {\n try {\n const call = await apiCall<Record<string, unknown>>(`/api/customers/companies?id=${encodeURIComponent(id)}&pageSize=1`)\n if (!call.ok) throw new Error()\n const payload = call.result ?? {}\n const items = Array.isArray(payload.items) ? payload.items : []\n const option = items\n .map((item: unknown) => (item && typeof item === 'object' ? extractCompanyOption(item as Record<string, unknown>) : null))\n .find((candidate: EntityOption | null): candidate is EntityOption => candidate !== null)\n return option ?? { id, label: id }\n } catch {\n return { id, label: id }\n }\n }))\n return results\n }, [])\n\n const disabled = pending || isSubmitting\n const canDelete = mode === 'edit' && typeof onDelete === 'function'\n\n const baseFields = React.useMemo<CrudField[]>(() => [\n {\n id: 'title',\n label: t('customers.people.detail.deals.fields.title', 'Title'),\n type: 'text',\n required: true,\n },\n {\n id: 'status',\n label: t('customers.people.detail.deals.fields.status', 'Status'),\n type: 'custom',\n layout: 'half',\n component: ({ value, setValue }) => (\n <DictionarySelectField\n kind=\"deal-statuses\"\n value={typeof value === 'string' ? value : undefined}\n onChange={(next) => setValue(next ?? '')}\n labels={dictionaryLabels.status}\n selectClassName=\"w-full\"\n />\n ),\n } as CrudField,\n {\n id: 'pipelineStage',\n label: t('customers.people.detail.deals.fields.pipelineStage', 'Pipeline stage'),\n type: 'custom',\n layout: 'half',\n component: ({ value, setValue }) => (\n <DictionarySelectField\n kind=\"pipeline-stages\"\n value={typeof value === 'string' ? value : undefined}\n onChange={(next) => setValue(next ?? '')}\n labels={dictionaryLabels.pipeline}\n selectClassName=\"w-full\"\n />\n ),\n } as CrudField,\n {\n id: 'valueAmount',\n label: t('customers.people.detail.deals.fields.valueAmount', 'Amount'),\n type: 'number',\n layout: 'half',\n },\n {\n id: 'valueCurrency',\n label: t('customers.people.detail.deals.fields.valueCurrency', 'Currency'),\n type: 'custom',\n layout: 'half',\n component: ({ value, setValue }) => (\n <div className=\"space-y-1\">\n <DictionaryEntrySelect\n value={typeof value === 'string' ? value : undefined}\n onChange={(next) => setValue(next ?? '')}\n fetchOptions={fetchCurrencyOptions}\n labels={currencyDictionaryLabels}\n manageHref=\"/backend/config/dictionaries?key=currency\"\n allowInlineCreate={false}\n allowAppearance={false}\n selectClassName=\"w-full\"\n disabled={disabled}\n showLabelInput={false}\n />\n {resolvedCurrencyError ? (\n <div className=\"text-xs text-muted-foreground\">{resolvedCurrencyError}</div>\n ) : null}\n </div>\n ),\n } as CrudField,\n {\n id: 'probability',\n label: t('customers.people.detail.deals.fields.probability', 'Probability (%)'),\n type: 'number',\n layout: 'half',\n },\n {\n id: 'expectedCloseAt',\n label: t('customers.people.detail.deals.fields.expectedCloseAt', 'Expected close'),\n type: 'date',\n layout: 'half',\n },\n {\n id: 'description',\n label: t('customers.people.detail.deals.fields.description', 'Description'),\n type: 'textarea',\n },\n {\n id: 'personIds',\n label: t('customers.people.detail.deals.fields.people', 'People'),\n type: 'custom',\n component: ({ value, setValue, autoFocus }) => (\n <EntityMultiSelect\n value={Array.isArray(value) ? value : []}\n onChange={(next) => setValue(next)}\n placeholder={t('customers.deals.form.people.searchPlaceholder', 'Search people\u2026')}\n emptyLabel={t('customers.deals.form.people.empty', 'No people linked yet.')}\n loadingLabel={t('customers.deals.form.people.loading', 'Searching people\u2026')}\n noResultsLabel={t('customers.deals.form.people.noResults', 'No people match your search.')}\n removeLabel={t('customers.deals.form.assignees.remove', 'Remove')}\n errorLabel={t('customers.deals.form.people.error', 'Failed to load people.')}\n search={searchPeople}\n fetchByIds={fetchPeopleByIds}\n disabled={disabled}\n autoFocus={autoFocus}\n />\n ),\n } as CrudField,\n {\n id: 'companyIds',\n label: t('customers.people.detail.deals.fields.companies', 'Companies'),\n type: 'custom',\n component: ({ value, setValue }) => (\n <EntityMultiSelect\n value={Array.isArray(value) ? value : []}\n onChange={(next) => setValue(next)}\n placeholder={t('customers.deals.form.companies.searchPlaceholder', 'Search companies\u2026')}\n emptyLabel={t('customers.deals.form.companies.empty', 'No companies linked yet.')}\n loadingLabel={t('customers.deals.form.companies.loading', 'Searching companies\u2026')}\n noResultsLabel={t('customers.deals.form.companies.noResults', 'No companies match your search.')}\n removeLabel={t('customers.deals.form.assignees.remove', 'Remove')}\n errorLabel={t('customers.deals.form.companies.error', 'Failed to load companies.')}\n search={searchCompanies}\n fetchByIds={fetchCompaniesByIds}\n disabled={disabled}\n />\n ),\n } as CrudField,\n ], [currencyDictionaryLabels, fetchCurrencyOptions, resolvedCurrencyError, dictionaryLabels.pipeline, dictionaryLabels.status, disabled, fetchCompaniesByIds, fetchPeopleByIds, searchCompanies, searchPeople, t])\n\n const groups = React.useMemo<CrudFormGroup[]>(() => [\n {\n id: 'details',\n title: t('customers.people.detail.deals.form.details', 'Deal details'),\n column: 1,\n fields: ['title', 'status', 'pipelineStage', 'valueAmount', 'valueCurrency', 'probability', 'expectedCloseAt', 'description'],\n },\n {\n id: 'associations',\n title: t('customers.people.detail.deals.form.associations', 'Associations'),\n column: 1,\n fields: ['personIds', 'companyIds'],\n },\n {\n id: 'custom',\n title: t('customers.people.detail.deals.form.customFields', 'Custom fields'),\n column: 2,\n kind: 'customFields',\n },\n ], [t])\n\n const embeddedInitialValues = React.useMemo(() => {\n const normalizeNumber = (value: unknown): number | null => {\n if (typeof value === 'number' && Number.isFinite(value)) return value\n if (typeof value === 'string') {\n const parsed = Number(value)\n return Number.isNaN(parsed) ? null : parsed\n }\n return null\n }\n\n const resolveIdsFromSource = (source: unknown): string[] => {\n if (Array.isArray(source)) {\n return sanitizeIdList(\n source.map((entry) => {\n if (typeof entry === 'string') return entry\n if (entry && typeof entry === 'object' && 'id' in entry && typeof (entry as any).id === 'string') {\n return (entry as any).id\n }\n return null\n }),\n )\n }\n return []\n }\n\n return {\n id: typeof initialValues?.id === 'string' ? initialValues.id : undefined,\n title: initialValues?.title ?? '',\n status: initialValues?.status ?? '',\n pipelineStage: initialValues?.pipelineStage ?? '',\n valueAmount: normalizeNumber(initialValues?.valueAmount ?? null),\n valueCurrency: normalizeCurrency(initialValues?.valueCurrency ?? null),\n probability: normalizeNumber(initialValues?.probability ?? null),\n expectedCloseAt: toDateInputValue(initialValues?.expectedCloseAt ?? null),\n description: initialValues?.description ?? '',\n personIds: sanitizeIdList(initialValues?.personIds ?? resolveIdsFromSource(initialValues?.people)),\n companyIds: sanitizeIdList(initialValues?.companyIds ?? resolveIdsFromSource(initialValues?.companies)),\n ...Object.fromEntries(\n Object.entries(initialValues ?? {})\n .filter(([key]) => key.startsWith('cf_'))\n .map(([key, value]) => [key, value]),\n ),\n }\n }, [initialValues])\n\n const handleSubmit = React.useCallback(\n async (values: Record<string, unknown>) => {\n if (pending || isSubmitting) return\n setPending(true)\n try {\n const parsed = schema.safeParse(values)\n if (!parsed.success) {\n throw buildDealValidationError(parsed.error.issues, t)\n }\n const expectedCloseAt =\n parsed.data.expectedCloseAt && parsed.data.expectedCloseAt.length\n ? new Date(parsed.data.expectedCloseAt).toISOString()\n : undefined\n const personIds = sanitizeIdList(parsed.data.personIds)\n const companyIds = sanitizeIdList(parsed.data.companyIds)\n const base: DealFormBaseValues = {\n title: parsed.data.title,\n status: parsed.data.status || undefined,\n pipelineStage: parsed.data.pipelineStage || undefined,\n valueAmount:\n typeof parsed.data.valueAmount === 'number' ? parsed.data.valueAmount : undefined,\n valueCurrency: parsed.data.valueCurrency || undefined,\n probability:\n typeof parsed.data.probability === 'number' ? parsed.data.probability : undefined,\n expectedCloseAt,\n description: parsed.data.description && parsed.data.description.length\n ? parsed.data.description\n : undefined,\n personIds,\n companyIds,\n }\n const customEntries = collectCustomFieldValues(values, {\n transform: (value) => normalizeCustomFieldSubmitValue(value),\n })\n await onSubmit({ base, custom: customEntries })\n } finally {\n setPending(false)\n }\n },\n [isSubmitting, onSubmit, pending, t],\n )\n\n return (\n <CrudForm<Record<string, unknown>>\n embedded={embedded}\n title={title}\n backHref={backHref}\n versionHistory={mode === 'edit' && initialValues?.id\n ? { resourceKind: 'customers.deal', resourceId: String(initialValues.id) }\n : undefined}\n schema={schema}\n fields={baseFields}\n groups={groups}\n entityIds={DEAL_ENTITY_IDS}\n initialValues={embeddedInitialValues}\n onSubmit={handleSubmit}\n onDelete={canDelete ? onDelete : undefined}\n deleteVisible={canDelete}\n submitLabel={\n submitLabel ??\n (mode === 'edit'\n ? t('customers.people.detail.deals.update', 'Update deal (\u2318/Ctrl + Enter)')\n : t('customers.people.detail.deals.save', 'Save deal (\u2318/Ctrl + Enter)'))\n }\n extraActions={(\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={onCancel}\n disabled={pending || isSubmitting}\n >\n {cancelLabel ?? t('customers.people.detail.deals.cancel', 'Cancel')}\n </Button>\n )}\n />\n )\n}\n\nexport function buildDealValidationError(issues: z.ZodIssue[], t: (key: string, fallback?: string) => string) {\n const issue = issues[0]\n const message =\n typeof issue?.message === 'string'\n ? issue.message\n : t('customers.people.detail.deals.error', 'Failed to save deal.')\n const firstPath = Array.isArray(issue?.path) ? issue?.path?.[0] : undefined\n const field = typeof firstPath === 'string' ? firstPath : undefined\n throw createCrudFormError(message, field ? { [field]: message } : undefined)\n}\n\nexport default DealForm\n"],
5
- "mappings": ";AAkVU,SAEE,KAFF;AAhVV,YAAY,WAAW;AACvB,SAAS,SAAS;AAClB,SAAS,YAAY;AACrB,SAAS,gBAAoD;AAC7D,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,2BAA2B;AACpC,SAAS,6BAA6B;AACtC,SAAS,oCAAoC;AAC7C,SAAS,SAAS;AAClB,SAAS,gCAAgC;AACzC,SAAS,6BAA6B;AACtC,SAAS,6BAA6B;AACtC,SAAS,uCAAuC;AAuDhD,MAAM,kBAAkB,CAAC,EAAE,UAAU,aAAa;AAClD,MAAM,oBAAoB,CAAC,OAAO,OAAO,OAAO,KAAK;AAErD,MAAM,SAAS,EAAE,OAAO;AAAA,EACtB,OAAO,EACJ,OAAO,EACP,KAAK,EACL,IAAI,GAAG,6CAA6C,EACpD,IAAI,KAAK,4CAA4C;AAAA,EACxD,QAAQ,EACL,OAAO,EACP,KAAK,EACL,IAAI,IAAI,6CAA6C,EACrD,SAAS;AAAA,EACZ,eAAe,EACZ,OAAO,EACP,KAAK,EACL,IAAI,KAAK,+CAA+C,EACxD,SAAS;AAAA,EACZ,aAAa,EACV,WAAW,CAAC,UAAU;AACrB,QAAI,UAAU,MAAM,UAAU,QAAQ,UAAU,OAAW,QAAO;AAClE,QAAI,OAAO,UAAU,SAAU,QAA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from 'react'\nimport { z } from 'zod'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { CrudForm, type CrudField, type CrudFormGroup } from '@open-mercato/ui/backend/CrudForm'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { createCrudFormError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { DictionarySelectField } from '../formConfig'\nimport { createDictionarySelectLabels } from './utils'\nimport { E } from '#generated/entities.ids.generated'\nimport { collectCustomFieldValues } from '@open-mercato/ui/backend/utils/customFieldValues'\nimport { useCurrencyDictionary } from './hooks/useCurrencyDictionary'\nimport { DictionaryEntrySelect } from '@open-mercato/core/modules/dictionaries/components/DictionaryEntrySelect'\nimport { normalizeCustomFieldSubmitValue } from './customFieldUtils'\n\nexport type DealFormBaseValues = {\n title: string\n status?: string | null\n pipelineStage?: string | null\n pipelineId?: string | null\n pipelineStageId?: string | null\n valueAmount?: number | null\n valueCurrency?: string | null\n probability?: number | null\n expectedCloseAt?: string | null\n description?: string | null\n personIds?: string[]\n companyIds?: string[]\n}\n\nexport type DealFormSubmitPayload = {\n base: DealFormBaseValues\n custom: Record<string, unknown>\n}\n\nexport type DealFormProps = {\n mode: 'create' | 'edit'\n initialValues?: Partial<DealFormBaseValues & Record<string, unknown>>\n onSubmit: (payload: DealFormSubmitPayload) => Promise<void>\n onCancel: () => void\n onDelete?: () => Promise<void> | void\n submitLabel?: string\n cancelLabel?: string\n isSubmitting?: boolean\n embedded?: boolean\n title?: string\n backHref?: string\n}\n\ntype EntityOption = {\n id: string\n label: string\n subtitle?: string | null\n}\n\ntype EntityMultiSelectProps = {\n value: string[]\n onChange: (next: string[]) => void\n placeholder: string\n emptyLabel: string\n loadingLabel: string\n noResultsLabel: string\n removeLabel: string\n errorLabel: string\n search: (query: string) => Promise<EntityOption[]>\n fetchByIds: (ids: string[]) => Promise<EntityOption[]>\n disabled?: boolean\n autoFocus?: boolean\n}\n\nconst DEAL_ENTITY_IDS = [E.customers.customer_deal]\nconst CURRENCY_PRIORITY = ['EUR', 'USD', 'GBP', 'PLN'] as const\n\nconst schema = z.object({\n title: z\n .string()\n .trim()\n .min(1, 'customers.people.detail.deals.titleRequired')\n .max(200, 'customers.people.detail.deals.titleTooLong'),\n status: z\n .string()\n .trim()\n .max(50, 'customers.people.detail.deals.statusTooLong')\n .optional(),\n pipelineStage: z\n .string()\n .trim()\n .max(100, 'customers.people.detail.deals.pipelineTooLong')\n .optional(),\n pipelineId: z.string().uuid().optional(),\n pipelineStageId: z.string().uuid().optional(),\n valueAmount: z\n .preprocess((value) => {\n if (value === '' || value === null || value === undefined) return undefined\n if (typeof value === 'number') return value\n if (typeof value === 'string') {\n const trimmed = value.trim()\n if (!trimmed) return undefined\n const parsed = Number(trimmed)\n if (Number.isNaN(parsed)) return value\n return parsed\n }\n return value\n }, z\n .number()\n .min(0, 'customers.people.detail.deals.valueInvalid')\n .optional())\n .optional(),\n valueCurrency: z\n .string()\n .transform((value) => value.trim().toUpperCase())\n .refine(\n (value) => !value || /^[A-Z]{3}$/.test(value),\n 'customers.people.detail.deals.currencyInvalid',\n )\n .optional(),\n probability: z\n .preprocess((value) => {\n if (value === '' || value === null || value === undefined) return undefined\n if (typeof value === 'number') return value\n if (typeof value === 'string') {\n const trimmed = value.trim()\n if (!trimmed) return undefined\n const parsed = Number(trimmed)\n if (Number.isNaN(parsed)) return value\n return parsed\n }\n return value\n }, z\n .number()\n .min(0, 'customers.people.detail.deals.probabilityInvalid')\n .max(100, 'customers.people.detail.deals.probabilityInvalid')\n .optional())\n .optional(),\n expectedCloseAt: z\n .string()\n .transform((value) => value.trim())\n .refine(\n (value) => {\n if (!value) return true\n const parsed = new Date(value)\n return !Number.isNaN(parsed.getTime())\n },\n 'customers.people.detail.deals.expectedCloseInvalid',\n )\n .optional(),\n description: z.string().max(4000, 'customers.people.detail.deals.descriptionTooLong').optional(),\n personIds: z.array(z.string().trim().min(1)).optional(),\n companyIds: z.array(z.string().trim().min(1)).optional(),\n}).passthrough()\n\nfunction toDateInputValue(value: string | null | undefined): string {\n if (!value) return ''\n const parsed = new Date(value)\n if (Number.isNaN(parsed.getTime())) return ''\n const year = parsed.getUTCFullYear()\n const month = String(parsed.getUTCMonth() + 1).padStart(2, '0')\n const day = String(parsed.getUTCDate()).padStart(2, '0')\n return `${year}-${month}-${day}`\n}\n\nfunction normalizeCurrency(value: string | null | undefined): string {\n if (!value) return ''\n return value.trim().slice(0, 3).toUpperCase()\n}\n\nfunction sanitizeIdList(input: unknown): string[] {\n if (!Array.isArray(input)) return []\n const set = new Set<string>()\n input.forEach((candidate) => {\n if (typeof candidate !== 'string') return\n const trimmed = candidate.trim()\n if (!trimmed.length) return\n set.add(trimmed)\n })\n return Array.from(set)\n}\n\nfunction extractPersonOption(record: Record<string, unknown>): EntityOption | null {\n const id = typeof record.id === 'string' ? record.id : null\n if (!id) return null\n const displayName =\n typeof record.displayName === 'string' && record.displayName.trim().length\n ? record.displayName.trim()\n : typeof record.display_name === 'string' && record.display_name.trim().length\n ? (record.display_name as string).trim()\n : null\n const email =\n typeof record.primaryEmail === 'string' && record.primaryEmail.trim().length\n ? record.primaryEmail.trim()\n : typeof record.primary_email === 'string' && record.primary_email.trim().length\n ? (record.primary_email as string).trim()\n : null\n const label = displayName ?? email ?? id\n const subtitle = email && email !== label ? email : null\n return { id, label, subtitle }\n}\n\nfunction extractCompanyOption(record: Record<string, unknown>): EntityOption | null {\n const id = typeof record.id === 'string' ? record.id : null\n if (!id) return null\n const displayName =\n typeof record.displayName === 'string' && record.displayName.trim().length\n ? record.displayName.trim()\n : typeof record.display_name === 'string' && record.display_name.trim().length\n ? (record.display_name as string).trim()\n : null\n const domain =\n typeof record.domain === 'string' && record.domain.trim().length\n ? record.domain.trim()\n : typeof record.websiteUrl === 'string' && record.websiteUrl.trim().length\n ? record.websiteUrl.trim()\n : typeof record.website_url === 'string' && record.website_url.trim().length\n ? (record.website_url as string).trim()\n : null\n const label = displayName ?? domain ?? id\n const subtitle = domain && domain !== label ? domain : null\n return { id, label, subtitle }\n}\n\nfunction EntityMultiSelect({\n value,\n onChange,\n placeholder,\n emptyLabel,\n loadingLabel,\n noResultsLabel,\n removeLabel,\n errorLabel,\n search,\n fetchByIds,\n disabled = false,\n autoFocus = false,\n}: EntityMultiSelectProps) {\n const [input, setInput] = React.useState('')\n const [suggestions, setSuggestions] = React.useState<EntityOption[]>([])\n const [cache, setCache] = React.useState<Map<string, EntityOption>>(() => new Map())\n const [loading, setLoading] = React.useState(false)\n const [error, setError] = React.useState<string | null>(null)\n\n const normalizedValue = React.useMemo(() => sanitizeIdList(value), [value])\n\n React.useEffect(() => {\n if (!normalizedValue.length) return\n const missing = normalizedValue.filter((id) => !cache.has(id))\n if (!missing.length) return\n let cancelled = false\n ;(async () => {\n try {\n const entries = await fetchByIds(missing)\n if (cancelled) return\n setCache((prev) => {\n const next = new Map(prev)\n entries.forEach((entry) => {\n if (entry?.id) next.set(entry.id, entry)\n })\n return next\n })\n } catch {\n if (!cancelled) setError(errorLabel)\n }\n })().catch(() => {})\n return () => { cancelled = true }\n }, [cache, errorLabel, fetchByIds, normalizedValue])\n\n React.useEffect(() => {\n if (disabled) {\n setLoading(false)\n return\n }\n let cancelled = false\n const handler = window.setTimeout(async () => {\n setLoading(true)\n try {\n const results = await search(input.trim())\n if (cancelled) return\n setSuggestions(results)\n setCache((prev) => {\n const next = new Map(prev)\n results.forEach((entry) => {\n if (entry?.id) next.set(entry.id, entry)\n })\n return next\n })\n setError(null)\n } catch {\n if (!cancelled) {\n setError(errorLabel)\n setSuggestions([])\n }\n } finally {\n if (!cancelled) setLoading(false)\n }\n }, 200)\n return () => {\n cancelled = true\n window.clearTimeout(handler)\n }\n }, [disabled, errorLabel, input, search])\n\n const filteredSuggestions = React.useMemo(\n () => suggestions.filter((option) => !normalizedValue.includes(option.id)),\n [normalizedValue, suggestions],\n )\n\n const selectedOptions = React.useMemo(\n () => normalizedValue.map((id) => cache.get(id) ?? { id, label: id }),\n [cache, normalizedValue],\n )\n\n const addOption = React.useCallback(\n (option: EntityOption) => {\n if (!option?.id) return\n if (normalizedValue.includes(option.id)) return\n const next = [...normalizedValue, option.id]\n onChange(next)\n setCache((prev) => {\n const nextCache = new Map(prev)\n nextCache.set(option.id, option)\n return nextCache\n })\n setInput('')\n setSuggestions([])\n },\n [normalizedValue, onChange],\n )\n\n const removeOption = React.useCallback(\n (id: string) => {\n const next = normalizedValue.filter((candidate) => candidate !== id)\n onChange(next)\n },\n [normalizedValue, onChange],\n )\n\n return (\n <div className=\"space-y-2\">\n <div className=\"flex flex-wrap items-center gap-2 rounded border px-2 py-1\">\n {selectedOptions.map((option) => (\n <span key={option.id} className=\"inline-flex items-center gap-1 rounded bg-muted px-2 py-0.5 text-xs\">\n {option.label}\n <IconButton\n variant=\"ghost\"\n size=\"xs\"\n className=\"opacity-60 hover:opacity-100\"\n onClick={() => removeOption(option.id)}\n aria-label={`${removeLabel} ${option.label}`}\n disabled={disabled}\n >\n \u00D7\n </IconButton>\n </span>\n ))}\n <input\n type=\"text\"\n className=\"flex-1 min-w-[160px] border-0 bg-transparent py-1 text-sm outline-none\"\n value={input}\n placeholder={placeholder}\n onChange={(event) => setInput(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === 'Enter') {\n event.preventDefault()\n const nextOption = filteredSuggestions[0]\n if (nextOption) addOption(nextOption)\n } else if (event.key === 'Backspace' && !input.length && normalizedValue.length) {\n removeOption(normalizedValue[normalizedValue.length - 1])\n }\n }}\n disabled={disabled}\n autoFocus={autoFocus}\n data-crud-focus-target=\"\"\n />\n </div>\n {loading ? <div className=\"text-xs text-muted-foreground\">{loadingLabel}</div> : null}\n {!loading && filteredSuggestions.length ? (\n <div className=\"flex flex-wrap gap-2\">\n {filteredSuggestions.slice(0, 10).map((option) => (\n <Button\n key={option.id}\n variant=\"outline\"\n size=\"sm\"\n className=\"h-auto px-2 py-1 text-xs font-normal\"\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => addOption(option)}\n disabled={disabled}\n >\n <span className=\"flex flex-col items-start\">\n <span>{option.label}</span>\n {option.subtitle ? (\n <span className=\"text-[10px] text-muted-foreground\">{option.subtitle}</span>\n ) : null}\n </span>\n </Button>\n ))}\n </div>\n ) : null}\n {!loading && !filteredSuggestions.length && input.trim().length ? (\n <div className=\"text-xs text-muted-foreground\">{noResultsLabel}</div>\n ) : null}\n {error ? <div className=\"text-xs text-red-600\">{error}</div> : null}\n {!normalizedValue.length && !input.trim().length ? (\n <div className=\"text-xs text-muted-foreground\">{emptyLabel}</div>\n ) : null}\n </div>\n )\n}\n\nexport function DealForm({\n mode,\n initialValues,\n onSubmit,\n onCancel,\n onDelete,\n submitLabel,\n cancelLabel,\n isSubmitting = false,\n embedded = true,\n title,\n backHref,\n}: DealFormProps) {\n const t = useT()\n const [pending, setPending] = React.useState(false)\n const {\n data: currencyDictionaryData,\n error: currencyDictionaryErrorRaw,\n isLoading: currencyDictionaryLoading,\n refetch: refetchCurrencyDictionary,\n } = useCurrencyDictionary()\n const currencyDictionaryError = currencyDictionaryErrorRaw\n ? currencyDictionaryErrorRaw instanceof Error\n ? currencyDictionaryErrorRaw.message\n : String(currencyDictionaryErrorRaw)\n : null\n\n const translate = React.useCallback(\n (key: string, fallback: string) => {\n const value = t(key)\n return value === key ? fallback : value\n },\n [t],\n )\n\n const dictionaryLabels = React.useMemo(() => ({\n status: createDictionarySelectLabels('deal-statuses', translate),\n }), [translate])\n\n const resolvedCurrencyError = React.useMemo(() => {\n if (currencyDictionaryError) return currencyDictionaryError\n if (!currencyDictionaryLoading && !currencyDictionaryData) {\n return t('customers.deals.form.currency.missing', 'Currency dictionary is not configured yet.')\n }\n return null\n }, [currencyDictionaryData, currencyDictionaryError, currencyDictionaryLoading, t])\n\n const fetchCurrencyOptions = React.useCallback(async () => {\n let payload = currencyDictionaryData ?? null\n if (!payload) {\n try {\n payload = await refetchCurrencyDictionary()\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err ?? '')\n throw new Error(message || t('customers.deals.form.currency.error', 'Failed to load currency dictionary.'))\n }\n }\n if (!payload) {\n throw new Error(t('customers.deals.form.currency.missing', 'Currency dictionary is not configured yet.'))\n }\n const priorityOrder = new Map<string, number>()\n CURRENCY_PRIORITY.forEach((code, index) => priorityOrder.set(code, index))\n const prioritized: { value: string; label: string; color: string | null; icon: string | null }[] = []\n const remainder: { value: string; label: string; color: string | null; icon: string | null }[] = []\n payload.entries.forEach((entry) => {\n const value = entry.value.toUpperCase()\n const label = entry.label && entry.label.length ? `${value} \u2013 ${entry.label}` : value\n const option = { value, label, color: null, icon: null }\n if (priorityOrder.has(value)) prioritized.push(option)\n else remainder.push(option)\n })\n prioritized.sort((a, b) => (priorityOrder.get(a.value)! - priorityOrder.get(b.value)!))\n remainder.sort((a, b) => a.label.localeCompare(b.label, undefined, { sensitivity: 'base' }))\n return [...prioritized, ...remainder]\n }, [currencyDictionaryData, refetchCurrencyDictionary, t])\n\n const currencyDictionaryLabels = React.useMemo(() => ({\n placeholder: t('customers.deals.form.currency.placeholder', 'Select currency\u2026'),\n addLabel: t('customers.deals.form.currency.add', 'Add currency'),\n dialogTitle: t('customers.deals.form.currency.dialogTitle', 'Add currency'),\n valueLabel: t('customers.deals.form.currency.valueLabel', 'Currency code'),\n valuePlaceholder: t('customers.deals.form.currency.valuePlaceholder', 'e.g. USD'),\n labelLabel: t('customers.deals.form.currency.labelLabel', 'Label'),\n labelPlaceholder: t('customers.deals.form.currency.labelPlaceholder', 'Display name shown in UI'),\n emptyError: t('customers.deals.form.currency.error.required', 'Currency code is required.'),\n cancelLabel: t('customers.deals.form.currency.cancel', 'Cancel'),\n saveLabel: t('customers.deals.form.currency.save', 'Save'),\n errorLoad: t('customers.deals.form.currency.error', 'Failed to load currency dictionary.'),\n errorSave: t('customers.deals.form.currency.error', 'Failed to load currency dictionary.'),\n loadingLabel: t('customers.deals.form.currency.loading', 'Loading currencies\u2026'),\n manageTitle: t('customers.deals.form.currency.manage', 'Manage currency dictionary'),\n }), [t])\n\n const searchPeople = React.useCallback(async (query: string): Promise<EntityOption[]> => {\n const params = new URLSearchParams({\n pageSize: '20',\n sortField: 'name',\n sortDir: 'asc',\n })\n if (query.trim().length) params.set('search', query.trim())\n const call = await apiCall<Record<string, unknown>>(`/api/customers/people?${params.toString()}`)\n if (!call.ok) {\n throw new Error(typeof call.result?.error === 'string' ? String(call.result?.error) : 'Failed to search people')\n }\n const payload = call.result ?? {}\n const items = Array.isArray(payload.items) ? payload.items : []\n return items\n .map((item: unknown) => (item && typeof item === 'object' ? extractPersonOption(item as Record<string, unknown>) : null))\n .filter((entry: EntityOption | null): entry is EntityOption => entry !== null)\n }, [])\n\n const fetchPeopleByIds = React.useCallback(async (ids: string[]): Promise<EntityOption[]> => {\n const unique = sanitizeIdList(ids)\n if (!unique.length) return []\n const results = await Promise.all(unique.map(async (id) => {\n try {\n const call = await apiCall<Record<string, unknown>>(`/api/customers/people?id=${encodeURIComponent(id)}&pageSize=1`)\n if (!call.ok) throw new Error()\n const payload = call.result ?? {}\n const items = Array.isArray(payload.items) ? payload.items : []\n const option = items\n .map((item: unknown) => (item && typeof item === 'object' ? extractPersonOption(item as Record<string, unknown>) : null))\n .find((candidate: EntityOption | null): candidate is EntityOption => candidate !== null)\n return option ?? { id, label: id }\n } catch {\n return { id, label: id }\n }\n }))\n return results\n }, [])\n\n const searchCompanies = React.useCallback(async (query: string): Promise<EntityOption[]> => {\n const params = new URLSearchParams({\n pageSize: '20',\n sortField: 'name',\n sortDir: 'asc',\n })\n if (query.trim().length) params.set('search', query.trim())\n const call = await apiCall<Record<string, unknown>>(`/api/customers/companies?${params.toString()}`)\n if (!call.ok) {\n throw new Error(typeof call.result?.error === 'string' ? String(call.result?.error) : 'Failed to search companies')\n }\n const payload = call.result ?? {}\n const items = Array.isArray(payload.items) ? payload.items : []\n return items\n .map((item: unknown) => (item && typeof item === 'object' ? extractCompanyOption(item as Record<string, unknown>) : null))\n .filter((entry: EntityOption | null): entry is EntityOption => entry !== null)\n }, [])\n\n const fetchCompaniesByIds = React.useCallback(async (ids: string[]): Promise<EntityOption[]> => {\n const unique = sanitizeIdList(ids)\n if (!unique.length) return []\n const results = await Promise.all(unique.map(async (id) => {\n try {\n const call = await apiCall<Record<string, unknown>>(`/api/customers/companies?id=${encodeURIComponent(id)}&pageSize=1`)\n if (!call.ok) throw new Error()\n const payload = call.result ?? {}\n const items = Array.isArray(payload.items) ? payload.items : []\n const option = items\n .map((item: unknown) => (item && typeof item === 'object' ? extractCompanyOption(item as Record<string, unknown>) : null))\n .find((candidate: EntityOption | null): candidate is EntityOption => candidate !== null)\n return option ?? { id, label: id }\n } catch {\n return { id, label: id }\n }\n }))\n return results\n }, [])\n\n const disabled = pending || isSubmitting\n const canDelete = mode === 'edit' && typeof onDelete === 'function'\n\n type PipelineOption = { id: string; name: string; isDefault: boolean }\n type PipelineStageOption = { id: string; label: string; order: number }\n\n const [pipelines, setPipelines] = React.useState<PipelineOption[]>([])\n const [pipelineStages, setPipelineStages] = React.useState<PipelineStageOption[]>([])\n\n const loadStagesForPipeline = React.useCallback(async (pipelineId: string) => {\n if (!pipelineId) {\n setPipelineStages([])\n return\n }\n try {\n const call = await apiCall<{ items: PipelineStageOption[] }>(`/api/customers/pipeline-stages?pipelineId=${encodeURIComponent(pipelineId)}`)\n if (call.ok && call.result?.items) {\n const sorted = [...call.result.items].sort((a, b) => a.order - b.order)\n setPipelineStages(sorted)\n }\n } catch {\n setPipelineStages([])\n }\n }, [])\n\n React.useEffect(() => {\n let cancelled = false\n ;(async () => {\n try {\n const call = await apiCall<{ items: PipelineOption[] }>('/api/customers/pipelines')\n if (cancelled) return\n if (call.ok && call.result?.items) {\n setPipelines(call.result.items)\n }\n } catch {\n // ignore\n }\n })().catch(() => {})\n return () => { cancelled = true }\n }, [])\n\n React.useEffect(() => {\n const pid = initialValues?.pipelineId\n if (typeof pid === 'string' && pid.length) {\n loadStagesForPipeline(pid).catch(() => {})\n }\n }, [initialValues?.pipelineId, loadStagesForPipeline])\n\n const baseFields = React.useMemo<CrudField[]>(() => [\n {\n id: 'title',\n label: t('customers.people.detail.deals.fields.title', 'Title'),\n type: 'text',\n required: true,\n },\n {\n id: 'status',\n label: t('customers.people.detail.deals.fields.status', 'Status'),\n type: 'custom',\n layout: 'half',\n component: ({ value, setValue }) => (\n <DictionarySelectField\n kind=\"deal-statuses\"\n value={typeof value === 'string' ? value : undefined}\n onChange={(next) => setValue(next ?? '')}\n labels={dictionaryLabels.status}\n selectClassName=\"w-full\"\n />\n ),\n } as CrudField,\n {\n id: 'pipelineId',\n label: t('customers.people.detail.deals.fields.pipeline', 'Pipeline'),\n type: 'custom',\n layout: 'half',\n component: ({ value, setValue }) => (\n <select\n className=\"w-full rounded border px-2 py-1.5 text-sm\"\n value={typeof value === 'string' ? value : ''}\n onChange={(e) => {\n setValue(e.target.value)\n loadStagesForPipeline(e.target.value).catch(() => {})\n }}\n disabled={disabled}\n >\n <option value=\"\">{t('customers.deals.form.pipeline.placeholder', 'Select pipeline\u2026')}</option>\n {pipelines.map((p) => (\n <option key={p.id} value={p.id}>{p.name}</option>\n ))}\n </select>\n ),\n } as CrudField,\n {\n id: 'pipelineStageId',\n label: t('customers.people.detail.deals.fields.pipelineStage', 'Pipeline stage'),\n type: 'custom',\n layout: 'half',\n component: ({ value, setValue }) => (\n <select\n className=\"w-full rounded border px-2 py-1.5 text-sm\"\n value={typeof value === 'string' ? value : ''}\n onChange={(e) => setValue(e.target.value)}\n disabled={disabled || !pipelineStages.length}\n >\n <option value=\"\">{t('customers.deals.form.pipelineStage.placeholder', 'Select stage\u2026')}</option>\n {pipelineStages.map((s) => (\n <option key={s.id} value={s.id}>{s.label}</option>\n ))}\n </select>\n ),\n } as CrudField,\n {\n id: 'valueAmount',\n label: t('customers.people.detail.deals.fields.valueAmount', 'Amount'),\n type: 'number',\n layout: 'half',\n },\n {\n id: 'valueCurrency',\n label: t('customers.people.detail.deals.fields.valueCurrency', 'Currency'),\n type: 'custom',\n layout: 'half',\n component: ({ value, setValue }) => (\n <div className=\"space-y-1\">\n <DictionaryEntrySelect\n value={typeof value === 'string' ? value : undefined}\n onChange={(next) => setValue(next ?? '')}\n fetchOptions={fetchCurrencyOptions}\n labels={currencyDictionaryLabels}\n manageHref=\"/backend/config/dictionaries?key=currency\"\n allowInlineCreate={false}\n allowAppearance={false}\n selectClassName=\"w-full\"\n disabled={disabled}\n showLabelInput={false}\n />\n {resolvedCurrencyError ? (\n <div className=\"text-xs text-muted-foreground\">{resolvedCurrencyError}</div>\n ) : null}\n </div>\n ),\n } as CrudField,\n {\n id: 'probability',\n label: t('customers.people.detail.deals.fields.probability', 'Probability (%)'),\n type: 'number',\n layout: 'half',\n },\n {\n id: 'expectedCloseAt',\n label: t('customers.people.detail.deals.fields.expectedCloseAt', 'Expected close'),\n type: 'date',\n layout: 'half',\n },\n {\n id: 'description',\n label: t('customers.people.detail.deals.fields.description', 'Description'),\n type: 'textarea',\n },\n {\n id: 'personIds',\n label: t('customers.people.detail.deals.fields.people', 'People'),\n type: 'custom',\n component: ({ value, setValue, autoFocus }) => (\n <EntityMultiSelect\n value={Array.isArray(value) ? value : []}\n onChange={(next) => setValue(next)}\n placeholder={t('customers.deals.form.people.searchPlaceholder', 'Search people\u2026')}\n emptyLabel={t('customers.deals.form.people.empty', 'No people linked yet.')}\n loadingLabel={t('customers.deals.form.people.loading', 'Searching people\u2026')}\n noResultsLabel={t('customers.deals.form.people.noResults', 'No people match your search.')}\n removeLabel={t('customers.deals.form.assignees.remove', 'Remove')}\n errorLabel={t('customers.deals.form.people.error', 'Failed to load people.')}\n search={searchPeople}\n fetchByIds={fetchPeopleByIds}\n disabled={disabled}\n autoFocus={autoFocus}\n />\n ),\n } as CrudField,\n {\n id: 'companyIds',\n label: t('customers.people.detail.deals.fields.companies', 'Companies'),\n type: 'custom',\n component: ({ value, setValue }) => (\n <EntityMultiSelect\n value={Array.isArray(value) ? value : []}\n onChange={(next) => setValue(next)}\n placeholder={t('customers.deals.form.companies.searchPlaceholder', 'Search companies\u2026')}\n emptyLabel={t('customers.deals.form.companies.empty', 'No companies linked yet.')}\n loadingLabel={t('customers.deals.form.companies.loading', 'Searching companies\u2026')}\n noResultsLabel={t('customers.deals.form.companies.noResults', 'No companies match your search.')}\n removeLabel={t('customers.deals.form.assignees.remove', 'Remove')}\n errorLabel={t('customers.deals.form.companies.error', 'Failed to load companies.')}\n search={searchCompanies}\n fetchByIds={fetchCompaniesByIds}\n disabled={disabled}\n />\n ),\n } as CrudField,\n ], [currencyDictionaryLabels, fetchCurrencyOptions, resolvedCurrencyError, pipelines, pipelineStages, loadStagesForPipeline, dictionaryLabels.status, disabled, fetchCompaniesByIds, fetchPeopleByIds, searchCompanies, searchPeople, t])\n\n const groups = React.useMemo<CrudFormGroup[]>(() => [\n {\n id: 'details',\n title: t('customers.people.detail.deals.form.details', 'Deal details'),\n column: 1,\n fields: ['title', 'status', 'pipelineId', 'pipelineStageId', 'valueAmount', 'valueCurrency', 'probability', 'expectedCloseAt', 'description'],\n },\n {\n id: 'associations',\n title: t('customers.people.detail.deals.form.associations', 'Associations'),\n column: 1,\n fields: ['personIds', 'companyIds'],\n },\n {\n id: 'custom',\n title: t('customers.people.detail.deals.form.customFields', 'Custom fields'),\n column: 2,\n kind: 'customFields',\n },\n ], [t])\n\n const embeddedInitialValues = React.useMemo(() => {\n const normalizeNumber = (value: unknown): number | null => {\n if (typeof value === 'number' && Number.isFinite(value)) return value\n if (typeof value === 'string') {\n const parsed = Number(value)\n return Number.isNaN(parsed) ? null : parsed\n }\n return null\n }\n\n const resolveIdsFromSource = (source: unknown): string[] => {\n if (Array.isArray(source)) {\n return sanitizeIdList(\n source.map((entry) => {\n if (typeof entry === 'string') return entry\n if (entry && typeof entry === 'object' && 'id' in entry && typeof (entry as any).id === 'string') {\n return (entry as any).id\n }\n return null\n }),\n )\n }\n return []\n }\n\n return {\n id: typeof initialValues?.id === 'string' ? initialValues.id : undefined,\n title: initialValues?.title ?? '',\n status: initialValues?.status ?? '',\n pipelineStage: initialValues?.pipelineStage ?? '',\n pipelineId: initialValues?.pipelineId ?? (typeof (initialValues as Record<string, unknown>)?.pipeline_id === 'string' ? (initialValues as Record<string, unknown>).pipeline_id as string : ''),\n pipelineStageId: initialValues?.pipelineStageId ?? (typeof (initialValues as Record<string, unknown>)?.pipeline_stage_id === 'string' ? (initialValues as Record<string, unknown>).pipeline_stage_id as string : ''),\n valueAmount: normalizeNumber(initialValues?.valueAmount ?? null),\n valueCurrency: normalizeCurrency(initialValues?.valueCurrency ?? null),\n probability: normalizeNumber(initialValues?.probability ?? null),\n expectedCloseAt: toDateInputValue(initialValues?.expectedCloseAt ?? null),\n description: initialValues?.description ?? '',\n personIds: sanitizeIdList(initialValues?.personIds ?? resolveIdsFromSource(initialValues?.people)),\n companyIds: sanitizeIdList(initialValues?.companyIds ?? resolveIdsFromSource(initialValues?.companies)),\n ...Object.fromEntries(\n Object.entries(initialValues ?? {})\n .filter(([key]) => key.startsWith('cf_'))\n .map(([key, value]) => [key, value]),\n ),\n }\n }, [initialValues])\n\n const handleSubmit = React.useCallback(\n async (values: Record<string, unknown>) => {\n if (pending || isSubmitting) return\n setPending(true)\n try {\n const parsed = schema.safeParse(values)\n if (!parsed.success) {\n throw buildDealValidationError(parsed.error.issues, t)\n }\n const expectedCloseAt =\n parsed.data.expectedCloseAt && parsed.data.expectedCloseAt.length\n ? new Date(parsed.data.expectedCloseAt).toISOString()\n : undefined\n const personIds = sanitizeIdList(parsed.data.personIds)\n const companyIds = sanitizeIdList(parsed.data.companyIds)\n const base: DealFormBaseValues = {\n title: parsed.data.title,\n status: parsed.data.status || undefined,\n pipelineStage: parsed.data.pipelineStage || undefined,\n pipelineId: parsed.data.pipelineId || undefined,\n pipelineStageId: parsed.data.pipelineStageId || undefined,\n valueAmount:\n typeof parsed.data.valueAmount === 'number' ? parsed.data.valueAmount : undefined,\n valueCurrency: parsed.data.valueCurrency || undefined,\n probability:\n typeof parsed.data.probability === 'number' ? parsed.data.probability : undefined,\n expectedCloseAt,\n description: parsed.data.description && parsed.data.description.length\n ? parsed.data.description\n : undefined,\n personIds,\n companyIds,\n }\n const customEntries = collectCustomFieldValues(values, {\n transform: (value) => normalizeCustomFieldSubmitValue(value),\n })\n await onSubmit({ base, custom: customEntries })\n } finally {\n setPending(false)\n }\n },\n [isSubmitting, onSubmit, pending, t],\n )\n\n return (\n <CrudForm<Record<string, unknown>>\n embedded={embedded}\n title={title}\n backHref={backHref}\n versionHistory={mode === 'edit' && initialValues?.id\n ? { resourceKind: 'customers.deal', resourceId: String(initialValues.id) }\n : undefined}\n schema={schema}\n fields={baseFields}\n groups={groups}\n entityIds={DEAL_ENTITY_IDS}\n initialValues={embeddedInitialValues}\n onSubmit={handleSubmit}\n onDelete={canDelete ? onDelete : undefined}\n deleteVisible={canDelete}\n submitLabel={\n submitLabel ??\n (mode === 'edit'\n ? t('customers.people.detail.deals.update', 'Update deal (\u2318/Ctrl + Enter)')\n : t('customers.people.detail.deals.save', 'Save deal (\u2318/Ctrl + Enter)'))\n }\n extraActions={(\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={onCancel}\n disabled={pending || isSubmitting}\n >\n {cancelLabel ?? t('customers.people.detail.deals.cancel', 'Cancel')}\n </Button>\n )}\n />\n )\n}\n\nexport function buildDealValidationError(issues: z.ZodIssue[], t: (key: string, fallback?: string) => string) {\n const issue = issues[0]\n const message =\n typeof issue?.message === 'string'\n ? issue.message\n : t('customers.people.detail.deals.error', 'Failed to save deal.')\n const firstPath = Array.isArray(issue?.path) ? issue?.path?.[0] : undefined\n const field = typeof firstPath === 'string' ? firstPath : undefined\n throw createCrudFormError(message, field ? { [field]: message } : undefined)\n}\n\nexport default DealForm\n"],
5
+ "mappings": ";AAsVU,SAEE,KAFF;AApVV,YAAY,WAAW;AACvB,SAAS,SAAS;AAClB,SAAS,YAAY;AACrB,SAAS,gBAAoD;AAC7D,SAAS,cAAc;AACvB,SAAS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