@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.
- package/.turbo/turbo-build.log +1 -1
- package/dist/generated/entities/action_log/index.js +8 -0
- package/dist/generated/entities/action_log/index.js.map +2 -2
- package/dist/generated/entities/customer_company_billing/index.js +23 -0
- package/dist/generated/entities/customer_company_billing/index.js.map +7 -0
- package/dist/generated/entities/customer_deal/index.js +8 -0
- package/dist/generated/entities/customer_deal/index.js.map +2 -2
- package/dist/generated/entities/customer_deal_stage_transition/index.js +31 -0
- package/dist/generated/entities/customer_deal_stage_transition/index.js.map +7 -0
- package/dist/generated/entities/customer_dictionary_kind_setting/index.js +21 -0
- package/dist/generated/entities/customer_dictionary_kind_setting/index.js.map +7 -0
- package/dist/generated/entities/customer_entity/index.js +8 -0
- package/dist/generated/entities/customer_entity/index.js.map +2 -2
- package/dist/generated/entities/customer_entity_role/index.js +23 -0
- package/dist/generated/entities/customer_entity_role/index.js.map +7 -0
- package/dist/generated/entities/customer_interaction/index.js +23 -1
- package/dist/generated/entities/customer_interaction/index.js.map +2 -2
- package/dist/generated/entities/customer_label/index.js +19 -0
- package/dist/generated/entities/customer_label/index.js.map +7 -0
- package/dist/generated/entities/customer_label_assignment/index.js +17 -0
- package/dist/generated/entities/customer_label_assignment/index.js.map +7 -0
- package/dist/generated/entities/customer_person_company_link/index.js +21 -0
- package/dist/generated/entities/customer_person_company_link/index.js.map +7 -0
- package/dist/generated/entities/customer_person_company_role/index.js +17 -0
- package/dist/generated/entities/customer_person_company_role/index.js.map +7 -0
- package/dist/generated/entities/dictionary_entry/index.js +4 -0
- package/dist/generated/entities/dictionary_entry/index.js.map +2 -2
- package/dist/generated/entities.ids.generated.js +9 -1
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +116 -1
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/modules/attachments/api/route.js +46 -8
- package/dist/modules/attachments/api/route.js.map +2 -2
- package/dist/modules/audit_logs/api/audit-logs/actions/export/route.js +208 -0
- package/dist/modules/audit_logs/api/audit-logs/actions/export/route.js.map +7 -0
- package/dist/modules/audit_logs/api/audit-logs/actions/route.js +52 -6
- package/dist/modules/audit_logs/api/audit-logs/actions/route.js.map +2 -2
- package/dist/modules/audit_logs/cli.js +62 -0
- package/dist/modules/audit_logs/cli.js.map +7 -0
- package/dist/modules/audit_logs/data/entities.js +21 -1
- package/dist/modules/audit_logs/data/entities.js.map +2 -2
- package/dist/modules/audit_logs/data/validators.js +9 -1
- package/dist/modules/audit_logs/data/validators.js.map +2 -2
- package/dist/modules/audit_logs/lib/changeRows.js +34 -0
- package/dist/modules/audit_logs/lib/changeRows.js.map +7 -0
- package/dist/modules/audit_logs/lib/display-helpers.js +2 -20
- package/dist/modules/audit_logs/lib/display-helpers.js.map +3 -3
- package/dist/modules/audit_logs/lib/projections.js +58 -0
- package/dist/modules/audit_logs/lib/projections.js.map +7 -0
- package/dist/modules/audit_logs/migrations/Migration20260412160533.js +21 -0
- package/dist/modules/audit_logs/migrations/Migration20260412160533.js.map +7 -0
- package/dist/modules/audit_logs/services/actionLogService.js +313 -79
- package/dist/modules/audit_logs/services/actionLogService.js.map +2 -2
- package/dist/modules/customers/acl.js +3 -1
- package/dist/modules/customers/acl.js.map +2 -2
- package/dist/modules/customers/api/activities/route.js +4 -0
- package/dist/modules/customers/api/activities/route.js.map +2 -2
- package/dist/modules/customers/api/assignable-staff/route.js +208 -0
- package/dist/modules/customers/api/assignable-staff/route.js.map +7 -0
- package/dist/modules/customers/api/companies/[id]/people/route.js +205 -0
- package/dist/modules/customers/api/companies/[id]/people/route.js.map +7 -0
- package/dist/modules/customers/api/companies/[id]/roles/route.js +22 -0
- package/dist/modules/customers/api/companies/[id]/roles/route.js.map +7 -0
- package/dist/modules/customers/api/companies/[id]/route.js +374 -32
- package/dist/modules/customers/api/companies/[id]/route.js.map +2 -2
- package/dist/modules/customers/api/companies/route.js +82 -7
- package/dist/modules/customers/api/companies/route.js.map +2 -2
- package/dist/modules/customers/api/deals/[id]/companies/route.js +172 -0
- package/dist/modules/customers/api/deals/[id]/companies/route.js.map +7 -0
- package/dist/modules/customers/api/deals/[id]/people/route.js +156 -0
- package/dist/modules/customers/api/deals/[id]/people/route.js.map +7 -0
- package/dist/modules/customers/api/deals/[id]/route.js +459 -53
- package/dist/modules/customers/api/deals/[id]/route.js.map +2 -2
- package/dist/modules/customers/api/deals/[id]/stats/route.js +195 -0
- package/dist/modules/customers/api/deals/[id]/stats/route.js.map +7 -0
- package/dist/modules/customers/api/deals/route.js +20 -10
- package/dist/modules/customers/api/deals/route.js.map +3 -3
- package/dist/modules/customers/api/dictionaries/[kind]/[id]/route.js +105 -4
- package/dist/modules/customers/api/dictionaries/[kind]/[id]/route.js.map +2 -2
- package/dist/modules/customers/api/dictionaries/[kind]/route.js +118 -42
- package/dist/modules/customers/api/dictionaries/[kind]/route.js.map +2 -2
- package/dist/modules/customers/api/dictionaries/context.js +30 -6
- package/dist/modules/customers/api/dictionaries/context.js.map +2 -2
- package/dist/modules/customers/api/dictionaries/kind-settings/route.js +207 -0
- package/dist/modules/customers/api/dictionaries/kind-settings/route.js.map +7 -0
- package/dist/modules/customers/api/entity-roles-factory.js +471 -0
- package/dist/modules/customers/api/entity-roles-factory.js.map +7 -0
- package/dist/modules/customers/api/interactions/conflicts/route.js +158 -0
- package/dist/modules/customers/api/interactions/conflicts/route.js.map +7 -0
- package/dist/modules/customers/api/interactions/counts/route.js +92 -0
- package/dist/modules/customers/api/interactions/counts/route.js.map +7 -0
- package/dist/modules/customers/api/interactions/route.js +83 -4
- package/dist/modules/customers/api/interactions/route.js.map +2 -2
- package/dist/modules/customers/api/labels/assign/route.js +189 -0
- package/dist/modules/customers/api/labels/assign/route.js.map +7 -0
- package/dist/modules/customers/api/labels/auth.js +17 -0
- package/dist/modules/customers/api/labels/auth.js.map +7 -0
- package/dist/modules/customers/api/labels/route.js +281 -0
- package/dist/modules/customers/api/labels/route.js.map +7 -0
- package/dist/modules/customers/api/labels/table-errors.js +38 -0
- package/dist/modules/customers/api/labels/table-errors.js.map +7 -0
- package/dist/modules/customers/api/labels/unassign/route.js +184 -0
- package/dist/modules/customers/api/labels/unassign/route.js.map +7 -0
- package/dist/modules/customers/api/people/[id]/companies/[linkId]/route.js +292 -0
- package/dist/modules/customers/api/people/[id]/companies/[linkId]/route.js.map +7 -0
- package/dist/modules/customers/api/people/[id]/companies/context.js +66 -0
- package/dist/modules/customers/api/people/[id]/companies/context.js.map +7 -0
- package/dist/modules/customers/api/people/[id]/companies/enriched/route.js +334 -0
- package/dist/modules/customers/api/people/[id]/companies/enriched/route.js.map +7 -0
- package/dist/modules/customers/api/people/[id]/companies/route.js +205 -0
- package/dist/modules/customers/api/people/[id]/companies/route.js.map +7 -0
- package/dist/modules/customers/api/people/[id]/roles/route.js +22 -0
- package/dist/modules/customers/api/people/[id]/roles/route.js.map +7 -0
- package/dist/modules/customers/api/people/[id]/route.js +134 -21
- package/dist/modules/customers/api/people/[id]/route.js.map +2 -2
- package/dist/modules/customers/api/people/route.js +122 -23
- package/dist/modules/customers/api/people/route.js.map +2 -2
- package/dist/modules/customers/api/todos/route.js +4 -0
- package/dist/modules/customers/api/todos/route.js.map +2 -2
- package/dist/modules/customers/api/utils.js +22 -0
- package/dist/modules/customers/api/utils.js.map +2 -2
- package/dist/modules/customers/backend/config/customers/page.js +2 -6
- package/dist/modules/customers/backend/config/customers/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/companies/page.js +37 -26
- package/dist/modules/customers/backend/customers/companies/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/companies-v2/[id]/page.js +265 -262
- package/dist/modules/customers/backend/customers/companies-v2/[id]/page.js.map +3 -3
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/formatters.js +23 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/formatters.js.map +7 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/types.js +1 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/types.js.map +7 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealActivities.js +43 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealActivities.js.map +7 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealAssociations.js +264 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealAssociations.js.map +7 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealClosure.js +88 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealClosure.js.map +7 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealData.js +41 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealData.js.map +7 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealFormHandlers.js +66 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealFormHandlers.js.map +7 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealInjectedTabs.js +39 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealInjectedTabs.js.map +7 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealMutationContext.js +49 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealMutationContext.js.map +7 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealPipeline.js +43 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealPipeline.js.map +7 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useScheduleDialog.js +28 -0
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useScheduleDialog.js.map +7 -0
- package/dist/modules/customers/backend/customers/deals/[id]/page.js +556 -503
- package/dist/modules/customers/backend/customers/deals/[id]/page.js.map +3 -3
- package/dist/modules/customers/backend/customers/deals/page.js +66 -21
- package/dist/modules/customers/backend/customers/deals/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/people/page.js +36 -28
- package/dist/modules/customers/backend/customers/people/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/people-v2/[id]/page.js +318 -203
- package/dist/modules/customers/backend/customers/people-v2/[id]/page.js.map +3 -3
- package/dist/modules/customers/cli.js +105 -13
- package/dist/modules/customers/cli.js.map +2 -2
- package/dist/modules/customers/commands/activities.js +6 -0
- package/dist/modules/customers/commands/activities.js.map +2 -2
- package/dist/modules/customers/commands/deals.js +315 -107
- package/dist/modules/customers/commands/deals.js.map +2 -2
- package/dist/modules/customers/commands/dictionaries.js +166 -32
- package/dist/modules/customers/commands/dictionaries.js.map +2 -2
- package/dist/modules/customers/commands/dictionaryKindSettings.js +208 -0
- package/dist/modules/customers/commands/dictionaryKindSettings.js.map +7 -0
- package/dist/modules/customers/commands/entity-roles.js +415 -0
- package/dist/modules/customers/commands/entity-roles.js.map +7 -0
- package/dist/modules/customers/commands/index.js +4 -0
- package/dist/modules/customers/commands/index.js.map +2 -2
- package/dist/modules/customers/commands/interactions.js +108 -21
- package/dist/modules/customers/commands/interactions.js.map +2 -2
- package/dist/modules/customers/commands/labels.js +539 -0
- package/dist/modules/customers/commands/labels.js.map +7 -0
- package/dist/modules/customers/commands/people.js +560 -463
- package/dist/modules/customers/commands/people.js.map +3 -3
- package/dist/modules/customers/commands/personCompanyLinks.js +568 -0
- package/dist/modules/customers/commands/personCompanyLinks.js.map +7 -0
- package/dist/modules/customers/commands/shared.js +12 -4
- package/dist/modules/customers/commands/shared.js.map +2 -2
- package/dist/modules/customers/commands/todos.js +10 -1
- package/dist/modules/customers/commands/todos.js.map +2 -2
- package/dist/modules/customers/components/AddressEditor.js +1 -1
- package/dist/modules/customers/components/AddressEditor.js.map +2 -2
- package/dist/modules/customers/components/CustomersConfigurationSections.js +31 -0
- package/dist/modules/customers/components/CustomersConfigurationSections.js.map +7 -0
- package/dist/modules/customers/components/DictionarySettings.js +37 -2
- package/dist/modules/customers/components/DictionarySettings.js.map +2 -2
- package/dist/modules/customers/components/detail/ActiveDealCard.js +121 -0
- package/dist/modules/customers/components/detail/ActiveDealCard.js.map +7 -0
- package/dist/modules/customers/components/detail/ActivitiesSection.js +222 -331
- package/dist/modules/customers/components/detail/ActivitiesSection.js.map +3 -3
- package/dist/modules/customers/components/detail/ActivityAiActions.js +36 -0
- package/dist/modules/customers/components/detail/ActivityAiActions.js.map +7 -0
- package/dist/modules/customers/components/detail/ActivityCard.js +126 -0
- package/dist/modules/customers/components/detail/ActivityCard.js.map +7 -0
- package/dist/modules/customers/components/detail/ActivityHistorySection.js +340 -0
- package/dist/modules/customers/components/detail/ActivityHistorySection.js.map +7 -0
- package/dist/modules/customers/components/detail/ActivityLogTab.js +56 -0
- package/dist/modules/customers/components/detail/ActivityLogTab.js.map +7 -0
- package/dist/modules/customers/components/detail/ActivityTimeline.js +108 -0
- package/dist/modules/customers/components/detail/ActivityTimeline.js.map +7 -0
- package/dist/modules/customers/components/detail/ActivityTimelineFilters.js +139 -0
- package/dist/modules/customers/components/detail/ActivityTimelineFilters.js.map +7 -0
- package/dist/modules/customers/components/detail/ActivityTypeSelector.js +42 -0
- package/dist/modules/customers/components/detail/ActivityTypeSelector.js.map +7 -0
- package/dist/modules/customers/components/detail/AiActionChips.js +38 -0
- package/dist/modules/customers/components/detail/AiActionChips.js.map +7 -0
- package/dist/modules/customers/components/detail/AssignRoleDialog.js +534 -0
- package/dist/modules/customers/components/detail/AssignRoleDialog.js.map +7 -0
- package/dist/modules/customers/components/detail/ChangelogEntryRow.js +79 -0
- package/dist/modules/customers/components/detail/ChangelogEntryRow.js.map +7 -0
- package/dist/modules/customers/components/detail/ChangelogFilters.js +176 -0
- package/dist/modules/customers/components/detail/ChangelogFilters.js.map +7 -0
- package/dist/modules/customers/components/detail/ChangelogKpiCards.js +88 -0
- package/dist/modules/customers/components/detail/ChangelogKpiCards.js.map +7 -0
- package/dist/modules/customers/components/detail/ChangelogTab.js +470 -0
- package/dist/modules/customers/components/detail/ChangelogTab.js.map +7 -0
- package/dist/modules/customers/components/detail/ComingSoonPlaceholder.js +16 -0
- package/dist/modules/customers/components/detail/ComingSoonPlaceholder.js.map +7 -0
- package/dist/modules/customers/components/detail/CompanyCard.js +283 -0
- package/dist/modules/customers/components/detail/CompanyCard.js.map +7 -0
- package/dist/modules/customers/components/detail/CompanyDashboardTab.js +133 -0
- package/dist/modules/customers/components/detail/CompanyDashboardTab.js.map +7 -0
- package/dist/modules/customers/components/detail/CompanyDetailHeader.js +191 -0
- package/dist/modules/customers/components/detail/CompanyDetailHeader.js.map +7 -0
- package/dist/modules/customers/components/detail/CompanyDetailTabs.js +123 -0
- package/dist/modules/customers/components/detail/CompanyDetailTabs.js.map +7 -0
- package/dist/modules/customers/components/detail/CompanyKpiBar.js +174 -0
- package/dist/modules/customers/components/detail/CompanyKpiBar.js.map +7 -0
- package/dist/modules/customers/components/detail/CompanyPeopleSection.js +514 -230
- package/dist/modules/customers/components/detail/CompanyPeopleSection.js.map +2 -2
- package/dist/modules/customers/components/detail/CompanyTagsDialog.js +22 -0
- package/dist/modules/customers/components/detail/CompanyTagsDialog.js.map +7 -0
- package/dist/modules/customers/components/detail/ConfirmDealLostDialog.js +159 -0
- package/dist/modules/customers/components/detail/ConfirmDealLostDialog.js.map +7 -0
- package/dist/modules/customers/components/detail/CreatePersonDialog.js +135 -0
- package/dist/modules/customers/components/detail/CreatePersonDialog.js.map +7 -0
- package/dist/modules/customers/components/detail/DealClosureActionBar.js +59 -0
- package/dist/modules/customers/components/detail/DealClosureActionBar.js.map +7 -0
- package/dist/modules/customers/components/detail/DealDetailHeader.js +237 -0
- package/dist/modules/customers/components/detail/DealDetailHeader.js.map +7 -0
- package/dist/modules/customers/components/detail/DealDetailTabs.js +109 -0
- package/dist/modules/customers/components/detail/DealDetailTabs.js.map +7 -0
- package/dist/modules/customers/components/detail/DealForm.js +219 -92
- package/dist/modules/customers/components/detail/DealForm.js.map +2 -2
- package/dist/modules/customers/components/detail/DealLinkedEntitiesTab.js +295 -0
- package/dist/modules/customers/components/detail/DealLinkedEntitiesTab.js.map +7 -0
- package/dist/modules/customers/components/detail/DealLostSummaryDialog.js +107 -0
- package/dist/modules/customers/components/detail/DealLostSummaryDialog.js.map +7 -0
- package/dist/modules/customers/components/detail/DealWonPopup.js +113 -0
- package/dist/modules/customers/components/detail/DealWonPopup.js.map +7 -0
- package/dist/modules/customers/components/detail/DealsSection.js +206 -193
- package/dist/modules/customers/components/detail/DealsSection.js.map +2 -2
- package/dist/modules/customers/components/detail/DecisionMakersFooter.js +39 -0
- package/dist/modules/customers/components/detail/DecisionMakersFooter.js.map +7 -0
- package/dist/modules/customers/components/detail/EntityTagsDialog.js +1096 -0
- package/dist/modules/customers/components/detail/EntityTagsDialog.js.map +7 -0
- package/dist/modules/customers/components/detail/InlineActivityComposer.js +197 -0
- package/dist/modules/customers/components/detail/InlineActivityComposer.js.map +7 -0
- package/dist/modules/customers/components/detail/ManageTagsDialog.js +1091 -0
- package/dist/modules/customers/components/detail/ManageTagsDialog.js.map +7 -0
- package/dist/modules/customers/components/detail/MiniWeekCalendar.js +272 -0
- package/dist/modules/customers/components/detail/MiniWeekCalendar.js.map +7 -0
- package/dist/modules/customers/components/detail/MobilePersonDetail.js +106 -0
- package/dist/modules/customers/components/detail/MobilePersonDetail.js.map +7 -0
- package/dist/modules/customers/components/detail/NextStepCard.js +72 -0
- package/dist/modules/customers/components/detail/NextStepCard.js.map +7 -0
- package/dist/modules/customers/components/detail/PersonCard.js +192 -0
- package/dist/modules/customers/components/detail/PersonCard.js.map +7 -0
- package/dist/modules/customers/components/detail/PersonCompaniesSection.js +345 -0
- package/dist/modules/customers/components/detail/PersonCompaniesSection.js.map +7 -0
- package/dist/modules/customers/components/detail/PersonDetailHeader.js +220 -0
- package/dist/modules/customers/components/detail/PersonDetailHeader.js.map +7 -0
- package/dist/modules/customers/components/detail/PersonDetailTabs.js +122 -0
- package/dist/modules/customers/components/detail/PersonDetailTabs.js.map +7 -0
- package/dist/modules/customers/components/detail/PersonTagsDialog.js +24 -0
- package/dist/modules/customers/components/detail/PersonTagsDialog.js.map +7 -0
- package/dist/modules/customers/components/detail/PipelineStepper.js +191 -0
- package/dist/modules/customers/components/detail/PipelineStepper.js.map +7 -0
- package/dist/modules/customers/components/detail/PlannedActivitiesSection.js +222 -0
- package/dist/modules/customers/components/detail/PlannedActivitiesSection.js.map +7 -0
- package/dist/modules/customers/components/detail/RelationshipHealthCard.js +49 -0
- package/dist/modules/customers/components/detail/RelationshipHealthCard.js.map +7 -0
- package/dist/modules/customers/components/detail/RoleAssignmentRow.js +189 -0
- package/dist/modules/customers/components/detail/RoleAssignmentRow.js.map +7 -0
- package/dist/modules/customers/components/detail/RolesSection.js +234 -0
- package/dist/modules/customers/components/detail/RolesSection.js.map +7 -0
- package/dist/modules/customers/components/detail/ScheduleActivityDialog.js +410 -0
- package/dist/modules/customers/components/detail/ScheduleActivityDialog.js.map +7 -0
- package/dist/modules/customers/components/detail/aiActionCatalog.js +41 -0
- package/dist/modules/customers/components/detail/aiActionCatalog.js.map +7 -0
- package/dist/modules/customers/components/detail/assignableStaff.js +48 -0
- package/dist/modules/customers/components/detail/assignableStaff.js.map +7 -0
- package/dist/modules/customers/components/detail/dashboard/ActiveDealWidget.js +48 -0
- package/dist/modules/customers/components/detail/dashboard/ActiveDealWidget.js.map +7 -0
- package/dist/modules/customers/components/detail/dashboard/OpenTasksWidget.js +86 -0
- package/dist/modules/customers/components/detail/dashboard/OpenTasksWidget.js.map +7 -0
- package/dist/modules/customers/components/detail/dashboard/RecentActivityWidget.js +53 -0
- package/dist/modules/customers/components/detail/dashboard/RecentActivityWidget.js.map +7 -0
- package/dist/modules/customers/components/detail/dashboard/RelationshipHealthWidget.js +30 -0
- package/dist/modules/customers/components/detail/dashboard/RelationshipHealthWidget.js.map +7 -0
- package/dist/modules/customers/components/detail/dashboard/UpcomingMeetingsWidget.js +43 -0
- package/dist/modules/customers/components/detail/dashboard/UpcomingMeetingsWidget.js.map +7 -0
- package/dist/modules/customers/components/detail/dashboard/helpers.js +71 -0
- package/dist/modules/customers/components/detail/dashboard/helpers.js.map +7 -0
- package/dist/modules/customers/components/detail/healthScoreUtils.js +69 -0
- package/dist/modules/customers/components/detail/healthScoreUtils.js.map +7 -0
- package/dist/modules/customers/components/detail/hooks/useCurrencyDictionary.js +5 -5
- package/dist/modules/customers/components/detail/hooks/useCurrencyDictionary.js.map +2 -2
- package/dist/modules/customers/components/detail/hooks/useCustomerDictionary.js +9 -8
- package/dist/modules/customers/components/detail/hooks/useCustomerDictionary.js.map +3 -3
- package/dist/modules/customers/components/detail/hooks/useInteractionMutations.js +65 -0
- package/dist/modules/customers/components/detail/hooks/useInteractionMutations.js.map +7 -0
- package/dist/modules/customers/components/detail/notesAdapter.js +70 -30
- package/dist/modules/customers/components/detail/notesAdapter.js.map +2 -2
- package/dist/modules/customers/components/detail/pipelineStageUtils.js +26 -0
- package/dist/modules/customers/components/detail/pipelineStageUtils.js.map +7 -0
- package/dist/modules/customers/components/detail/schedule/DateTimeFields.js +144 -0
- package/dist/modules/customers/components/detail/schedule/DateTimeFields.js.map +7 -0
- package/dist/modules/customers/components/detail/schedule/FooterFields.js +60 -0
- package/dist/modules/customers/components/detail/schedule/FooterFields.js.map +7 -0
- package/dist/modules/customers/components/detail/schedule/LinkedEntitiesField.js +216 -0
- package/dist/modules/customers/components/detail/schedule/LinkedEntitiesField.js.map +7 -0
- package/dist/modules/customers/components/detail/schedule/LocationField.js +34 -0
- package/dist/modules/customers/components/detail/schedule/LocationField.js.map +7 -0
- package/dist/modules/customers/components/detail/schedule/ParticipantsField.js +226 -0
- package/dist/modules/customers/components/detail/schedule/ParticipantsField.js.map +7 -0
- package/dist/modules/customers/components/detail/schedule/fieldConfig.js +69 -0
- package/dist/modules/customers/components/detail/schedule/fieldConfig.js.map +7 -0
- package/dist/modules/customers/components/detail/schedule/index.js +21 -0
- package/dist/modules/customers/components/detail/schedule/index.js.map +7 -0
- package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js +172 -0
- package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js.map +7 -0
- package/dist/modules/customers/components/detail/utils.js +23 -0
- package/dist/modules/customers/components/detail/utils.js.map +2 -2
- package/dist/modules/customers/components/formConfig.js +144 -22
- package/dist/modules/customers/components/formConfig.js.map +2 -2
- package/dist/modules/customers/components/linking/LinkEntityDialog.js +661 -0
- package/dist/modules/customers/components/linking/LinkEntityDialog.js.map +7 -0
- package/dist/modules/customers/components/linking/adapters/companyAdapter.js +252 -0
- package/dist/modules/customers/components/linking/adapters/companyAdapter.js.map +7 -0
- package/dist/modules/customers/components/linking/adapters/dealAdapter.js +384 -0
- package/dist/modules/customers/components/linking/adapters/dealAdapter.js.map +7 -0
- package/dist/modules/customers/components/linking/adapters/personAdapter.js +324 -0
- package/dist/modules/customers/components/linking/adapters/personAdapter.js.map +7 -0
- package/dist/modules/customers/components/list/CollectionPreviewCell.js +53 -0
- package/dist/modules/customers/components/list/CollectionPreviewCell.js.map +7 -0
- package/dist/modules/customers/data/entities.js +407 -1
- package/dist/modules/customers/data/entities.js.map +2 -2
- package/dist/modules/customers/data/validators.js +139 -21
- package/dist/modules/customers/data/validators.js.map +2 -2
- package/dist/modules/customers/events.js +19 -1
- package/dist/modules/customers/events.js.map +2 -2
- package/dist/modules/customers/lib/customerRoleTypes.js +19 -0
- package/dist/modules/customers/lib/customerRoleTypes.js.map +7 -0
- package/dist/modules/customers/lib/dealClosureNotification.js +39 -0
- package/dist/modules/customers/lib/dealClosureNotification.js.map +7 -0
- package/dist/modules/customers/lib/dealStageTransitionTable.js +29 -0
- package/dist/modules/customers/lib/dealStageTransitionTable.js.map +7 -0
- package/dist/modules/customers/lib/dictionaries.js +25 -0
- package/dist/modules/customers/lib/dictionaries.js.map +2 -2
- package/dist/modules/customers/lib/interactionReadModel.js +10 -0
- package/dist/modules/customers/lib/interactionReadModel.js.map +2 -2
- package/dist/modules/customers/lib/personCompanies.js +235 -0
- package/dist/modules/customers/lib/personCompanies.js.map +7 -0
- package/dist/modules/customers/lib/personCompanyLinkTable.js +42 -0
- package/dist/modules/customers/lib/personCompanyLinkTable.js.map +7 -0
- package/dist/modules/customers/lib/roleTypeUsage.js +104 -0
- package/dist/modules/customers/lib/roleTypeUsage.js.map +7 -0
- package/dist/modules/customers/migrations/Migration20260406214502.js +18 -0
- package/dist/modules/customers/migrations/Migration20260406214502.js.map +7 -0
- package/dist/modules/customers/migrations/Migration20260408135736.js +17 -0
- package/dist/modules/customers/migrations/Migration20260408135736.js.map +7 -0
- package/dist/modules/customers/migrations/Migration20260408225345.js +21 -0
- package/dist/modules/customers/migrations/Migration20260408225345.js.map +7 -0
- package/dist/modules/customers/migrations/Migration20260411075533.js +27 -0
- package/dist/modules/customers/migrations/Migration20260411075533.js.map +7 -0
- package/dist/modules/customers/migrations/Migration20260411103551.js +13 -0
- package/dist/modules/customers/migrations/Migration20260411103551.js.map +7 -0
- package/dist/modules/customers/migrations/Migration20260411130944.js +26 -0
- package/dist/modules/customers/migrations/Migration20260411130944.js.map +7 -0
- package/dist/modules/customers/migrations/Migration20260415095203.js +13 -0
- package/dist/modules/customers/migrations/Migration20260415095203.js.map +7 -0
- package/dist/modules/customers/migrations/Migration20260415135056.js +20 -0
- package/dist/modules/customers/migrations/Migration20260415135056.js.map +7 -0
- package/dist/modules/customers/migrations/Migration20260417140000.js +15 -0
- package/dist/modules/customers/migrations/Migration20260417140000.js.map +7 -0
- package/dist/modules/customers/migrations/Migration20260417160000.js +17 -0
- package/dist/modules/customers/migrations/Migration20260417160000.js.map +7 -0
- package/dist/modules/customers/migrations/Migration20260417235407.js +13 -0
- package/dist/modules/customers/migrations/Migration20260417235407.js.map +7 -0
- package/dist/modules/customers/setup.js +16 -1
- package/dist/modules/customers/setup.js.map +2 -2
- package/dist/modules/customers/subscribers/deal-closure-notification.js +16 -0
- package/dist/modules/customers/subscribers/deal-closure-notification.js.map +7 -0
- package/dist/modules/customers/subscribers/deal-lost-notification.js +16 -0
- package/dist/modules/customers/subscribers/deal-lost-notification.js.map +7 -0
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.js +2 -0
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.js.map +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/reorder/route.js +154 -0
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/reorder/route.js.map +7 -0
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/route.js +6 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/route.js.map +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/set-default/route.js +154 -0
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/set-default/route.js.map +7 -0
- package/dist/modules/dictionaries/api/context.js +8 -1
- package/dist/modules/dictionaries/api/context.js.map +2 -2
- package/dist/modules/dictionaries/api/openapi.js +18 -1
- package/dist/modules/dictionaries/api/openapi.js.map +2 -2
- package/dist/modules/dictionaries/commands/entry-operations.js +388 -0
- package/dist/modules/dictionaries/commands/entry-operations.js.map +7 -0
- package/dist/modules/dictionaries/commands/factory.js +24 -3
- package/dist/modules/dictionaries/commands/factory.js.map +2 -2
- package/dist/modules/dictionaries/commands/index.js +1 -0
- package/dist/modules/dictionaries/commands/index.js.map +2 -2
- package/dist/modules/dictionaries/components/DictionaryTable.js +6 -3
- package/dist/modules/dictionaries/components/DictionaryTable.js.map +2 -2
- package/dist/modules/dictionaries/data/entities.js +11 -1
- package/dist/modules/dictionaries/data/entities.js.map +2 -2
- package/dist/modules/dictionaries/data/validators.js +28 -2
- package/dist/modules/dictionaries/data/validators.js.map +2 -2
- package/dist/modules/dictionaries/events.js +18 -0
- package/dist/modules/dictionaries/events.js.map +7 -0
- package/dist/modules/dictionaries/lib/clientEntries.js +43 -0
- package/dist/modules/dictionaries/lib/clientEntries.js.map +7 -0
- package/dist/modules/dictionaries/migrations/Migration20260410171544.js +45 -0
- package/dist/modules/dictionaries/migrations/Migration20260410171544.js.map +7 -0
- package/dist/modules/inbox_ops/api/proposals/[id]/route.js +4 -1
- package/dist/modules/inbox_ops/api/proposals/[id]/route.js.map +2 -2
- package/dist/modules/query_index/lib/engine.js +1 -1
- package/dist/modules/query_index/lib/engine.js.map +2 -2
- package/dist/modules/sales/components/documents/AddressesSection.js +82 -42
- package/dist/modules/sales/components/documents/AddressesSection.js.map +2 -2
- package/dist/modules/sales/lib/dictionaries.js +16 -0
- package/dist/modules/sales/lib/dictionaries.js.map +2 -2
- package/dist/modules/sales/widgets/injection-table.js +5 -1
- package/dist/modules/sales/widgets/injection-table.js.map +2 -2
- package/generated/entities/action_log/index.ts +4 -0
- package/generated/entities/customer_company_billing/index.ts +10 -0
- package/generated/entities/customer_deal/index.ts +4 -0
- package/generated/entities/customer_deal_stage_transition/index.ts +14 -0
- package/generated/entities/customer_dictionary_kind_setting/index.ts +9 -0
- package/generated/entities/customer_entity/index.ts +4 -0
- package/generated/entities/customer_entity_role/index.ts +10 -0
- package/generated/entities/customer_interaction/index.ts +11 -0
- package/generated/entities/customer_label/index.ts +8 -0
- package/generated/entities/customer_label_assignment/index.ts +7 -0
- package/generated/entities/customer_person_company_link/index.ts +9 -0
- package/generated/entities/customer_person_company_role/index.ts +7 -0
- package/generated/entities/dictionary_entry/index.ts +2 -0
- package/generated/entities.ids.generated.ts +9 -1
- package/generated/entity-fields-registry.ts +116 -1
- package/package.json +3 -3
- package/src/modules/attachments/api/route.ts +48 -6
- package/src/modules/attachments/i18n/de.json +4 -0
- package/src/modules/attachments/i18n/en.json +4 -0
- package/src/modules/attachments/i18n/es.json +4 -0
- package/src/modules/attachments/i18n/pl.json +4 -0
- package/src/modules/audit_logs/api/audit-logs/actions/export/route.ts +260 -0
- package/src/modules/audit_logs/api/audit-logs/actions/route.ts +81 -6
- package/src/modules/audit_logs/cli.ts +79 -0
- package/src/modules/audit_logs/data/entities.ts +17 -0
- package/src/modules/audit_logs/data/validators.ts +9 -1
- package/src/modules/audit_logs/lib/changeRows.ts +47 -0
- package/src/modules/audit_logs/lib/display-helpers.tsx +4 -30
- package/src/modules/audit_logs/lib/projections.ts +110 -0
- package/src/modules/audit_logs/migrations/.snapshot-open-mercato.json +325 -2
- package/src/modules/audit_logs/migrations/Migration20260412160533.ts +21 -0
- package/src/modules/audit_logs/services/actionLogService.ts +455 -85
- package/src/modules/catalog/i18n/de.json +1 -0
- package/src/modules/catalog/i18n/en.json +1 -0
- package/src/modules/catalog/i18n/es.json +1 -0
- package/src/modules/catalog/i18n/pl.json +1 -0
- package/src/modules/customer_accounts/i18n/de.json +2 -0
- package/src/modules/customer_accounts/i18n/en.json +2 -0
- package/src/modules/customer_accounts/i18n/es.json +2 -0
- package/src/modules/customer_accounts/i18n/pl.json +2 -0
- package/src/modules/customers/acl.ts +2 -0
- package/src/modules/customers/api/activities/route.ts +4 -0
- package/src/modules/customers/api/assignable-staff/route.ts +250 -0
- package/src/modules/customers/api/companies/[id]/people/route.ts +244 -0
- package/src/modules/customers/api/companies/[id]/roles/route.ts +15 -0
- package/src/modules/customers/api/companies/[id]/route.ts +458 -40
- package/src/modules/customers/api/companies/route.ts +93 -15
- package/src/modules/customers/api/deals/[id]/companies/route.ts +203 -0
- package/src/modules/customers/api/deals/[id]/people/route.ts +182 -0
- package/src/modules/customers/api/deals/[id]/route.ts +554 -57
- package/src/modules/customers/api/deals/[id]/stats/route.ts +221 -0
- package/src/modules/customers/api/deals/route.ts +35 -46
- package/src/modules/customers/api/dictionaries/[kind]/[id]/route.ts +105 -3
- package/src/modules/customers/api/dictionaries/[kind]/route.ts +143 -44
- package/src/modules/customers/api/dictionaries/context.ts +45 -16
- package/src/modules/customers/api/dictionaries/kind-settings/route.ts +232 -0
- package/src/modules/customers/api/entity-roles-factory.ts +520 -0
- package/src/modules/customers/api/interactions/conflicts/route.ts +196 -0
- package/src/modules/customers/api/interactions/counts/route.ts +112 -0
- package/src/modules/customers/api/interactions/route.ts +95 -2
- package/src/modules/customers/api/labels/assign/route.ts +202 -0
- package/src/modules/customers/api/labels/auth.ts +19 -0
- package/src/modules/customers/api/labels/route.ts +310 -0
- package/src/modules/customers/api/labels/table-errors.ts +36 -0
- package/src/modules/customers/api/labels/unassign/route.ts +197 -0
- package/src/modules/customers/api/people/[id]/companies/[linkId]/route.ts +331 -0
- package/src/modules/customers/api/people/[id]/companies/context.ts +70 -0
- package/src/modules/customers/api/people/[id]/companies/enriched/route.ts +384 -0
- package/src/modules/customers/api/people/[id]/companies/route.ts +215 -0
- package/src/modules/customers/api/people/[id]/roles/route.ts +15 -0
- package/src/modules/customers/api/people/[id]/route.ts +153 -26
- package/src/modules/customers/api/people/route.ts +134 -31
- package/src/modules/customers/api/todos/route.ts +4 -0
- package/src/modules/customers/api/utils.ts +36 -0
- package/src/modules/customers/backend/config/customers/page.tsx +2 -6
- package/src/modules/customers/backend/customers/companies/page.tsx +36 -26
- package/src/modules/customers/backend/customers/companies-v2/[id]/page.tsx +277 -262
- package/src/modules/customers/backend/customers/deals/[id]/hooks/formatters.ts +19 -0
- package/src/modules/customers/backend/customers/deals/[id]/hooks/types.ts +104 -0
- package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealActivities.ts +60 -0
- package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealAssociations.ts +362 -0
- package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealClosure.ts +113 -0
- package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealData.ts +52 -0
- package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealFormHandlers.ts +86 -0
- package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealInjectedTabs.tsx +60 -0
- package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealMutationContext.ts +76 -0
- package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealPipeline.ts +56 -0
- package/src/modules/customers/backend/customers/deals/[id]/hooks/useScheduleDialog.ts +38 -0
- package/src/modules/customers/backend/customers/deals/[id]/page.tsx +587 -624
- package/src/modules/customers/backend/customers/deals/page.tsx +71 -28
- package/src/modules/customers/backend/customers/people/page.tsx +35 -29
- package/src/modules/customers/backend/customers/people-v2/[id]/page.tsx +343 -209
- package/src/modules/customers/cli.ts +107 -12
- package/src/modules/customers/commands/activities.ts +13 -0
- package/src/modules/customers/commands/deals.ts +386 -114
- package/src/modules/customers/commands/dictionaries.ts +175 -32
- package/src/modules/customers/commands/dictionaryKindSettings.ts +268 -0
- package/src/modules/customers/commands/entity-roles.ts +494 -0
- package/src/modules/customers/commands/index.ts +4 -0
- package/src/modules/customers/commands/interactions.ts +125 -21
- package/src/modules/customers/commands/labels.ts +626 -0
- package/src/modules/customers/commands/people.ts +373 -259
- package/src/modules/customers/commands/personCompanyLinks.ts +654 -0
- package/src/modules/customers/commands/shared.ts +16 -15
- package/src/modules/customers/commands/todos.ts +17 -1
- package/src/modules/customers/components/AddressEditor.tsx +1 -1
- package/src/modules/customers/components/CustomersConfigurationSections.tsx +36 -0
- package/src/modules/customers/components/DictionarySettings.tsx +43 -2
- package/src/modules/customers/components/detail/ActiveDealCard.tsx +175 -0
- package/src/modules/customers/components/detail/ActivitiesSection.tsx +267 -361
- package/src/modules/customers/components/detail/ActivityAiActions.tsx +49 -0
- package/src/modules/customers/components/detail/ActivityCard.tsx +154 -0
- package/src/modules/customers/components/detail/ActivityHistorySection.tsx +412 -0
- package/src/modules/customers/components/detail/ActivityLogTab.tsx +67 -0
- package/src/modules/customers/components/detail/ActivityTimeline.tsx +158 -0
- package/src/modules/customers/components/detail/ActivityTimelineFilters.tsx +163 -0
- package/src/modules/customers/components/detail/ActivityTypeSelector.tsx +53 -0
- package/src/modules/customers/components/detail/AiActionChips.tsx +48 -0
- package/src/modules/customers/components/detail/AssignRoleDialog.tsx +672 -0
- package/src/modules/customers/components/detail/ChangelogEntryRow.tsx +132 -0
- package/src/modules/customers/components/detail/ChangelogFilters.tsx +193 -0
- package/src/modules/customers/components/detail/ChangelogKpiCards.tsx +107 -0
- package/src/modules/customers/components/detail/ChangelogTab.tsx +629 -0
- package/src/modules/customers/components/detail/ComingSoonPlaceholder.tsx +21 -0
- package/src/modules/customers/components/detail/CompanyCard.tsx +419 -0
- package/src/modules/customers/components/detail/CompanyDashboardTab.tsx +161 -0
- package/src/modules/customers/components/detail/CompanyDetailHeader.tsx +243 -0
- package/src/modules/customers/components/detail/CompanyDetailTabs.tsx +172 -0
- package/src/modules/customers/components/detail/CompanyKpiBar.tsx +206 -0
- package/src/modules/customers/components/detail/CompanyPeopleSection.tsx +582 -288
- package/src/modules/customers/components/detail/CompanyTagsDialog.tsx +23 -0
- package/src/modules/customers/components/detail/ConfirmDealLostDialog.tsx +210 -0
- package/src/modules/customers/components/detail/CreatePersonDialog.tsx +178 -0
- package/src/modules/customers/components/detail/DealClosureActionBar.tsx +63 -0
- package/src/modules/customers/components/detail/DealDetailHeader.tsx +335 -0
- package/src/modules/customers/components/detail/DealDetailTabs.tsx +154 -0
- package/src/modules/customers/components/detail/DealForm.tsx +253 -101
- package/src/modules/customers/components/detail/DealLinkedEntitiesTab.tsx +349 -0
- package/src/modules/customers/components/detail/DealLostSummaryDialog.tsx +156 -0
- package/src/modules/customers/components/detail/DealWonPopup.tsx +164 -0
- package/src/modules/customers/components/detail/DealsSection.tsx +276 -221
- package/src/modules/customers/components/detail/DecisionMakersFooter.tsx +56 -0
- package/src/modules/customers/components/detail/EntityTagsDialog.tsx +1372 -0
- package/src/modules/customers/components/detail/InlineActivityComposer.tsx +239 -0
- package/src/modules/customers/components/detail/ManageTagsDialog.tsx +1331 -0
- package/src/modules/customers/components/detail/MiniWeekCalendar.tsx +338 -0
- package/src/modules/customers/components/detail/MobilePersonDetail.tsx +124 -0
- package/src/modules/customers/components/detail/NextStepCard.tsx +104 -0
- package/src/modules/customers/components/detail/PersonCard.tsx +238 -0
- package/src/modules/customers/components/detail/PersonCompaniesSection.tsx +426 -0
- package/src/modules/customers/components/detail/PersonDetailHeader.tsx +294 -0
- package/src/modules/customers/components/detail/PersonDetailTabs.tsx +172 -0
- package/src/modules/customers/components/detail/PersonTagsDialog.tsx +26 -0
- package/src/modules/customers/components/detail/PipelineStepper.tsx +245 -0
- package/src/modules/customers/components/detail/PlannedActivitiesSection.tsx +255 -0
- package/src/modules/customers/components/detail/RelationshipHealthCard.tsx +63 -0
- package/src/modules/customers/components/detail/RoleAssignmentRow.tsx +248 -0
- package/src/modules/customers/components/detail/RolesSection.tsx +311 -0
- package/src/modules/customers/components/detail/ScheduleActivityDialog.tsx +481 -0
- package/src/modules/customers/components/detail/aiActionCatalog.ts +77 -0
- package/src/modules/customers/components/detail/assignableStaff.ts +124 -0
- package/src/modules/customers/components/detail/dashboard/ActiveDealWidget.tsx +63 -0
- package/src/modules/customers/components/detail/dashboard/OpenTasksWidget.tsx +114 -0
- package/src/modules/customers/components/detail/dashboard/RecentActivityWidget.tsx +69 -0
- package/src/modules/customers/components/detail/dashboard/RelationshipHealthWidget.tsx +40 -0
- package/src/modules/customers/components/detail/dashboard/UpcomingMeetingsWidget.tsx +64 -0
- package/src/modules/customers/components/detail/dashboard/helpers.ts +78 -0
- package/src/modules/customers/components/detail/healthScoreUtils.ts +91 -0
- package/src/modules/customers/components/detail/hooks/useCurrencyDictionary.ts +8 -8
- package/src/modules/customers/components/detail/hooks/useCustomerDictionary.ts +10 -6
- package/src/modules/customers/components/detail/hooks/useInteractionMutations.ts +91 -0
- package/src/modules/customers/components/detail/notesAdapter.ts +91 -30
- package/src/modules/customers/components/detail/pipelineStageUtils.ts +29 -0
- package/src/modules/customers/components/detail/schedule/DateTimeFields.tsx +187 -0
- package/src/modules/customers/components/detail/schedule/FooterFields.tsx +79 -0
- package/src/modules/customers/components/detail/schedule/LinkedEntitiesField.tsx +277 -0
- package/src/modules/customers/components/detail/schedule/LocationField.tsx +42 -0
- package/src/modules/customers/components/detail/schedule/ParticipantsField.tsx +255 -0
- package/src/modules/customers/components/detail/schedule/fieldConfig.ts +70 -0
- package/src/modules/customers/components/detail/schedule/index.ts +9 -0
- package/src/modules/customers/components/detail/schedule/useScheduleFormState.ts +221 -0
- package/src/modules/customers/components/detail/types.ts +16 -0
- package/src/modules/customers/components/detail/utils.ts +25 -0
- package/src/modules/customers/components/formConfig.tsx +223 -28
- package/src/modules/customers/components/linking/LinkEntityDialog.tsx +920 -0
- package/src/modules/customers/components/linking/adapters/companyAdapter.tsx +398 -0
- package/src/modules/customers/components/linking/adapters/dealAdapter.tsx +578 -0
- package/src/modules/customers/components/linking/adapters/personAdapter.tsx +512 -0
- package/src/modules/customers/components/list/CollectionPreviewCell.tsx +66 -0
- package/src/modules/customers/data/entities.ts +353 -1
- package/src/modules/customers/data/validators.ts +170 -19
- package/src/modules/customers/events.ts +22 -0
- package/src/modules/customers/i18n/de.json +841 -2
- package/src/modules/customers/i18n/en.json +841 -2
- package/src/modules/customers/i18n/es.json +840 -1
- package/src/modules/customers/i18n/pl.json +841 -2
- package/src/modules/customers/lib/customerRoleTypes.ts +24 -0
- package/src/modules/customers/lib/dealClosureNotification.ts +64 -0
- package/src/modules/customers/lib/dealStageTransitionTable.ts +32 -0
- package/src/modules/customers/lib/dictionaries.ts +26 -10
- package/src/modules/customers/lib/interactionReadModel.ts +10 -0
- package/src/modules/customers/lib/personCompanies.ts +317 -0
- package/src/modules/customers/lib/personCompanyLinkTable.ts +58 -0
- package/src/modules/customers/lib/roleTypeUsage.ts +146 -0
- package/src/modules/customers/migrations/.snapshot-open-mercato.json +2747 -798
- package/src/modules/customers/migrations/Migration20260406214502.ts +19 -0
- package/src/modules/customers/migrations/Migration20260408135736.ts +15 -0
- package/src/modules/customers/migrations/Migration20260408225345.ts +23 -0
- package/src/modules/customers/migrations/Migration20260411075533.ts +30 -0
- package/src/modules/customers/migrations/Migration20260411103551.ts +13 -0
- package/src/modules/customers/migrations/Migration20260411130944.ts +30 -0
- package/src/modules/customers/migrations/Migration20260415095203.ts +13 -0
- package/src/modules/customers/migrations/Migration20260415135056.ts +22 -0
- package/src/modules/customers/migrations/Migration20260417140000.ts +15 -0
- package/src/modules/customers/migrations/Migration20260417160000.ts +17 -0
- package/src/modules/customers/migrations/Migration20260417235407.ts +13 -0
- package/src/modules/customers/setup.ts +15 -0
- package/src/modules/customers/subscribers/deal-closure-notification.ts +22 -0
- package/src/modules/customers/subscribers/deal-lost-notification.ts +22 -0
- package/src/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.ts +2 -0
- package/src/modules/dictionaries/api/[dictionaryId]/entries/reorder/route.ts +162 -0
- package/src/modules/dictionaries/api/[dictionaryId]/entries/route.ts +6 -2
- package/src/modules/dictionaries/api/[dictionaryId]/entries/set-default/route.ts +162 -0
- package/src/modules/dictionaries/api/context.ts +9 -0
- package/src/modules/dictionaries/api/openapi.ts +17 -0
- package/src/modules/dictionaries/commands/entry-operations.ts +457 -0
- package/src/modules/dictionaries/commands/factory.ts +31 -3
- package/src/modules/dictionaries/commands/index.ts +1 -0
- package/src/modules/dictionaries/components/DictionaryTable.tsx +15 -6
- package/src/modules/dictionaries/data/entities.ts +9 -0
- package/src/modules/dictionaries/data/validators.ts +34 -0
- package/src/modules/dictionaries/events.ts +20 -0
- package/src/modules/dictionaries/i18n/de.json +2 -0
- package/src/modules/dictionaries/i18n/en.json +2 -0
- package/src/modules/dictionaries/i18n/es.json +2 -0
- package/src/modules/dictionaries/i18n/pl.json +2 -0
- package/src/modules/dictionaries/lib/clientEntries.ts +66 -0
- package/src/modules/dictionaries/migrations/.snapshot-open-mercato.json +185 -3
- package/src/modules/dictionaries/migrations/Migration20260410171544.ts +49 -0
- package/src/modules/inbox_ops/api/proposals/[id]/route.ts +4 -1
- package/src/modules/query_index/lib/engine.ts +9 -1
- package/src/modules/sales/components/documents/AddressesSection.tsx +92 -42
- package/src/modules/sales/i18n/de.json +28 -0
- package/src/modules/sales/i18n/en.json +28 -0
- package/src/modules/sales/i18n/es.json +28 -0
- package/src/modules/sales/i18n/pl.json +28 -0
- package/src/modules/sales/lib/dictionaries.ts +18 -0
- package/src/modules/sales/widgets/injection-table.ts +4 -0
|
@@ -0,0 +1,920 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import {
|
|
5
|
+
Check,
|
|
6
|
+
Link2,
|
|
7
|
+
Loader2,
|
|
8
|
+
Plus,
|
|
9
|
+
Search,
|
|
10
|
+
X,
|
|
11
|
+
} from 'lucide-react'
|
|
12
|
+
import { cn } from '@open-mercato/shared/lib/utils'
|
|
13
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
14
|
+
import { Avatar } from '@open-mercato/ui/primitives/avatar'
|
|
15
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
16
|
+
import {
|
|
17
|
+
Dialog,
|
|
18
|
+
DialogContent,
|
|
19
|
+
DialogDescription,
|
|
20
|
+
DialogFooter,
|
|
21
|
+
DialogHeader,
|
|
22
|
+
DialogTitle,
|
|
23
|
+
} from '@open-mercato/ui/primitives/dialog'
|
|
24
|
+
import { IconButton } from '@open-mercato/ui/primitives/icon-button'
|
|
25
|
+
import { Input } from '@open-mercato/ui/primitives/input'
|
|
26
|
+
|
|
27
|
+
export type LinkEntityKind = 'company' | 'person' | 'deal'
|
|
28
|
+
|
|
29
|
+
export type LinkEntityOption = {
|
|
30
|
+
id: string
|
|
31
|
+
label: string
|
|
32
|
+
subtitle?: string | null
|
|
33
|
+
avatarSeed?: string | null
|
|
34
|
+
icon?: React.ReactNode
|
|
35
|
+
meta?: Record<string, unknown>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type LinkEntitySearchPage = {
|
|
39
|
+
items: LinkEntityOption[]
|
|
40
|
+
totalPages: number
|
|
41
|
+
total?: number
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type LinkEntityFilterOption = {
|
|
45
|
+
id: string
|
|
46
|
+
label: string
|
|
47
|
+
count?: number
|
|
48
|
+
dotColor?: string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type LinkEntityRowContext = {
|
|
52
|
+
selected: boolean
|
|
53
|
+
focused: boolean
|
|
54
|
+
disabled?: boolean
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type LinkEntityAdapter<TDetails = unknown, TLinkSettings = Record<string, unknown>> = {
|
|
58
|
+
kind: LinkEntityKind
|
|
59
|
+
searchPage: (
|
|
60
|
+
query: string,
|
|
61
|
+
page: number,
|
|
62
|
+
filterId?: string,
|
|
63
|
+
) => Promise<LinkEntitySearchPage>
|
|
64
|
+
fetchByIds: (ids: string[]) => Promise<LinkEntityOption[]>
|
|
65
|
+
fetchDetails?: (id: string) => Promise<TDetails>
|
|
66
|
+
|
|
67
|
+
dialogTitle: string
|
|
68
|
+
dialogSubtitle?: string
|
|
69
|
+
headerIcon?: React.ReactNode
|
|
70
|
+
sectionLabel?: string
|
|
71
|
+
searchPlaceholder: string
|
|
72
|
+
searchEmptyHint: string
|
|
73
|
+
selectedEmptyHint: string
|
|
74
|
+
confirmButtonLabel: string
|
|
75
|
+
defaultAvatarIcon?: React.ReactNode
|
|
76
|
+
|
|
77
|
+
filters?: {
|
|
78
|
+
options: LinkEntityFilterOption[]
|
|
79
|
+
defaultId?: string
|
|
80
|
+
/**
|
|
81
|
+
* Optional client-side predicate applied AFTER the server response.
|
|
82
|
+
* Return true to keep the option when the given filter id is active.
|
|
83
|
+
* When not provided, all items pass regardless of filter (filter effectively
|
|
84
|
+
* only applies server-side via searchPage's third argument).
|
|
85
|
+
*/
|
|
86
|
+
clientFilter?: (option: LinkEntityOption, filterId: string) => boolean
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
renderRow?: (
|
|
90
|
+
option: LinkEntityOption,
|
|
91
|
+
ctx: LinkEntityRowContext,
|
|
92
|
+
) => React.ReactNode
|
|
93
|
+
renderPreview?: (option: LinkEntityOption, details?: TDetails) => React.ReactNode
|
|
94
|
+
renderLinkSettings?: (
|
|
95
|
+
settings: TLinkSettings,
|
|
96
|
+
onChange: (next: TLinkSettings) => void,
|
|
97
|
+
focusedOption: LinkEntityOption | null,
|
|
98
|
+
) => React.ReactNode
|
|
99
|
+
initialLinkSettings?: TLinkSettings
|
|
100
|
+
|
|
101
|
+
computeOrphanWarning?: (option: LinkEntityOption) => Promise<string | null>
|
|
102
|
+
|
|
103
|
+
addNew?: {
|
|
104
|
+
title: string
|
|
105
|
+
subtitle?: string
|
|
106
|
+
render: (ctx: {
|
|
107
|
+
onCreated: (created: LinkEntityOption) => void
|
|
108
|
+
onCancel: () => void
|
|
109
|
+
}) => React.ReactNode
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export type LinkEntityConfirmInput<TLinkSettings = Record<string, unknown>> = {
|
|
114
|
+
addedIds: string[]
|
|
115
|
+
removedIds: string[]
|
|
116
|
+
nextSelectedIds: string[]
|
|
117
|
+
primaryId?: string | null
|
|
118
|
+
optionsById: Record<string, LinkEntityOption>
|
|
119
|
+
linkSettings?: TLinkSettings
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
type GuardedMutationRunner = <T,>(
|
|
123
|
+
operation: () => Promise<T>,
|
|
124
|
+
mutationPayload?: Record<string, unknown>,
|
|
125
|
+
) => Promise<T>
|
|
126
|
+
|
|
127
|
+
export type LinkEntityDialogProps<TDetails = unknown, TLinkSettings = Record<string, unknown>> = {
|
|
128
|
+
open: boolean
|
|
129
|
+
onOpenChange: (open: boolean) => void
|
|
130
|
+
adapter: LinkEntityAdapter<TDetails, TLinkSettings>
|
|
131
|
+
initialSelectedIds: string[]
|
|
132
|
+
initialPrimaryId?: string | null
|
|
133
|
+
primarySupported?: boolean
|
|
134
|
+
onConfirm: (next: LinkEntityConfirmInput<TLinkSettings>) => Promise<void>
|
|
135
|
+
runGuardedMutation?: GuardedMutationRunner
|
|
136
|
+
avatarVariant?: 'default' | 'monochrome'
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const SEARCH_DEBOUNCE_MS = 200
|
|
140
|
+
|
|
141
|
+
function diffSelection(initial: string[], next: string[]): { addedIds: string[]; removedIds: string[] } {
|
|
142
|
+
const initialSet = new Set(initial)
|
|
143
|
+
const nextSet = new Set(next)
|
|
144
|
+
const addedIds: string[] = []
|
|
145
|
+
const removedIds: string[] = []
|
|
146
|
+
next.forEach((id) => {
|
|
147
|
+
if (!initialSet.has(id)) addedIds.push(id)
|
|
148
|
+
})
|
|
149
|
+
initial.forEach((id) => {
|
|
150
|
+
if (!nextSet.has(id)) removedIds.push(id)
|
|
151
|
+
})
|
|
152
|
+
return { addedIds, removedIds }
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function sameIds(left: string[], right: string[]): boolean {
|
|
156
|
+
if (left.length !== right.length) return false
|
|
157
|
+
const rightSet = new Set(right)
|
|
158
|
+
return left.every((value) => rightSet.has(value))
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function mergeOptionMaps(
|
|
162
|
+
existing: Map<string, LinkEntityOption>,
|
|
163
|
+
entries: LinkEntityOption[],
|
|
164
|
+
): Map<string, LinkEntityOption> {
|
|
165
|
+
const next = new Map(existing)
|
|
166
|
+
entries.forEach((entry) => next.set(entry.id, entry))
|
|
167
|
+
return next
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
type SelectionIndicatorProps = {
|
|
171
|
+
checked: boolean
|
|
172
|
+
disabled?: boolean
|
|
173
|
+
label: string
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function SelectionIndicator({ checked, disabled, label }: SelectionIndicatorProps) {
|
|
177
|
+
return (
|
|
178
|
+
<span
|
|
179
|
+
role="checkbox"
|
|
180
|
+
aria-checked={checked}
|
|
181
|
+
aria-disabled={disabled || undefined}
|
|
182
|
+
aria-label={label}
|
|
183
|
+
className={cn(
|
|
184
|
+
'inline-flex size-6 shrink-0 items-center justify-center rounded-full border transition-colors',
|
|
185
|
+
checked
|
|
186
|
+
? 'border-foreground bg-foreground text-background'
|
|
187
|
+
: 'border-border bg-background',
|
|
188
|
+
disabled && 'opacity-50',
|
|
189
|
+
)}
|
|
190
|
+
>
|
|
191
|
+
{checked ? <Check className="size-3" strokeWidth={2.5} /> : null}
|
|
192
|
+
</span>
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
type DefaultRowProps = {
|
|
197
|
+
option: LinkEntityOption
|
|
198
|
+
ctx: LinkEntityRowContext
|
|
199
|
+
avatarVariant: 'default' | 'monochrome'
|
|
200
|
+
defaultAvatarIcon?: React.ReactNode
|
|
201
|
+
selectLabel: string
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function DefaultRow({
|
|
205
|
+
option,
|
|
206
|
+
ctx,
|
|
207
|
+
avatarVariant,
|
|
208
|
+
defaultAvatarIcon,
|
|
209
|
+
selectLabel,
|
|
210
|
+
}: DefaultRowProps) {
|
|
211
|
+
return (
|
|
212
|
+
<>
|
|
213
|
+
<Avatar
|
|
214
|
+
label={option.label}
|
|
215
|
+
variant={avatarVariant}
|
|
216
|
+
size="md"
|
|
217
|
+
icon={option.icon ?? defaultAvatarIcon}
|
|
218
|
+
/>
|
|
219
|
+
<div className="min-w-0 flex-1">
|
|
220
|
+
<div className="truncate text-sm font-semibold text-foreground">{option.label}</div>
|
|
221
|
+
{option.subtitle ? (
|
|
222
|
+
<div className="mt-0.5 truncate text-xs text-muted-foreground">{option.subtitle}</div>
|
|
223
|
+
) : null}
|
|
224
|
+
</div>
|
|
225
|
+
<SelectionIndicator checked={ctx.selected} label={selectLabel} />
|
|
226
|
+
</>
|
|
227
|
+
)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export function LinkEntityDialog<TDetails = unknown, TLinkSettings = Record<string, unknown>>({
|
|
231
|
+
open,
|
|
232
|
+
onOpenChange,
|
|
233
|
+
adapter,
|
|
234
|
+
initialSelectedIds,
|
|
235
|
+
initialPrimaryId,
|
|
236
|
+
primarySupported = false,
|
|
237
|
+
onConfirm,
|
|
238
|
+
avatarVariant = 'monochrome',
|
|
239
|
+
}: LinkEntityDialogProps<TDetails, TLinkSettings>) {
|
|
240
|
+
const t = useT()
|
|
241
|
+
const [query, setQuery] = React.useState('')
|
|
242
|
+
const [activeFilter, setActiveFilter] = React.useState<string | undefined>(
|
|
243
|
+
adapter.filters?.defaultId,
|
|
244
|
+
)
|
|
245
|
+
const [searchPage, setSearchPage] = React.useState(1)
|
|
246
|
+
const [searchTotalPages, setSearchTotalPages] = React.useState(1)
|
|
247
|
+
const [searchTotal, setSearchTotal] = React.useState<number | null>(null)
|
|
248
|
+
const [searchResults, setSearchResults] = React.useState<LinkEntityOption[]>([])
|
|
249
|
+
const [searchLoading, setSearchLoading] = React.useState(false)
|
|
250
|
+
const [draftIds, setDraftIds] = React.useState<string[]>(initialSelectedIds)
|
|
251
|
+
const [draftPrimaryId, setDraftPrimaryId] = React.useState<string | null>(
|
|
252
|
+
initialPrimaryId ?? null,
|
|
253
|
+
)
|
|
254
|
+
const [focusedId, setFocusedId] = React.useState<string | null>(null)
|
|
255
|
+
const [optionCache, setOptionCache] = React.useState<Map<string, LinkEntityOption>>(
|
|
256
|
+
() => new Map(),
|
|
257
|
+
)
|
|
258
|
+
const [details, setDetails] = React.useState<Record<string, TDetails>>({})
|
|
259
|
+
const [detailsLoadingId, setDetailsLoadingId] = React.useState<string | null>(null)
|
|
260
|
+
const [linkSettings, setLinkSettings] = React.useState<TLinkSettings>(
|
|
261
|
+
adapter.initialLinkSettings ?? ({} as TLinkSettings),
|
|
262
|
+
)
|
|
263
|
+
const [saving, setSaving] = React.useState(false)
|
|
264
|
+
const [nestedOpen, setNestedOpen] = React.useState(false)
|
|
265
|
+
const requestIdRef = React.useRef(0)
|
|
266
|
+
|
|
267
|
+
const initialIdsKey = React.useMemo(() => initialSelectedIds.join('|'), [initialSelectedIds])
|
|
268
|
+
|
|
269
|
+
React.useEffect(() => {
|
|
270
|
+
if (!open) return
|
|
271
|
+
setDraftIds(initialSelectedIds)
|
|
272
|
+
setDraftPrimaryId(initialPrimaryId ?? null)
|
|
273
|
+
setQuery('')
|
|
274
|
+
setActiveFilter(adapter.filters?.defaultId)
|
|
275
|
+
setSearchPage(1)
|
|
276
|
+
setSearchTotalPages(1)
|
|
277
|
+
setSearchTotal(null)
|
|
278
|
+
setSearchResults([])
|
|
279
|
+
setFocusedId(null)
|
|
280
|
+
setDetails({})
|
|
281
|
+
setDetailsLoadingId(null)
|
|
282
|
+
setLinkSettings(adapter.initialLinkSettings ?? ({} as TLinkSettings))
|
|
283
|
+
setNestedOpen(false)
|
|
284
|
+
}, [open, initialIdsKey, initialPrimaryId, adapter])
|
|
285
|
+
|
|
286
|
+
React.useEffect(() => {
|
|
287
|
+
if (!open) return
|
|
288
|
+
setSearchPage(1)
|
|
289
|
+
}, [open, query, activeFilter])
|
|
290
|
+
|
|
291
|
+
React.useEffect(() => {
|
|
292
|
+
if (!open) return
|
|
293
|
+
let cancelled = false
|
|
294
|
+
const current = ++requestIdRef.current
|
|
295
|
+
setSearchLoading(true)
|
|
296
|
+
const timeout = window.setTimeout(async () => {
|
|
297
|
+
try {
|
|
298
|
+
const result = await adapter.searchPage(query, searchPage, activeFilter)
|
|
299
|
+
if (cancelled || current !== requestIdRef.current) return
|
|
300
|
+
setSearchResults(result.items)
|
|
301
|
+
setSearchTotalPages(Math.max(1, result.totalPages))
|
|
302
|
+
setSearchTotal(typeof result.total === 'number' ? result.total : null)
|
|
303
|
+
setOptionCache((prev) => mergeOptionMaps(prev, result.items))
|
|
304
|
+
} catch {
|
|
305
|
+
if (cancelled || current !== requestIdRef.current) return
|
|
306
|
+
setSearchResults([])
|
|
307
|
+
setSearchTotalPages(1)
|
|
308
|
+
setSearchTotal(0)
|
|
309
|
+
} finally {
|
|
310
|
+
if (!cancelled && current === requestIdRef.current) {
|
|
311
|
+
setSearchLoading(false)
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}, SEARCH_DEBOUNCE_MS)
|
|
315
|
+
return () => {
|
|
316
|
+
cancelled = true
|
|
317
|
+
window.clearTimeout(timeout)
|
|
318
|
+
}
|
|
319
|
+
}, [adapter, activeFilter, open, query, searchPage])
|
|
320
|
+
|
|
321
|
+
React.useEffect(() => {
|
|
322
|
+
if (!open) return
|
|
323
|
+
const missingIds = draftIds.filter((id) => !optionCache.has(id))
|
|
324
|
+
if (!missingIds.length) return
|
|
325
|
+
let cancelled = false
|
|
326
|
+
void adapter
|
|
327
|
+
.fetchByIds(missingIds)
|
|
328
|
+
.then((entries) => {
|
|
329
|
+
if (cancelled) return
|
|
330
|
+
setOptionCache((prev) => mergeOptionMaps(prev, entries))
|
|
331
|
+
})
|
|
332
|
+
.catch((error) => console.warn('[LinkEntityDialog] fetchByIds failed', error))
|
|
333
|
+
return () => {
|
|
334
|
+
cancelled = true
|
|
335
|
+
}
|
|
336
|
+
}, [adapter, draftIds, open, optionCache])
|
|
337
|
+
|
|
338
|
+
const focusedOption: LinkEntityOption | null = React.useMemo(
|
|
339
|
+
() => (focusedId ? optionCache.get(focusedId) ?? null : null),
|
|
340
|
+
[focusedId, optionCache],
|
|
341
|
+
)
|
|
342
|
+
|
|
343
|
+
const fetchDetails = adapter.fetchDetails
|
|
344
|
+
React.useEffect(() => {
|
|
345
|
+
if (!open || !focusedId || !fetchDetails) return
|
|
346
|
+
if (details[focusedId] !== undefined) return
|
|
347
|
+
let cancelled = false
|
|
348
|
+
setDetailsLoadingId(focusedId)
|
|
349
|
+
void fetchDetails(focusedId)
|
|
350
|
+
.then((result) => {
|
|
351
|
+
if (cancelled) return
|
|
352
|
+
setDetails((prev) => ({ ...prev, [focusedId]: result }))
|
|
353
|
+
})
|
|
354
|
+
.catch((error) => console.warn('[LinkEntityDialog] fetchDetails failed', error))
|
|
355
|
+
.finally(() => {
|
|
356
|
+
if (!cancelled) setDetailsLoadingId(null)
|
|
357
|
+
})
|
|
358
|
+
return () => {
|
|
359
|
+
cancelled = true
|
|
360
|
+
}
|
|
361
|
+
}, [details, fetchDetails, focusedId, open])
|
|
362
|
+
|
|
363
|
+
const draftSet = React.useMemo(() => new Set(draftIds), [draftIds])
|
|
364
|
+
|
|
365
|
+
const displayedResults = React.useMemo(() => {
|
|
366
|
+
const predicate = adapter.filters?.clientFilter
|
|
367
|
+
const effectiveFilter = activeFilter ?? adapter.filters?.defaultId
|
|
368
|
+
if (!predicate || !effectiveFilter) return searchResults
|
|
369
|
+
return searchResults.filter((option) => predicate(option, effectiveFilter))
|
|
370
|
+
}, [adapter.filters, activeFilter, searchResults])
|
|
371
|
+
|
|
372
|
+
const selectedOptions = React.useMemo(
|
|
373
|
+
() =>
|
|
374
|
+
draftIds.map((id) => optionCache.get(id) ?? { id, label: id }).filter((entry): entry is LinkEntityOption => Boolean(entry)),
|
|
375
|
+
[draftIds, optionCache],
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
React.useEffect(() => {
|
|
379
|
+
if (!primarySupported) return
|
|
380
|
+
setDraftPrimaryId((current) => {
|
|
381
|
+
const normalizedCurrent = current ?? null
|
|
382
|
+
if (draftIds.length === 0) return null
|
|
383
|
+
if (normalizedCurrent && draftIds.includes(normalizedCurrent)) return normalizedCurrent
|
|
384
|
+
return draftIds[0]
|
|
385
|
+
})
|
|
386
|
+
}, [draftIds, primarySupported])
|
|
387
|
+
|
|
388
|
+
const toggleDraftId = React.useCallback((id: string, checked: boolean) => {
|
|
389
|
+
setDraftIds((current) => {
|
|
390
|
+
if (checked) {
|
|
391
|
+
if (current.includes(id)) return current
|
|
392
|
+
return [...current, id]
|
|
393
|
+
}
|
|
394
|
+
return current.filter((candidate) => candidate !== id)
|
|
395
|
+
})
|
|
396
|
+
}, [])
|
|
397
|
+
|
|
398
|
+
const handleRowClick = React.useCallback(
|
|
399
|
+
(option: LinkEntityOption) => {
|
|
400
|
+
setFocusedId(option.id)
|
|
401
|
+
const isSelected = draftSet.has(option.id)
|
|
402
|
+
toggleDraftId(option.id, !isSelected)
|
|
403
|
+
},
|
|
404
|
+
[draftSet, toggleDraftId],
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
const handleAddNewCreated = React.useCallback(
|
|
408
|
+
(option: LinkEntityOption) => {
|
|
409
|
+
setOptionCache((prev) => mergeOptionMaps(prev, [option]))
|
|
410
|
+
setDraftIds((current) => (current.includes(option.id) ? current : [...current, option.id]))
|
|
411
|
+
setFocusedId(option.id)
|
|
412
|
+
setNestedOpen(false)
|
|
413
|
+
},
|
|
414
|
+
[],
|
|
415
|
+
)
|
|
416
|
+
|
|
417
|
+
const handleDialogOpenChange = React.useCallback(
|
|
418
|
+
(next: boolean) => {
|
|
419
|
+
if (nestedOpen && !next) return
|
|
420
|
+
onOpenChange(next)
|
|
421
|
+
},
|
|
422
|
+
[nestedOpen, onOpenChange],
|
|
423
|
+
)
|
|
424
|
+
|
|
425
|
+
const handleSetPrimary = React.useCallback(
|
|
426
|
+
(id: string) => {
|
|
427
|
+
if (!primarySupported || !draftSet.has(id)) return
|
|
428
|
+
setDraftPrimaryId(id)
|
|
429
|
+
setFocusedId(id)
|
|
430
|
+
},
|
|
431
|
+
[draftSet, primarySupported],
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
const hasChanges = React.useMemo(() => {
|
|
435
|
+
if (!sameIds(initialSelectedIds, draftIds)) return true
|
|
436
|
+
if (primarySupported && (draftPrimaryId ?? null) !== (initialPrimaryId ?? null)) return true
|
|
437
|
+
return false
|
|
438
|
+
}, [draftIds, draftPrimaryId, initialPrimaryId, initialSelectedIds, primarySupported])
|
|
439
|
+
|
|
440
|
+
const handleSave = React.useCallback(async () => {
|
|
441
|
+
if (saving) return
|
|
442
|
+
const { addedIds, removedIds } = diffSelection(initialSelectedIds, draftIds)
|
|
443
|
+
const primaryChanged = primarySupported
|
|
444
|
+
? (draftPrimaryId ?? null) !== (initialPrimaryId ?? null)
|
|
445
|
+
: false
|
|
446
|
+
if (!addedIds.length && !removedIds.length && !primaryChanged) {
|
|
447
|
+
onOpenChange(false)
|
|
448
|
+
return
|
|
449
|
+
}
|
|
450
|
+
setSaving(true)
|
|
451
|
+
try {
|
|
452
|
+
const optionsById: Record<string, LinkEntityOption> = {}
|
|
453
|
+
optionCache.forEach((value, key) => {
|
|
454
|
+
optionsById[key] = value
|
|
455
|
+
})
|
|
456
|
+
await onConfirm({
|
|
457
|
+
addedIds,
|
|
458
|
+
removedIds,
|
|
459
|
+
nextSelectedIds: draftIds,
|
|
460
|
+
primaryId: primarySupported ? draftPrimaryId : undefined,
|
|
461
|
+
optionsById,
|
|
462
|
+
linkSettings,
|
|
463
|
+
})
|
|
464
|
+
onOpenChange(false)
|
|
465
|
+
} finally {
|
|
466
|
+
setSaving(false)
|
|
467
|
+
}
|
|
468
|
+
}, [
|
|
469
|
+
draftIds,
|
|
470
|
+
draftPrimaryId,
|
|
471
|
+
initialPrimaryId,
|
|
472
|
+
initialSelectedIds,
|
|
473
|
+
linkSettings,
|
|
474
|
+
onConfirm,
|
|
475
|
+
onOpenChange,
|
|
476
|
+
optionCache,
|
|
477
|
+
primarySupported,
|
|
478
|
+
saving,
|
|
479
|
+
])
|
|
480
|
+
|
|
481
|
+
const handleKeyDown = React.useCallback(
|
|
482
|
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
483
|
+
if (nestedOpen) return
|
|
484
|
+
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
|
|
485
|
+
event.preventDefault()
|
|
486
|
+
void handleSave()
|
|
487
|
+
return
|
|
488
|
+
}
|
|
489
|
+
if (event.key === 'Escape') {
|
|
490
|
+
event.preventDefault()
|
|
491
|
+
handleDialogOpenChange(false)
|
|
492
|
+
}
|
|
493
|
+
},
|
|
494
|
+
[handleDialogOpenChange, handleSave, nestedOpen],
|
|
495
|
+
)
|
|
496
|
+
|
|
497
|
+
const selectedCountLabel = React.useMemo(() => {
|
|
498
|
+
const kindLabels: Record<LinkEntityKind, [string, string, string, string]> = {
|
|
499
|
+
person: [
|
|
500
|
+
'customers.linking.footer.personSingular',
|
|
501
|
+
'{{count}} person selected',
|
|
502
|
+
'customers.linking.footer.personPlural',
|
|
503
|
+
'{{count}} people selected',
|
|
504
|
+
],
|
|
505
|
+
company: [
|
|
506
|
+
'customers.linking.footer.companySingular',
|
|
507
|
+
'{{count}} company selected',
|
|
508
|
+
'customers.linking.footer.companyPlural',
|
|
509
|
+
'{{count}} companies selected',
|
|
510
|
+
],
|
|
511
|
+
deal: [
|
|
512
|
+
'customers.linking.footer.dealSingular',
|
|
513
|
+
'{{count}} deal selected',
|
|
514
|
+
'customers.linking.footer.dealPlural',
|
|
515
|
+
'{{count}} deals selected',
|
|
516
|
+
],
|
|
517
|
+
}
|
|
518
|
+
const [singularKey, singularDefault, pluralKey, pluralDefault] = kindLabels[adapter.kind]
|
|
519
|
+
if (draftIds.length === 1) {
|
|
520
|
+
return t(singularKey, singularDefault, { count: String(draftIds.length) })
|
|
521
|
+
}
|
|
522
|
+
return t(pluralKey, pluralDefault, { count: String(draftIds.length) })
|
|
523
|
+
}, [adapter.kind, draftIds.length, t])
|
|
524
|
+
|
|
525
|
+
const filterOptions = adapter.filters?.options ?? []
|
|
526
|
+
|
|
527
|
+
return (
|
|
528
|
+
<>
|
|
529
|
+
<Dialog open={open} onOpenChange={handleDialogOpenChange}>
|
|
530
|
+
<DialogContent
|
|
531
|
+
className="flex flex-col gap-0 overflow-hidden p-0"
|
|
532
|
+
style={{
|
|
533
|
+
width: 'min(calc(100vw - 2rem), 920px)',
|
|
534
|
+
maxWidth: 'min(calc(100vw - 2rem), 920px)',
|
|
535
|
+
maxHeight: 'min(640px, calc(100vh - 4rem))',
|
|
536
|
+
}}
|
|
537
|
+
onKeyDown={handleKeyDown}
|
|
538
|
+
aria-hidden={nestedOpen ? 'true' : undefined}
|
|
539
|
+
>
|
|
540
|
+
<DialogHeader className="flex flex-row items-center gap-3 space-y-0 border-b border-border/70 bg-card px-6 py-5">
|
|
541
|
+
{adapter.headerIcon ? (
|
|
542
|
+
<div className="flex size-6 shrink-0 items-center justify-center text-foreground">
|
|
543
|
+
{adapter.headerIcon}
|
|
544
|
+
</div>
|
|
545
|
+
) : null}
|
|
546
|
+
<div className="min-w-0 flex-1">
|
|
547
|
+
<DialogTitle className="text-lg font-bold text-foreground">
|
|
548
|
+
{adapter.dialogTitle}
|
|
549
|
+
</DialogTitle>
|
|
550
|
+
{adapter.dialogSubtitle ? (
|
|
551
|
+
<DialogDescription className="mt-0.5 text-sm text-muted-foreground">
|
|
552
|
+
{adapter.dialogSubtitle}
|
|
553
|
+
</DialogDescription>
|
|
554
|
+
) : null}
|
|
555
|
+
</div>
|
|
556
|
+
</DialogHeader>
|
|
557
|
+
|
|
558
|
+
<div className="flex min-h-0 flex-1 flex-col lg:flex-row">
|
|
559
|
+
<div className="flex min-h-0 flex-col gap-3 border-b border-border/70 bg-card p-4 lg:w-[480px] lg:shrink-0 lg:border-b-0 lg:border-r">
|
|
560
|
+
<div className="relative">
|
|
561
|
+
<Search className="pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground" />
|
|
562
|
+
<Input
|
|
563
|
+
value={query}
|
|
564
|
+
onChange={(event) => setQuery(event.target.value)}
|
|
565
|
+
placeholder={adapter.searchPlaceholder}
|
|
566
|
+
className="h-10 rounded-md pl-9 pr-20 text-sm"
|
|
567
|
+
autoFocus
|
|
568
|
+
aria-label={adapter.searchPlaceholder}
|
|
569
|
+
/>
|
|
570
|
+
{searchTotal !== null && !searchLoading ? (
|
|
571
|
+
<span className="pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-xs text-muted-foreground">
|
|
572
|
+
{t('customers.linking.resultsCount', '{{count}} results', {
|
|
573
|
+
count: String(searchTotal),
|
|
574
|
+
})}
|
|
575
|
+
</span>
|
|
576
|
+
) : null}
|
|
577
|
+
</div>
|
|
578
|
+
|
|
579
|
+
{filterOptions.length > 0 ? (
|
|
580
|
+
<div className="flex flex-wrap items-center gap-1.5">
|
|
581
|
+
{filterOptions.map((filter) => {
|
|
582
|
+
const isActive = (activeFilter ?? adapter.filters?.defaultId) === filter.id
|
|
583
|
+
return (
|
|
584
|
+
<button
|
|
585
|
+
key={filter.id}
|
|
586
|
+
type="button"
|
|
587
|
+
onClick={() => setActiveFilter(filter.id)}
|
|
588
|
+
className={cn(
|
|
589
|
+
'inline-flex h-6 items-center gap-1.5 rounded-full px-2.5 text-xs font-semibold transition-colors',
|
|
590
|
+
isActive
|
|
591
|
+
? 'bg-foreground text-background'
|
|
592
|
+
: 'bg-muted/70 text-muted-foreground hover:bg-muted',
|
|
593
|
+
)}
|
|
594
|
+
>
|
|
595
|
+
{filter.dotColor ? (
|
|
596
|
+
<span
|
|
597
|
+
aria-hidden="true"
|
|
598
|
+
className="inline-block size-1.5 rounded-full"
|
|
599
|
+
style={{ backgroundColor: filter.dotColor }}
|
|
600
|
+
/>
|
|
601
|
+
) : null}
|
|
602
|
+
<span>{filter.label}</span>
|
|
603
|
+
{typeof filter.count === 'number' ? (
|
|
604
|
+
<span
|
|
605
|
+
className={cn(
|
|
606
|
+
'inline-flex min-w-[14px] items-center justify-center rounded-full px-1 text-xs',
|
|
607
|
+
isActive
|
|
608
|
+
? 'bg-background/20 text-background'
|
|
609
|
+
: 'bg-background text-muted-foreground',
|
|
610
|
+
)}
|
|
611
|
+
>
|
|
612
|
+
{filter.count}
|
|
613
|
+
</span>
|
|
614
|
+
) : null}
|
|
615
|
+
</button>
|
|
616
|
+
)
|
|
617
|
+
})}
|
|
618
|
+
</div>
|
|
619
|
+
) : null}
|
|
620
|
+
|
|
621
|
+
{adapter.sectionLabel ? (
|
|
622
|
+
<div className="text-overline font-semibold uppercase tracking-wider text-muted-foreground">
|
|
623
|
+
{adapter.sectionLabel}
|
|
624
|
+
</div>
|
|
625
|
+
) : null}
|
|
626
|
+
|
|
627
|
+
<div className="flex min-h-0 flex-1 flex-col gap-2 overflow-auto">
|
|
628
|
+
{searchLoading && displayedResults.length === 0 ? (
|
|
629
|
+
<div className="flex items-center gap-2 rounded-lg border border-dashed border-border/70 px-4 py-6 text-sm text-muted-foreground">
|
|
630
|
+
<Loader2 className="size-4 animate-spin" />
|
|
631
|
+
{t('customers.linking.searching', 'Searching…')}
|
|
632
|
+
</div>
|
|
633
|
+
) : displayedResults.length === 0 ? (
|
|
634
|
+
<div className="rounded-lg border border-dashed border-border/70 px-4 py-6 text-sm text-muted-foreground">
|
|
635
|
+
{adapter.searchEmptyHint}
|
|
636
|
+
</div>
|
|
637
|
+
) : (
|
|
638
|
+
displayedResults.map((result) => {
|
|
639
|
+
const checked = draftSet.has(result.id)
|
|
640
|
+
const focused = focusedId === result.id
|
|
641
|
+
const ctx: LinkEntityRowContext = { selected: checked, focused }
|
|
642
|
+
const selectLabel = t('customers.linking.selectEntity', 'Select {{name}}', {
|
|
643
|
+
name: result.label,
|
|
644
|
+
})
|
|
645
|
+
return (
|
|
646
|
+
<div
|
|
647
|
+
key={result.id}
|
|
648
|
+
role="button"
|
|
649
|
+
tabIndex={0}
|
|
650
|
+
aria-pressed={checked}
|
|
651
|
+
onClick={() => handleRowClick(result)}
|
|
652
|
+
onKeyDown={(event) => {
|
|
653
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
654
|
+
event.preventDefault()
|
|
655
|
+
handleRowClick(result)
|
|
656
|
+
}
|
|
657
|
+
}}
|
|
658
|
+
className={cn(
|
|
659
|
+
'group flex cursor-pointer items-center gap-3 rounded-lg border px-3.5 py-3 transition-colors focus:outline-none focus:ring-2 focus:ring-ring/40',
|
|
660
|
+
checked
|
|
661
|
+
? 'border-border bg-muted/50'
|
|
662
|
+
: 'border-border/70 bg-card hover:bg-muted/30',
|
|
663
|
+
)}
|
|
664
|
+
>
|
|
665
|
+
{adapter.renderRow ? (
|
|
666
|
+
adapter.renderRow(result, ctx)
|
|
667
|
+
) : (
|
|
668
|
+
<DefaultRow
|
|
669
|
+
option={result}
|
|
670
|
+
ctx={ctx}
|
|
671
|
+
avatarVariant={avatarVariant}
|
|
672
|
+
defaultAvatarIcon={adapter.defaultAvatarIcon}
|
|
673
|
+
selectLabel={selectLabel}
|
|
674
|
+
/>
|
|
675
|
+
)}
|
|
676
|
+
</div>
|
|
677
|
+
)
|
|
678
|
+
})
|
|
679
|
+
)}
|
|
680
|
+
|
|
681
|
+
{adapter.addNew ? (
|
|
682
|
+
<button
|
|
683
|
+
type="button"
|
|
684
|
+
onClick={() => setNestedOpen(true)}
|
|
685
|
+
className="mt-2 flex items-center gap-3 rounded-lg border border-dashed border-border px-4 py-3.5 text-left transition-colors hover:bg-muted/30 focus:outline-none focus:ring-2 focus:ring-ring/40"
|
|
686
|
+
>
|
|
687
|
+
<span className="flex size-9 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground">
|
|
688
|
+
<Plus className="size-4" />
|
|
689
|
+
</span>
|
|
690
|
+
<span className="min-w-0 flex-1">
|
|
691
|
+
<span className="block truncate text-sm font-semibold text-foreground">
|
|
692
|
+
{adapter.addNew.title}
|
|
693
|
+
</span>
|
|
694
|
+
{adapter.addNew.subtitle ? (
|
|
695
|
+
<span className="mt-0.5 block truncate text-xs text-muted-foreground">
|
|
696
|
+
{adapter.addNew.subtitle}
|
|
697
|
+
</span>
|
|
698
|
+
) : null}
|
|
699
|
+
</span>
|
|
700
|
+
<span className="flex size-8 shrink-0 items-center justify-center rounded-md bg-foreground text-background">
|
|
701
|
+
<Plus className="size-3.5" />
|
|
702
|
+
</span>
|
|
703
|
+
</button>
|
|
704
|
+
) : null}
|
|
705
|
+
|
|
706
|
+
{searchTotalPages > 1 ? (
|
|
707
|
+
<div className="flex items-center justify-between pt-2 text-xs text-muted-foreground">
|
|
708
|
+
<span aria-live="polite">
|
|
709
|
+
{t('customers.linking.pagination.pageOf', 'Page {{page}} of {{total}}', {
|
|
710
|
+
page: String(Math.min(searchPage, searchTotalPages)),
|
|
711
|
+
total: String(searchTotalPages),
|
|
712
|
+
})}
|
|
713
|
+
</span>
|
|
714
|
+
<div className="flex items-center gap-2">
|
|
715
|
+
<Button
|
|
716
|
+
type="button"
|
|
717
|
+
variant="outline"
|
|
718
|
+
size="sm"
|
|
719
|
+
className="h-8 rounded-md px-2.5 text-xs"
|
|
720
|
+
disabled={searchLoading || searchPage <= 1}
|
|
721
|
+
onClick={() => setSearchPage((current) => Math.max(1, current - 1))}
|
|
722
|
+
>
|
|
723
|
+
{t('customers.linking.pagination.previousShort', 'Previous')}
|
|
724
|
+
</Button>
|
|
725
|
+
<Button
|
|
726
|
+
type="button"
|
|
727
|
+
variant="outline"
|
|
728
|
+
size="sm"
|
|
729
|
+
className="h-8 rounded-md px-2.5 text-xs"
|
|
730
|
+
disabled={searchLoading || searchPage >= searchTotalPages}
|
|
731
|
+
onClick={() =>
|
|
732
|
+
setSearchPage((current) => Math.min(searchTotalPages, current + 1))
|
|
733
|
+
}
|
|
734
|
+
>
|
|
735
|
+
{t('customers.linking.pagination.nextShort', 'Next')}
|
|
736
|
+
</Button>
|
|
737
|
+
</div>
|
|
738
|
+
</div>
|
|
739
|
+
) : null}
|
|
740
|
+
</div>
|
|
741
|
+
</div>
|
|
742
|
+
|
|
743
|
+
<div className="flex min-h-0 flex-1 flex-col gap-4 overflow-auto bg-muted/20 p-5">
|
|
744
|
+
<div className="rounded-lg border border-border/70 bg-card p-4">
|
|
745
|
+
<div className="mb-3 text-overline font-semibold uppercase tracking-wider text-muted-foreground">
|
|
746
|
+
{t('customers.linking.selected.label', 'Selected')}
|
|
747
|
+
</div>
|
|
748
|
+
{selectedOptions.length > 0 ? (
|
|
749
|
+
<div className="space-y-2">
|
|
750
|
+
{selectedOptions.map((option) => {
|
|
751
|
+
const isPrimary = primarySupported && draftPrimaryId === option.id
|
|
752
|
+
return (
|
|
753
|
+
<div
|
|
754
|
+
key={option.id}
|
|
755
|
+
className={cn(
|
|
756
|
+
'flex items-center gap-3 rounded-lg border px-3 py-2.5 transition-colors',
|
|
757
|
+
focusedId === option.id
|
|
758
|
+
? 'border-border bg-muted/50'
|
|
759
|
+
: 'border-border/70 bg-card',
|
|
760
|
+
)}
|
|
761
|
+
>
|
|
762
|
+
<button
|
|
763
|
+
type="button"
|
|
764
|
+
onClick={() => setFocusedId(option.id)}
|
|
765
|
+
className="flex min-w-0 flex-1 items-center gap-3 text-left"
|
|
766
|
+
>
|
|
767
|
+
<Avatar
|
|
768
|
+
label={option.label}
|
|
769
|
+
variant={avatarVariant}
|
|
770
|
+
size="sm"
|
|
771
|
+
icon={option.icon ?? adapter.defaultAvatarIcon}
|
|
772
|
+
/>
|
|
773
|
+
<span className="min-w-0 flex-1">
|
|
774
|
+
<span className="block truncate text-sm font-semibold text-foreground">
|
|
775
|
+
{option.label}
|
|
776
|
+
</span>
|
|
777
|
+
{option.subtitle ? (
|
|
778
|
+
<span className="mt-0.5 block truncate text-xs text-muted-foreground">
|
|
779
|
+
{option.subtitle}
|
|
780
|
+
</span>
|
|
781
|
+
) : null}
|
|
782
|
+
</span>
|
|
783
|
+
</button>
|
|
784
|
+
{primarySupported ? (
|
|
785
|
+
<Button
|
|
786
|
+
type="button"
|
|
787
|
+
size="sm"
|
|
788
|
+
variant={isPrimary ? 'default' : 'outline'}
|
|
789
|
+
className="h-7 rounded-full px-3 text-xs"
|
|
790
|
+
onClick={() => handleSetPrimary(option.id)}
|
|
791
|
+
disabled={isPrimary}
|
|
792
|
+
>
|
|
793
|
+
{isPrimary
|
|
794
|
+
? t('customers.linking.primary.current', 'Primary')
|
|
795
|
+
: t('customers.linking.primary.set', 'Set primary')}
|
|
796
|
+
</Button>
|
|
797
|
+
) : null}
|
|
798
|
+
</div>
|
|
799
|
+
)
|
|
800
|
+
})}
|
|
801
|
+
</div>
|
|
802
|
+
) : (
|
|
803
|
+
<div className="rounded-lg border border-dashed border-border/70 px-4 py-4 text-sm text-muted-foreground">
|
|
804
|
+
{adapter.selectedEmptyHint}
|
|
805
|
+
</div>
|
|
806
|
+
)}
|
|
807
|
+
{primarySupported && selectedOptions.length > 0 ? (
|
|
808
|
+
<div className="mt-3 text-xs text-muted-foreground">
|
|
809
|
+
{t(
|
|
810
|
+
'customers.linking.primary.help',
|
|
811
|
+
'Choose which linked company should remain primary.',
|
|
812
|
+
)}
|
|
813
|
+
</div>
|
|
814
|
+
) : null}
|
|
815
|
+
</div>
|
|
816
|
+
|
|
817
|
+
<div className="text-overline font-semibold uppercase tracking-wider text-muted-foreground">
|
|
818
|
+
{t('customers.linking.preview.label', 'Preview')}
|
|
819
|
+
</div>
|
|
820
|
+
|
|
821
|
+
{focusedOption ? (
|
|
822
|
+
<>
|
|
823
|
+
{adapter.renderPreview ? (
|
|
824
|
+
adapter.renderPreview(focusedOption, details[focusedOption.id])
|
|
825
|
+
) : (
|
|
826
|
+
<div className="rounded-lg border border-border/70 bg-card p-4">
|
|
827
|
+
<div className="flex items-center gap-3">
|
|
828
|
+
<Avatar
|
|
829
|
+
label={focusedOption.label}
|
|
830
|
+
variant={avatarVariant}
|
|
831
|
+
size="lg"
|
|
832
|
+
icon={focusedOption.icon ?? adapter.defaultAvatarIcon}
|
|
833
|
+
/>
|
|
834
|
+
<div className="min-w-0">
|
|
835
|
+
<div className="truncate text-base font-bold text-foreground">
|
|
836
|
+
{focusedOption.label}
|
|
837
|
+
</div>
|
|
838
|
+
{focusedOption.subtitle ? (
|
|
839
|
+
<div className="mt-0.5 truncate text-xs text-muted-foreground">
|
|
840
|
+
{focusedOption.subtitle}
|
|
841
|
+
</div>
|
|
842
|
+
) : null}
|
|
843
|
+
</div>
|
|
844
|
+
</div>
|
|
845
|
+
</div>
|
|
846
|
+
)}
|
|
847
|
+
{detailsLoadingId === focusedOption.id && adapter.fetchDetails ? (
|
|
848
|
+
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
|
849
|
+
<Loader2 className="size-3.5 animate-spin" />
|
|
850
|
+
{t('customers.linking.preview.loading', 'Loading details…')}
|
|
851
|
+
</div>
|
|
852
|
+
) : null}
|
|
853
|
+
|
|
854
|
+
{adapter.renderLinkSettings ? (
|
|
855
|
+
<div className="rounded-lg border border-border/70 bg-card p-4">
|
|
856
|
+
<div className="mb-3 text-overline font-semibold uppercase tracking-wider text-muted-foreground">
|
|
857
|
+
{t('customers.linking.settings.label', 'Link settings')}
|
|
858
|
+
</div>
|
|
859
|
+
{adapter.renderLinkSettings(linkSettings, setLinkSettings, focusedOption)}
|
|
860
|
+
</div>
|
|
861
|
+
) : null}
|
|
862
|
+
</>
|
|
863
|
+
) : (
|
|
864
|
+
<div className="flex flex-1 flex-col items-center justify-center rounded-lg border border-dashed border-border/70 bg-card/40 p-6 text-center text-sm text-muted-foreground">
|
|
865
|
+
<Link2 className="mb-2 size-5 opacity-60" />
|
|
866
|
+
{t(
|
|
867
|
+
'customers.linking.preview.empty',
|
|
868
|
+
'Select an entry on the left to see details here.',
|
|
869
|
+
)}
|
|
870
|
+
</div>
|
|
871
|
+
)}
|
|
872
|
+
</div>
|
|
873
|
+
</div>
|
|
874
|
+
|
|
875
|
+
<DialogFooter className="flex flex-row items-center justify-between border-t border-border/70 bg-muted/30 px-6 py-4 sm:flex-row sm:justify-between">
|
|
876
|
+
<div className="text-xs text-muted-foreground">{selectedCountLabel}</div>
|
|
877
|
+
<div className="flex items-center gap-3">
|
|
878
|
+
<Button
|
|
879
|
+
type="button"
|
|
880
|
+
variant="outline"
|
|
881
|
+
onClick={() => handleDialogOpenChange(false)}
|
|
882
|
+
disabled={saving}
|
|
883
|
+
className="h-9 rounded-md px-4"
|
|
884
|
+
>
|
|
885
|
+
{t('customers.linking.actions.cancel', 'Cancel')}
|
|
886
|
+
</Button>
|
|
887
|
+
<Button
|
|
888
|
+
type="button"
|
|
889
|
+
onClick={() => {
|
|
890
|
+
void handleSave()
|
|
891
|
+
}}
|
|
892
|
+
disabled={saving || !hasChanges}
|
|
893
|
+
className="h-9 rounded-md bg-foreground px-5 text-background hover:bg-foreground/90"
|
|
894
|
+
>
|
|
895
|
+
{saving ? (
|
|
896
|
+
<>
|
|
897
|
+
<Loader2 className="mr-2 size-4 animate-spin" />
|
|
898
|
+
{t('customers.linking.actions.saving', 'Saving…')}
|
|
899
|
+
</>
|
|
900
|
+
) : (
|
|
901
|
+
<>
|
|
902
|
+
<Link2 className="mr-2 size-4" />
|
|
903
|
+
{adapter.confirmButtonLabel}
|
|
904
|
+
</>
|
|
905
|
+
)}
|
|
906
|
+
</Button>
|
|
907
|
+
</div>
|
|
908
|
+
</DialogFooter>
|
|
909
|
+
</DialogContent>
|
|
910
|
+
</Dialog>
|
|
911
|
+
|
|
912
|
+
{adapter.addNew && nestedOpen
|
|
913
|
+
? adapter.addNew.render({
|
|
914
|
+
onCreated: handleAddNewCreated,
|
|
915
|
+
onCancel: () => setNestedOpen(false),
|
|
916
|
+
})
|
|
917
|
+
: null}
|
|
918
|
+
</>
|
|
919
|
+
)
|
|
920
|
+
}
|