@open-mercato/core 0.5.1-develop.2663.2c29774b5b → 0.5.1-develop.2681.c559bb2bc3

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 (687) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/generated/entities/action_log/index.js +8 -0
  3. package/dist/generated/entities/action_log/index.js.map +2 -2
  4. package/dist/generated/entities/customer_company_billing/index.js +23 -0
  5. package/dist/generated/entities/customer_company_billing/index.js.map +7 -0
  6. package/dist/generated/entities/customer_deal/index.js +8 -0
  7. package/dist/generated/entities/customer_deal/index.js.map +2 -2
  8. package/dist/generated/entities/customer_deal_stage_transition/index.js +31 -0
  9. package/dist/generated/entities/customer_deal_stage_transition/index.js.map +7 -0
  10. package/dist/generated/entities/customer_dictionary_kind_setting/index.js +21 -0
  11. package/dist/generated/entities/customer_dictionary_kind_setting/index.js.map +7 -0
  12. package/dist/generated/entities/customer_entity/index.js +8 -0
  13. package/dist/generated/entities/customer_entity/index.js.map +2 -2
  14. package/dist/generated/entities/customer_entity_role/index.js +23 -0
  15. package/dist/generated/entities/customer_entity_role/index.js.map +7 -0
  16. package/dist/generated/entities/customer_interaction/index.js +23 -1
  17. package/dist/generated/entities/customer_interaction/index.js.map +2 -2
  18. package/dist/generated/entities/customer_label/index.js +19 -0
  19. package/dist/generated/entities/customer_label/index.js.map +7 -0
  20. package/dist/generated/entities/customer_label_assignment/index.js +17 -0
  21. package/dist/generated/entities/customer_label_assignment/index.js.map +7 -0
  22. package/dist/generated/entities/customer_person_company_link/index.js +21 -0
  23. package/dist/generated/entities/customer_person_company_link/index.js.map +7 -0
  24. package/dist/generated/entities/customer_person_company_role/index.js +17 -0
  25. package/dist/generated/entities/customer_person_company_role/index.js.map +7 -0
  26. package/dist/generated/entities/dictionary_entry/index.js +4 -0
  27. package/dist/generated/entities/dictionary_entry/index.js.map +2 -2
  28. package/dist/generated/entities.ids.generated.js +9 -1
  29. package/dist/generated/entities.ids.generated.js.map +2 -2
  30. package/dist/generated/entity-fields-registry.js +116 -1
  31. package/dist/generated/entity-fields-registry.js.map +2 -2
  32. package/dist/modules/attachments/api/route.js +46 -8
  33. package/dist/modules/attachments/api/route.js.map +2 -2
  34. package/dist/modules/audit_logs/api/audit-logs/actions/export/route.js +208 -0
  35. package/dist/modules/audit_logs/api/audit-logs/actions/export/route.js.map +7 -0
  36. package/dist/modules/audit_logs/api/audit-logs/actions/route.js +52 -6
  37. package/dist/modules/audit_logs/api/audit-logs/actions/route.js.map +2 -2
  38. package/dist/modules/audit_logs/cli.js +62 -0
  39. package/dist/modules/audit_logs/cli.js.map +7 -0
  40. package/dist/modules/audit_logs/data/entities.js +21 -1
  41. package/dist/modules/audit_logs/data/entities.js.map +2 -2
  42. package/dist/modules/audit_logs/data/validators.js +9 -1
  43. package/dist/modules/audit_logs/data/validators.js.map +2 -2
  44. package/dist/modules/audit_logs/lib/changeRows.js +34 -0
  45. package/dist/modules/audit_logs/lib/changeRows.js.map +7 -0
  46. package/dist/modules/audit_logs/lib/display-helpers.js +2 -20
  47. package/dist/modules/audit_logs/lib/display-helpers.js.map +3 -3
  48. package/dist/modules/audit_logs/lib/projections.js +58 -0
  49. package/dist/modules/audit_logs/lib/projections.js.map +7 -0
  50. package/dist/modules/audit_logs/migrations/Migration20260412160533.js +21 -0
  51. package/dist/modules/audit_logs/migrations/Migration20260412160533.js.map +7 -0
  52. package/dist/modules/audit_logs/services/actionLogService.js +313 -79
  53. package/dist/modules/audit_logs/services/actionLogService.js.map +2 -2
  54. package/dist/modules/customers/acl.js +3 -1
  55. package/dist/modules/customers/acl.js.map +2 -2
  56. package/dist/modules/customers/api/activities/route.js +4 -0
  57. package/dist/modules/customers/api/activities/route.js.map +2 -2
  58. package/dist/modules/customers/api/assignable-staff/route.js +208 -0
  59. package/dist/modules/customers/api/assignable-staff/route.js.map +7 -0
  60. package/dist/modules/customers/api/companies/[id]/people/route.js +205 -0
  61. package/dist/modules/customers/api/companies/[id]/people/route.js.map +7 -0
  62. package/dist/modules/customers/api/companies/[id]/roles/route.js +22 -0
  63. package/dist/modules/customers/api/companies/[id]/roles/route.js.map +7 -0
  64. package/dist/modules/customers/api/companies/[id]/route.js +374 -32
  65. package/dist/modules/customers/api/companies/[id]/route.js.map +2 -2
  66. package/dist/modules/customers/api/companies/route.js +82 -7
  67. package/dist/modules/customers/api/companies/route.js.map +2 -2
  68. package/dist/modules/customers/api/deals/[id]/companies/route.js +172 -0
  69. package/dist/modules/customers/api/deals/[id]/companies/route.js.map +7 -0
  70. package/dist/modules/customers/api/deals/[id]/people/route.js +156 -0
  71. package/dist/modules/customers/api/deals/[id]/people/route.js.map +7 -0
  72. package/dist/modules/customers/api/deals/[id]/route.js +459 -53
  73. package/dist/modules/customers/api/deals/[id]/route.js.map +2 -2
  74. package/dist/modules/customers/api/deals/[id]/stats/route.js +195 -0
  75. package/dist/modules/customers/api/deals/[id]/stats/route.js.map +7 -0
  76. package/dist/modules/customers/api/deals/route.js +20 -10
  77. package/dist/modules/customers/api/deals/route.js.map +3 -3
  78. package/dist/modules/customers/api/dictionaries/[kind]/[id]/route.js +105 -4
  79. package/dist/modules/customers/api/dictionaries/[kind]/[id]/route.js.map +2 -2
  80. package/dist/modules/customers/api/dictionaries/[kind]/route.js +118 -42
  81. package/dist/modules/customers/api/dictionaries/[kind]/route.js.map +2 -2
  82. package/dist/modules/customers/api/dictionaries/context.js +30 -6
  83. package/dist/modules/customers/api/dictionaries/context.js.map +2 -2
  84. package/dist/modules/customers/api/dictionaries/kind-settings/route.js +207 -0
  85. package/dist/modules/customers/api/dictionaries/kind-settings/route.js.map +7 -0
  86. package/dist/modules/customers/api/entity-roles-factory.js +471 -0
  87. package/dist/modules/customers/api/entity-roles-factory.js.map +7 -0
  88. package/dist/modules/customers/api/interactions/conflicts/route.js +158 -0
  89. package/dist/modules/customers/api/interactions/conflicts/route.js.map +7 -0
  90. package/dist/modules/customers/api/interactions/counts/route.js +92 -0
  91. package/dist/modules/customers/api/interactions/counts/route.js.map +7 -0
  92. package/dist/modules/customers/api/interactions/route.js +83 -4
  93. package/dist/modules/customers/api/interactions/route.js.map +2 -2
  94. package/dist/modules/customers/api/labels/assign/route.js +189 -0
  95. package/dist/modules/customers/api/labels/assign/route.js.map +7 -0
  96. package/dist/modules/customers/api/labels/auth.js +17 -0
  97. package/dist/modules/customers/api/labels/auth.js.map +7 -0
  98. package/dist/modules/customers/api/labels/route.js +281 -0
  99. package/dist/modules/customers/api/labels/route.js.map +7 -0
  100. package/dist/modules/customers/api/labels/table-errors.js +38 -0
  101. package/dist/modules/customers/api/labels/table-errors.js.map +7 -0
  102. package/dist/modules/customers/api/labels/unassign/route.js +184 -0
  103. package/dist/modules/customers/api/labels/unassign/route.js.map +7 -0
  104. package/dist/modules/customers/api/people/[id]/companies/[linkId]/route.js +292 -0
  105. package/dist/modules/customers/api/people/[id]/companies/[linkId]/route.js.map +7 -0
  106. package/dist/modules/customers/api/people/[id]/companies/context.js +66 -0
  107. package/dist/modules/customers/api/people/[id]/companies/context.js.map +7 -0
  108. package/dist/modules/customers/api/people/[id]/companies/enriched/route.js +334 -0
  109. package/dist/modules/customers/api/people/[id]/companies/enriched/route.js.map +7 -0
  110. package/dist/modules/customers/api/people/[id]/companies/route.js +205 -0
  111. package/dist/modules/customers/api/people/[id]/companies/route.js.map +7 -0
  112. package/dist/modules/customers/api/people/[id]/roles/route.js +22 -0
  113. package/dist/modules/customers/api/people/[id]/roles/route.js.map +7 -0
  114. package/dist/modules/customers/api/people/[id]/route.js +134 -21
  115. package/dist/modules/customers/api/people/[id]/route.js.map +2 -2
  116. package/dist/modules/customers/api/people/route.js +122 -23
  117. package/dist/modules/customers/api/people/route.js.map +2 -2
  118. package/dist/modules/customers/api/todos/route.js +4 -0
  119. package/dist/modules/customers/api/todos/route.js.map +2 -2
  120. package/dist/modules/customers/api/utils.js +22 -0
  121. package/dist/modules/customers/api/utils.js.map +2 -2
  122. package/dist/modules/customers/backend/config/customers/page.js +2 -6
  123. package/dist/modules/customers/backend/config/customers/page.js.map +2 -2
  124. package/dist/modules/customers/backend/customers/companies/page.js +37 -26
  125. package/dist/modules/customers/backend/customers/companies/page.js.map +2 -2
  126. package/dist/modules/customers/backend/customers/companies-v2/[id]/page.js +265 -262
  127. package/dist/modules/customers/backend/customers/companies-v2/[id]/page.js.map +3 -3
  128. package/dist/modules/customers/backend/customers/deals/[id]/hooks/formatters.js +23 -0
  129. package/dist/modules/customers/backend/customers/deals/[id]/hooks/formatters.js.map +7 -0
  130. package/dist/modules/customers/backend/customers/deals/[id]/hooks/types.js +1 -0
  131. package/dist/modules/customers/backend/customers/deals/[id]/hooks/types.js.map +7 -0
  132. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealActivities.js +43 -0
  133. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealActivities.js.map +7 -0
  134. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealAssociations.js +264 -0
  135. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealAssociations.js.map +7 -0
  136. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealClosure.js +88 -0
  137. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealClosure.js.map +7 -0
  138. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealData.js +41 -0
  139. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealData.js.map +7 -0
  140. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealFormHandlers.js +66 -0
  141. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealFormHandlers.js.map +7 -0
  142. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealInjectedTabs.js +39 -0
  143. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealInjectedTabs.js.map +7 -0
  144. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealMutationContext.js +49 -0
  145. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealMutationContext.js.map +7 -0
  146. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealPipeline.js +43 -0
  147. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealPipeline.js.map +7 -0
  148. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useScheduleDialog.js +28 -0
  149. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useScheduleDialog.js.map +7 -0
  150. package/dist/modules/customers/backend/customers/deals/[id]/page.js +556 -503
  151. package/dist/modules/customers/backend/customers/deals/[id]/page.js.map +3 -3
  152. package/dist/modules/customers/backend/customers/deals/page.js +66 -21
  153. package/dist/modules/customers/backend/customers/deals/page.js.map +2 -2
  154. package/dist/modules/customers/backend/customers/people/page.js +36 -28
  155. package/dist/modules/customers/backend/customers/people/page.js.map +2 -2
  156. package/dist/modules/customers/backend/customers/people-v2/[id]/page.js +318 -203
  157. package/dist/modules/customers/backend/customers/people-v2/[id]/page.js.map +3 -3
  158. package/dist/modules/customers/cli.js +105 -13
  159. package/dist/modules/customers/cli.js.map +2 -2
  160. package/dist/modules/customers/commands/activities.js +6 -0
  161. package/dist/modules/customers/commands/activities.js.map +2 -2
  162. package/dist/modules/customers/commands/deals.js +315 -107
  163. package/dist/modules/customers/commands/deals.js.map +2 -2
  164. package/dist/modules/customers/commands/dictionaries.js +166 -32
  165. package/dist/modules/customers/commands/dictionaries.js.map +2 -2
  166. package/dist/modules/customers/commands/dictionaryKindSettings.js +208 -0
  167. package/dist/modules/customers/commands/dictionaryKindSettings.js.map +7 -0
  168. package/dist/modules/customers/commands/entity-roles.js +415 -0
  169. package/dist/modules/customers/commands/entity-roles.js.map +7 -0
  170. package/dist/modules/customers/commands/index.js +4 -0
  171. package/dist/modules/customers/commands/index.js.map +2 -2
  172. package/dist/modules/customers/commands/interactions.js +108 -21
  173. package/dist/modules/customers/commands/interactions.js.map +2 -2
  174. package/dist/modules/customers/commands/labels.js +539 -0
  175. package/dist/modules/customers/commands/labels.js.map +7 -0
  176. package/dist/modules/customers/commands/people.js +560 -463
  177. package/dist/modules/customers/commands/people.js.map +3 -3
  178. package/dist/modules/customers/commands/personCompanyLinks.js +568 -0
  179. package/dist/modules/customers/commands/personCompanyLinks.js.map +7 -0
  180. package/dist/modules/customers/commands/shared.js +12 -4
  181. package/dist/modules/customers/commands/shared.js.map +2 -2
  182. package/dist/modules/customers/commands/todos.js +10 -1
  183. package/dist/modules/customers/commands/todos.js.map +2 -2
  184. package/dist/modules/customers/components/AddressEditor.js +1 -1
  185. package/dist/modules/customers/components/AddressEditor.js.map +2 -2
  186. package/dist/modules/customers/components/CustomersConfigurationSections.js +31 -0
  187. package/dist/modules/customers/components/CustomersConfigurationSections.js.map +7 -0
  188. package/dist/modules/customers/components/DictionarySettings.js +37 -2
  189. package/dist/modules/customers/components/DictionarySettings.js.map +2 -2
  190. package/dist/modules/customers/components/detail/ActiveDealCard.js +121 -0
  191. package/dist/modules/customers/components/detail/ActiveDealCard.js.map +7 -0
  192. package/dist/modules/customers/components/detail/ActivitiesSection.js +222 -331
  193. package/dist/modules/customers/components/detail/ActivitiesSection.js.map +3 -3
  194. package/dist/modules/customers/components/detail/ActivityAiActions.js +36 -0
  195. package/dist/modules/customers/components/detail/ActivityAiActions.js.map +7 -0
  196. package/dist/modules/customers/components/detail/ActivityCard.js +126 -0
  197. package/dist/modules/customers/components/detail/ActivityCard.js.map +7 -0
  198. package/dist/modules/customers/components/detail/ActivityHistorySection.js +340 -0
  199. package/dist/modules/customers/components/detail/ActivityHistorySection.js.map +7 -0
  200. package/dist/modules/customers/components/detail/ActivityLogTab.js +56 -0
  201. package/dist/modules/customers/components/detail/ActivityLogTab.js.map +7 -0
  202. package/dist/modules/customers/components/detail/ActivityTimeline.js +108 -0
  203. package/dist/modules/customers/components/detail/ActivityTimeline.js.map +7 -0
  204. package/dist/modules/customers/components/detail/ActivityTimelineFilters.js +139 -0
  205. package/dist/modules/customers/components/detail/ActivityTimelineFilters.js.map +7 -0
  206. package/dist/modules/customers/components/detail/ActivityTypeSelector.js +42 -0
  207. package/dist/modules/customers/components/detail/ActivityTypeSelector.js.map +7 -0
  208. package/dist/modules/customers/components/detail/AiActionChips.js +38 -0
  209. package/dist/modules/customers/components/detail/AiActionChips.js.map +7 -0
  210. package/dist/modules/customers/components/detail/AssignRoleDialog.js +534 -0
  211. package/dist/modules/customers/components/detail/AssignRoleDialog.js.map +7 -0
  212. package/dist/modules/customers/components/detail/ChangelogEntryRow.js +79 -0
  213. package/dist/modules/customers/components/detail/ChangelogEntryRow.js.map +7 -0
  214. package/dist/modules/customers/components/detail/ChangelogFilters.js +176 -0
  215. package/dist/modules/customers/components/detail/ChangelogFilters.js.map +7 -0
  216. package/dist/modules/customers/components/detail/ChangelogKpiCards.js +88 -0
  217. package/dist/modules/customers/components/detail/ChangelogKpiCards.js.map +7 -0
  218. package/dist/modules/customers/components/detail/ChangelogTab.js +470 -0
  219. package/dist/modules/customers/components/detail/ChangelogTab.js.map +7 -0
  220. package/dist/modules/customers/components/detail/ComingSoonPlaceholder.js +16 -0
  221. package/dist/modules/customers/components/detail/ComingSoonPlaceholder.js.map +7 -0
  222. package/dist/modules/customers/components/detail/CompanyCard.js +283 -0
  223. package/dist/modules/customers/components/detail/CompanyCard.js.map +7 -0
  224. package/dist/modules/customers/components/detail/CompanyDashboardTab.js +133 -0
  225. package/dist/modules/customers/components/detail/CompanyDashboardTab.js.map +7 -0
  226. package/dist/modules/customers/components/detail/CompanyDetailHeader.js +191 -0
  227. package/dist/modules/customers/components/detail/CompanyDetailHeader.js.map +7 -0
  228. package/dist/modules/customers/components/detail/CompanyDetailTabs.js +123 -0
  229. package/dist/modules/customers/components/detail/CompanyDetailTabs.js.map +7 -0
  230. package/dist/modules/customers/components/detail/CompanyKpiBar.js +174 -0
  231. package/dist/modules/customers/components/detail/CompanyKpiBar.js.map +7 -0
  232. package/dist/modules/customers/components/detail/CompanyPeopleSection.js +514 -230
  233. package/dist/modules/customers/components/detail/CompanyPeopleSection.js.map +2 -2
  234. package/dist/modules/customers/components/detail/CompanyTagsDialog.js +22 -0
  235. package/dist/modules/customers/components/detail/CompanyTagsDialog.js.map +7 -0
  236. package/dist/modules/customers/components/detail/ConfirmDealLostDialog.js +159 -0
  237. package/dist/modules/customers/components/detail/ConfirmDealLostDialog.js.map +7 -0
  238. package/dist/modules/customers/components/detail/CreatePersonDialog.js +135 -0
  239. package/dist/modules/customers/components/detail/CreatePersonDialog.js.map +7 -0
  240. package/dist/modules/customers/components/detail/DealClosureActionBar.js +59 -0
  241. package/dist/modules/customers/components/detail/DealClosureActionBar.js.map +7 -0
  242. package/dist/modules/customers/components/detail/DealDetailHeader.js +237 -0
  243. package/dist/modules/customers/components/detail/DealDetailHeader.js.map +7 -0
  244. package/dist/modules/customers/components/detail/DealDetailTabs.js +109 -0
  245. package/dist/modules/customers/components/detail/DealDetailTabs.js.map +7 -0
  246. package/dist/modules/customers/components/detail/DealForm.js +219 -92
  247. package/dist/modules/customers/components/detail/DealForm.js.map +2 -2
  248. package/dist/modules/customers/components/detail/DealLinkedEntitiesTab.js +295 -0
  249. package/dist/modules/customers/components/detail/DealLinkedEntitiesTab.js.map +7 -0
  250. package/dist/modules/customers/components/detail/DealLostSummaryDialog.js +107 -0
  251. package/dist/modules/customers/components/detail/DealLostSummaryDialog.js.map +7 -0
  252. package/dist/modules/customers/components/detail/DealWonPopup.js +113 -0
  253. package/dist/modules/customers/components/detail/DealWonPopup.js.map +7 -0
  254. package/dist/modules/customers/components/detail/DealsSection.js +206 -193
  255. package/dist/modules/customers/components/detail/DealsSection.js.map +2 -2
  256. package/dist/modules/customers/components/detail/DecisionMakersFooter.js +39 -0
  257. package/dist/modules/customers/components/detail/DecisionMakersFooter.js.map +7 -0
  258. package/dist/modules/customers/components/detail/EntityTagsDialog.js +1096 -0
  259. package/dist/modules/customers/components/detail/EntityTagsDialog.js.map +7 -0
  260. package/dist/modules/customers/components/detail/InlineActivityComposer.js +197 -0
  261. package/dist/modules/customers/components/detail/InlineActivityComposer.js.map +7 -0
  262. package/dist/modules/customers/components/detail/ManageTagsDialog.js +1091 -0
  263. package/dist/modules/customers/components/detail/ManageTagsDialog.js.map +7 -0
  264. package/dist/modules/customers/components/detail/MiniWeekCalendar.js +272 -0
  265. package/dist/modules/customers/components/detail/MiniWeekCalendar.js.map +7 -0
  266. package/dist/modules/customers/components/detail/MobilePersonDetail.js +106 -0
  267. package/dist/modules/customers/components/detail/MobilePersonDetail.js.map +7 -0
  268. package/dist/modules/customers/components/detail/NextStepCard.js +72 -0
  269. package/dist/modules/customers/components/detail/NextStepCard.js.map +7 -0
  270. package/dist/modules/customers/components/detail/PersonCard.js +192 -0
  271. package/dist/modules/customers/components/detail/PersonCard.js.map +7 -0
  272. package/dist/modules/customers/components/detail/PersonCompaniesSection.js +345 -0
  273. package/dist/modules/customers/components/detail/PersonCompaniesSection.js.map +7 -0
  274. package/dist/modules/customers/components/detail/PersonDetailHeader.js +220 -0
  275. package/dist/modules/customers/components/detail/PersonDetailHeader.js.map +7 -0
  276. package/dist/modules/customers/components/detail/PersonDetailTabs.js +122 -0
  277. package/dist/modules/customers/components/detail/PersonDetailTabs.js.map +7 -0
  278. package/dist/modules/customers/components/detail/PersonTagsDialog.js +24 -0
  279. package/dist/modules/customers/components/detail/PersonTagsDialog.js.map +7 -0
  280. package/dist/modules/customers/components/detail/PipelineStepper.js +191 -0
  281. package/dist/modules/customers/components/detail/PipelineStepper.js.map +7 -0
  282. package/dist/modules/customers/components/detail/PlannedActivitiesSection.js +222 -0
  283. package/dist/modules/customers/components/detail/PlannedActivitiesSection.js.map +7 -0
  284. package/dist/modules/customers/components/detail/RelationshipHealthCard.js +49 -0
  285. package/dist/modules/customers/components/detail/RelationshipHealthCard.js.map +7 -0
  286. package/dist/modules/customers/components/detail/RoleAssignmentRow.js +189 -0
  287. package/dist/modules/customers/components/detail/RoleAssignmentRow.js.map +7 -0
  288. package/dist/modules/customers/components/detail/RolesSection.js +234 -0
  289. package/dist/modules/customers/components/detail/RolesSection.js.map +7 -0
  290. package/dist/modules/customers/components/detail/ScheduleActivityDialog.js +410 -0
  291. package/dist/modules/customers/components/detail/ScheduleActivityDialog.js.map +7 -0
  292. package/dist/modules/customers/components/detail/aiActionCatalog.js +41 -0
  293. package/dist/modules/customers/components/detail/aiActionCatalog.js.map +7 -0
  294. package/dist/modules/customers/components/detail/assignableStaff.js +48 -0
  295. package/dist/modules/customers/components/detail/assignableStaff.js.map +7 -0
  296. package/dist/modules/customers/components/detail/dashboard/ActiveDealWidget.js +48 -0
  297. package/dist/modules/customers/components/detail/dashboard/ActiveDealWidget.js.map +7 -0
  298. package/dist/modules/customers/components/detail/dashboard/OpenTasksWidget.js +86 -0
  299. package/dist/modules/customers/components/detail/dashboard/OpenTasksWidget.js.map +7 -0
  300. package/dist/modules/customers/components/detail/dashboard/RecentActivityWidget.js +53 -0
  301. package/dist/modules/customers/components/detail/dashboard/RecentActivityWidget.js.map +7 -0
  302. package/dist/modules/customers/components/detail/dashboard/RelationshipHealthWidget.js +30 -0
  303. package/dist/modules/customers/components/detail/dashboard/RelationshipHealthWidget.js.map +7 -0
  304. package/dist/modules/customers/components/detail/dashboard/UpcomingMeetingsWidget.js +43 -0
  305. package/dist/modules/customers/components/detail/dashboard/UpcomingMeetingsWidget.js.map +7 -0
  306. package/dist/modules/customers/components/detail/dashboard/helpers.js +71 -0
  307. package/dist/modules/customers/components/detail/dashboard/helpers.js.map +7 -0
  308. package/dist/modules/customers/components/detail/healthScoreUtils.js +69 -0
  309. package/dist/modules/customers/components/detail/healthScoreUtils.js.map +7 -0
  310. package/dist/modules/customers/components/detail/hooks/useCurrencyDictionary.js +5 -5
  311. package/dist/modules/customers/components/detail/hooks/useCurrencyDictionary.js.map +2 -2
  312. package/dist/modules/customers/components/detail/hooks/useCustomerDictionary.js +9 -8
  313. package/dist/modules/customers/components/detail/hooks/useCustomerDictionary.js.map +3 -3
  314. package/dist/modules/customers/components/detail/hooks/useInteractionMutations.js +65 -0
  315. package/dist/modules/customers/components/detail/hooks/useInteractionMutations.js.map +7 -0
  316. package/dist/modules/customers/components/detail/notesAdapter.js +70 -30
  317. package/dist/modules/customers/components/detail/notesAdapter.js.map +2 -2
  318. package/dist/modules/customers/components/detail/pipelineStageUtils.js +26 -0
  319. package/dist/modules/customers/components/detail/pipelineStageUtils.js.map +7 -0
  320. package/dist/modules/customers/components/detail/schedule/DateTimeFields.js +144 -0
  321. package/dist/modules/customers/components/detail/schedule/DateTimeFields.js.map +7 -0
  322. package/dist/modules/customers/components/detail/schedule/FooterFields.js +60 -0
  323. package/dist/modules/customers/components/detail/schedule/FooterFields.js.map +7 -0
  324. package/dist/modules/customers/components/detail/schedule/LinkedEntitiesField.js +216 -0
  325. package/dist/modules/customers/components/detail/schedule/LinkedEntitiesField.js.map +7 -0
  326. package/dist/modules/customers/components/detail/schedule/LocationField.js +34 -0
  327. package/dist/modules/customers/components/detail/schedule/LocationField.js.map +7 -0
  328. package/dist/modules/customers/components/detail/schedule/ParticipantsField.js +226 -0
  329. package/dist/modules/customers/components/detail/schedule/ParticipantsField.js.map +7 -0
  330. package/dist/modules/customers/components/detail/schedule/fieldConfig.js +69 -0
  331. package/dist/modules/customers/components/detail/schedule/fieldConfig.js.map +7 -0
  332. package/dist/modules/customers/components/detail/schedule/index.js +21 -0
  333. package/dist/modules/customers/components/detail/schedule/index.js.map +7 -0
  334. package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js +172 -0
  335. package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js.map +7 -0
  336. package/dist/modules/customers/components/detail/utils.js +23 -0
  337. package/dist/modules/customers/components/detail/utils.js.map +2 -2
  338. package/dist/modules/customers/components/formConfig.js +144 -22
  339. package/dist/modules/customers/components/formConfig.js.map +2 -2
  340. package/dist/modules/customers/components/linking/LinkEntityDialog.js +661 -0
  341. package/dist/modules/customers/components/linking/LinkEntityDialog.js.map +7 -0
  342. package/dist/modules/customers/components/linking/adapters/companyAdapter.js +252 -0
  343. package/dist/modules/customers/components/linking/adapters/companyAdapter.js.map +7 -0
  344. package/dist/modules/customers/components/linking/adapters/dealAdapter.js +384 -0
  345. package/dist/modules/customers/components/linking/adapters/dealAdapter.js.map +7 -0
  346. package/dist/modules/customers/components/linking/adapters/personAdapter.js +324 -0
  347. package/dist/modules/customers/components/linking/adapters/personAdapter.js.map +7 -0
  348. package/dist/modules/customers/components/list/CollectionPreviewCell.js +53 -0
  349. package/dist/modules/customers/components/list/CollectionPreviewCell.js.map +7 -0
  350. package/dist/modules/customers/data/entities.js +407 -1
  351. package/dist/modules/customers/data/entities.js.map +2 -2
  352. package/dist/modules/customers/data/validators.js +139 -21
  353. package/dist/modules/customers/data/validators.js.map +2 -2
  354. package/dist/modules/customers/events.js +19 -1
  355. package/dist/modules/customers/events.js.map +2 -2
  356. package/dist/modules/customers/lib/customerRoleTypes.js +19 -0
  357. package/dist/modules/customers/lib/customerRoleTypes.js.map +7 -0
  358. package/dist/modules/customers/lib/dealClosureNotification.js +39 -0
  359. package/dist/modules/customers/lib/dealClosureNotification.js.map +7 -0
  360. package/dist/modules/customers/lib/dealStageTransitionTable.js +29 -0
  361. package/dist/modules/customers/lib/dealStageTransitionTable.js.map +7 -0
  362. package/dist/modules/customers/lib/dictionaries.js +25 -0
  363. package/dist/modules/customers/lib/dictionaries.js.map +2 -2
  364. package/dist/modules/customers/lib/interactionReadModel.js +10 -0
  365. package/dist/modules/customers/lib/interactionReadModel.js.map +2 -2
  366. package/dist/modules/customers/lib/personCompanies.js +235 -0
  367. package/dist/modules/customers/lib/personCompanies.js.map +7 -0
  368. package/dist/modules/customers/lib/personCompanyLinkTable.js +42 -0
  369. package/dist/modules/customers/lib/personCompanyLinkTable.js.map +7 -0
  370. package/dist/modules/customers/lib/roleTypeUsage.js +104 -0
  371. package/dist/modules/customers/lib/roleTypeUsage.js.map +7 -0
  372. package/dist/modules/customers/migrations/Migration20260406214502.js +18 -0
  373. package/dist/modules/customers/migrations/Migration20260406214502.js.map +7 -0
  374. package/dist/modules/customers/migrations/Migration20260408135736.js +17 -0
  375. package/dist/modules/customers/migrations/Migration20260408135736.js.map +7 -0
  376. package/dist/modules/customers/migrations/Migration20260408225345.js +21 -0
  377. package/dist/modules/customers/migrations/Migration20260408225345.js.map +7 -0
  378. package/dist/modules/customers/migrations/Migration20260411075533.js +27 -0
  379. package/dist/modules/customers/migrations/Migration20260411075533.js.map +7 -0
  380. package/dist/modules/customers/migrations/Migration20260411103551.js +13 -0
  381. package/dist/modules/customers/migrations/Migration20260411103551.js.map +7 -0
  382. package/dist/modules/customers/migrations/Migration20260411130944.js +26 -0
  383. package/dist/modules/customers/migrations/Migration20260411130944.js.map +7 -0
  384. package/dist/modules/customers/migrations/Migration20260415095203.js +13 -0
  385. package/dist/modules/customers/migrations/Migration20260415095203.js.map +7 -0
  386. package/dist/modules/customers/migrations/Migration20260415135056.js +20 -0
  387. package/dist/modules/customers/migrations/Migration20260415135056.js.map +7 -0
  388. package/dist/modules/customers/migrations/Migration20260417140000.js +15 -0
  389. package/dist/modules/customers/migrations/Migration20260417140000.js.map +7 -0
  390. package/dist/modules/customers/migrations/Migration20260417160000.js +17 -0
  391. package/dist/modules/customers/migrations/Migration20260417160000.js.map +7 -0
  392. package/dist/modules/customers/migrations/Migration20260417235407.js +13 -0
  393. package/dist/modules/customers/migrations/Migration20260417235407.js.map +7 -0
  394. package/dist/modules/customers/setup.js +16 -1
  395. package/dist/modules/customers/setup.js.map +2 -2
  396. package/dist/modules/customers/subscribers/deal-closure-notification.js +16 -0
  397. package/dist/modules/customers/subscribers/deal-closure-notification.js.map +7 -0
  398. package/dist/modules/customers/subscribers/deal-lost-notification.js +16 -0
  399. package/dist/modules/customers/subscribers/deal-lost-notification.js.map +7 -0
  400. package/dist/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.js +2 -0
  401. package/dist/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.js.map +2 -2
  402. package/dist/modules/dictionaries/api/[dictionaryId]/entries/reorder/route.js +154 -0
  403. package/dist/modules/dictionaries/api/[dictionaryId]/entries/reorder/route.js.map +7 -0
  404. package/dist/modules/dictionaries/api/[dictionaryId]/entries/route.js +6 -2
  405. package/dist/modules/dictionaries/api/[dictionaryId]/entries/route.js.map +2 -2
  406. package/dist/modules/dictionaries/api/[dictionaryId]/entries/set-default/route.js +154 -0
  407. package/dist/modules/dictionaries/api/[dictionaryId]/entries/set-default/route.js.map +7 -0
  408. package/dist/modules/dictionaries/api/context.js +8 -1
  409. package/dist/modules/dictionaries/api/context.js.map +2 -2
  410. package/dist/modules/dictionaries/api/openapi.js +18 -1
  411. package/dist/modules/dictionaries/api/openapi.js.map +2 -2
  412. package/dist/modules/dictionaries/commands/entry-operations.js +388 -0
  413. package/dist/modules/dictionaries/commands/entry-operations.js.map +7 -0
  414. package/dist/modules/dictionaries/commands/factory.js +24 -3
  415. package/dist/modules/dictionaries/commands/factory.js.map +2 -2
  416. package/dist/modules/dictionaries/commands/index.js +1 -0
  417. package/dist/modules/dictionaries/commands/index.js.map +2 -2
  418. package/dist/modules/dictionaries/components/DictionaryTable.js +6 -3
  419. package/dist/modules/dictionaries/components/DictionaryTable.js.map +2 -2
  420. package/dist/modules/dictionaries/data/entities.js +11 -1
  421. package/dist/modules/dictionaries/data/entities.js.map +2 -2
  422. package/dist/modules/dictionaries/data/validators.js +28 -2
  423. package/dist/modules/dictionaries/data/validators.js.map +2 -2
  424. package/dist/modules/dictionaries/events.js +18 -0
  425. package/dist/modules/dictionaries/events.js.map +7 -0
  426. package/dist/modules/dictionaries/lib/clientEntries.js +43 -0
  427. package/dist/modules/dictionaries/lib/clientEntries.js.map +7 -0
  428. package/dist/modules/dictionaries/migrations/Migration20260410171544.js +45 -0
  429. package/dist/modules/dictionaries/migrations/Migration20260410171544.js.map +7 -0
  430. package/dist/modules/inbox_ops/api/proposals/[id]/route.js +4 -1
  431. package/dist/modules/inbox_ops/api/proposals/[id]/route.js.map +2 -2
  432. package/dist/modules/query_index/lib/engine.js +1 -1
  433. package/dist/modules/query_index/lib/engine.js.map +2 -2
  434. package/dist/modules/sales/components/documents/AddressesSection.js +82 -42
  435. package/dist/modules/sales/components/documents/AddressesSection.js.map +2 -2
  436. package/dist/modules/sales/lib/dictionaries.js +16 -0
  437. package/dist/modules/sales/lib/dictionaries.js.map +2 -2
  438. package/dist/modules/sales/widgets/injection-table.js +5 -1
  439. package/dist/modules/sales/widgets/injection-table.js.map +2 -2
  440. package/generated/entities/action_log/index.ts +4 -0
  441. package/generated/entities/customer_company_billing/index.ts +10 -0
  442. package/generated/entities/customer_deal/index.ts +4 -0
  443. package/generated/entities/customer_deal_stage_transition/index.ts +14 -0
  444. package/generated/entities/customer_dictionary_kind_setting/index.ts +9 -0
  445. package/generated/entities/customer_entity/index.ts +4 -0
  446. package/generated/entities/customer_entity_role/index.ts +10 -0
  447. package/generated/entities/customer_interaction/index.ts +11 -0
  448. package/generated/entities/customer_label/index.ts +8 -0
  449. package/generated/entities/customer_label_assignment/index.ts +7 -0
  450. package/generated/entities/customer_person_company_link/index.ts +9 -0
  451. package/generated/entities/customer_person_company_role/index.ts +7 -0
  452. package/generated/entities/dictionary_entry/index.ts +2 -0
  453. package/generated/entities.ids.generated.ts +9 -1
  454. package/generated/entity-fields-registry.ts +116 -1
  455. package/package.json +3 -3
  456. package/src/modules/attachments/api/route.ts +48 -6
  457. package/src/modules/attachments/i18n/de.json +4 -0
  458. package/src/modules/attachments/i18n/en.json +4 -0
  459. package/src/modules/attachments/i18n/es.json +4 -0
  460. package/src/modules/attachments/i18n/pl.json +4 -0
  461. package/src/modules/audit_logs/api/audit-logs/actions/export/route.ts +260 -0
  462. package/src/modules/audit_logs/api/audit-logs/actions/route.ts +81 -6
  463. package/src/modules/audit_logs/cli.ts +79 -0
  464. package/src/modules/audit_logs/data/entities.ts +17 -0
  465. package/src/modules/audit_logs/data/validators.ts +9 -1
  466. package/src/modules/audit_logs/lib/changeRows.ts +47 -0
  467. package/src/modules/audit_logs/lib/display-helpers.tsx +4 -30
  468. package/src/modules/audit_logs/lib/projections.ts +110 -0
  469. package/src/modules/audit_logs/migrations/.snapshot-open-mercato.json +325 -2
  470. package/src/modules/audit_logs/migrations/Migration20260412160533.ts +21 -0
  471. package/src/modules/audit_logs/services/actionLogService.ts +455 -85
  472. package/src/modules/catalog/i18n/de.json +1 -0
  473. package/src/modules/catalog/i18n/en.json +1 -0
  474. package/src/modules/catalog/i18n/es.json +1 -0
  475. package/src/modules/catalog/i18n/pl.json +1 -0
  476. package/src/modules/customer_accounts/i18n/de.json +2 -0
  477. package/src/modules/customer_accounts/i18n/en.json +2 -0
  478. package/src/modules/customer_accounts/i18n/es.json +2 -0
  479. package/src/modules/customer_accounts/i18n/pl.json +2 -0
  480. package/src/modules/customers/acl.ts +2 -0
  481. package/src/modules/customers/api/activities/route.ts +4 -0
  482. package/src/modules/customers/api/assignable-staff/route.ts +250 -0
  483. package/src/modules/customers/api/companies/[id]/people/route.ts +244 -0
  484. package/src/modules/customers/api/companies/[id]/roles/route.ts +15 -0
  485. package/src/modules/customers/api/companies/[id]/route.ts +458 -40
  486. package/src/modules/customers/api/companies/route.ts +93 -15
  487. package/src/modules/customers/api/deals/[id]/companies/route.ts +203 -0
  488. package/src/modules/customers/api/deals/[id]/people/route.ts +182 -0
  489. package/src/modules/customers/api/deals/[id]/route.ts +554 -57
  490. package/src/modules/customers/api/deals/[id]/stats/route.ts +221 -0
  491. package/src/modules/customers/api/deals/route.ts +35 -46
  492. package/src/modules/customers/api/dictionaries/[kind]/[id]/route.ts +105 -3
  493. package/src/modules/customers/api/dictionaries/[kind]/route.ts +143 -44
  494. package/src/modules/customers/api/dictionaries/context.ts +45 -16
  495. package/src/modules/customers/api/dictionaries/kind-settings/route.ts +232 -0
  496. package/src/modules/customers/api/entity-roles-factory.ts +520 -0
  497. package/src/modules/customers/api/interactions/conflicts/route.ts +196 -0
  498. package/src/modules/customers/api/interactions/counts/route.ts +112 -0
  499. package/src/modules/customers/api/interactions/route.ts +95 -2
  500. package/src/modules/customers/api/labels/assign/route.ts +202 -0
  501. package/src/modules/customers/api/labels/auth.ts +19 -0
  502. package/src/modules/customers/api/labels/route.ts +310 -0
  503. package/src/modules/customers/api/labels/table-errors.ts +36 -0
  504. package/src/modules/customers/api/labels/unassign/route.ts +197 -0
  505. package/src/modules/customers/api/people/[id]/companies/[linkId]/route.ts +331 -0
  506. package/src/modules/customers/api/people/[id]/companies/context.ts +70 -0
  507. package/src/modules/customers/api/people/[id]/companies/enriched/route.ts +384 -0
  508. package/src/modules/customers/api/people/[id]/companies/route.ts +215 -0
  509. package/src/modules/customers/api/people/[id]/roles/route.ts +15 -0
  510. package/src/modules/customers/api/people/[id]/route.ts +153 -26
  511. package/src/modules/customers/api/people/route.ts +134 -31
  512. package/src/modules/customers/api/todos/route.ts +4 -0
  513. package/src/modules/customers/api/utils.ts +36 -0
  514. package/src/modules/customers/backend/config/customers/page.tsx +2 -6
  515. package/src/modules/customers/backend/customers/companies/page.tsx +36 -26
  516. package/src/modules/customers/backend/customers/companies-v2/[id]/page.tsx +277 -262
  517. package/src/modules/customers/backend/customers/deals/[id]/hooks/formatters.ts +19 -0
  518. package/src/modules/customers/backend/customers/deals/[id]/hooks/types.ts +104 -0
  519. package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealActivities.ts +60 -0
  520. package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealAssociations.ts +362 -0
  521. package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealClosure.ts +113 -0
  522. package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealData.ts +52 -0
  523. package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealFormHandlers.ts +86 -0
  524. package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealInjectedTabs.tsx +60 -0
  525. package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealMutationContext.ts +76 -0
  526. package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealPipeline.ts +56 -0
  527. package/src/modules/customers/backend/customers/deals/[id]/hooks/useScheduleDialog.ts +38 -0
  528. package/src/modules/customers/backend/customers/deals/[id]/page.tsx +587 -624
  529. package/src/modules/customers/backend/customers/deals/page.tsx +71 -28
  530. package/src/modules/customers/backend/customers/people/page.tsx +35 -29
  531. package/src/modules/customers/backend/customers/people-v2/[id]/page.tsx +343 -209
  532. package/src/modules/customers/cli.ts +107 -12
  533. package/src/modules/customers/commands/activities.ts +13 -0
  534. package/src/modules/customers/commands/deals.ts +386 -114
  535. package/src/modules/customers/commands/dictionaries.ts +175 -32
  536. package/src/modules/customers/commands/dictionaryKindSettings.ts +268 -0
  537. package/src/modules/customers/commands/entity-roles.ts +494 -0
  538. package/src/modules/customers/commands/index.ts +4 -0
  539. package/src/modules/customers/commands/interactions.ts +125 -21
  540. package/src/modules/customers/commands/labels.ts +626 -0
  541. package/src/modules/customers/commands/people.ts +373 -259
  542. package/src/modules/customers/commands/personCompanyLinks.ts +654 -0
  543. package/src/modules/customers/commands/shared.ts +16 -15
  544. package/src/modules/customers/commands/todos.ts +17 -1
  545. package/src/modules/customers/components/AddressEditor.tsx +1 -1
  546. package/src/modules/customers/components/CustomersConfigurationSections.tsx +36 -0
  547. package/src/modules/customers/components/DictionarySettings.tsx +43 -2
  548. package/src/modules/customers/components/detail/ActiveDealCard.tsx +175 -0
  549. package/src/modules/customers/components/detail/ActivitiesSection.tsx +267 -361
  550. package/src/modules/customers/components/detail/ActivityAiActions.tsx +49 -0
  551. package/src/modules/customers/components/detail/ActivityCard.tsx +154 -0
  552. package/src/modules/customers/components/detail/ActivityHistorySection.tsx +412 -0
  553. package/src/modules/customers/components/detail/ActivityLogTab.tsx +67 -0
  554. package/src/modules/customers/components/detail/ActivityTimeline.tsx +158 -0
  555. package/src/modules/customers/components/detail/ActivityTimelineFilters.tsx +163 -0
  556. package/src/modules/customers/components/detail/ActivityTypeSelector.tsx +53 -0
  557. package/src/modules/customers/components/detail/AiActionChips.tsx +48 -0
  558. package/src/modules/customers/components/detail/AssignRoleDialog.tsx +672 -0
  559. package/src/modules/customers/components/detail/ChangelogEntryRow.tsx +132 -0
  560. package/src/modules/customers/components/detail/ChangelogFilters.tsx +193 -0
  561. package/src/modules/customers/components/detail/ChangelogKpiCards.tsx +107 -0
  562. package/src/modules/customers/components/detail/ChangelogTab.tsx +629 -0
  563. package/src/modules/customers/components/detail/ComingSoonPlaceholder.tsx +21 -0
  564. package/src/modules/customers/components/detail/CompanyCard.tsx +419 -0
  565. package/src/modules/customers/components/detail/CompanyDashboardTab.tsx +161 -0
  566. package/src/modules/customers/components/detail/CompanyDetailHeader.tsx +243 -0
  567. package/src/modules/customers/components/detail/CompanyDetailTabs.tsx +172 -0
  568. package/src/modules/customers/components/detail/CompanyKpiBar.tsx +206 -0
  569. package/src/modules/customers/components/detail/CompanyPeopleSection.tsx +582 -288
  570. package/src/modules/customers/components/detail/CompanyTagsDialog.tsx +23 -0
  571. package/src/modules/customers/components/detail/ConfirmDealLostDialog.tsx +210 -0
  572. package/src/modules/customers/components/detail/CreatePersonDialog.tsx +178 -0
  573. package/src/modules/customers/components/detail/DealClosureActionBar.tsx +63 -0
  574. package/src/modules/customers/components/detail/DealDetailHeader.tsx +335 -0
  575. package/src/modules/customers/components/detail/DealDetailTabs.tsx +154 -0
  576. package/src/modules/customers/components/detail/DealForm.tsx +253 -101
  577. package/src/modules/customers/components/detail/DealLinkedEntitiesTab.tsx +349 -0
  578. package/src/modules/customers/components/detail/DealLostSummaryDialog.tsx +156 -0
  579. package/src/modules/customers/components/detail/DealWonPopup.tsx +164 -0
  580. package/src/modules/customers/components/detail/DealsSection.tsx +276 -221
  581. package/src/modules/customers/components/detail/DecisionMakersFooter.tsx +56 -0
  582. package/src/modules/customers/components/detail/EntityTagsDialog.tsx +1372 -0
  583. package/src/modules/customers/components/detail/InlineActivityComposer.tsx +239 -0
  584. package/src/modules/customers/components/detail/ManageTagsDialog.tsx +1331 -0
  585. package/src/modules/customers/components/detail/MiniWeekCalendar.tsx +338 -0
  586. package/src/modules/customers/components/detail/MobilePersonDetail.tsx +124 -0
  587. package/src/modules/customers/components/detail/NextStepCard.tsx +104 -0
  588. package/src/modules/customers/components/detail/PersonCard.tsx +238 -0
  589. package/src/modules/customers/components/detail/PersonCompaniesSection.tsx +426 -0
  590. package/src/modules/customers/components/detail/PersonDetailHeader.tsx +294 -0
  591. package/src/modules/customers/components/detail/PersonDetailTabs.tsx +172 -0
  592. package/src/modules/customers/components/detail/PersonTagsDialog.tsx +26 -0
  593. package/src/modules/customers/components/detail/PipelineStepper.tsx +245 -0
  594. package/src/modules/customers/components/detail/PlannedActivitiesSection.tsx +255 -0
  595. package/src/modules/customers/components/detail/RelationshipHealthCard.tsx +63 -0
  596. package/src/modules/customers/components/detail/RoleAssignmentRow.tsx +248 -0
  597. package/src/modules/customers/components/detail/RolesSection.tsx +311 -0
  598. package/src/modules/customers/components/detail/ScheduleActivityDialog.tsx +481 -0
  599. package/src/modules/customers/components/detail/aiActionCatalog.ts +77 -0
  600. package/src/modules/customers/components/detail/assignableStaff.ts +124 -0
  601. package/src/modules/customers/components/detail/dashboard/ActiveDealWidget.tsx +63 -0
  602. package/src/modules/customers/components/detail/dashboard/OpenTasksWidget.tsx +114 -0
  603. package/src/modules/customers/components/detail/dashboard/RecentActivityWidget.tsx +69 -0
  604. package/src/modules/customers/components/detail/dashboard/RelationshipHealthWidget.tsx +40 -0
  605. package/src/modules/customers/components/detail/dashboard/UpcomingMeetingsWidget.tsx +64 -0
  606. package/src/modules/customers/components/detail/dashboard/helpers.ts +78 -0
  607. package/src/modules/customers/components/detail/healthScoreUtils.ts +91 -0
  608. package/src/modules/customers/components/detail/hooks/useCurrencyDictionary.ts +8 -8
  609. package/src/modules/customers/components/detail/hooks/useCustomerDictionary.ts +10 -6
  610. package/src/modules/customers/components/detail/hooks/useInteractionMutations.ts +91 -0
  611. package/src/modules/customers/components/detail/notesAdapter.ts +91 -30
  612. package/src/modules/customers/components/detail/pipelineStageUtils.ts +29 -0
  613. package/src/modules/customers/components/detail/schedule/DateTimeFields.tsx +187 -0
  614. package/src/modules/customers/components/detail/schedule/FooterFields.tsx +79 -0
  615. package/src/modules/customers/components/detail/schedule/LinkedEntitiesField.tsx +277 -0
  616. package/src/modules/customers/components/detail/schedule/LocationField.tsx +42 -0
  617. package/src/modules/customers/components/detail/schedule/ParticipantsField.tsx +255 -0
  618. package/src/modules/customers/components/detail/schedule/fieldConfig.ts +70 -0
  619. package/src/modules/customers/components/detail/schedule/index.ts +9 -0
  620. package/src/modules/customers/components/detail/schedule/useScheduleFormState.ts +221 -0
  621. package/src/modules/customers/components/detail/types.ts +16 -0
  622. package/src/modules/customers/components/detail/utils.ts +25 -0
  623. package/src/modules/customers/components/formConfig.tsx +223 -28
  624. package/src/modules/customers/components/linking/LinkEntityDialog.tsx +920 -0
  625. package/src/modules/customers/components/linking/adapters/companyAdapter.tsx +398 -0
  626. package/src/modules/customers/components/linking/adapters/dealAdapter.tsx +578 -0
  627. package/src/modules/customers/components/linking/adapters/personAdapter.tsx +512 -0
  628. package/src/modules/customers/components/list/CollectionPreviewCell.tsx +66 -0
  629. package/src/modules/customers/data/entities.ts +353 -1
  630. package/src/modules/customers/data/validators.ts +170 -19
  631. package/src/modules/customers/events.ts +22 -0
  632. package/src/modules/customers/i18n/de.json +841 -2
  633. package/src/modules/customers/i18n/en.json +841 -2
  634. package/src/modules/customers/i18n/es.json +840 -1
  635. package/src/modules/customers/i18n/pl.json +841 -2
  636. package/src/modules/customers/lib/customerRoleTypes.ts +24 -0
  637. package/src/modules/customers/lib/dealClosureNotification.ts +64 -0
  638. package/src/modules/customers/lib/dealStageTransitionTable.ts +32 -0
  639. package/src/modules/customers/lib/dictionaries.ts +26 -10
  640. package/src/modules/customers/lib/interactionReadModel.ts +10 -0
  641. package/src/modules/customers/lib/personCompanies.ts +317 -0
  642. package/src/modules/customers/lib/personCompanyLinkTable.ts +58 -0
  643. package/src/modules/customers/lib/roleTypeUsage.ts +146 -0
  644. package/src/modules/customers/migrations/.snapshot-open-mercato.json +2747 -798
  645. package/src/modules/customers/migrations/Migration20260406214502.ts +19 -0
  646. package/src/modules/customers/migrations/Migration20260408135736.ts +15 -0
  647. package/src/modules/customers/migrations/Migration20260408225345.ts +23 -0
  648. package/src/modules/customers/migrations/Migration20260411075533.ts +30 -0
  649. package/src/modules/customers/migrations/Migration20260411103551.ts +13 -0
  650. package/src/modules/customers/migrations/Migration20260411130944.ts +30 -0
  651. package/src/modules/customers/migrations/Migration20260415095203.ts +13 -0
  652. package/src/modules/customers/migrations/Migration20260415135056.ts +22 -0
  653. package/src/modules/customers/migrations/Migration20260417140000.ts +15 -0
  654. package/src/modules/customers/migrations/Migration20260417160000.ts +17 -0
  655. package/src/modules/customers/migrations/Migration20260417235407.ts +13 -0
  656. package/src/modules/customers/setup.ts +15 -0
  657. package/src/modules/customers/subscribers/deal-closure-notification.ts +22 -0
  658. package/src/modules/customers/subscribers/deal-lost-notification.ts +22 -0
  659. package/src/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.ts +2 -0
  660. package/src/modules/dictionaries/api/[dictionaryId]/entries/reorder/route.ts +162 -0
  661. package/src/modules/dictionaries/api/[dictionaryId]/entries/route.ts +6 -2
  662. package/src/modules/dictionaries/api/[dictionaryId]/entries/set-default/route.ts +162 -0
  663. package/src/modules/dictionaries/api/context.ts +9 -0
  664. package/src/modules/dictionaries/api/openapi.ts +17 -0
  665. package/src/modules/dictionaries/commands/entry-operations.ts +457 -0
  666. package/src/modules/dictionaries/commands/factory.ts +31 -3
  667. package/src/modules/dictionaries/commands/index.ts +1 -0
  668. package/src/modules/dictionaries/components/DictionaryTable.tsx +15 -6
  669. package/src/modules/dictionaries/data/entities.ts +9 -0
  670. package/src/modules/dictionaries/data/validators.ts +34 -0
  671. package/src/modules/dictionaries/events.ts +20 -0
  672. package/src/modules/dictionaries/i18n/de.json +2 -0
  673. package/src/modules/dictionaries/i18n/en.json +2 -0
  674. package/src/modules/dictionaries/i18n/es.json +2 -0
  675. package/src/modules/dictionaries/i18n/pl.json +2 -0
  676. package/src/modules/dictionaries/lib/clientEntries.ts +66 -0
  677. package/src/modules/dictionaries/migrations/.snapshot-open-mercato.json +185 -3
  678. package/src/modules/dictionaries/migrations/Migration20260410171544.ts +49 -0
  679. package/src/modules/inbox_ops/api/proposals/[id]/route.ts +4 -1
  680. package/src/modules/query_index/lib/engine.ts +9 -1
  681. package/src/modules/sales/components/documents/AddressesSection.tsx +92 -42
  682. package/src/modules/sales/i18n/de.json +28 -0
  683. package/src/modules/sales/i18n/en.json +28 -0
  684. package/src/modules/sales/i18n/es.json +28 -0
  685. package/src/modules/sales/i18n/pl.json +28 -0
  686. package/src/modules/sales/lib/dictionaries.ts +18 -0
  687. package/src/modules/sales/widgets/injection-table.ts +4 -0
@@ -0,0 +1,1091 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import {
5
+ CalendarDays,
6
+ ChevronsLeft,
7
+ ChevronsRight,
8
+ ChevronDown,
9
+ ChevronUp,
10
+ Check,
11
+ GripVertical,
12
+ Hash,
13
+ Info,
14
+ Plus,
15
+ Radio,
16
+ RefreshCw,
17
+ Save,
18
+ Search,
19
+ Tag,
20
+ Thermometer,
21
+ Trash2,
22
+ Users,
23
+ X
24
+ } from "lucide-react";
25
+ import {
26
+ DndContext,
27
+ closestCenter,
28
+ PointerSensor,
29
+ KeyboardSensor,
30
+ useSensor,
31
+ useSensors
32
+ } from "@dnd-kit/core";
33
+ import {
34
+ SortableContext,
35
+ verticalListSortingStrategy,
36
+ useSortable,
37
+ arrayMove
38
+ } from "@dnd-kit/sortable";
39
+ import { CSS } from "@dnd-kit/utilities";
40
+ import { useT } from "@open-mercato/shared/lib/i18n/context";
41
+ import { apiCallOrThrow, readApiResultOrThrow } from "@open-mercato/ui/backend/utils/apiCall";
42
+ import { flash } from "@open-mercato/ui/backend/FlashMessages";
43
+ import { useGuardedMutation } from "@open-mercato/ui/backend/injection/useGuardedMutation";
44
+ import { Button } from "@open-mercato/ui/primitives/button";
45
+ import { IconButton } from "@open-mercato/ui/primitives/icon-button";
46
+ import {
47
+ Dialog,
48
+ DialogContent,
49
+ DialogTitle
50
+ } from "@open-mercato/ui/primitives/dialog";
51
+ import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
52
+ const BUILTIN_CATEGORIES = [
53
+ {
54
+ kind: "statuses",
55
+ icon: Tag,
56
+ shortLabelKey: "customers.personTags.category.statuses",
57
+ shortLabelFallback: "Status",
58
+ descriptionKey: "customers.tags.manage.description.customers.status",
59
+ descriptionFallback: "Single-select values visible on the hero area of person, company, and deal cards.",
60
+ badges: ["system", "required"],
61
+ noteTitleKey: "customers.tags.manage.noteTitle.customers.status",
62
+ noteTitleFallback: "System category",
63
+ noteDescriptionKey: "customers.tags.manage.noteDescription.customers.status",
64
+ noteDescriptionFallback: "Status is required on customer cards. Existing rows can be edited, but this category should remain available tenant-wide."
65
+ },
66
+ {
67
+ kind: "lifecycle-stages",
68
+ icon: RefreshCw,
69
+ shortLabelKey: "customers.personTags.category.lifecycle-stages",
70
+ shortLabelFallback: "Lifecycle",
71
+ descriptionKey: "customers.tags.manage.description.customers.lifecycle_stage",
72
+ descriptionFallback: "Pipeline-aligned lifecycle values shared across CRM detail pages.",
73
+ badges: ["system"],
74
+ noteTitleKey: "customers.tags.manage.noteTitle.customers.lifecycle_stage",
75
+ noteTitleFallback: "Shared lifecycle values",
76
+ noteDescriptionKey: "customers.tags.manage.noteDescription.customers.lifecycle_stage",
77
+ noteDescriptionFallback: "Use lifecycle stages to keep person and company headers visually consistent across CRM detail views."
78
+ },
79
+ {
80
+ kind: "sources",
81
+ icon: Radio,
82
+ shortLabelKey: "customers.personTags.category.sources",
83
+ shortLabelFallback: "Source",
84
+ descriptionKey: "customers.tags.manage.description.customers.source",
85
+ descriptionFallback: "Acquisition source labels used in Zone 1 forms and CRM summary badges.",
86
+ badges: ["system"],
87
+ noteTitleKey: "customers.tags.manage.noteTitle.customers.source",
88
+ noteTitleFallback: "Source dictionary",
89
+ noteDescriptionKey: "customers.tags.manage.noteDescription.customers.source",
90
+ noteDescriptionFallback: "These values are reused by customer forms and reporting filters."
91
+ },
92
+ {
93
+ kind: "temperature",
94
+ icon: Thermometer,
95
+ shortLabelKey: "customers.personTags.category.temperature",
96
+ shortLabelFallback: "Temperature",
97
+ descriptionKey: "customers.tags.manage.description.customers.temperature",
98
+ descriptionFallback: "Temperature / interest level for leads and contacts.",
99
+ noteTitleKey: "customers.tags.manage.noteTitle.customers.temperature",
100
+ noteTitleFallback: "Temperature / Interest",
101
+ noteDescriptionKey: "customers.tags.manage.noteDescription.customers.temperature",
102
+ noteDescriptionFallback: "Use temperature to quickly classify contact interest level from hot to cold."
103
+ },
104
+ {
105
+ kind: "renewal-quarters",
106
+ icon: CalendarDays,
107
+ shortLabelKey: "customers.personTags.category.renewal-quarters",
108
+ shortLabelFallback: "Renewal",
109
+ descriptionKey: "customers.tags.manage.description.customers.renewal_quarter",
110
+ descriptionFallback: "Renewal quarter labels for tracking contract renewal timing.",
111
+ noteTitleKey: "customers.tags.manage.noteTitle.customers.renewal_quarter",
112
+ noteTitleFallback: "Renewal quarter",
113
+ noteDescriptionKey: "customers.tags.manage.noteDescription.customers.renewal_quarter",
114
+ noteDescriptionFallback: "Assign renewal quarters to track when contracts or subscriptions are up for renewal."
115
+ },
116
+ {
117
+ kind: "person-company-roles",
118
+ icon: Users,
119
+ shortLabelKey: "customers.personTags.category.person-company-roles",
120
+ shortLabelFallback: "Roles",
121
+ descriptionKey: "customers.tags.manage.description.customers.person_company_role",
122
+ descriptionFallback: "Person-company relationship roles such as decision maker, influencer, or budget holder.",
123
+ noteTitleKey: "customers.tags.manage.noteTitle.customers.person_company_role",
124
+ noteTitleFallback: "Person-company roles",
125
+ noteDescriptionKey: "customers.tags.manage.noteDescription.customers.person_company_role",
126
+ noteDescriptionFallback: "Use roles to classify how a person relates to a company, for example decision maker, technical evaluator, or primary contact."
127
+ },
128
+ {
129
+ kind: "activity-types",
130
+ icon: CalendarDays,
131
+ shortLabelKey: "customers.personTags.category.activity-types",
132
+ shortLabelFallback: "Activity",
133
+ descriptionKey: "customers.tags.manage.description.customers.activity_type",
134
+ descriptionFallback: "Activity types for calls, emails, meetings, and other CRM interactions.",
135
+ noteTitleKey: "customers.tags.manage.noteTitle.customers.activity_type",
136
+ noteTitleFallback: "Activity types",
137
+ noteDescriptionKey: "customers.tags.manage.noteDescription.customers.activity_type",
138
+ noteDescriptionFallback: "Keep activity type names consistent so timeline filters remain readable across CRM views."
139
+ },
140
+ {
141
+ kind: "deal-statuses",
142
+ icon: Tag,
143
+ shortLabelKey: "customers.personTags.category.deal-statuses",
144
+ shortLabelFallback: "Deal status",
145
+ descriptionKey: "customers.tags.manage.description.customers.deal_status",
146
+ descriptionFallback: "Deal status labels used in pipeline views and deal detail cards.",
147
+ noteTitleKey: "customers.tags.manage.noteTitle.customers.deal_status",
148
+ noteTitleFallback: "Deal statuses",
149
+ noteDescriptionKey: "customers.tags.manage.noteDescription.customers.deal_status",
150
+ noteDescriptionFallback: "Deal status values affect pipeline filtering and reporting groupings."
151
+ },
152
+ {
153
+ kind: "industries",
154
+ icon: Hash,
155
+ shortLabelKey: "customers.personTags.category.industries",
156
+ shortLabelFallback: "Industry",
157
+ descriptionKey: "customers.config.dictionaries.sections.industries.description",
158
+ descriptionFallback: "Industry classification labels for companies and contacts.",
159
+ noteTitleKey: "customers.tags.manage.noteTitle.customers.industry",
160
+ noteTitleFallback: "Industry labels",
161
+ noteDescriptionKey: "customers.tags.manage.noteDescription.customers.industry",
162
+ noteDescriptionFallback: "Add industry categories that match your target market segments for consistent CRM classification."
163
+ }
164
+ ];
165
+ const BUILTIN_CATEGORY_KINDS = new Set(BUILTIN_CATEGORIES.map((category) => category.kind));
166
+ function createLocalId() {
167
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
168
+ return crypto.randomUUID();
169
+ }
170
+ return `draft-${Math.random().toString(36).slice(2)}`;
171
+ }
172
+ function normalizeColor(value) {
173
+ if (typeof value !== "string") return "#D1D5DB";
174
+ const trimmed = value.trim();
175
+ if (/^#([0-9a-fA-F]{6})$/.test(trimmed)) {
176
+ return `#${trimmed.slice(1).toLowerCase()}`;
177
+ }
178
+ return "#D1D5DB";
179
+ }
180
+ function slugifyLabel(value) {
181
+ return value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
182
+ }
183
+ function sanitizeIcon(value) {
184
+ return typeof value === "string" ? value.trim() : "";
185
+ }
186
+ function humanizeCategoryKind(kind) {
187
+ return kind.split(/[-_]+/).filter((part) => part.trim().length > 0).map((part) => `${part.slice(0, 1).toUpperCase()}${part.slice(1)}`).join(" ");
188
+ }
189
+ function createCustomCategoryDef(kind) {
190
+ const label = humanizeCategoryKind(kind);
191
+ return {
192
+ kind,
193
+ icon: Hash,
194
+ shortLabelKey: "",
195
+ shortLabelFallback: label,
196
+ descriptionKey: "customers.tags.manage.customCategoryDescription",
197
+ descriptionFallback: `Custom CRM category: ${label}.`,
198
+ noteTitleKey: "customers.tags.manage.customCategoryNoteTitle",
199
+ noteTitleFallback: "Custom category",
200
+ noteDescriptionKey: "customers.tags.manage.customCategoryNoteDescription",
201
+ noteDescriptionFallback: "Use this category to group and manage additional CRM values for your team.",
202
+ isCustom: true
203
+ };
204
+ }
205
+ function makeDraftEntry(entry) {
206
+ const id = typeof entry.id === "string" ? entry.id : null;
207
+ const value = typeof entry.value === "string" ? entry.value.trim() : "";
208
+ if (!value.length) return null;
209
+ return {
210
+ localId: id ?? createLocalId(),
211
+ id,
212
+ value,
213
+ label: typeof entry.label === "string" && entry.label.trim().length ? entry.label.trim() : value,
214
+ color: normalizeColor(typeof entry.color === "string" ? entry.color : null),
215
+ icon: sanitizeIcon(typeof entry.icon === "string" ? entry.icon : null),
216
+ isDefault: false,
217
+ isInherited: typeof entry.isInherited === "boolean" ? entry.isInherited : false,
218
+ manualValue: true,
219
+ deleted: false
220
+ };
221
+ }
222
+ function cloneDrafts(entries) {
223
+ return entries.map((entry) => ({ ...entry }));
224
+ }
225
+ function serializeEntries(entries) {
226
+ return JSON.stringify(
227
+ entries.filter((entry) => !entry.deleted).map((entry) => ({
228
+ id: entry.id,
229
+ value: entry.value,
230
+ label: entry.label,
231
+ color: entry.color,
232
+ icon: entry.icon
233
+ }))
234
+ );
235
+ }
236
+ function SortableEntryRow({
237
+ entry,
238
+ index,
239
+ total,
240
+ isDefault,
241
+ onLabelChange,
242
+ onValueChange,
243
+ onColorChange,
244
+ onDelete,
245
+ onMoveUp,
246
+ onMoveDown,
247
+ t
248
+ }) {
249
+ const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
250
+ id: entry.localId
251
+ });
252
+ const style = {
253
+ transform: CSS.Transform.toString(transform),
254
+ transition,
255
+ opacity: isDragging ? 0.5 : 1
256
+ };
257
+ const isFirst = index === 0;
258
+ const isLast = index === total - 1;
259
+ return /* @__PURE__ */ jsxs(
260
+ "div",
261
+ {
262
+ ref: setNodeRef,
263
+ style,
264
+ className: "flex items-center gap-2.5 rounded-md border border-border bg-card px-2.5 py-2",
265
+ children: [
266
+ /* @__PURE__ */ jsx(
267
+ "div",
268
+ {
269
+ "aria-label": t("customers.tags.manage.dragHandle", "Drag to reorder"),
270
+ title: t("customers.tags.manage.dragHandle", "Drag to reorder"),
271
+ className: "flex size-5 shrink-0 cursor-grab items-center justify-center text-muted-foreground/70",
272
+ ...attributes,
273
+ ...listeners,
274
+ children: /* @__PURE__ */ jsx(GripVertical, { className: "size-3.5" })
275
+ }
276
+ ),
277
+ /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 flex-col gap-0.5", children: [
278
+ /* @__PURE__ */ jsx(
279
+ IconButton,
280
+ {
281
+ type: "button",
282
+ variant: "ghost",
283
+ size: "xs",
284
+ "aria-label": t("customers.tags.manage.moveUp", "Move up"),
285
+ disabled: isFirst,
286
+ onClick: onMoveUp,
287
+ className: "h-5 w-5 text-muted-foreground hover:text-foreground disabled:opacity-40",
288
+ children: /* @__PURE__ */ jsx(ChevronUp, { className: "size-3" })
289
+ }
290
+ ),
291
+ /* @__PURE__ */ jsx(
292
+ IconButton,
293
+ {
294
+ type: "button",
295
+ variant: "ghost",
296
+ size: "xs",
297
+ "aria-label": t("customers.tags.manage.moveDown", "Move down"),
298
+ disabled: isLast,
299
+ onClick: onMoveDown,
300
+ className: "h-5 w-5 text-muted-foreground hover:text-foreground disabled:opacity-40",
301
+ children: /* @__PURE__ */ jsx(ChevronDown, { className: "size-3" })
302
+ }
303
+ )
304
+ ] }),
305
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
306
+ /* @__PURE__ */ jsx(
307
+ "input",
308
+ {
309
+ type: "text",
310
+ value: entry.label,
311
+ onChange: (e) => onLabelChange(e.target.value),
312
+ className: "w-full rounded-md border border-input bg-background px-3 py-2 text-sm font-medium text-foreground outline-none focus:border-foreground"
313
+ }
314
+ ),
315
+ isDefault && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
316
+ /* @__PURE__ */ jsx(Check, { className: "size-2.5 text-status-success-icon" }),
317
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t("customers.tags.manage.defaultEntry", "default when creating new records") })
318
+ ] })
319
+ ] }),
320
+ /* @__PURE__ */ jsx("div", { className: "w-[140px] shrink-0", children: /* @__PURE__ */ jsx(
321
+ "input",
322
+ {
323
+ type: "text",
324
+ value: entry.value,
325
+ onChange: (e) => onValueChange(slugifyLabel(e.target.value)),
326
+ className: "w-full rounded-md bg-muted px-2.5 py-2 text-xs font-medium text-muted-foreground outline-none"
327
+ }
328
+ ) }),
329
+ /* @__PURE__ */ jsxs("div", { className: "flex w-[80px] shrink-0 items-center gap-1.5 rounded-md border border-input px-2 py-1.5", children: [
330
+ /* @__PURE__ */ jsxs("label", { className: "relative size-4 shrink-0 cursor-pointer", children: [
331
+ /* @__PURE__ */ jsx(
332
+ "span",
333
+ {
334
+ className: "block size-full rounded-sm",
335
+ style: { backgroundColor: normalizeColor(entry.color) }
336
+ }
337
+ ),
338
+ /* @__PURE__ */ jsx(
339
+ "input",
340
+ {
341
+ type: "color",
342
+ value: normalizeColor(entry.color),
343
+ onChange: (e) => onColorChange(normalizeColor(e.target.value)),
344
+ className: "absolute inset-0 size-full cursor-pointer opacity-0"
345
+ }
346
+ )
347
+ ] }),
348
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: normalizeColor(entry.color) })
349
+ ] }),
350
+ /* @__PURE__ */ jsx(
351
+ IconButton,
352
+ {
353
+ type: "button",
354
+ variant: "ghost",
355
+ size: "sm",
356
+ className: "size-8 shrink-0 text-muted-foreground hover:text-destructive",
357
+ onClick: onDelete,
358
+ "aria-label": t("customers.tags.manage.delete", "Delete"),
359
+ children: /* @__PURE__ */ jsx(Trash2, { className: "size-3.5" })
360
+ }
361
+ )
362
+ ]
363
+ }
364
+ );
365
+ }
366
+ function ManageTagsDialog({ open, onClose }) {
367
+ const t = useT();
368
+ const [categories, setCategories] = React.useState(BUILTIN_CATEGORIES);
369
+ const [activeTab, setActiveTab] = React.useState(BUILTIN_CATEGORIES[0].kind);
370
+ const [loading, setLoading] = React.useState(true);
371
+ const [saving, setSaving] = React.useState(false);
372
+ const [searchValue, setSearchValue] = React.useState("");
373
+ const [entryCounts, setEntryCounts] = React.useState({});
374
+ const [draftsByKind, setDraftsByKind] = React.useState({});
375
+ const [originalByKind, setOriginalByKind] = React.useState({});
376
+ const [createCategoryOpen, setCreateCategoryOpen] = React.useState(false);
377
+ const [newCategoryName, setNewCategoryName] = React.useState("");
378
+ const [newCategorySelectionMode, setNewCategorySelectionMode] = React.useState("multi");
379
+ const [creatingCategory, setCreatingCategory] = React.useState(false);
380
+ const [canScrollLeft, setCanScrollLeft] = React.useState(false);
381
+ const [canScrollRight, setCanScrollRight] = React.useState(false);
382
+ const categoryRailRef = React.useRef(null);
383
+ const { runMutation, retryLastMutation } = useGuardedMutation({
384
+ contextId: "customers-manage-tags",
385
+ blockedMessage: t("ui.forms.flash.saveBlocked", "Save blocked by validation")
386
+ });
387
+ const mutationContext = React.useMemo(
388
+ () => ({
389
+ formId: "customers-manage-tags",
390
+ resourceKind: "customers.dictionary_entry",
391
+ resourceId: "bulk",
392
+ retryLastMutation
393
+ }),
394
+ [retryLastMutation]
395
+ );
396
+ const runGuardedMutation = React.useCallback(
397
+ async (operation, mutationPayload) => runMutation({
398
+ operation,
399
+ mutationPayload,
400
+ context: mutationContext
401
+ }),
402
+ [mutationContext, runMutation]
403
+ );
404
+ const translatedCategories = React.useMemo(
405
+ () => categories.map((category) => ({
406
+ ...category,
407
+ shortLabel: category.shortLabelKey ? t(category.shortLabelKey, category.shortLabelFallback) : category.shortLabelFallback,
408
+ description: category.descriptionKey ? t(
409
+ category.descriptionKey,
410
+ category.descriptionFallback,
411
+ category.isCustom ? { name: category.shortLabelFallback } : void 0
412
+ ) : category.descriptionFallback,
413
+ noteTitle: category.noteTitleKey ? t(category.noteTitleKey, category.noteTitleFallback) : category.noteTitleFallback,
414
+ noteDescription: category.noteDescriptionKey ? t(category.noteDescriptionKey, category.noteDescriptionFallback) : category.noteDescriptionFallback
415
+ })),
416
+ [categories, t]
417
+ );
418
+ const sensors = useSensors(
419
+ useSensor(PointerSensor, { activationConstraint: { distance: 5 } }),
420
+ useSensor(KeyboardSensor)
421
+ );
422
+ const loadData = React.useCallback(async () => {
423
+ setLoading(true);
424
+ try {
425
+ let kindSettings = [];
426
+ try {
427
+ const settings = await readApiResultOrThrow(
428
+ "/api/customers/dictionaries/kind-settings",
429
+ { cache: "no-store" }
430
+ );
431
+ kindSettings = Array.isArray(settings?.items) ? settings.items : [];
432
+ } catch {
433
+ kindSettings = [];
434
+ }
435
+ const customCategories = kindSettings.filter((setting) => !BUILTIN_CATEGORY_KINDS.has(setting.kind)).sort((left, right) => left.sortOrder - right.sortOrder || left.kind.localeCompare(right.kind)).map((setting) => createCustomCategoryDef(setting.kind));
436
+ const resolvedCategories = [...BUILTIN_CATEGORIES, ...customCategories];
437
+ const loadedDrafts = {};
438
+ const counts = {};
439
+ for (const category of resolvedCategories) {
440
+ try {
441
+ const data = await readApiResultOrThrow(`/api/customers/dictionaries/${category.kind}`, { cache: "no-store" });
442
+ const entries = Array.isArray(data?.items) ? data.items.map(makeDraftEntry).filter((entry) => entry !== null) : [];
443
+ loadedDrafts[category.kind] = entries;
444
+ counts[category.kind] = entries.length;
445
+ } catch {
446
+ loadedDrafts[category.kind] = [];
447
+ counts[category.kind] = 0;
448
+ }
449
+ }
450
+ setCategories(resolvedCategories);
451
+ setDraftsByKind(
452
+ Object.fromEntries(
453
+ Object.entries(loadedDrafts).map(([k, v]) => [k, cloneDrafts(v)])
454
+ )
455
+ );
456
+ setOriginalByKind(
457
+ Object.fromEntries(
458
+ Object.entries(loadedDrafts).map(([k, v]) => [k, cloneDrafts(v)])
459
+ )
460
+ );
461
+ setEntryCounts(counts);
462
+ setActiveTab(
463
+ (current) => resolvedCategories.some((category) => category.kind === current) ? current : resolvedCategories[0]?.kind ?? BUILTIN_CATEGORIES[0].kind
464
+ );
465
+ } catch (error) {
466
+ const message = error instanceof Error ? error.message : t("customers.tags.manage.loadError", "Failed to load tag dictionaries.");
467
+ flash(message, "error");
468
+ } finally {
469
+ setLoading(false);
470
+ }
471
+ }, [t]);
472
+ React.useEffect(() => {
473
+ if (!open) return;
474
+ setSearchValue("");
475
+ setCreateCategoryOpen(false);
476
+ setNewCategoryName("");
477
+ setNewCategorySelectionMode("multi");
478
+ loadData().catch((err) => console.warn("[ManageTagsDialog] loadData failed", err));
479
+ }, [loadData, open]);
480
+ const activeMeta = translatedCategories.find((category) => category.kind === activeTab) ?? null;
481
+ const activeEntries = draftsByKind[activeTab] ?? [];
482
+ const visibleEntries = React.useMemo(() => {
483
+ const query = searchValue.trim().toLowerCase();
484
+ return activeEntries.filter((entry) => {
485
+ if (entry.deleted) return false;
486
+ if (!query) return true;
487
+ return entry.label.toLowerCase().includes(query) || entry.value.toLowerCase().includes(query);
488
+ });
489
+ }, [activeEntries, searchValue]);
490
+ const hasChanges = React.useMemo(
491
+ () => categories.some((category) => {
492
+ const original = originalByKind[category.kind] ?? [];
493
+ const current = draftsByKind[category.kind] ?? [];
494
+ return serializeEntries(original) !== serializeEntries(current);
495
+ }),
496
+ [categories, draftsByKind, originalByKind]
497
+ );
498
+ const updateDraftEntry = React.useCallback(
499
+ (kind, localId, updater) => {
500
+ setDraftsByKind((current) => ({
501
+ ...current,
502
+ [kind]: (current[kind] ?? []).map(
503
+ (entry) => entry.localId === localId ? updater(entry) : entry
504
+ )
505
+ }));
506
+ },
507
+ []
508
+ );
509
+ const handleAddEntry = React.useCallback(() => {
510
+ setDraftsByKind((current) => ({
511
+ ...current,
512
+ [activeTab]: [
513
+ ...current[activeTab] ?? [],
514
+ {
515
+ localId: createLocalId(),
516
+ id: null,
517
+ value: "",
518
+ label: "",
519
+ color: "#D1D5DB",
520
+ icon: "",
521
+ isDefault: false,
522
+ isInherited: false,
523
+ manualValue: false,
524
+ deleted: false
525
+ }
526
+ ]
527
+ }));
528
+ }, [activeTab]);
529
+ const handleDeleteEntry = React.useCallback(
530
+ (kind, localId) => {
531
+ setDraftsByKind((current) => {
532
+ const nextEntries = (current[kind] ?? []).map((entry) => {
533
+ if (entry.localId !== localId) return entry;
534
+ if (!entry.id) return null;
535
+ return { ...entry, deleted: true };
536
+ }).filter((entry) => entry !== null);
537
+ return { ...current, [kind]: nextEntries };
538
+ });
539
+ },
540
+ []
541
+ );
542
+ const handleDragEnd = React.useCallback(
543
+ (event) => {
544
+ const { active, over } = event;
545
+ if (!over || active.id === over.id) return;
546
+ setDraftsByKind((current) => {
547
+ const entries = current[activeTab] ?? [];
548
+ const liveEntries = entries.filter((e) => !e.deleted);
549
+ const oldIndex = liveEntries.findIndex((e) => e.localId === active.id);
550
+ const newIndex = liveEntries.findIndex((e) => e.localId === over.id);
551
+ if (oldIndex === -1 || newIndex === -1) return current;
552
+ const reordered = arrayMove(liveEntries, oldIndex, newIndex);
553
+ const deletedEntries = entries.filter((e) => e.deleted);
554
+ return { ...current, [activeTab]: [...reordered, ...deletedEntries] };
555
+ });
556
+ },
557
+ [activeTab]
558
+ );
559
+ const moveEntryByDelta = React.useCallback(
560
+ (localId, delta) => {
561
+ setDraftsByKind((current) => {
562
+ const entries = current[activeTab] ?? [];
563
+ const liveEntries = entries.filter((entry) => !entry.deleted);
564
+ const oldIndex = liveEntries.findIndex((entry) => entry.localId === localId);
565
+ if (oldIndex < 0) return current;
566
+ const newIndex = oldIndex + delta;
567
+ if (newIndex < 0 || newIndex >= liveEntries.length) return current;
568
+ const reordered = arrayMove(liveEntries, oldIndex, newIndex);
569
+ const deletedEntries = entries.filter((entry) => entry.deleted);
570
+ return { ...current, [activeTab]: [...reordered, ...deletedEntries] };
571
+ });
572
+ },
573
+ [activeTab]
574
+ );
575
+ const handleSave = React.useCallback(async () => {
576
+ if (saving) return;
577
+ for (const category of categories) {
578
+ const entries = draftsByKind[category.kind] ?? [];
579
+ for (const entry of entries) {
580
+ if (entry.deleted) continue;
581
+ const nextLabel = entry.label.trim();
582
+ const nextValue = entry.value.trim();
583
+ if (!nextLabel || !nextValue) {
584
+ flash(
585
+ t(
586
+ "customers.tags.manage.validation.required",
587
+ "Each entry must have both a label and a slug before saving."
588
+ ),
589
+ "error"
590
+ );
591
+ return;
592
+ }
593
+ }
594
+ }
595
+ setSaving(true);
596
+ try {
597
+ for (const category of categories) {
598
+ const currentEntries = draftsByKind[category.kind] ?? [];
599
+ const originalEntries = originalByKind[category.kind] ?? [];
600
+ const originalById = new Map(
601
+ originalEntries.filter((e) => e.id).map((e) => [e.id, e])
602
+ );
603
+ for (const entry of currentEntries) {
604
+ if (entry.deleted) {
605
+ if (entry.id) {
606
+ await runGuardedMutation(
607
+ () => apiCallOrThrow(`/api/customers/dictionaries/${category.kind}/${entry.id}`, {
608
+ method: "DELETE"
609
+ }),
610
+ { kind: category.kind, entryId: entry.id, operation: "delete" }
611
+ );
612
+ }
613
+ continue;
614
+ }
615
+ const payload = {
616
+ value: entry.value.trim(),
617
+ label: entry.label.trim(),
618
+ color: normalizeColor(entry.color),
619
+ icon: sanitizeIcon(entry.icon) || null
620
+ };
621
+ if (!entry.id) {
622
+ await runGuardedMutation(
623
+ () => apiCallOrThrow(`/api/customers/dictionaries/${category.kind}`, {
624
+ method: "POST",
625
+ headers: { "content-type": "application/json" },
626
+ body: JSON.stringify(payload)
627
+ }),
628
+ { kind: category.kind, value: payload.value, operation: "create" }
629
+ );
630
+ continue;
631
+ }
632
+ if (entry.isInherited) continue;
633
+ const originalEntry = originalById.get(entry.id);
634
+ if (originalEntry && originalEntry.value === payload.value && originalEntry.label === payload.label && normalizeColor(originalEntry.color) === normalizeColor(payload.color) && sanitizeIcon(originalEntry.icon) === sanitizeIcon(payload.icon)) {
635
+ continue;
636
+ }
637
+ await runGuardedMutation(
638
+ () => apiCallOrThrow(`/api/customers/dictionaries/${category.kind}/${entry.id}`, {
639
+ method: "PATCH",
640
+ headers: { "content-type": "application/json" },
641
+ body: JSON.stringify(payload)
642
+ }),
643
+ { kind: category.kind, entryId: entry.id, value: payload.value, operation: "update" }
644
+ );
645
+ }
646
+ }
647
+ flash(t("customers.tags.manage.saveSuccess", "Tag dictionaries updated."), "success");
648
+ await loadData();
649
+ } catch (error) {
650
+ const message = error instanceof Error ? error.message : t("customers.tags.manage.saveError", "Failed to save tag dictionaries.");
651
+ flash(message, "error");
652
+ } finally {
653
+ setSaving(false);
654
+ }
655
+ }, [categories, draftsByKind, loadData, originalByKind, runGuardedMutation, saving, t]);
656
+ const updateCategoryRailState = React.useCallback(() => {
657
+ const rail = categoryRailRef.current;
658
+ if (!rail) {
659
+ setCanScrollLeft(false);
660
+ setCanScrollRight(false);
661
+ return;
662
+ }
663
+ const maxScrollLeft = Math.max(0, rail.scrollWidth - rail.clientWidth);
664
+ setCanScrollLeft(rail.scrollLeft > 4);
665
+ setCanScrollRight(rail.scrollLeft < maxScrollLeft - 4);
666
+ }, []);
667
+ const scrollCategoryRail = React.useCallback(
668
+ (direction) => {
669
+ const rail = categoryRailRef.current;
670
+ if (!rail) return;
671
+ const offset = Math.max(180, Math.round(rail.clientWidth * 0.65));
672
+ rail.scrollBy({
673
+ left: direction === "left" ? -offset : offset,
674
+ behavior: "smooth"
675
+ });
676
+ },
677
+ []
678
+ );
679
+ React.useEffect(() => {
680
+ if (!open) return;
681
+ const rail = categoryRailRef.current;
682
+ if (!rail) return;
683
+ updateCategoryRailState();
684
+ rail.addEventListener("scroll", updateCategoryRailState, { passive: true });
685
+ const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => updateCategoryRailState()) : null;
686
+ resizeObserver?.observe(rail);
687
+ return () => {
688
+ rail.removeEventListener("scroll", updateCategoryRailState);
689
+ resizeObserver?.disconnect();
690
+ };
691
+ }, [open, translatedCategories, updateCategoryRailState]);
692
+ const handleCreateCategory = React.useCallback(async () => {
693
+ if (creatingCategory) return;
694
+ const trimmedName = newCategoryName.trim();
695
+ const kind = slugifyLabel(trimmedName);
696
+ if (!kind.length) {
697
+ flash(
698
+ t("customers.tags.manage.addCategoryRequired", "Enter a category name first."),
699
+ "error"
700
+ );
701
+ return;
702
+ }
703
+ if (categories.some((category) => category.kind === kind)) {
704
+ setActiveTab(kind);
705
+ setCreateCategoryOpen(false);
706
+ return;
707
+ }
708
+ setCreatingCategory(true);
709
+ try {
710
+ await runGuardedMutation(
711
+ () => apiCallOrThrow("/api/customers/dictionaries/kind-settings", {
712
+ method: "PATCH",
713
+ headers: { "content-type": "application/json" },
714
+ body: JSON.stringify({
715
+ kind,
716
+ selectionMode: newCategorySelectionMode,
717
+ visibleInTags: true,
718
+ sortOrder: categories.length + 1
719
+ })
720
+ }),
721
+ {
722
+ kind,
723
+ selectionMode: newCategorySelectionMode,
724
+ operation: "createCategory"
725
+ }
726
+ );
727
+ await loadData();
728
+ setActiveTab(kind);
729
+ setCreateCategoryOpen(false);
730
+ setNewCategoryName("");
731
+ setNewCategorySelectionMode("multi");
732
+ flash(t("customers.tags.manage.createCategorySuccess", "Category created."), "success");
733
+ } catch (error) {
734
+ const message = error instanceof Error ? error.message : t("customers.tags.manage.createCategoryError", "Failed to create category.");
735
+ flash(message, "error");
736
+ } finally {
737
+ setCreatingCategory(false);
738
+ }
739
+ }, [categories, creatingCategory, loadData, newCategoryName, newCategorySelectionMode, runGuardedMutation, t]);
740
+ React.useEffect(() => {
741
+ if (!open) return;
742
+ const handler = (e) => {
743
+ if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
744
+ e.preventDefault();
745
+ void handleSave();
746
+ }
747
+ };
748
+ window.addEventListener("keydown", handler);
749
+ return () => window.removeEventListener("keydown", handler);
750
+ }, [open, handleSave]);
751
+ return /* @__PURE__ */ jsx(
752
+ Dialog,
753
+ {
754
+ open,
755
+ onOpenChange: (nextOpen) => {
756
+ if (!nextOpen) onClose();
757
+ },
758
+ children: /* @__PURE__ */ jsxs(
759
+ DialogContent,
760
+ {
761
+ className: "flex max-h-[90vh] flex-col overflow-hidden border-border p-0 shadow-[0px_20px_48px_0px_rgba(0,0,0,0.18)] sm:max-w-[820px] sm:rounded-lg [&>[data-dialog-close]]:hidden",
762
+ "aria-describedby": void 0,
763
+ children: [
764
+ /* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx(DialogTitle, { children: t("customers.tags.manage.title", "Manage tags") }) }),
765
+ /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center justify-between pb-2.5 pl-6 pr-5 pt-4", children: [
766
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
767
+ /* @__PURE__ */ jsx("h2", { className: "text-base font-bold leading-tight text-foreground", children: t("customers.tags.manage.title", "Manage tags") }),
768
+ /* @__PURE__ */ jsx("p", { className: "text-xs leading-tight text-muted-foreground", children: t(
769
+ "customers.tags.manage.subtitle",
770
+ "Tag dictionaries for the entire tenant"
771
+ ) })
772
+ ] }),
773
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
774
+ /* @__PURE__ */ jsxs(
775
+ Button,
776
+ {
777
+ type: "button",
778
+ variant: "outline",
779
+ size: "sm",
780
+ className: "h-auto gap-1.5 rounded-md px-3 py-2 text-xs font-semibold",
781
+ onClick: () => {
782
+ setCreateCategoryOpen((current) => !current);
783
+ setNewCategoryName("");
784
+ setNewCategorySelectionMode("multi");
785
+ },
786
+ children: [
787
+ /* @__PURE__ */ jsx(Plus, { className: "size-3.5" }),
788
+ t("customers.tags.manage.addCategory", "New category")
789
+ ]
790
+ }
791
+ ),
792
+ /* @__PURE__ */ jsx(
793
+ IconButton,
794
+ {
795
+ type: "button",
796
+ variant: "outline",
797
+ size: "sm",
798
+ className: "size-7 shrink-0 rounded-md border-border",
799
+ onClick: onClose,
800
+ "aria-label": t("customers.tags.manage.closeDialog", "Close"),
801
+ children: /* @__PURE__ */ jsx(X, { className: "size-3.5" })
802
+ }
803
+ )
804
+ ] })
805
+ ] }),
806
+ /* @__PURE__ */ jsx("div", { className: "h-px shrink-0 bg-border" }),
807
+ loading ? /* @__PURE__ */ jsx("div", { className: "px-7 py-12 text-center text-sm text-muted-foreground", children: t("customers.tags.manage.loading", "Loading...") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
808
+ createCategoryOpen ? /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 flex-wrap items-center gap-2.5 border-b border-border px-6 py-3", children: [
809
+ /* @__PURE__ */ jsx("div", { className: "min-w-[220px] flex-1 rounded-md border border-input bg-background px-3 py-2", children: /* @__PURE__ */ jsx(
810
+ "input",
811
+ {
812
+ type: "text",
813
+ value: newCategoryName,
814
+ onChange: (event) => setNewCategoryName(event.target.value),
815
+ onKeyDown: (event) => {
816
+ if (event.key === "Enter") {
817
+ event.preventDefault();
818
+ void handleCreateCategory();
819
+ }
820
+ },
821
+ placeholder: t("customers.tags.manage.addCategoryPlaceholder", "Category name..."),
822
+ className: "w-full bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground"
823
+ }
824
+ ) }),
825
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 rounded-md border border-border bg-muted/60 p-1", children: [
826
+ /* @__PURE__ */ jsx(
827
+ Button,
828
+ {
829
+ type: "button",
830
+ variant: newCategorySelectionMode === "single" ? "secondary" : "ghost",
831
+ size: "sm",
832
+ className: "h-auto rounded-md px-2.5 py-1.5 text-xs",
833
+ onClick: () => setNewCategorySelectionMode("single"),
834
+ children: t("customers.tags.manage.categoryMode.single", "Single")
835
+ }
836
+ ),
837
+ /* @__PURE__ */ jsx(
838
+ Button,
839
+ {
840
+ type: "button",
841
+ variant: newCategorySelectionMode === "multi" ? "secondary" : "ghost",
842
+ size: "sm",
843
+ className: "h-auto rounded-md px-2.5 py-1.5 text-xs",
844
+ onClick: () => setNewCategorySelectionMode("multi"),
845
+ children: t("customers.tags.manage.categoryMode.multi", "Multi")
846
+ }
847
+ )
848
+ ] }),
849
+ /* @__PURE__ */ jsx(
850
+ Button,
851
+ {
852
+ type: "button",
853
+ size: "sm",
854
+ className: "h-auto rounded-md px-3 py-2 text-xs font-semibold",
855
+ onClick: () => {
856
+ void handleCreateCategory();
857
+ },
858
+ disabled: creatingCategory,
859
+ children: creatingCategory ? t("customers.tags.manage.creatingCategory", "Creating...") : t("customers.tags.manage.createCategory", "Create category")
860
+ }
861
+ )
862
+ ] }) : null,
863
+ /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-2 border-b border-border px-4 py-1.5", children: [
864
+ /* @__PURE__ */ jsx(
865
+ IconButton,
866
+ {
867
+ type: "button",
868
+ variant: "ghost",
869
+ size: "sm",
870
+ className: "size-8 shrink-0 rounded-full",
871
+ onClick: () => scrollCategoryRail("left"),
872
+ disabled: !canScrollLeft,
873
+ "aria-label": t("customers.tags.manage.scrollLeft", "Scroll categories left"),
874
+ children: /* @__PURE__ */ jsx(ChevronsLeft, { className: "size-3.5" })
875
+ }
876
+ ),
877
+ /* @__PURE__ */ jsx(
878
+ "div",
879
+ {
880
+ ref: categoryRailRef,
881
+ className: "min-w-0 flex-1 overflow-x-auto [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
882
+ children: /* @__PURE__ */ jsx("div", { className: "flex items-end gap-0.5", children: translatedCategories.map((category) => {
883
+ const Icon = category.icon;
884
+ const isActive = category.kind === activeTab;
885
+ const count = entryCounts[category.kind] ?? 0;
886
+ return /* @__PURE__ */ jsxs(
887
+ Button,
888
+ {
889
+ type: "button",
890
+ variant: "ghost",
891
+ size: "sm",
892
+ onClick: () => {
893
+ setActiveTab(category.kind);
894
+ setSearchValue("");
895
+ },
896
+ className: `flex h-auto shrink-0 items-center gap-1.5 rounded-none border-b-2 px-2.5 py-2 hover:bg-transparent ${isActive ? "-mb-px border-foreground text-foreground" : "-mb-px border-transparent text-muted-foreground"}`,
897
+ children: [
898
+ /* @__PURE__ */ jsx(Icon, { className: "size-3.5" }),
899
+ /* @__PURE__ */ jsx(
900
+ "span",
901
+ {
902
+ className: `whitespace-nowrap text-xs ${isActive ? "font-semibold" : "font-medium"}`,
903
+ children: category.shortLabel
904
+ }
905
+ ),
906
+ /* @__PURE__ */ jsx("span", { className: "rounded-sm bg-muted px-1 py-px text-overline font-semibold text-foreground", children: count })
907
+ ]
908
+ },
909
+ category.kind
910
+ );
911
+ }) })
912
+ }
913
+ ),
914
+ /* @__PURE__ */ jsx(
915
+ IconButton,
916
+ {
917
+ type: "button",
918
+ variant: "ghost",
919
+ size: "sm",
920
+ className: "size-8 shrink-0 rounded-full",
921
+ onClick: () => scrollCategoryRail("right"),
922
+ disabled: !canScrollRight,
923
+ "aria-label": t("customers.tags.manage.scrollRight", "Scroll categories right"),
924
+ children: /* @__PURE__ */ jsx(ChevronsRight, { className: "size-3.5" })
925
+ }
926
+ )
927
+ ] }),
928
+ /* @__PURE__ */ jsx("div", { className: "flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-6 py-3.5", children: activeMeta ? /* @__PURE__ */ jsxs(Fragment, { children: [
929
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
930
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
931
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
932
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-bold text-foreground", children: activeMeta.shortLabel }),
933
+ (activeMeta.badges ?? []).map((badge) => /* @__PURE__ */ jsx(
934
+ "span",
935
+ {
936
+ className: `rounded-sm px-2 py-0.5 text-overline font-bold ${badge === "required" ? "bg-status-warning-bg text-status-warning-text" : "bg-muted text-muted-foreground"}`,
937
+ children: badge === "required" ? t("customers.tags.manage.badge.required", "REQUIRED") : t("customers.tags.manage.badge.system", "SYSTEM")
938
+ },
939
+ badge
940
+ ))
941
+ ] }),
942
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
943
+ /* @__PURE__ */ jsx(Info, { className: "size-3 shrink-0 text-muted-foreground" }),
944
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: activeMeta.description })
945
+ ] })
946
+ ] }),
947
+ /* @__PURE__ */ jsxs("div", { className: "relative w-[220px] shrink-0", children: [
948
+ /* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground/70" }),
949
+ /* @__PURE__ */ jsx(
950
+ "input",
951
+ {
952
+ type: "text",
953
+ value: searchValue,
954
+ onChange: (e) => setSearchValue(e.target.value),
955
+ placeholder: t("customers.tags.manage.search", "Search values..."),
956
+ className: "w-full rounded-md border border-input bg-background py-2 pl-9 pr-3 text-xs text-foreground outline-none placeholder:text-muted-foreground/70 focus:border-foreground"
957
+ }
958
+ )
959
+ ] })
960
+ ] }),
961
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 px-3 py-1.5", children: [
962
+ /* @__PURE__ */ jsx("div", { className: "w-[18px] shrink-0" }),
963
+ /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx("span", { className: "text-overline font-bold uppercase text-muted-foreground", children: t("customers.tags.manage.columns.label", "LABEL") }) }),
964
+ /* @__PURE__ */ jsx("div", { className: "w-[140px] shrink-0", children: /* @__PURE__ */ jsx("span", { className: "text-overline font-bold uppercase text-muted-foreground", children: t("customers.tags.manage.columns.slug", "SLUG") }) }),
965
+ /* @__PURE__ */ jsx("div", { className: "w-[80px] shrink-0", children: /* @__PURE__ */ jsx("span", { className: "text-overline font-bold uppercase text-muted-foreground", children: t("customers.tags.manage.columns.color", "COLOR") }) }),
966
+ /* @__PURE__ */ jsx("div", { className: "w-[32px] shrink-0" })
967
+ ] }),
968
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
969
+ /* @__PURE__ */ jsx(
970
+ DndContext,
971
+ {
972
+ sensors,
973
+ collisionDetection: closestCenter,
974
+ onDragEnd: handleDragEnd,
975
+ children: /* @__PURE__ */ jsx(
976
+ SortableContext,
977
+ {
978
+ items: visibleEntries.map((e) => e.localId),
979
+ strategy: verticalListSortingStrategy,
980
+ children: visibleEntries.map((entry, index) => /* @__PURE__ */ jsx(
981
+ SortableEntryRow,
982
+ {
983
+ entry,
984
+ index,
985
+ total: visibleEntries.length,
986
+ isDefault: index === 0 && entry.id !== null,
987
+ onLabelChange: (value) => {
988
+ updateDraftEntry(activeTab, entry.localId, (current) => ({
989
+ ...current,
990
+ label: value,
991
+ value: current.manualValue ? current.value : slugifyLabel(value)
992
+ }));
993
+ },
994
+ onValueChange: (value) => {
995
+ updateDraftEntry(activeTab, entry.localId, (current) => ({
996
+ ...current,
997
+ value,
998
+ manualValue: true
999
+ }));
1000
+ },
1001
+ onColorChange: (value) => {
1002
+ updateDraftEntry(activeTab, entry.localId, (current) => ({
1003
+ ...current,
1004
+ color: value
1005
+ }));
1006
+ },
1007
+ onDelete: () => handleDeleteEntry(activeTab, entry.localId),
1008
+ onMoveUp: () => moveEntryByDelta(entry.localId, -1),
1009
+ onMoveDown: () => moveEntryByDelta(entry.localId, 1),
1010
+ t
1011
+ },
1012
+ entry.localId
1013
+ ))
1014
+ }
1015
+ )
1016
+ }
1017
+ ),
1018
+ visibleEntries.length === 0 && /* @__PURE__ */ jsx("div", { className: "px-4 py-8 text-center text-sm text-muted-foreground", children: t(
1019
+ "customers.tags.manage.noMatches",
1020
+ "No entries match the current search."
1021
+ ) })
1022
+ ] }),
1023
+ /* @__PURE__ */ jsxs(
1024
+ Button,
1025
+ {
1026
+ type: "button",
1027
+ variant: "ghost",
1028
+ onClick: handleAddEntry,
1029
+ className: "flex h-auto w-full items-center justify-center gap-2 rounded-md border border-dashed border-border bg-background p-3 text-xs font-semibold text-foreground hover:bg-muted",
1030
+ children: [
1031
+ /* @__PURE__ */ jsx(Plus, { className: "size-3.5" }),
1032
+ t("customers.tags.manage.addValue", "Add new value")
1033
+ ]
1034
+ }
1035
+ ),
1036
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2.5 rounded-md bg-muted px-3.5 py-3", children: [
1037
+ /* @__PURE__ */ jsx(Info, { className: "mt-0.5 size-3.5 shrink-0 text-muted-foreground" }),
1038
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col gap-1", children: [
1039
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-semibold text-foreground", children: activeMeta.noteTitle }),
1040
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: activeMeta.noteDescription })
1041
+ ] })
1042
+ ] })
1043
+ ] }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center text-sm text-muted-foreground", children: t("customers.tags.manage.noDictionaries", "No tag categories found.") }) }),
1044
+ /* @__PURE__ */ jsx("div", { className: "h-px shrink-0 bg-border" }),
1045
+ /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center justify-between px-6 py-3", children: [
1046
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
1047
+ /* @__PURE__ */ jsx(Info, { className: "size-3 shrink-0 text-muted-foreground" }),
1048
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t(
1049
+ "customers.tags.manage.tenantNotice",
1050
+ "Changes apply to the entire tenant \xB7 visible immediately"
1051
+ ) })
1052
+ ] }),
1053
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2.5", children: [
1054
+ /* @__PURE__ */ jsx(
1055
+ Button,
1056
+ {
1057
+ type: "button",
1058
+ variant: "outline",
1059
+ onClick: onClose,
1060
+ className: "rounded-md border-border px-4 py-2.5 text-sm font-semibold text-foreground",
1061
+ children: t("customers.tags.manage.close", "Cancel")
1062
+ }
1063
+ ),
1064
+ /* @__PURE__ */ jsxs(
1065
+ Button,
1066
+ {
1067
+ type: "button",
1068
+ onClick: () => {
1069
+ void handleSave();
1070
+ },
1071
+ disabled: saving || !hasChanges,
1072
+ className: "rounded-md bg-foreground px-4 py-2.5 text-sm font-semibold text-background hover:bg-foreground/90",
1073
+ children: [
1074
+ /* @__PURE__ */ jsx(Save, { className: "mr-2 size-4" }),
1075
+ saving ? t("customers.tags.manage.saving", "Saving...") : t("customers.tags.manage.save", "Save changes")
1076
+ ]
1077
+ }
1078
+ )
1079
+ ] })
1080
+ ] })
1081
+ ] })
1082
+ ]
1083
+ }
1084
+ )
1085
+ }
1086
+ );
1087
+ }
1088
+ export {
1089
+ ManageTagsDialog
1090
+ };
1091
+ //# sourceMappingURL=ManageTagsDialog.js.map