@open-mercato/core 0.7.0 → 0.7.1-develop.7103.1.41ff100d93
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/helpers/integration/api.js +13 -1
- package/dist/helpers/integration/api.js.map +2 -2
- package/dist/helpers/integration/communicationChannelsFixtures.js +19 -0
- package/dist/helpers/integration/communicationChannelsFixtures.js.map +2 -2
- package/dist/modules/api_keys/api/keys/route.js +1 -1
- package/dist/modules/api_keys/api/keys/route.js.map +2 -2
- package/dist/modules/api_keys/backend/api-keys/page.js +3 -1
- package/dist/modules/api_keys/backend/api-keys/page.js.map +2 -2
- package/dist/modules/api_keys/di.js +9 -0
- package/dist/modules/api_keys/di.js.map +7 -0
- package/dist/modules/api_keys/services/principalService.js +31 -0
- package/dist/modules/api_keys/services/principalService.js.map +7 -0
- package/dist/modules/attachments/api/route.js +2 -2
- package/dist/modules/attachments/api/route.js.map +2 -2
- package/dist/modules/attachments/components/AttachmentLibrary.js +2 -0
- package/dist/modules/attachments/components/AttachmentLibrary.js.map +2 -2
- package/dist/modules/attachments/di.js +11 -1
- package/dist/modules/attachments/di.js.map +2 -2
- package/dist/modules/attachments/index.js.map +1 -1
- package/dist/modules/attachments/lib/attachment-service.js +313 -0
- package/dist/modules/attachments/lib/attachment-service.js.map +7 -0
- package/dist/modules/attachments/lib/scoped-upload-service.js +15 -2
- package/dist/modules/attachments/lib/scoped-upload-service.js.map +2 -2
- package/dist/modules/attachments/lib/upload-limits.js +6 -2
- package/dist/modules/attachments/lib/upload-limits.js.map +2 -2
- package/dist/modules/audit_logs/backend/audit-logs/page.js +6 -0
- package/dist/modules/audit_logs/backend/audit-logs/page.js.map +2 -2
- package/dist/modules/audit_logs/lib/display-helpers.js +19 -11
- package/dist/modules/audit_logs/lib/display-helpers.js.map +2 -2
- package/dist/modules/audit_logs/services/actionLogService.js +57 -12
- package/dist/modules/audit_logs/services/actionLogService.js.map +3 -3
- package/dist/modules/auth/acl.js +30 -5
- package/dist/modules/auth/acl.js.map +2 -2
- package/dist/modules/auth/api/feature-check.js +8 -2
- package/dist/modules/auth/api/feature-check.js.map +2 -2
- package/dist/modules/auth/api/login.js +4 -1
- package/dist/modules/auth/api/login.js.map +2 -2
- package/dist/modules/auth/api/reset/validate.js +55 -0
- package/dist/modules/auth/api/reset/validate.js.map +7 -0
- package/dist/modules/auth/api/roles/acl/route.js +28 -33
- package/dist/modules/auth/api/roles/acl/route.js.map +2 -2
- package/dist/modules/auth/api/session/refresh.js +25 -1
- package/dist/modules/auth/api/session/refresh.js.map +2 -2
- package/dist/modules/auth/api/users/acl/route.js +96 -51
- package/dist/modules/auth/api/users/acl/route.js.map +2 -2
- package/dist/modules/auth/api/users/route.js +13 -5
- package/dist/modules/auth/api/users/route.js.map +2 -2
- package/dist/modules/auth/backend/roles/[id]/edit/page.meta.js +5 -1
- package/dist/modules/auth/backend/roles/[id]/edit/page.meta.js.map +2 -2
- package/dist/modules/auth/backend/roles/page.js +3 -1
- package/dist/modules/auth/backend/roles/page.js.map +2 -2
- package/dist/modules/auth/backend/users/[id]/edit/page.meta.js +5 -1
- package/dist/modules/auth/backend/users/[id]/edit/page.meta.js.map +2 -2
- package/dist/modules/auth/backend/users/page.js +2 -1
- package/dist/modules/auth/backend/users/page.js.map +2 -2
- package/dist/modules/auth/commands/acl.js +254 -0
- package/dist/modules/auth/commands/acl.js.map +7 -0
- package/dist/modules/auth/components/AclEditor.js +39 -30
- package/dist/modules/auth/components/AclEditor.js.map +2 -2
- package/dist/modules/auth/data/entities.js.map +2 -2
- package/dist/modules/auth/data/validators.js +5 -1
- package/dist/modules/auth/data/validators.js.map +2 -2
- package/dist/modules/auth/di.js +35 -9
- package/dist/modules/auth/di.js.map +2 -2
- package/dist/modules/auth/frontend/reset/[token]/page.js +46 -0
- package/dist/modules/auth/frontend/reset/[token]/page.js.map +2 -2
- package/dist/modules/auth/lib/grantChecks.js.map +2 -2
- package/dist/modules/auth/lib/userIdFilter.js +16 -0
- package/dist/modules/auth/lib/userIdFilter.js.map +7 -0
- package/dist/modules/auth/services/authService.js +16 -2
- package/dist/modules/auth/services/authService.js.map +2 -2
- package/dist/modules/auth/services/principalService.js +200 -0
- package/dist/modules/auth/services/principalService.js.map +7 -0
- package/dist/modules/auth/services/rbacService.js +67 -24
- package/dist/modules/auth/services/rbacService.js.map +3 -3
- package/dist/modules/auth/services/roleOrganizationScope.js +41 -0
- package/dist/modules/auth/services/roleOrganizationScope.js.map +7 -0
- package/dist/modules/business_rules/backend/logs/page.js +3 -1
- package/dist/modules/business_rules/backend/logs/page.js.map +2 -2
- package/dist/modules/business_rules/backend/rules/page.js +3 -1
- package/dist/modules/business_rules/backend/rules/page.js.map +2 -2
- package/dist/modules/business_rules/backend/sets/page.js +3 -1
- package/dist/modules/business_rules/backend/sets/page.js.map +2 -2
- package/dist/modules/business_rules/lib/expression-evaluator.js +9 -9
- package/dist/modules/business_rules/lib/expression-evaluator.js.map +2 -2
- package/dist/modules/business_rules/lib/rule-evaluator.js +10 -9
- package/dist/modules/business_rules/lib/rule-evaluator.js.map +2 -2
- package/dist/modules/catalog/ai-agents.js +1 -1
- package/dist/modules/catalog/ai-agents.js.map +1 -1
- package/dist/modules/catalog/ai-tools/merchandising-pack.js +2 -2
- package/dist/modules/catalog/ai-tools/merchandising-pack.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/MerchandisingAssistantSheet.js +5 -2
- package/dist/modules/catalog/backend/catalog/products/MerchandisingAssistantSheet.js.map +2 -2
- package/dist/modules/catalog/components/categories/CategoriesDataTable.js +2 -0
- package/dist/modules/catalog/components/categories/CategoriesDataTable.js.map +2 -2
- package/dist/modules/catalog/components/products/ProductsDataTable.js +7 -1
- package/dist/modules/catalog/components/products/ProductsDataTable.js.map +2 -2
- package/dist/modules/catalog/widgets/injection/merchandising-assistant-trigger/widget.client.js +2 -0
- package/dist/modules/catalog/widgets/injection/merchandising-assistant-trigger/widget.client.js.map +2 -2
- package/dist/modules/communication_channels/api/post/channels/[id]/test-send/route.js +9 -1
- package/dist/modules/communication_channels/api/post/channels/[id]/test-send/route.js.map +2 -2
- package/dist/modules/communication_channels/api/post/test-seed/route.js +95 -10
- package/dist/modules/communication_channels/api/post/test-seed/route.js.map +2 -2
- package/dist/modules/communication_channels/backend/communication_channels/channels/page.js +3 -0
- package/dist/modules/communication_channels/backend/communication_channels/channels/page.js.map +2 -2
- package/dist/modules/communication_channels/commands/ingest-inbound-message.js +14 -1
- package/dist/modules/communication_channels/commands/ingest-inbound-message.js.map +2 -2
- package/dist/modules/communication_channels/di.js +7 -1
- package/dist/modules/communication_channels/di.js.map +2 -2
- package/dist/modules/communication_channels/lib/email-capabilities.js +4 -1
- package/dist/modules/communication_channels/lib/email-capabilities.js.map +2 -2
- package/dist/modules/communication_channels/lib/outbound-recipient.js +33 -0
- package/dist/modules/communication_channels/lib/outbound-recipient.js.map +7 -0
- package/dist/modules/communication_channels/lib/resolve-channel-type.js +51 -0
- package/dist/modules/communication_channels/lib/resolve-channel-type.js.map +7 -0
- package/dist/modules/communication_channels/lib/test-seed.js +41 -2
- package/dist/modules/communication_channels/lib/test-seed.js.map +2 -2
- package/dist/modules/configs/lib/system-status.js +9 -0
- package/dist/modules/configs/lib/system-status.js.map +2 -2
- package/dist/modules/currencies/backend/currencies/page.js +3 -1
- package/dist/modules/currencies/backend/currencies/page.js.map +2 -2
- package/dist/modules/currencies/backend/exchange-rates/page.js +3 -1
- package/dist/modules/currencies/backend/exchange-rates/page.js.map +2 -2
- package/dist/modules/currencies/services/rateFetchingService.js +6 -1
- package/dist/modules/currencies/services/rateFetchingService.js.map +2 -2
- package/dist/modules/customer_accounts/api/admin/domain-mappings.js +9 -0
- package/dist/modules/customer_accounts/api/admin/domain-mappings.js.map +2 -2
- package/dist/modules/customer_accounts/backend/customer_accounts/roles/page.js +3 -1
- package/dist/modules/customer_accounts/backend/customer_accounts/roles/page.js.map +2 -2
- package/dist/modules/customer_accounts/backend/customer_accounts/users/PortalUsersPageClient.js +3 -1
- package/dist/modules/customer_accounts/backend/customer_accounts/users/PortalUsersPageClient.js.map +2 -2
- package/dist/modules/customer_accounts/services/domainMappingService.js +10 -0
- package/dist/modules/customer_accounts/services/domainMappingService.js.map +2 -2
- package/dist/modules/customers/ai-tools/companies-pack.js +4 -1
- package/dist/modules/customers/ai-tools/companies-pack.js.map +2 -2
- package/dist/modules/customers/ai-tools/deal-analyzer-pack.js +13 -2
- package/dist/modules/customers/ai-tools/deal-analyzer-pack.js.map +2 -2
- package/dist/modules/customers/ai-tools/deals-pack.js +52 -6
- package/dist/modules/customers/ai-tools/deals-pack.js.map +2 -2
- package/dist/modules/customers/ai-tools/people-pack.js +4 -1
- package/dist/modules/customers/ai-tools/people-pack.js.map +2 -2
- package/dist/modules/customers/api/activities/route.js +48 -6
- package/dist/modules/customers/api/activities/route.js.map +2 -2
- package/dist/modules/customers/api/companies/[id]/people/route.js +20 -64
- package/dist/modules/customers/api/companies/[id]/people/route.js.map +2 -2
- package/dist/modules/customers/api/companies/[id]/route.js +17 -94
- package/dist/modules/customers/api/companies/[id]/route.js.map +2 -2
- package/dist/modules/customers/api/dashboard/widgets/customer-todos/route.js +8 -5
- package/dist/modules/customers/api/dashboard/widgets/customer-todos/route.js.map +2 -2
- package/dist/modules/customers/api/deals/[id]/companies/route.js +1 -1
- package/dist/modules/customers/api/deals/[id]/companies/route.js.map +2 -2
- package/dist/modules/customers/api/deals/[id]/people/route.js +1 -1
- package/dist/modules/customers/api/deals/[id]/people/route.js.map +2 -2
- package/dist/modules/customers/api/deals/[id]/route.js +8 -25
- package/dist/modules/customers/api/deals/[id]/route.js.map +2 -2
- package/dist/modules/customers/api/deals/[id]/stats/route.js +3 -22
- package/dist/modules/customers/api/deals/[id]/stats/route.js.map +2 -2
- package/dist/modules/customers/api/deals/aggregate/route.js +14 -9
- package/dist/modules/customers/api/deals/aggregate/route.js.map +2 -2
- package/dist/modules/customers/api/deals/map/route.js +5 -5
- package/dist/modules/customers/api/deals/map/route.js.map +2 -2
- package/dist/modules/customers/api/deals/route.js +38 -1
- package/dist/modules/customers/api/deals/route.js.map +2 -2
- package/dist/modules/customers/api/entity-roles-factory.js +4 -4
- package/dist/modules/customers/api/entity-roles-factory.js.map +2 -2
- package/dist/modules/customers/api/interactions/route.js +3 -1
- package/dist/modules/customers/api/interactions/route.js.map +2 -2
- package/dist/modules/customers/api/interactions/tasks/route.js +27 -4
- package/dist/modules/customers/api/interactions/tasks/route.js.map +2 -2
- package/dist/modules/customers/api/people/[id]/companies/[linkId]/route.js +4 -3
- package/dist/modules/customers/api/people/[id]/companies/[linkId]/route.js.map +2 -2
- package/dist/modules/customers/api/people/[id]/companies/context.js +1 -1
- package/dist/modules/customers/api/people/[id]/companies/context.js.map +2 -2
- package/dist/modules/customers/api/people/[id]/companies/enriched/route.js +1 -1
- package/dist/modules/customers/api/people/[id]/companies/enriched/route.js.map +2 -2
- package/dist/modules/customers/api/people/[id]/route.js +11 -10
- package/dist/modules/customers/api/people/[id]/route.js.map +2 -2
- package/dist/modules/customers/api/people/check-phone/route.js +51 -9
- package/dist/modules/customers/api/people/check-phone/route.js.map +2 -2
- package/dist/modules/customers/api/todos/route.js +30 -5
- package/dist/modules/customers/api/todos/route.js.map +2 -2
- package/dist/modules/customers/backend/customers/companies/page.js +4 -2
- package/dist/modules/customers/backend/customers/companies/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/[id]/page.js +6 -1
- package/dist/modules/customers/backend/customers/deals/[id]/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/page.js +5 -2
- package/dist/modules/customers/backend/customers/deals/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/pipeline/components/Lane.js +4 -13
- package/dist/modules/customers/backend/customers/deals/pipeline/components/Lane.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/pipeline/components/StatusFilterPopover.js +85 -14
- package/dist/modules/customers/backend/customers/deals/pipeline/components/StatusFilterPopover.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/pipeline/components/toneClasses.js +18 -0
- package/dist/modules/customers/backend/customers/deals/pipeline/components/toneClasses.js.map +7 -0
- package/dist/modules/customers/backend/customers/people/page.js +4 -2
- package/dist/modules/customers/backend/customers/people/page.js.map +2 -2
- package/dist/modules/customers/backend/hooks/useEmailDuplicateCheck.js +9 -3
- package/dist/modules/customers/backend/hooks/useEmailDuplicateCheck.js.map +2 -2
- package/dist/modules/customers/commands/deals.js +21 -34
- package/dist/modules/customers/commands/deals.js.map +2 -2
- package/dist/modules/customers/commands/interactions.js.map +1 -1
- package/dist/modules/customers/commands/personCompanyLinks.js +131 -2
- package/dist/modules/customers/commands/personCompanyLinks.js.map +2 -2
- package/dist/modules/customers/components/CustomerTodosTable.js +1 -0
- package/dist/modules/customers/components/CustomerTodosTable.js.map +2 -2
- package/dist/modules/customers/components/DealsKpiStrip.js +7 -6
- package/dist/modules/customers/components/DealsKpiStrip.js.map +2 -2
- package/dist/modules/customers/components/calendar/AgendaList.js +2 -2
- package/dist/modules/customers/components/calendar/AgendaList.js.map +2 -2
- package/dist/modules/customers/components/calendar/CalendarEventEditor.js +1 -1
- package/dist/modules/customers/components/calendar/CalendarEventEditor.js.map +2 -2
- package/dist/modules/customers/components/calendar/CalendarScreen.js +1 -1
- package/dist/modules/customers/components/calendar/CalendarScreen.js.map +2 -2
- package/dist/modules/customers/components/calendar/CalendarSettingsModal.js +1 -1
- package/dist/modules/customers/components/calendar/CalendarSettingsModal.js.map +2 -2
- package/dist/modules/customers/components/calendar/EventBlock.js +1 -1
- package/dist/modules/customers/components/calendar/EventBlock.js.map +2 -2
- package/dist/modules/customers/components/calendar/EventPeekPopover.js +3 -2
- package/dist/modules/customers/components/calendar/EventPeekPopover.js.map +2 -2
- package/dist/modules/customers/components/calendar/editor/PeopleField.js +40 -5
- package/dist/modules/customers/components/calendar/editor/PeopleField.js.map +2 -2
- package/dist/modules/customers/components/calendar/editor/hooks.js +2 -1
- package/dist/modules/customers/components/calendar/editor/hooks.js.map +2 -2
- package/dist/modules/customers/components/calendar/types.js +1 -1
- package/dist/modules/customers/components/calendar/types.js.map +2 -2
- package/dist/modules/customers/components/detail/CompanyKpiBar.js +5 -4
- package/dist/modules/customers/components/detail/CompanyKpiBar.js.map +2 -2
- package/dist/modules/customers/components/detail/CompanyPeopleSection.js +3 -1
- package/dist/modules/customers/components/detail/CompanyPeopleSection.js.map +2 -2
- package/dist/modules/customers/components/detail/DealForm.js +19 -7
- package/dist/modules/customers/components/detail/DealForm.js.map +2 -2
- package/dist/modules/customers/components/detail/DealsSection.js +6 -5
- package/dist/modules/customers/components/detail/DealsSection.js.map +2 -2
- package/dist/modules/customers/components/detail/EntityTagsDialog.js +35 -11
- package/dist/modules/customers/components/detail/EntityTagsDialog.js.map +2 -2
- package/dist/modules/customers/components/detail/PersonCompaniesSection.js +3 -1
- package/dist/modules/customers/components/detail/PersonCompaniesSection.js.map +2 -2
- package/dist/modules/customers/components/detail/hooks/usePersonTasks.js +19 -13
- package/dist/modules/customers/components/detail/hooks/usePersonTasks.js.map +2 -2
- package/dist/modules/customers/components/detail/schedule/ParticipantsField.js +4 -4
- package/dist/modules/customers/components/detail/schedule/ParticipantsField.js.map +2 -2
- package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js +3 -3
- package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js.map +2 -2
- package/dist/modules/customers/components/detail/utils.js +5 -5
- package/dist/modules/customers/components/detail/utils.js.map +2 -2
- package/dist/modules/customers/data/entities.js.map +1 -1
- package/dist/modules/customers/data/validators.js +32 -3
- package/dist/modules/customers/data/validators.js.map +2 -2
- package/dist/modules/customers/events.js +5 -0
- package/dist/modules/customers/events.js.map +2 -2
- package/dist/modules/customers/lib/calendar/conflicts.js +8 -2
- package/dist/modules/customers/lib/calendar/conflicts.js.map +2 -2
- package/dist/modules/customers/lib/calendar/editorPayload.js +3 -2
- package/dist/modules/customers/lib/calendar/editorPayload.js.map +2 -2
- package/dist/modules/customers/lib/calendar/mapItem.js +8 -3
- package/dist/modules/customers/lib/calendar/mapItem.js.map +2 -2
- package/dist/modules/customers/lib/calendar/participantIdentity.js +9 -0
- package/dist/modules/customers/lib/calendar/participantIdentity.js.map +7 -0
- package/dist/modules/customers/lib/closureStage.js +45 -0
- package/dist/modules/customers/lib/closureStage.js.map +7 -0
- package/dist/modules/customers/lib/dealStatus.js +30 -0
- package/dist/modules/customers/lib/dealStatus.js.map +2 -2
- package/dist/modules/customers/lib/detailReadAccess.js +12 -0
- package/dist/modules/customers/lib/detailReadAccess.js.map +7 -0
- package/dist/modules/customers/lib/findPeopleByAddresses.js +1 -0
- package/dist/modules/customers/lib/findPeopleByAddresses.js.map +2 -2
- package/dist/modules/customers/lib/personCompanies.js +100 -2
- package/dist/modules/customers/lib/personCompanies.js.map +2 -2
- package/dist/modules/customers/lib/todoCompatibility.js +12 -0
- package/dist/modules/customers/lib/todoCompatibility.js.map +2 -2
- package/dist/modules/dashboards/lib/widgetScope.js +6 -1
- package/dist/modules/dashboards/lib/widgetScope.js.map +2 -2
- package/dist/modules/data_sync/backend/data-sync/page.js +3 -1
- package/dist/modules/data_sync/backend/data-sync/page.js.map +2 -2
- package/dist/modules/data_sync/lib/abandoned-run.js +19 -0
- package/dist/modules/data_sync/lib/abandoned-run.js.map +7 -0
- package/dist/modules/data_sync/lib/sync-engine.js +72 -6
- package/dist/modules/data_sync/lib/sync-engine.js.map +2 -2
- package/dist/modules/data_sync/workers/sync-export.js +5 -1
- package/dist/modules/data_sync/workers/sync-export.js.map +2 -2
- package/dist/modules/data_sync/workers/sync-import.js +5 -1
- package/dist/modules/data_sync/workers/sync-import.js.map +2 -2
- package/dist/modules/devices/acl.js +9 -1
- package/dist/modules/devices/acl.js.map +2 -2
- package/dist/modules/devices/api/admin/devices/[id]/route.js +5 -32
- package/dist/modules/devices/api/admin/devices/[id]/route.js.map +2 -2
- package/dist/modules/devices/api/admin/devices/route.js +14 -1
- package/dist/modules/devices/api/admin/devices/route.js.map +2 -2
- package/dist/modules/devices/api/deviceList.js +99 -12
- package/dist/modules/devices/api/deviceList.js.map +2 -2
- package/dist/modules/devices/api/deviceSerialization.js +46 -0
- package/dist/modules/devices/api/deviceSerialization.js.map +7 -0
- package/dist/modules/devices/api/openapi.js +3 -1
- package/dist/modules/devices/api/openapi.js.map +2 -2
- package/dist/modules/devices/api/route.js +9 -1
- package/dist/modules/devices/api/route.js.map +2 -2
- package/dist/modules/devices/backend/devices/[id]/page.js +10 -26
- package/dist/modules/devices/backend/devices/[id]/page.js.map +2 -2
- package/dist/modules/devices/backend/devices/create/page.js +17 -1
- package/dist/modules/devices/backend/devices/create/page.js.map +2 -2
- package/dist/modules/devices/backend/devices/page.js +28 -34
- package/dist/modules/devices/backend/devices/page.js.map +2 -2
- package/dist/modules/devices/backend/devices/useDeviceUserLabels.js +34 -0
- package/dist/modules/devices/backend/devices/useDeviceUserLabels.js.map +7 -0
- package/dist/modules/devices/backend/devices/userOptions.js +52 -0
- package/dist/modules/devices/backend/devices/userOptions.js.map +7 -0
- package/dist/modules/devices/setup.js +6 -2
- package/dist/modules/devices/setup.js.map +2 -2
- package/dist/modules/directory/backend/directory/organizations/page.js +2 -1
- package/dist/modules/directory/backend/directory/organizations/page.js.map +2 -2
- package/dist/modules/directory/backend/directory/tenants/page.js +2 -1
- package/dist/modules/directory/backend/directory/tenants/page.js.map +2 -2
- package/dist/modules/directory/di.js +9 -0
- package/dist/modules/directory/di.js.map +2 -2
- package/dist/modules/directory/services/organizationHierarchyService.js +29 -0
- package/dist/modules/directory/services/organizationHierarchyService.js.map +7 -0
- package/dist/modules/directory/services/organizationScopeService.js +56 -0
- package/dist/modules/directory/services/organizationScopeService.js.map +7 -0
- package/dist/modules/directory/utils/organizationScope.js.map +2 -2
- package/dist/modules/entities/api/records.js +4 -2
- package/dist/modules/entities/api/records.js.map +2 -2
- package/dist/modules/entities/backend/entities/user/[entityId]/records/page.js +3 -1
- package/dist/modules/entities/backend/entities/user/[entityId]/records/page.js.map +2 -2
- package/dist/modules/eudr/api/plots/route.js +5 -1
- package/dist/modules/eudr/api/plots/route.js.map +2 -2
- package/dist/modules/eudr/backend/eudr/evidence-submissions/page.js +3 -0
- package/dist/modules/eudr/backend/eudr/evidence-submissions/page.js.map +2 -2
- package/dist/modules/eudr/backend/eudr/plots/page.js +3 -0
- package/dist/modules/eudr/backend/eudr/plots/page.js.map +2 -2
- package/dist/modules/eudr/backend/eudr/product-mappings/page.js +3 -0
- package/dist/modules/eudr/backend/eudr/product-mappings/page.js.map +2 -2
- package/dist/modules/eudr/backend/eudr/risk-assessments/page.js +3 -0
- package/dist/modules/eudr/backend/eudr/risk-assessments/page.js.map +2 -2
- package/dist/modules/eudr/backend/eudr/statements/page.js +3 -0
- package/dist/modules/eudr/backend/eudr/statements/page.js.map +2 -2
- package/dist/modules/eudr/commands/statements.js +0 -3
- package/dist/modules/eudr/commands/statements.js.map +2 -2
- package/dist/modules/eudr/data/validators.js +4 -1
- package/dist/modules/eudr/data/validators.js.map +2 -2
- package/dist/modules/feature_toggles/components/FeatureTogglesTable.js +1 -0
- package/dist/modules/feature_toggles/components/FeatureTogglesTable.js.map +2 -2
- package/dist/modules/feature_toggles/components/OverridesTable.js +1 -0
- package/dist/modules/feature_toggles/components/OverridesTable.js.map +2 -2
- package/dist/modules/feature_toggles/defaults.json +0 -8
- package/dist/modules/inbox_ops/backend/inbox-ops/log/page.js +3 -0
- package/dist/modules/inbox_ops/backend/inbox-ops/log/page.js.map +2 -2
- package/dist/modules/inbox_ops/backend/inbox-ops/page.js +3 -0
- package/dist/modules/inbox_ops/backend/inbox-ops/page.js.map +2 -2
- package/dist/modules/inbox_ops/lib/htmlToPlainText.js +1 -12
- package/dist/modules/inbox_ops/lib/htmlToPlainText.js.map +2 -2
- package/dist/modules/integrations/api/[id]/credentials/route.js +6 -1
- package/dist/modules/integrations/api/[id]/credentials/route.js.map +2 -2
- package/dist/modules/integrations/backend/integrations/[id]/page.js +38 -29
- package/dist/modules/integrations/backend/integrations/[id]/page.js.map +2 -2
- package/dist/modules/integrations/backend/integrations/bundle/[id]/page.js +36 -9
- package/dist/modules/integrations/backend/integrations/bundle/[id]/page.js.map +2 -2
- package/dist/modules/integrations/backend/integrations/credential-secret-fields.js +55 -0
- package/dist/modules/integrations/backend/integrations/credential-secret-fields.js.map +7 -0
- package/dist/modules/integrations/data/validators.js +11 -3
- package/dist/modules/integrations/data/validators.js.map +2 -2
- package/dist/modules/integrations/lib/credentials-masking.js +6 -2
- package/dist/modules/integrations/lib/credentials-masking.js.map +2 -2
- package/dist/modules/messages/api/[id]/route.js +29 -1
- package/dist/modules/messages/api/[id]/route.js.map +2 -2
- package/dist/modules/messages/api/openapi.js +17 -2
- package/dist/modules/messages/api/openapi.js.map +2 -2
- package/dist/modules/messages/api/route.js +17 -2
- package/dist/modules/messages/api/route.js.map +2 -2
- package/dist/modules/messages/components/MessagesInboxPageClient.js +7 -14
- package/dist/modules/messages/components/MessagesInboxPageClient.js.map +2 -2
- package/dist/modules/messages/components/inboxFilters.js +15 -0
- package/dist/modules/messages/components/inboxFilters.js.map +2 -2
- package/dist/modules/messages/components/message-detail/hooks/useMessageDetailsConversation.js +11 -1
- package/dist/modules/messages/components/message-detail/hooks/useMessageDetailsConversation.js.map +2 -2
- package/dist/modules/messages/components/message-detail/panels/MessageHeader.js +3 -1
- package/dist/modules/messages/components/message-detail/panels/MessageHeader.js.map +2 -2
- package/dist/modules/messages/components/message-detail/panels/thread-panel.js +2 -1
- package/dist/modules/messages/components/message-detail/panels/thread-panel.js.map +2 -2
- package/dist/modules/messages/components/messageListLabels.js +14 -2
- package/dist/modules/messages/components/messageListLabels.js.map +2 -2
- package/dist/modules/messages/data/validators.js +18 -4
- package/dist/modules/messages/data/validators.js.map +2 -2
- package/dist/modules/messages/lib/channel-sender-identity.js +26 -0
- package/dist/modules/messages/lib/channel-sender-identity.js.map +7 -0
- package/dist/modules/messages/lib/composeSourceChannelType.js +41 -0
- package/dist/modules/messages/lib/composeSourceChannelType.js.map +7 -0
- package/dist/modules/payment_gateways/api/webhook/[provider]/route.js +4 -6
- package/dist/modules/payment_gateways/api/webhook/[provider]/route.js.map +2 -2
- package/dist/modules/payment_gateways/backend/payment-gateways/page.js +3 -1
- package/dist/modules/payment_gateways/backend/payment-gateways/page.js.map +2 -2
- package/dist/modules/payment_gateways/lib/webhook-processor.js +7 -0
- package/dist/modules/payment_gateways/lib/webhook-processor.js.map +2 -2
- package/dist/modules/planner/backend/planner/availability-rulesets/page.js +3 -0
- package/dist/modules/planner/backend/planner/availability-rulesets/page.js.map +2 -2
- package/dist/modules/push_notifications/backend/push_notifications/page.js +3 -1
- package/dist/modules/push_notifications/backend/push_notifications/page.js.map +2 -2
- package/dist/modules/push_notifications/backend/push_notifications/send/page.js +1 -1
- package/dist/modules/push_notifications/backend/push_notifications/send/page.js.map +2 -2
- package/dist/modules/query_index/lib/engine.js +150 -51
- package/dist/modules/query_index/lib/engine.js.map +2 -2
- package/dist/modules/query_index/lib/search-entity-policy.js +14 -0
- package/dist/modules/query_index/lib/search-entity-policy.js.map +7 -0
- package/dist/modules/query_index/lib/search-tokens.js +79 -3
- package/dist/modules/query_index/lib/search-tokens.js.map +2 -2
- package/dist/modules/resources/backend/resources/resource-types/page.js +3 -1
- package/dist/modules/resources/backend/resources/resource-types/page.js.map +2 -2
- package/dist/modules/resources/backend/resources/resources/page.js +3 -1
- package/dist/modules/resources/backend/resources/resources/page.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/offers/page.js +3 -0
- package/dist/modules/sales/backend/sales/channels/offers/page.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/page.js +3 -0
- package/dist/modules/sales/backend/sales/channels/page.js.map +2 -2
- package/dist/modules/sales/backend/sales/documents/[id]/page.js +10 -8
- package/dist/modules/sales/backend/sales/documents/[id]/page.js.map +2 -2
- package/dist/modules/sales/commands/documents.js +79 -1
- package/dist/modules/sales/commands/documents.js.map +2 -2
- package/dist/modules/sales/components/PriceWithCurrency.js +7 -5
- package/dist/modules/sales/components/PriceWithCurrency.js.map +2 -2
- package/dist/modules/sales/components/channels/SalesChannelOffersPanel.js +3 -0
- package/dist/modules/sales/components/channels/SalesChannelOffersPanel.js.map +2 -2
- package/dist/modules/sales/components/documents/AdjustmentsSection.js +8 -6
- package/dist/modules/sales/components/documents/AdjustmentsSection.js.map +2 -2
- package/dist/modules/sales/components/documents/ItemsSection.js +51 -22
- package/dist/modules/sales/components/documents/ItemsSection.js.map +2 -2
- package/dist/modules/sales/components/documents/LineItemDialog.js +83 -18
- package/dist/modules/sales/components/documents/LineItemDialog.js.map +2 -2
- package/dist/modules/sales/components/documents/PaymentsSection.js +23 -9
- package/dist/modules/sales/components/documents/PaymentsSection.js.map +2 -2
- package/dist/modules/sales/components/documents/ReturnsSection.js +8 -6
- package/dist/modules/sales/components/documents/ReturnsSection.js.map +2 -2
- package/dist/modules/sales/components/documents/SalesDocumentsTable.js +68 -14
- package/dist/modules/sales/components/documents/SalesDocumentsTable.js.map +2 -2
- package/dist/modules/sales/components/documents/SalesOrderDraftLines.js +6 -5
- package/dist/modules/sales/components/documents/SalesOrderDraftLines.js.map +2 -2
- package/dist/modules/sales/components/documents/ShipmentDialog.js +5 -4
- package/dist/modules/sales/components/documents/ShipmentDialog.js.map +2 -2
- package/dist/modules/sales/components/documents/ShipmentsSection.js +8 -6
- package/dist/modules/sales/components/documents/ShipmentsSection.js.map +2 -2
- package/dist/modules/sales/components/documents/lineItemShipmentLock.js +54 -0
- package/dist/modules/sales/components/documents/lineItemShipmentLock.js.map +7 -0
- package/dist/modules/sales/components/documents/lineItemUtils.js +2 -2
- package/dist/modules/sales/components/documents/lineItemUtils.js.map +2 -2
- package/dist/modules/sales/data/entities.js +8 -2
- package/dist/modules/sales/data/entities.js.map +2 -2
- package/dist/modules/sales/extension-points.js +1 -0
- package/dist/modules/sales/extension-points.js.map +2 -2
- package/dist/modules/sales/lib/salesChannelsToggleSeed.js +33 -0
- package/dist/modules/sales/lib/salesChannelsToggleSeed.js.map +7 -0
- package/dist/modules/sales/migrations/Migration20260821120000_sales_notes_addresses_context_idx.js +32 -0
- package/dist/modules/sales/migrations/Migration20260821120000_sales_notes_addresses_context_idx.js.map +7 -0
- package/dist/modules/sales/setup.js +2 -0
- package/dist/modules/sales/setup.js.map +2 -2
- package/dist/modules/sales/widgets/injection/payment-gateway-status-column/widget.js +10 -2
- package/dist/modules/sales/widgets/injection/payment-gateway-status-column/widget.js.map +2 -2
- package/dist/modules/sales/widgets/injection-table.js +4 -7
- package/dist/modules/sales/widgets/injection-table.js.map +2 -2
- package/dist/modules/staff/backend/staff/leave-requests/page.js +3 -0
- package/dist/modules/staff/backend/staff/leave-requests/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/my-leave-requests/page.js +3 -0
- package/dist/modules/staff/backend/staff/my-leave-requests/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/team-members/page.js +3 -0
- package/dist/modules/staff/backend/staff/team-members/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/team-roles/page.js +3 -0
- package/dist/modules/staff/backend/staff/team-roles/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js +3 -0
- package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/teams/page.js +3 -0
- package/dist/modules/staff/backend/staff/teams/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/page.js +29 -18
- package/dist/modules/staff/backend/staff/timesheets/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/timesheets/projects/page.js +3 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/page.js.map +2 -2
- package/dist/modules/sync_excel/lib/adapters/customers.js +1 -0
- package/dist/modules/sync_excel/lib/adapters/customers.js.map +2 -2
- package/dist/modules/warranty_claims/api/assignees/route.js +3 -3
- package/dist/modules/warranty_claims/api/assignees/route.js.map +2 -2
- package/dist/modules/warranty_claims/api/portal/attachments/route.js +2 -2
- package/dist/modules/warranty_claims/api/portal/attachments/route.js.map +2 -2
- package/dist/modules/warranty_claims/api/portal/claims/route.js +12 -9
- package/dist/modules/warranty_claims/api/portal/claims/route.js.map +2 -2
- package/dist/modules/warranty_claims/backend/page.js +3 -0
- package/dist/modules/warranty_claims/backend/page.js.map +2 -2
- package/dist/modules/warranty_claims/backend/warranty_claims/registrations/page.js +3 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/registrations/page.js.map +2 -2
- package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/page.js +3 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/page.js.map +2 -2
- package/dist/modules/warranty_claims/backend/warranty_claims/vendor-policies/page.js +3 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/vendor-policies/page.js.map +2 -2
- package/dist/modules/warranty_claims/frontend/[orgSlug]/portal/claims/page.js +3 -0
- package/dist/modules/warranty_claims/frontend/[orgSlug]/portal/claims/page.js.map +2 -2
- package/dist/modules/wms/api/warehouseSearch.js +21 -0
- package/dist/modules/wms/api/warehouseSearch.js.map +7 -0
- package/dist/modules/wms/api/warehouses/route.js +13 -9
- package/dist/modules/wms/api/warehouses/route.js.map +2 -2
- package/dist/modules/wms/api/zones/route.js +15 -2
- package/dist/modules/wms/api/zones/route.js.map +2 -2
- package/dist/modules/wms/commands/configuration.js +121 -9
- package/dist/modules/wms/commands/configuration.js.map +2 -2
- package/dist/modules/wms/commands/inventory-actions.js +3 -0
- package/dist/modules/wms/commands/inventory-actions.js.map +2 -2
- package/dist/modules/wms/commands/shared.js +9 -1
- package/dist/modules/wms/commands/shared.js.map +2 -2
- package/dist/modules/wms/components/backend/WarehouseEditDialog.js +158 -0
- package/dist/modules/wms/components/backend/WarehouseEditDialog.js.map +7 -0
- package/dist/modules/wms/components/backend/WmsConfigurationPage.js +76 -111
- package/dist/modules/wms/components/backend/WmsConfigurationPage.js.map +3 -3
- package/dist/modules/wms/components/backend/WmsInventoryConsolePage.js +1 -0
- package/dist/modules/wms/components/backend/WmsInventoryConsolePage.js.map +2 -2
- package/dist/modules/wms/components/backend/WmsLotsListPage.js +1 -0
- package/dist/modules/wms/components/backend/WmsLotsListPage.js.map +2 -2
- package/dist/modules/wms/components/backend/inventoryMutationLoaders.js +27 -20
- package/dist/modules/wms/components/backend/inventoryMutationLoaders.js.map +2 -2
- package/dist/modules/wms/components/backend/warehouseFormOptions.js +66 -0
- package/dist/modules/wms/components/backend/warehouseFormOptions.js.map +7 -0
- package/dist/modules/workflows/backend/definitions/page.js +3 -1
- package/dist/modules/workflows/backend/definitions/page.js.map +2 -2
- package/dist/modules/workflows/backend/events/page.js +3 -1
- package/dist/modules/workflows/backend/events/page.js.map +2 -2
- package/dist/modules/workflows/backend/instances/page.js +3 -1
- package/dist/modules/workflows/backend/instances/page.js.map +2 -2
- package/dist/modules/workflows/backend/tasks/page.js +3 -1
- package/dist/modules/workflows/backend/tasks/page.js.map +2 -2
- package/dist/modules/workflows/lib/activity-executor.js +4 -0
- package/dist/modules/workflows/lib/activity-executor.js.map +2 -2
- package/package.json +9 -10
- package/src/helpers/integration/api.ts +33 -1
- package/src/helpers/integration/communicationChannelsFixtures.ts +69 -1
- package/src/modules/api_keys/api/keys/route.ts +3 -1
- package/src/modules/api_keys/backend/api-keys/page.tsx +4 -1
- package/src/modules/api_keys/di.ts +7 -0
- package/src/modules/api_keys/services/principalService.ts +33 -0
- package/src/modules/attachments/AGENTS.md +15 -0
- package/src/modules/attachments/api/route.ts +2 -2
- package/src/modules/attachments/components/AttachmentLibrary.tsx +3 -0
- package/src/modules/attachments/di.ts +16 -0
- package/src/modules/attachments/i18n/de.json +5 -0
- package/src/modules/attachments/i18n/en.json +5 -0
- package/src/modules/attachments/i18n/es.json +5 -0
- package/src/modules/attachments/i18n/ko.json +5 -0
- package/src/modules/attachments/i18n/pl.json +5 -0
- package/src/modules/attachments/index.ts +10 -0
- package/src/modules/attachments/lib/attachment-service.ts +468 -0
- package/src/modules/attachments/lib/scoped-upload-service.ts +46 -0
- package/src/modules/attachments/lib/upload-limits.ts +6 -2
- package/src/modules/audit_logs/backend/audit-logs/page.tsx +8 -0
- package/src/modules/audit_logs/lib/display-helpers.tsx +42 -32
- package/src/modules/audit_logs/services/actionLogService.ts +74 -11
- package/src/modules/auth/acl.ts +30 -6
- package/src/modules/auth/api/feature-check.ts +10 -3
- package/src/modules/auth/api/login.ts +9 -1
- package/src/modules/auth/api/reset/validate.ts +57 -0
- package/src/modules/auth/api/roles/acl/route.ts +42 -39
- package/src/modules/auth/api/session/refresh.ts +32 -1
- package/src/modules/auth/api/users/acl/route.ts +177 -53
- package/src/modules/auth/api/users/route.ts +18 -5
- package/src/modules/auth/backend/roles/[id]/edit/page.meta.ts +5 -2
- package/src/modules/auth/backend/roles/page.tsx +4 -2
- package/src/modules/auth/backend/users/[id]/edit/page.meta.ts +5 -2
- package/src/modules/auth/backend/users/page.tsx +3 -2
- package/src/modules/auth/commands/acl.ts +495 -0
- package/src/modules/auth/components/AclEditor.tsx +63 -33
- package/src/modules/auth/data/entities.ts +4 -1
- package/src/modules/auth/data/validators.ts +5 -0
- package/src/modules/auth/di.ts +46 -16
- package/src/modules/auth/frontend/reset/[token]/page.tsx +74 -0
- package/src/modules/auth/i18n/de.json +389 -0
- package/src/modules/auth/i18n/en.json +389 -0
- package/src/modules/auth/i18n/es.json +389 -0
- package/src/modules/auth/i18n/ko.json +389 -0
- package/src/modules/auth/i18n/pl.json +391 -2
- package/src/modules/auth/lib/grantChecks.ts +6 -0
- package/src/modules/auth/lib/userIdFilter.ts +31 -0
- package/src/modules/auth/services/authService.ts +18 -2
- package/src/modules/auth/services/principalService.ts +266 -0
- package/src/modules/auth/services/rbacService.ts +110 -24
- package/src/modules/auth/services/roleOrganizationScope.ts +70 -0
- package/src/modules/business_rules/backend/logs/page.tsx +4 -1
- package/src/modules/business_rules/backend/rules/page.tsx +4 -1
- package/src/modules/business_rules/backend/sets/page.tsx +4 -1
- package/src/modules/business_rules/lib/expression-evaluator.ts +9 -9
- package/src/modules/business_rules/lib/rule-evaluator.ts +10 -9
- package/src/modules/catalog/ai-agents.ts +1 -1
- package/src/modules/catalog/ai-tools/merchandising-pack.ts +2 -2
- package/src/modules/catalog/backend/catalog/products/MerchandisingAssistantSheet.tsx +12 -5
- package/src/modules/catalog/components/categories/CategoriesDataTable.tsx +3 -0
- package/src/modules/catalog/components/products/ProductsDataTable.tsx +7 -0
- 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/ko.json +1 -0
- package/src/modules/catalog/i18n/pl.json +1 -0
- package/src/modules/catalog/widgets/injection/merchandising-assistant-trigger/widget.client.tsx +4 -0
- package/src/modules/communication_channels/api/post/channels/[id]/test-send/route.ts +17 -1
- package/src/modules/communication_channels/api/post/test-seed/route.ts +155 -16
- package/src/modules/communication_channels/backend/communication_channels/channels/page.tsx +4 -0
- package/src/modules/communication_channels/commands/ingest-inbound-message.ts +38 -1
- package/src/modules/communication_channels/di.ts +7 -0
- package/src/modules/communication_channels/lib/adapter.ts +14 -0
- package/src/modules/communication_channels/lib/email-capabilities.ts +4 -0
- package/src/modules/communication_channels/lib/outbound-recipient.ts +71 -0
- package/src/modules/communication_channels/lib/resolve-channel-type.ts +99 -0
- package/src/modules/communication_channels/lib/test-seed.ts +64 -4
- package/src/modules/configs/i18n/de.json +2 -0
- package/src/modules/configs/i18n/en.json +2 -0
- package/src/modules/configs/i18n/es.json +2 -0
- package/src/modules/configs/i18n/ko.json +2 -0
- package/src/modules/configs/i18n/pl.json +2 -0
- package/src/modules/configs/lib/system-status.ts +9 -0
- package/src/modules/currencies/AGENTS.md +3 -0
- package/src/modules/currencies/backend/currencies/page.tsx +4 -1
- package/src/modules/currencies/backend/exchange-rates/page.tsx +4 -1
- package/src/modules/currencies/services/README.md +45 -0
- package/src/modules/currencies/services/rateFetchingService.ts +6 -1
- package/src/modules/customer_accounts/api/admin/domain-mappings.ts +7 -0
- package/src/modules/customer_accounts/backend/customer_accounts/roles/page.tsx +4 -1
- package/src/modules/customer_accounts/backend/customer_accounts/users/PortalUsersPageClient.tsx +4 -1
- package/src/modules/customer_accounts/services/domainMappingService.ts +10 -0
- package/src/modules/customers/ai-tools/companies-pack.ts +4 -1
- package/src/modules/customers/ai-tools/deal-analyzer-pack.ts +17 -2
- package/src/modules/customers/ai-tools/deals-pack.ts +66 -1
- package/src/modules/customers/ai-tools/people-pack.ts +4 -1
- package/src/modules/customers/api/activities/route.ts +45 -0
- package/src/modules/customers/api/companies/[id]/people/route.ts +24 -73
- package/src/modules/customers/api/companies/[id]/route.ts +24 -107
- package/src/modules/customers/api/dashboard/widgets/customer-todos/route.ts +16 -8
- package/src/modules/customers/api/deals/[id]/companies/route.ts +4 -1
- package/src/modules/customers/api/deals/[id]/people/route.ts +4 -1
- package/src/modules/customers/api/deals/[id]/route.ts +17 -28
- package/src/modules/customers/api/deals/[id]/stats/route.ts +10 -25
- package/src/modules/customers/api/deals/aggregate/route.ts +17 -9
- package/src/modules/customers/api/deals/map/route.ts +4 -4
- package/src/modules/customers/api/deals/route.ts +50 -1
- package/src/modules/customers/api/entity-roles-factory.ts +8 -4
- package/src/modules/customers/api/interactions/route.ts +8 -2
- package/src/modules/customers/api/interactions/tasks/route.ts +24 -1
- package/src/modules/customers/api/people/[id]/companies/[linkId]/route.ts +12 -4
- package/src/modules/customers/api/people/[id]/companies/context.ts +4 -1
- package/src/modules/customers/api/people/[id]/companies/enriched/route.ts +4 -1
- package/src/modules/customers/api/people/[id]/route.ts +16 -11
- package/src/modules/customers/api/people/check-phone/route.ts +75 -10
- package/src/modules/customers/api/todos/route.ts +27 -2
- package/src/modules/customers/backend/customers/companies/page.tsx +5 -2
- package/src/modules/customers/backend/customers/deals/[id]/page.tsx +7 -2
- package/src/modules/customers/backend/customers/deals/page.tsx +8 -2
- package/src/modules/customers/backend/customers/deals/pipeline/components/Lane.tsx +5 -14
- package/src/modules/customers/backend/customers/deals/pipeline/components/StatusFilterPopover.tsx +109 -27
- package/src/modules/customers/backend/customers/deals/pipeline/components/toneClasses.ts +21 -0
- package/src/modules/customers/backend/customers/people/page.tsx +5 -2
- package/src/modules/customers/backend/hooks/useEmailDuplicateCheck.ts +12 -4
- package/src/modules/customers/commands/deals.ts +34 -59
- package/src/modules/customers/commands/interactions.ts +1 -1
- package/src/modules/customers/commands/personCompanyLinks.ts +224 -8
- package/src/modules/customers/components/CustomerTodosTable.tsx +2 -0
- package/src/modules/customers/components/DealsKpiStrip.tsx +7 -7
- package/src/modules/customers/components/calendar/AgendaList.tsx +3 -3
- package/src/modules/customers/components/calendar/CalendarEventEditor.tsx +1 -1
- package/src/modules/customers/components/calendar/CalendarScreen.tsx +1 -1
- package/src/modules/customers/components/calendar/CalendarSettingsModal.tsx +1 -1
- package/src/modules/customers/components/calendar/EventBlock.tsx +2 -2
- package/src/modules/customers/components/calendar/EventPeekPopover.tsx +4 -2
- package/src/modules/customers/components/calendar/editor/PeopleField.tsx +61 -5
- package/src/modules/customers/components/calendar/editor/hooks.ts +7 -1
- package/src/modules/customers/components/calendar/types.ts +2 -2
- package/src/modules/customers/components/detail/CompanyKpiBar.tsx +5 -4
- package/src/modules/customers/components/detail/CompanyPeopleSection.tsx +8 -1
- package/src/modules/customers/components/detail/DealForm.tsx +22 -2
- package/src/modules/customers/components/detail/DealsSection.tsx +11 -5
- package/src/modules/customers/components/detail/EntityTagsDialog.tsx +58 -12
- package/src/modules/customers/components/detail/PersonCompaniesSection.tsx +8 -1
- package/src/modules/customers/components/detail/hooks/usePersonTasks.ts +23 -14
- package/src/modules/customers/components/detail/schedule/ParticipantsField.tsx +5 -5
- package/src/modules/customers/components/detail/schedule/useScheduleFormState.ts +5 -5
- package/src/modules/customers/components/detail/types.ts +1 -1
- package/src/modules/customers/components/detail/utils.ts +15 -5
- package/src/modules/customers/data/entities.ts +1 -1
- package/src/modules/customers/data/validators.ts +50 -9
- package/src/modules/customers/events.ts +5 -0
- package/src/modules/customers/i18n/de.json +9 -1
- package/src/modules/customers/i18n/en.json +9 -1
- package/src/modules/customers/i18n/es.json +9 -1
- package/src/modules/customers/i18n/ko.json +9 -1
- package/src/modules/customers/i18n/pl.json +9 -1
- package/src/modules/customers/lib/calendar/conflicts.ts +10 -2
- package/src/modules/customers/lib/calendar/editorPayload.ts +4 -3
- package/src/modules/customers/lib/calendar/mapItem.ts +8 -3
- package/src/modules/customers/lib/calendar/participantIdentity.ts +17 -0
- package/src/modules/customers/lib/closureStage.ts +76 -0
- package/src/modules/customers/lib/dealStatus.ts +42 -0
- package/src/modules/customers/lib/detailReadAccess.ts +35 -0
- package/src/modules/customers/lib/findPeopleByAddresses.ts +8 -6
- package/src/modules/customers/lib/personCompanies.ts +136 -1
- package/src/modules/customers/lib/todoCompatibility.ts +19 -1
- package/src/modules/dashboards/i18n/es.json +4 -4
- package/src/modules/dashboards/i18n/pl.json +7 -7
- package/src/modules/dashboards/lib/widgetScope.ts +6 -0
- package/src/modules/data_sync/AGENTS.md +1 -1
- package/src/modules/data_sync/backend/data-sync/page.tsx +4 -1
- package/src/modules/data_sync/lib/abandoned-run.ts +56 -0
- package/src/modules/data_sync/lib/adapter.ts +36 -0
- package/src/modules/data_sync/lib/sync-engine.ts +113 -5
- package/src/modules/data_sync/workers/sync-export.ts +4 -0
- package/src/modules/data_sync/workers/sync-import.ts +4 -0
- package/src/modules/devices/AGENTS.md +20 -1
- package/src/modules/devices/acl.ts +9 -1
- package/src/modules/devices/api/admin/devices/[id]/route.ts +5 -34
- package/src/modules/devices/api/admin/devices/route.ts +14 -1
- package/src/modules/devices/api/deviceList.ts +135 -11
- package/src/modules/devices/api/deviceSerialization.ts +50 -0
- package/src/modules/devices/api/openapi.ts +9 -1
- package/src/modules/devices/api/route.ts +9 -1
- package/src/modules/devices/backend/devices/[id]/page.tsx +18 -32
- package/src/modules/devices/backend/devices/create/page.tsx +17 -1
- package/src/modules/devices/backend/devices/page.tsx +44 -45
- package/src/modules/devices/backend/devices/useDeviceUserLabels.ts +45 -0
- package/src/modules/devices/backend/devices/userOptions.ts +99 -0
- package/src/modules/devices/i18n/de.json +3 -2
- package/src/modules/devices/i18n/en.json +3 -2
- package/src/modules/devices/i18n/es.json +3 -2
- package/src/modules/devices/i18n/ko.json +3 -2
- package/src/modules/devices/i18n/pl.json +3 -2
- package/src/modules/devices/setup.ts +6 -2
- package/src/modules/directory/backend/directory/organizations/page.tsx +3 -1
- package/src/modules/directory/backend/directory/tenants/page.tsx +3 -1
- package/src/modules/directory/di.ts +14 -2
- package/src/modules/directory/services/organizationHierarchyService.ts +34 -0
- package/src/modules/directory/services/organizationScopeService.ts +85 -0
- package/src/modules/directory/utils/organizationScope.ts +4 -15
- package/src/modules/entities/api/records.ts +2 -0
- package/src/modules/entities/backend/entities/user/[entityId]/records/page.tsx +4 -1
- package/src/modules/eudr/api/plots/route.ts +4 -0
- package/src/modules/eudr/backend/eudr/evidence-submissions/page.tsx +4 -0
- package/src/modules/eudr/backend/eudr/plots/page.tsx +4 -0
- package/src/modules/eudr/backend/eudr/product-mappings/page.tsx +4 -0
- package/src/modules/eudr/backend/eudr/risk-assessments/page.tsx +4 -0
- package/src/modules/eudr/backend/eudr/statements/page.tsx +4 -0
- package/src/modules/eudr/commands/statements.ts +0 -3
- package/src/modules/eudr/data/validators.ts +16 -1
- package/src/modules/feature_toggles/components/FeatureTogglesTable.tsx +2 -1
- package/src/modules/feature_toggles/components/OverridesTable.tsx +2 -1
- package/src/modules/feature_toggles/defaults.json +0 -8
- package/src/modules/inbox_ops/backend/inbox-ops/log/page.tsx +4 -0
- package/src/modules/inbox_ops/backend/inbox-ops/page.tsx +4 -0
- package/src/modules/inbox_ops/lib/htmlToPlainText.ts +1 -17
- package/src/modules/integrations/api/[id]/credentials/route.ts +6 -4
- package/src/modules/integrations/backend/integrations/[id]/page.tsx +61 -31
- package/src/modules/integrations/backend/integrations/bundle/[id]/page.tsx +44 -9
- package/src/modules/integrations/backend/integrations/credential-secret-fields.ts +84 -0
- package/src/modules/integrations/data/validators.ts +12 -2
- package/src/modules/integrations/i18n/de.json +1 -0
- package/src/modules/integrations/i18n/en.json +1 -0
- package/src/modules/integrations/i18n/es.json +1 -0
- package/src/modules/integrations/i18n/ko.json +1 -0
- package/src/modules/integrations/i18n/pl.json +1 -0
- package/src/modules/integrations/lib/credentials-masking.ts +10 -6
- package/src/modules/messages/api/[id]/route.ts +55 -1
- package/src/modules/messages/api/openapi.ts +20 -0
- package/src/modules/messages/api/route.ts +31 -2
- package/src/modules/messages/components/MessagesInboxPageClient.tsx +9 -16
- package/src/modules/messages/components/inboxFilters.ts +36 -0
- package/src/modules/messages/components/message-detail/hooks/useMessageDetailsConversation.ts +14 -1
- package/src/modules/messages/components/message-detail/panels/MessageHeader.tsx +3 -1
- package/src/modules/messages/components/message-detail/panels/thread-panel.tsx +2 -1
- package/src/modules/messages/components/message-detail/types.ts +3 -0
- package/src/modules/messages/components/messageListLabels.ts +52 -3
- package/src/modules/messages/data/validators.ts +43 -4
- package/src/modules/messages/lib/channel-sender-identity.ts +55 -0
- package/src/modules/messages/lib/composeSourceChannelType.ts +95 -0
- package/src/modules/payment_gateways/api/webhook/[provider]/route.ts +4 -6
- package/src/modules/payment_gateways/backend/payment-gateways/page.tsx +4 -1
- package/src/modules/payment_gateways/lib/webhook-processor.ts +11 -0
- package/src/modules/planner/backend/planner/availability-rulesets/page.tsx +4 -0
- package/src/modules/push_notifications/backend/push_notifications/page.tsx +4 -1
- package/src/modules/push_notifications/backend/push_notifications/send/page.tsx +4 -4
- package/src/modules/query_index/lib/engine.ts +249 -61
- package/src/modules/query_index/lib/search-entity-policy.ts +46 -0
- package/src/modules/query_index/lib/search-tokens.ts +135 -3
- package/src/modules/resources/backend/resources/resource-types/page.tsx +4 -1
- package/src/modules/resources/backend/resources/resources/page.tsx +4 -1
- package/src/modules/sales/backend/sales/channels/offers/page.tsx +4 -0
- package/src/modules/sales/backend/sales/channels/page.tsx +4 -0
- package/src/modules/sales/backend/sales/documents/[id]/page.tsx +14 -8
- package/src/modules/sales/commands/documents.ts +93 -0
- package/src/modules/sales/components/PriceWithCurrency.tsx +17 -5
- package/src/modules/sales/components/channels/SalesChannelOffersPanel.tsx +4 -0
- package/src/modules/sales/components/documents/AdjustmentsSection.tsx +6 -5
- package/src/modules/sales/components/documents/ItemsSection.tsx +56 -18
- package/src/modules/sales/components/documents/LineItemDialog.tsx +137 -20
- package/src/modules/sales/components/documents/PaymentsSection.tsx +20 -9
- package/src/modules/sales/components/documents/ReturnsSection.tsx +6 -5
- package/src/modules/sales/components/documents/SalesDocumentsTable.tsx +106 -14
- package/src/modules/sales/components/documents/SalesOrderDraftLines.tsx +6 -5
- package/src/modules/sales/components/documents/ShipmentDialog.tsx +5 -4
- package/src/modules/sales/components/documents/ShipmentsSection.tsx +6 -5
- package/src/modules/sales/components/documents/lineItemShipmentLock.ts +74 -0
- package/src/modules/sales/components/documents/lineItemUtils.ts +7 -2
- package/src/modules/sales/data/entities.ts +6 -0
- package/src/modules/sales/extension-points.ts +1 -0
- package/src/modules/sales/i18n/de.json +8 -0
- package/src/modules/sales/i18n/en.json +8 -0
- package/src/modules/sales/i18n/es.json +8 -0
- package/src/modules/sales/i18n/ko.json +8 -0
- package/src/modules/sales/i18n/pl.json +8 -0
- package/src/modules/sales/lib/salesChannelsToggleSeed.ts +42 -0
- package/src/modules/sales/migrations/.snapshot-open-mercato.json +60 -0
- package/src/modules/sales/migrations/Migration20260821120000_sales_notes_addresses_context_idx.ts +87 -0
- package/src/modules/sales/setup.ts +2 -0
- package/src/modules/sales/widgets/injection/payment-gateway-status-column/widget.ts +9 -1
- package/src/modules/sales/widgets/injection-table.ts +4 -7
- package/src/modules/staff/backend/staff/leave-requests/page.tsx +4 -0
- package/src/modules/staff/backend/staff/my-leave-requests/page.tsx +4 -0
- package/src/modules/staff/backend/staff/team-members/page.tsx +6 -0
- package/src/modules/staff/backend/staff/team-roles/page.tsx +4 -0
- package/src/modules/staff/backend/staff/teams/[id]/edit/page.tsx +4 -0
- package/src/modules/staff/backend/staff/teams/page.tsx +4 -0
- package/src/modules/staff/backend/staff/timesheets/page.tsx +12 -1
- package/src/modules/staff/backend/staff/timesheets/projects/page.tsx +4 -0
- package/src/modules/sync_excel/lib/adapters/customers.ts +5 -0
- package/src/modules/warranty_claims/api/assignees/route.ts +3 -3
- package/src/modules/warranty_claims/api/portal/attachments/route.ts +2 -2
- package/src/modules/warranty_claims/api/portal/claims/route.ts +12 -9
- package/src/modules/warranty_claims/backend/page.tsx +4 -0
- package/src/modules/warranty_claims/backend/warranty_claims/registrations/page.tsx +4 -0
- package/src/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/page.tsx +4 -0
- package/src/modules/warranty_claims/backend/warranty_claims/vendor-policies/page.tsx +4 -0
- package/src/modules/warranty_claims/frontend/[orgSlug]/portal/claims/page.tsx +4 -0
- package/src/modules/wms/api/warehouseSearch.ts +23 -0
- package/src/modules/wms/api/warehouses/route.ts +13 -9
- package/src/modules/wms/api/zones/route.ts +16 -0
- package/src/modules/wms/commands/configuration.ts +159 -10
- package/src/modules/wms/commands/inventory-actions.ts +3 -0
- package/src/modules/wms/commands/shared.ts +17 -0
- package/src/modules/wms/components/backend/WarehouseEditDialog.tsx +216 -0
- package/src/modules/wms/components/backend/WmsConfigurationPage.tsx +95 -141
- package/src/modules/wms/components/backend/WmsInventoryConsolePage.tsx +2 -0
- package/src/modules/wms/components/backend/WmsLotsListPage.tsx +2 -0
- package/src/modules/wms/components/backend/inventoryMutationLoaders.ts +36 -20
- package/src/modules/wms/components/backend/warehouseFormOptions.ts +72 -0
- package/src/modules/wms/i18n/de.json +2 -0
- package/src/modules/wms/i18n/en.json +2 -0
- package/src/modules/wms/i18n/es.json +2 -0
- package/src/modules/wms/i18n/ko.json +2 -0
- package/src/modules/wms/i18n/pl.json +2 -0
- package/src/modules/workflows/backend/definitions/page.tsx +4 -1
- package/src/modules/workflows/backend/events/page.tsx +4 -1
- package/src/modules/workflows/backend/instances/page.tsx +4 -1
- package/src/modules/workflows/backend/tasks/page.tsx +4 -1
- package/src/modules/workflows/lib/activity-executor.ts +9 -0
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
|
+
import { useOptionalLocale } from "@open-mercato/shared/lib/i18n/context";
|
|
4
5
|
import { cn } from "@open-mercato/shared/lib/utils";
|
|
5
|
-
function formatPriceWithCurrency(amount, currency, fallback = "\u2014") {
|
|
6
|
+
function formatPriceWithCurrency(amount, currency, fallback = "\u2014", locale) {
|
|
6
7
|
if (amount === null || amount === void 0) return fallback;
|
|
7
8
|
const parsed = typeof amount === "string" ? Number(amount) : amount;
|
|
8
9
|
if (Number.isNaN(parsed)) return fallback;
|
|
9
10
|
if (currency) {
|
|
10
11
|
try {
|
|
11
|
-
return new Intl.NumberFormat(
|
|
12
|
+
return new Intl.NumberFormat(locale, {
|
|
12
13
|
style: "currency",
|
|
13
14
|
currency,
|
|
14
15
|
minimumFractionDigits: 2,
|
|
@@ -17,12 +18,13 @@ function formatPriceWithCurrency(amount, currency, fallback = "\u2014") {
|
|
|
17
18
|
} catch {
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
return parsed.toLocaleString(
|
|
21
|
+
return parsed.toLocaleString(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
21
22
|
}
|
|
22
23
|
function PriceWithCurrency({ amount, currency, fallback = "\u2014", className }) {
|
|
24
|
+
const locale = useOptionalLocale();
|
|
23
25
|
const label = React.useMemo(
|
|
24
|
-
() => formatPriceWithCurrency(amount, currency, fallback),
|
|
25
|
-
[amount, currency, fallback]
|
|
26
|
+
() => formatPriceWithCurrency(amount, currency, fallback, locale),
|
|
27
|
+
[amount, currency, fallback, locale]
|
|
26
28
|
);
|
|
27
29
|
return /* @__PURE__ */ jsx("span", { className: cn("font-mono text-sm text-foreground", className), children: label });
|
|
28
30
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/sales/components/PriceWithCurrency.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { cn } from '@open-mercato/shared/lib/utils'\n\nexport function formatPriceWithCurrency(\n amount: number | string | null | undefined,\n currency: string | null | undefined,\n fallback = '\u2014'\n): string {\n if (amount === null || amount === undefined) return fallback\n const parsed = typeof amount === 'string' ? Number(amount) : amount\n if (Number.isNaN(parsed)) return fallback\n if (currency) {\n try {\n return new Intl.NumberFormat(
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { useOptionalLocale } from '@open-mercato/shared/lib/i18n/context'\nimport { cn } from '@open-mercato/shared/lib/utils'\n\n/**\n * Pass `locale` to format in the application locale (`useLocale()` in client components).\n * Omitting it keeps the runtime default, which varies per machine and is therefore not\n * assertable in tests.\n */\nexport function formatPriceWithCurrency(\n amount: number | string | null | undefined,\n currency: string | null | undefined,\n fallback = '\u2014',\n locale?: string\n): string {\n if (amount === null || amount === undefined) return fallback\n const parsed = typeof amount === 'string' ? Number(amount) : amount\n if (Number.isNaN(parsed)) return fallback\n if (currency) {\n try {\n return new Intl.NumberFormat(locale, {\n style: 'currency',\n currency,\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n }).format(parsed)\n } catch {\n // fall through to plain number formatting\n }\n }\n return parsed.toLocaleString(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 })\n}\n\ntype PriceWithCurrencyProps = {\n amount: number | string | null | undefined\n currency: string | null | undefined\n fallback?: string\n className?: string\n}\n\nexport function PriceWithCurrency({ amount, currency, fallback = '\u2014', className }: PriceWithCurrencyProps) {\n // `useOptionalLocale` rather than `useLocale`: this component is deep-importable and had no i18n\n // dependency at all before it started formatting in the app locale, so making it throw outside\n // `I18nProvider` would narrow its mounting contract. Without a provider it falls back to the\n // runtime default, which is exactly the behaviour it had before.\n const locale = useOptionalLocale()\n const label = React.useMemo(\n () => formatPriceWithCurrency(amount, currency, fallback, locale),\n [amount, currency, fallback, locale]\n )\n return <span className={cn('font-mono text-sm text-foreground', className)}>{label}</span>\n}\n"],
|
|
5
|
+
"mappings": ";AAoDS;AAlDT,YAAY,WAAW;AACvB,SAAS,yBAAyB;AAClC,SAAS,UAAU;AAOZ,SAAS,wBACd,QACA,UACA,WAAW,UACX,QACQ;AACR,MAAI,WAAW,QAAQ,WAAW,OAAW,QAAO;AACpD,QAAM,SAAS,OAAO,WAAW,WAAW,OAAO,MAAM,IAAI;AAC7D,MAAI,OAAO,MAAM,MAAM,EAAG,QAAO;AACjC,MAAI,UAAU;AACZ,QAAI;AACF,aAAO,IAAI,KAAK,aAAa,QAAQ;AAAA,QACnC,OAAO;AAAA,QACP;AAAA,QACA,uBAAuB;AAAA,QACvB,uBAAuB;AAAA,MACzB,CAAC,EAAE,OAAO,MAAM;AAAA,IAClB,QAAQ;AAAA,IAER;AAAA,EACF;AACA,SAAO,OAAO,eAAe,QAAQ,EAAE,uBAAuB,GAAG,uBAAuB,EAAE,CAAC;AAC7F;AASO,SAAS,kBAAkB,EAAE,QAAQ,UAAU,WAAW,UAAK,UAAU,GAA2B;AAKzG,QAAM,SAAS,kBAAkB;AACjC,QAAM,QAAQ,MAAM;AAAA,IAClB,MAAM,wBAAwB,QAAQ,UAAU,UAAU,MAAM;AAAA,IAChE,CAAC,QAAQ,UAAU,UAAU,MAAM;AAAA,EACrC;AACA,SAAO,oBAAC,UAAK,WAAW,GAAG,qCAAqC,SAAS,GAAI,iBAAM;AACrF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -38,6 +38,7 @@ function SalesChannelOffersPanel({ channelId, channelName }) {
|
|
|
38
38
|
const [page, setPage] = React.useState(1);
|
|
39
39
|
const [total, setTotal] = React.useState(0);
|
|
40
40
|
const [totalPages, setTotalPages] = React.useState(1);
|
|
41
|
+
const [totalIsCapped, setTotalIsCapped] = React.useState(false);
|
|
41
42
|
const [search, setSearch] = React.useState("");
|
|
42
43
|
const [isLoading, setLoading] = React.useState(true);
|
|
43
44
|
const [sorting, setSorting] = React.useState([]);
|
|
@@ -104,6 +105,7 @@ function SalesChannelOffersPanel({ channelId, channelName }) {
|
|
|
104
105
|
setRows(items.map(mapOfferRow));
|
|
105
106
|
setTotal(typeof payload.total === "number" ? payload.total : items.length);
|
|
106
107
|
setTotalPages(typeof payload.totalPages === "number" ? payload.totalPages : Math.max(1, Math.ceil(items.length / PAGE_SIZE)));
|
|
108
|
+
setTotalIsCapped(payload?.totalIsCapped === true);
|
|
107
109
|
} catch (err) {
|
|
108
110
|
logger.error("sales.channels.offers", { err });
|
|
109
111
|
flash(t("sales.channels.offers.errors.load", "Failed to load offers."), "error");
|
|
@@ -161,6 +163,7 @@ function SalesChannelOffersPanel({ channelId, channelName }) {
|
|
|
161
163
|
pageSize: PAGE_SIZE,
|
|
162
164
|
total,
|
|
163
165
|
totalPages,
|
|
166
|
+
totalIsCapped,
|
|
164
167
|
onPageChange: setPage
|
|
165
168
|
},
|
|
166
169
|
refreshButton: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/modules/sales/components/channels/SalesChannelOffersPanel.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { useRouter } from 'next/navigation'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport type { SortingState } from '@tanstack/react-table'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { BooleanIcon } from '@open-mercato/ui/backend/ValueIcons'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { readApiResultOrThrow, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { deleteCrud } from '@open-mercato/ui/backend/utils/crud'\nimport { surfaceRecordConflict } from '@open-mercato/ui/backend/conflicts'\nimport { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { mapOfferRow, renderOfferPriceSummary, type OfferRow } from './offerTableUtils'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('sales')\n\ntype OffersResponse = {\n items?: Array<Record<string, unknown>>\n total?: number\n totalPages?: number\n}\n\nconst PAGE_SIZE = 25\n\nconst SAVE_CONTEXT_ID = 'sales-channel-offers-panel'\n\nexport function SalesChannelOffersPanel({ channelId, channelName }: { channelId: string; channelName?: string }) {\n const t = useT()\n const router = useRouter()\n const { runMutation, retryLastMutation } = useGuardedMutation<{\n formId: string\n resourceKind: string\n retryLastMutation: () => Promise<boolean>\n }>({\n contextId: SAVE_CONTEXT_ID,\n blockedMessage: t('ui.forms.flash.saveBlocked', 'Save blocked by validation'),\n })\n const mutationContext = React.useMemo(\n () => ({\n formId: SAVE_CONTEXT_ID,\n resourceKind: 'sales.channels.offers',\n retryLastMutation,\n }),\n [retryLastMutation],\n )\n const [rows, setRows] = React.useState<OfferRow[]>([])\n const [page, setPage] = React.useState(1)\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const [search, setSearch] = React.useState('')\n const [isLoading, setLoading] = React.useState(true)\n const [sorting, setSorting] = React.useState<SortingState>([])\n const [reloadToken, setReloadToken] = React.useState(0)\n\n const columns = React.useMemo<ColumnDef<OfferRow>[]>(() => [\n {\n accessorKey: 'title',\n header: t('sales.channels.offers.table.offer', 'Offer'),\n cell: ({ row }) => (\n <div className=\"flex items-center gap-3\">\n {row.original.productMediaUrl ? (\n <img\n src={row.original.productMediaUrl}\n alt={row.original.productTitle ?? row.original.title}\n className=\"h-12 w-12 rounded border object-cover\"\n />\n ) : (\n <div className=\"h-12 w-12 rounded border bg-muted\" />\n )}\n <div className=\"flex flex-col gap-1\">\n <div>\n <span className=\"font-medium\">{row.original.title}</span>\n <div className=\"text-xs text-muted-foreground\">\n {row.original.productTitle ?? t('sales.channels.offers.table.emptyProduct', 'Unlinked product')}\n </div>\n </div>\n </div>\n </div>\n ),\n meta: { sticky: true },\n },\n {\n accessorKey: 'pricing',\n header: t('sales.channels.offers.table.pricing', 'Prices'),\n cell: ({ row }) => (\n <div className=\"text-sm\">{renderOfferPriceSummary(row.original, t as any)}</div>\n ),\n },\n {\n accessorKey: 'isActive',\n header: t('sales.channels.offers.table.active', 'Active'),\n cell: ({ row }) => <BooleanIcon value={row.original.isActive} />,\n },\n {\n accessorKey: 'updatedAt',\n header: t('sales.channels.offers.table.updated', 'Updated'),\n cell: ({ row }) =>\n row.original.updatedAt\n ? <span className=\"text-xs text-muted-foreground\">{new Date(row.original.updatedAt).toLocaleDateString()}</span>\n : <span className=\"text-xs text-muted-foreground\">\u2014</span>,\n },\n ], [t])\n\n const loadOffers = React.useCallback(async () => {\n if (!channelId) return\n setLoading(true)\n try {\n const params = new URLSearchParams({\n page: String(page),\n pageSize: String(PAGE_SIZE),\n channelId,\n })\n if (search.trim().length) {\n params.set('search', search.trim())\n }\n const sort = sorting[0]\n if (sort?.id) {\n params.set('sortField', sort.id)\n params.set('sortDir', sort.desc ? 'desc' : 'asc')\n }\n const payload = await readApiResultOrThrow<OffersResponse>(\n `/api/catalog/offers?${params.toString()}`,\n undefined,\n { errorMessage: t('sales.channels.offers.errors.load', 'Failed to load offers.') },\n )\n const items = Array.isArray(payload.items) ? payload.items : []\n setRows(items.map(mapOfferRow))\n setTotal(typeof payload.total === 'number' ? payload.total : items.length)\n setTotalPages(typeof payload.totalPages === 'number' ? payload.totalPages : Math.max(1, Math.ceil(items.length / PAGE_SIZE)))\n } catch (err) {\n logger.error('sales.channels.offers', { err })\n flash(t('sales.channels.offers.errors.load', 'Failed to load offers.'), 'error')\n } finally {\n setLoading(false)\n }\n }, [channelId, page, search, sorting, t])\n\n React.useEffect(() => {\n void loadOffers()\n }, [loadOffers, reloadToken])\n\n const handleDelete = React.useCallback(async (row: OfferRow) => {\n try {\n await runMutation({\n operation: () =>\n withScopedApiRequestHeaders(buildOptimisticLockHeader(row.updatedAt), () =>\n deleteCrud('catalog/offers', row.id, {\n errorMessage: t('sales.channels.offers.errors.delete', 'Failed to delete offer.'),\n }),\n ),\n context: mutationContext,\n mutationPayload: { action: 'delete', id: row.id },\n })\n flash(t('sales.channels.offers.messages.deleted', 'Offer deleted.'), 'success')\n setReloadToken((token) => token + 1)\n } catch (err) {\n if (surfaceRecordConflict(err, t)) return\n logger.error('sales.channels.offers.delete', { err })\n flash(t('sales.channels.offers.errors.delete', 'Failed to delete offer.'), 'error')\n }\n }, [mutationContext, runMutation, t])\n\n const handleSearchChange = React.useCallback((value: string) => {\n setSearch(value)\n setPage(1)\n }, [])\n\n const tableTitle = (\n <div>\n <div className=\"text-lg font-semibold\">\n {t('sales.channels.offers.heading', 'Offers for {{name}}', { name: channelName || t('sales.channels.nav.title', 'Sales channels') })}\n </div>\n <p className=\"text-sm text-muted-foreground\">\n {t('sales.channels.offers.subtitle', 'Override product presentation and pricing per channel.')}\n </p>\n </div>\n )\n\n const actions = (\n <Button asChild>\n <Link href={`/backend/sales/channels/${channelId}/offers/create`}>\n {t('sales.channels.offers.actions.create', 'Add offer')}\n </Link>\n </Button>\n )\n\n return (\n <DataTable<OfferRow>\n title={tableTitle}\n actions={actions}\n columns={columns}\n data={rows}\n isLoading={isLoading}\n sorting={sorting}\n onSortingChange={setSorting}\n searchValue={search}\n onSearchChange={handleSearchChange}\n searchPlaceholder={t('sales.channels.offers.table.search', 'Search offers\u2026')}\n pagination={{\n page,\n pageSize: PAGE_SIZE,\n total,\n totalPages,\n onPageChange: setPage,\n }}\n refreshButton={{\n label: t('sales.channels.offers.table.refresh', 'Refresh'),\n onRefresh: () => setReloadToken((token) => token + 1),\n isRefreshing: isLoading,\n }}\n rowActions={(row) => (\n <RowActions\n items={[\n {\n id: 'edit',\n label: t('sales.channels.offers.actions.edit', 'Edit'),\n href: `/backend/sales/channels/${channelId}/offers/${row.id}/edit`,\n },\n {\n id: 'delete',\n label: t('sales.channels.offers.actions.delete', 'Delete'),\n onSelect: () => handleDelete(row),\n destructive: true,\n },\n ]}\n />\n )}\n onRowClick={(row) => router.push(`/backend/sales/channels/${channelId}/offers/${row.id}/edit`)}\n emptyState={\n <div className=\"py-10 text-center text-sm text-muted-foreground\">\n {t('sales.channels.offers.table.empty', 'No offers for this channel yet.')}\n </div>\n }\n />\n )\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { useRouter } from 'next/navigation'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport type { SortingState } from '@tanstack/react-table'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { BooleanIcon } from '@open-mercato/ui/backend/ValueIcons'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { readApiResultOrThrow, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { deleteCrud } from '@open-mercato/ui/backend/utils/crud'\nimport { surfaceRecordConflict } from '@open-mercato/ui/backend/conflicts'\nimport { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { mapOfferRow, renderOfferPriceSummary, type OfferRow } from './offerTableUtils'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('sales')\n\ntype OffersResponse = {\n items?: Array<Record<string, unknown>>\n total?: number\n totalPages?: number\n totalIsCapped?: boolean\n}\n\nconst PAGE_SIZE = 25\n\nconst SAVE_CONTEXT_ID = 'sales-channel-offers-panel'\n\nexport function SalesChannelOffersPanel({ channelId, channelName }: { channelId: string; channelName?: string }) {\n const t = useT()\n const router = useRouter()\n const { runMutation, retryLastMutation } = useGuardedMutation<{\n formId: string\n resourceKind: string\n retryLastMutation: () => Promise<boolean>\n }>({\n contextId: SAVE_CONTEXT_ID,\n blockedMessage: t('ui.forms.flash.saveBlocked', 'Save blocked by validation'),\n })\n const mutationContext = React.useMemo(\n () => ({\n formId: SAVE_CONTEXT_ID,\n resourceKind: 'sales.channels.offers',\n retryLastMutation,\n }),\n [retryLastMutation],\n )\n const [rows, setRows] = React.useState<OfferRow[]>([])\n const [page, setPage] = React.useState(1)\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const [totalIsCapped, setTotalIsCapped] = React.useState(false)\n const [search, setSearch] = React.useState('')\n const [isLoading, setLoading] = React.useState(true)\n const [sorting, setSorting] = React.useState<SortingState>([])\n const [reloadToken, setReloadToken] = React.useState(0)\n\n const columns = React.useMemo<ColumnDef<OfferRow>[]>(() => [\n {\n accessorKey: 'title',\n header: t('sales.channels.offers.table.offer', 'Offer'),\n cell: ({ row }) => (\n <div className=\"flex items-center gap-3\">\n {row.original.productMediaUrl ? (\n <img\n src={row.original.productMediaUrl}\n alt={row.original.productTitle ?? row.original.title}\n className=\"h-12 w-12 rounded border object-cover\"\n />\n ) : (\n <div className=\"h-12 w-12 rounded border bg-muted\" />\n )}\n <div className=\"flex flex-col gap-1\">\n <div>\n <span className=\"font-medium\">{row.original.title}</span>\n <div className=\"text-xs text-muted-foreground\">\n {row.original.productTitle ?? t('sales.channels.offers.table.emptyProduct', 'Unlinked product')}\n </div>\n </div>\n </div>\n </div>\n ),\n meta: { sticky: true },\n },\n {\n accessorKey: 'pricing',\n header: t('sales.channels.offers.table.pricing', 'Prices'),\n cell: ({ row }) => (\n <div className=\"text-sm\">{renderOfferPriceSummary(row.original, t as any)}</div>\n ),\n },\n {\n accessorKey: 'isActive',\n header: t('sales.channels.offers.table.active', 'Active'),\n cell: ({ row }) => <BooleanIcon value={row.original.isActive} />,\n },\n {\n accessorKey: 'updatedAt',\n header: t('sales.channels.offers.table.updated', 'Updated'),\n cell: ({ row }) =>\n row.original.updatedAt\n ? <span className=\"text-xs text-muted-foreground\">{new Date(row.original.updatedAt).toLocaleDateString()}</span>\n : <span className=\"text-xs text-muted-foreground\">\u2014</span>,\n },\n ], [t])\n\n const loadOffers = React.useCallback(async () => {\n if (!channelId) return\n setLoading(true)\n try {\n const params = new URLSearchParams({\n page: String(page),\n pageSize: String(PAGE_SIZE),\n channelId,\n })\n if (search.trim().length) {\n params.set('search', search.trim())\n }\n const sort = sorting[0]\n if (sort?.id) {\n params.set('sortField', sort.id)\n params.set('sortDir', sort.desc ? 'desc' : 'asc')\n }\n const payload = await readApiResultOrThrow<OffersResponse>(\n `/api/catalog/offers?${params.toString()}`,\n undefined,\n { errorMessage: t('sales.channels.offers.errors.load', 'Failed to load offers.') },\n )\n const items = Array.isArray(payload.items) ? payload.items : []\n setRows(items.map(mapOfferRow))\n setTotal(typeof payload.total === 'number' ? payload.total : items.length)\n setTotalPages(typeof payload.totalPages === 'number' ? payload.totalPages : Math.max(1, Math.ceil(items.length / PAGE_SIZE)))\n setTotalIsCapped(payload?.totalIsCapped === true)\n } catch (err) {\n logger.error('sales.channels.offers', { err })\n flash(t('sales.channels.offers.errors.load', 'Failed to load offers.'), 'error')\n } finally {\n setLoading(false)\n }\n }, [channelId, page, search, sorting, t])\n\n React.useEffect(() => {\n void loadOffers()\n }, [loadOffers, reloadToken])\n\n const handleDelete = React.useCallback(async (row: OfferRow) => {\n try {\n await runMutation({\n operation: () =>\n withScopedApiRequestHeaders(buildOptimisticLockHeader(row.updatedAt), () =>\n deleteCrud('catalog/offers', row.id, {\n errorMessage: t('sales.channels.offers.errors.delete', 'Failed to delete offer.'),\n }),\n ),\n context: mutationContext,\n mutationPayload: { action: 'delete', id: row.id },\n })\n flash(t('sales.channels.offers.messages.deleted', 'Offer deleted.'), 'success')\n setReloadToken((token) => token + 1)\n } catch (err) {\n if (surfaceRecordConflict(err, t)) return\n logger.error('sales.channels.offers.delete', { err })\n flash(t('sales.channels.offers.errors.delete', 'Failed to delete offer.'), 'error')\n }\n }, [mutationContext, runMutation, t])\n\n const handleSearchChange = React.useCallback((value: string) => {\n setSearch(value)\n setPage(1)\n }, [])\n\n const tableTitle = (\n <div>\n <div className=\"text-lg font-semibold\">\n {t('sales.channels.offers.heading', 'Offers for {{name}}', { name: channelName || t('sales.channels.nav.title', 'Sales channels') })}\n </div>\n <p className=\"text-sm text-muted-foreground\">\n {t('sales.channels.offers.subtitle', 'Override product presentation and pricing per channel.')}\n </p>\n </div>\n )\n\n const actions = (\n <Button asChild>\n <Link href={`/backend/sales/channels/${channelId}/offers/create`}>\n {t('sales.channels.offers.actions.create', 'Add offer')}\n </Link>\n </Button>\n )\n\n return (\n <DataTable<OfferRow>\n title={tableTitle}\n actions={actions}\n columns={columns}\n data={rows}\n isLoading={isLoading}\n sorting={sorting}\n onSortingChange={setSorting}\n searchValue={search}\n onSearchChange={handleSearchChange}\n searchPlaceholder={t('sales.channels.offers.table.search', 'Search offers\u2026')}\n pagination={{\n page,\n pageSize: PAGE_SIZE,\n total,\n totalPages,\n totalIsCapped,\n onPageChange: setPage,\n }}\n refreshButton={{\n label: t('sales.channels.offers.table.refresh', 'Refresh'),\n onRefresh: () => setReloadToken((token) => token + 1),\n isRefreshing: isLoading,\n }}\n rowActions={(row) => (\n <RowActions\n items={[\n {\n id: 'edit',\n label: t('sales.channels.offers.actions.edit', 'Edit'),\n href: `/backend/sales/channels/${channelId}/offers/${row.id}/edit`,\n },\n {\n id: 'delete',\n label: t('sales.channels.offers.actions.delete', 'Delete'),\n onSelect: () => handleDelete(row),\n destructive: true,\n },\n ]}\n />\n )}\n onRowClick={(row) => router.push(`/backend/sales/channels/${channelId}/offers/${row.id}/edit`)}\n emptyState={\n <div className=\"py-10 text-center text-sm text-muted-foreground\">\n {t('sales.channels.offers.table.empty', 'No offers for this channel yet.')}\n </div>\n }\n />\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAsEY,cASA,YATA;AApEZ,YAAY,WAAW;AACvB,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAG1B,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AACtB,SAAS,sBAAsB,mCAAmC;AAClE,SAAS,iCAAiC;AAC1C,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AACtC,SAAS,0BAA0B;AACnC,SAAS,YAAY;AACrB,SAAS,aAAa,+BAA8C;AACpE,SAAS,oBAAoB;AAE7B,MAAM,SAAS,aAAa,OAAO;AASnC,MAAM,YAAY;AAElB,MAAM,kBAAkB;AAEjB,SAAS,wBAAwB,EAAE,WAAW,YAAY,GAAgD;AAC/G,QAAM,IAAI,KAAK;AACf,QAAM,SAAS,UAAU;AACzB,QAAM,EAAE,aAAa,kBAAkB,IAAI,mBAIxC;AAAA,IACD,WAAW;AAAA,IACX,gBAAgB,EAAE,8BAA8B,4BAA4B;AAAA,EAC9E,CAAC;AACD,QAAM,kBAAkB,MAAM;AAAA,IAC5B,OAAO;AAAA,MACL,QAAQ;AAAA,MACR,cAAc;AAAA,MACd;AAAA,IACF;AAAA,IACA,CAAC,iBAAiB;AAAA,EACpB;AACA,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAqB,CAAC,CAAC;AACrD,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,CAAC;AACxC,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,CAAC;AAC1C,QAAM,CAAC,YAAY,aAAa,IAAI,MAAM,SAAS,CAAC;AACpD,QAAM,CAAC,eAAe,gBAAgB,IAAI,MAAM,SAAS,KAAK;AAC9D,QAAM,CAAC,QAAQ,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b,8BAAC,QAAK,MAAM,2BAA2B,SAAS,kBAC7C,YAAE,wCAAwC,WAAW,GACxD,GACF;AAGF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA,iBAAiB;AAAA,MACjB,aAAa;AAAA,MACb,gBAAgB;AAAA,MAChB,mBAAmB,EAAE,sCAAsC,qBAAgB;AAAA,MAC3E,YAAY;AAAA,QACV;AAAA,QACA,UAAU;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAc;AAAA,MAChB;AAAA,MACA,eAAe;AAAA,QACb,OAAO,EAAE,uCAAuC,SAAS;AAAA,QACzD,WAAW,MAAM,eAAe,CAAC,UAAU,QAAQ,CAAC;AAAA,QACpD,cAAc;AAAA,MAChB;AAAA,MACI,YAAY,CAAC,QACX;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL;AAAA,cACE,IAAI;AAAA,cACJ,OAAO,EAAE,sCAAsC,MAAM;AAAA,cACrD,MAAM,2BAA2B,SAAS,WAAW,IAAI,EAAE;AAAA,YAC7D;AAAA,YACA;AAAA,cACE,IAAI;AAAA,cACJ,OAAO,EAAE,wCAAwC,QAAQ;AAAA,cACzD,UAAU,MAAM,aAAa,GAAG;AAAA,cAChC,aAAa;AAAA,YACnB;AAAA,UACF;AAAA;AAAA,MACF;AAAA,MAEF,YAAY,CAAC,QAAQ,OAAO,KAAK,2BAA2B,SAAS,WAAW,IAAI,EAAE,OAAO;AAAA,MAC7F,YACE,oBAAC,SAAI,WAAU,mDACZ,YAAE,qCAAqC,iCAAiC,GAC3E;AAAA;AAAA,EAEJ;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "@open-mercato/core/modules/sales/lib/frontend/documentTotalsEvents";
|
|
18
18
|
import { PriceWithCurrency } from "../PriceWithCurrency.js";
|
|
19
19
|
import { AdjustmentDialog } from "./AdjustmentDialog.js";
|
|
20
|
-
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
20
|
+
import { useT, useLocale } from "@open-mercato/shared/lib/i18n/context";
|
|
21
21
|
import { useOrganizationScopeDetail } from "@open-mercato/shared/lib/frontend/useOrganizationScope";
|
|
22
22
|
import { extractCustomFieldValues } from "./customFieldHelpers.js";
|
|
23
23
|
import { createLogger } from "@open-mercato/shared/lib/logger";
|
|
@@ -37,9 +37,9 @@ function normalizeNumber(value, fallback = 0) {
|
|
|
37
37
|
}
|
|
38
38
|
return fallback;
|
|
39
39
|
}
|
|
40
|
-
function formatPercent(value) {
|
|
40
|
+
function formatPercent(value, locale) {
|
|
41
41
|
if (value === null || value === void 0) return "\u2014";
|
|
42
|
-
const formatter = new Intl.NumberFormat(
|
|
42
|
+
const formatter = new Intl.NumberFormat(locale, { style: "percent", maximumFractionDigits: 2 });
|
|
43
43
|
return formatter.format(value / 100);
|
|
44
44
|
}
|
|
45
45
|
function SalesDocumentAdjustmentsSection({
|
|
@@ -53,6 +53,7 @@ function SalesDocumentAdjustmentsSection({
|
|
|
53
53
|
onRowsChange
|
|
54
54
|
}) {
|
|
55
55
|
const t = useT();
|
|
56
|
+
const locale = useLocale();
|
|
56
57
|
const { organizationId, tenantId } = useOrganizationScopeDetail();
|
|
57
58
|
const resolvedOrganizationId = orgFromProps ?? organizationId ?? null;
|
|
58
59
|
const resolvedTenantId = tenantFromProps ?? tenantId ?? null;
|
|
@@ -342,7 +343,7 @@ function SalesDocumentAdjustmentsSection({
|
|
|
342
343
|
{
|
|
343
344
|
id: "rate",
|
|
344
345
|
header: t("sales.documents.adjustments.rate", "Rate"),
|
|
345
|
-
cell: ({ row }) => /* @__PURE__ */ jsx("span", { className: "font-mono text-sm text-muted-foreground", children: formatPercent(row.original.rate) })
|
|
346
|
+
cell: ({ row }) => /* @__PURE__ */ jsx("span", { className: "font-mono text-sm text-muted-foreground", children: formatPercent(row.original.rate, locale) })
|
|
346
347
|
},
|
|
347
348
|
{
|
|
348
349
|
id: "position",
|
|
@@ -350,7 +351,7 @@ function SalesDocumentAdjustmentsSection({
|
|
|
350
351
|
cell: ({ row }) => /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: row.original.position })
|
|
351
352
|
}
|
|
352
353
|
],
|
|
353
|
-
[currencyCode, resolveKindLabel, t]
|
|
354
|
+
[currencyCode, locale, resolveKindLabel, t]
|
|
354
355
|
);
|
|
355
356
|
const showLoadingState = loading && rows.length === 0;
|
|
356
357
|
const renderRowActions = React.useCallback(
|
|
@@ -430,6 +431,7 @@ function SalesDocumentAdjustmentsSection({
|
|
|
430
431
|
] });
|
|
431
432
|
}
|
|
432
433
|
export {
|
|
433
|
-
SalesDocumentAdjustmentsSection
|
|
434
|
+
SalesDocumentAdjustmentsSection,
|
|
435
|
+
formatPercent
|
|
434
436
|
};
|
|
435
437
|
//# sourceMappingURL=AdjustmentsSection.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/modules/sales/components/documents/AdjustmentsSection.tsx"],
|
|
4
|
-
"sourcesContent": ["// @ts-nocheck\n\n\"use client\"\n\nimport * as React from 'react'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport { Badge } from '@open-mercato/ui/primitives/badge'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport { ErrorMessage, LoadingMessage, TabEmptyState } from '@open-mercato/ui/backend/detail'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { apiCall, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { createCrud, deleteCrud, updateCrud } from '@open-mercato/ui/backend/utils/crud'\nimport { createCrudFormError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { handleSectionMutationError } from './optimisticLock'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { type DictionaryOption } from '@open-mercato/core/modules/dictionaries/components/DictionaryEntrySelect'\nimport {\n emitSalesDocumentTotalsRefresh,\n subscribeSalesDocumentTotalsRefresh,\n} from '@open-mercato/core/modules/sales/lib/frontend/documentTotalsEvents'\nimport type { SectionAction } from '@open-mercato/core/modules/customers/components/detail/types'\nimport type { SalesAdjustmentKind } from '../../data/entities'\nimport { PriceWithCurrency } from '../PriceWithCurrency'\nimport { AdjustmentDialog, type AdjustmentRowData, type AdjustmentSubmitPayload } from './AdjustmentDialog'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { useOrganizationScopeDetail } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { extractCustomFieldValues } from './customFieldHelpers'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('sales')\n\ntype AdjustmentRow = AdjustmentRowData\n\ntype SalesDocumentAdjustmentsSectionProps = {\n documentId: string\n kind: 'order' | 'quote'\n currencyCode: string | null | undefined\n documentUpdatedAt?: string | null\n organizationId?: string | null\n tenantId?: string | null\n onActionChange?: (action: SectionAction | null) => void\n onRowsChange?: (rows: AdjustmentRow[]) => void\n}\n\nconst FALLBACK_ADJUSTMENT_KIND_VALUES: SalesAdjustmentKind[] = [\n 'discount',\n 'tax',\n 'shipping',\n 'surcharge',\n 'custom',\n]\n\nfunction normalizeNumber(value: unknown, fallback = 0): number {\n if (typeof value === 'number' && Number.isFinite(value)) return value\n if (typeof value === 'string' && value.trim().length) {\n const parsed = Number(value)\n if (!Number.isNaN(parsed)) return parsed\n }\n return fallback\n}\n\nfunction formatPercent(value: number | null | undefined): string {\n if (value === null || value === undefined) return '\u2014'\n const formatter = new Intl.NumberFormat(undefined, { style: 'percent', maximumFractionDigits: 2 })\n return formatter.format(value / 100)\n}\n\nexport function SalesDocumentAdjustmentsSection({\n documentId,\n kind,\n currencyCode,\n documentUpdatedAt,\n organizationId: orgFromProps,\n tenantId: tenantFromProps,\n onActionChange,\n onRowsChange,\n}: SalesDocumentAdjustmentsSectionProps) {\n const t = useT()\n const { organizationId, tenantId } = useOrganizationScopeDetail()\n const resolvedOrganizationId = orgFromProps ?? organizationId ?? null\n const resolvedTenantId = tenantFromProps ?? tenantId ?? null\n const [rows, setRows] = React.useState<AdjustmentRow[]>([])\n const [loading, setLoading] = React.useState(false)\n const [error, setError] = React.useState<string | null>(null)\n const [dialogOpen, setDialogOpen] = React.useState(false)\n const [activeAdjustment, setActiveAdjustment] = React.useState<AdjustmentRow | null>(null)\n const [kindOptions, setKindOptions] = React.useState<DictionaryOption[]>([])\n const kindLoadingRef = React.useRef(false)\n\n const apiResourcePath = React.useMemo(\n () => (kind === 'order' ? '/api/sales/order-adjustments' : '/api/sales/quote-adjustments'),\n [kind]\n )\n const crudResourcePath = React.useMemo(\n () => (kind === 'order' ? 'sales/order-adjustments' : 'sales/quote-adjustments'),\n [kind]\n )\n const documentKey = kind === 'order' ? 'orderId' : 'quoteId'\n const fallbackKindOptions = React.useMemo<DictionaryOption[]>(\n () =>\n FALLBACK_ADJUSTMENT_KIND_VALUES.map((value) => ({\n value,\n label: t(`sales.documents.adjustments.kindLabels.${value}`, value),\n color: null,\n icon: null,\n })),\n [t]\n )\n const kindOptionMap = React.useMemo(\n () =>\n kindOptions.reduce<Record<string, DictionaryOption>>((acc, entry) => {\n acc[entry.value] = entry\n return acc\n }, {}),\n [kindOptions]\n )\n const loadKindOptions = React.useCallback(async (): Promise<DictionaryOption[]> => {\n if (kindOptions.length) return kindOptions\n if (kindLoadingRef.current) return kindOptions.length ? kindOptions : fallbackKindOptions\n kindLoadingRef.current = true\n try {\n const params = new URLSearchParams({ page: '1', pageSize: '100' })\n const response = await apiCall<{ items?: Array<Record<string, unknown>> }>(\n `/api/sales/adjustment-kinds?${params.toString()}`,\n undefined,\n { fallback: { items: [] } }\n )\n const items = Array.isArray(response.result?.items) ? response.result.items : []\n const parsed = items\n .map((item) => {\n const value = typeof (item as any).value === 'string' ? (item as any).value.trim() : ''\n if (!value) return null\n const label =\n typeof (item as any).label === 'string' && (item as any).label.trim().length\n ? (item as any).label.trim()\n : value\n const color =\n typeof (item as any).color === 'string' && /^#([0-9a-fA-F]{6})$/.test((item as any).color)\n ? `#${(item as any).color.slice(1).toLowerCase()}`\n : null\n const icon =\n typeof (item as any).icon === 'string' && (item as any).icon.trim().length\n ? (item as any).icon.trim()\n : null\n return { value, label, color, icon }\n })\n .filter((entry): entry is DictionaryOption => Boolean(entry))\n const merged = new Map<string, DictionaryOption>()\n fallbackKindOptions.forEach((entry) => merged.set(entry.value, entry))\n parsed.forEach((entry) => merged.set(entry.value, entry))\n const options = Array.from(merged.values()).sort((a, b) =>\n a.label.localeCompare(b.label, undefined, { sensitivity: 'base' })\n )\n setKindOptions(options)\n kindLoadingRef.current = false\n return options\n } catch (err) {\n logger.error('sales.adjustment-kinds.fetch', { err })\n kindLoadingRef.current = false\n setKindOptions(fallbackKindOptions)\n return fallbackKindOptions\n }\n }, [fallbackKindOptions, kindOptions])\n\n React.useEffect(() => {\n loadKindOptions().catch(() => {})\n }, [loadKindOptions, resolvedOrganizationId, resolvedTenantId])\n\n const loadAdjustments = React.useCallback(async () => {\n setLoading(true)\n setError(null)\n try {\n const params = new URLSearchParams({ page: '1', pageSize: '100', [documentKey]: documentId })\n const response = await apiCall<{ items?: Array<Record<string, unknown>> }>(\n `${apiResourcePath}?${params.toString()}`,\n undefined,\n { fallback: { items: [] } }\n )\n const items = Array.isArray(response.result?.items) ? response.result.items : []\n const mapped: AdjustmentRow[] = items\n .map((item) => {\n const id = typeof item.id === 'string' ? item.id : null\n if (!id) return null\n const amountNet = normalizeNumber(\n (item as any).amount_net ?? (item as any).amountNet ?? (item as any).amount_net_amount,\n NaN\n )\n const amountGross = normalizeNumber(\n (item as any).amount_gross ?? (item as any).amountGross ?? (item as any).amount_gross_amount,\n NaN\n )\n const rateRaw = normalizeNumber((item as any).rate, NaN)\n const kindValue =\n typeof item.kind === 'string' && item.kind.trim().length\n ? (item.kind.trim() as SalesAdjustmentKind)\n : 'custom'\n const currency =\n typeof (item as any).currency_code === 'string'\n ? (item as any).currency_code\n : typeof (item as any).currencyCode === 'string'\n ? (item as any).currencyCode\n : currencyCode ?? null\n const customFields = extractCustomFieldValues(item as Record<string, unknown>)\n const customFieldSetId =\n typeof (item as any).custom_field_set_id === 'string'\n ? (item as any).custom_field_set_id\n : typeof (item as any).customFieldSetId === 'string'\n ? (item as any).customFieldSetId\n : null\n const metadata =\n typeof (item as any).metadata === 'object' && (item as any).metadata\n ? ((item as any).metadata as Record<string, unknown>)\n : null\n return {\n id,\n label: typeof item.label === 'string' ? item.label : null,\n code: typeof item.code === 'string' ? item.code : null,\n kind: kindValue,\n calculatorKey:\n typeof (item as any).calculator_key === 'string'\n ? (item as any).calculator_key\n : typeof (item as any).calculatorKey === 'string'\n ? (item as any).calculatorKey\n : null,\n rate: Number.isFinite(rateRaw) ? rateRaw : null,\n amountNet: Number.isFinite(amountNet) ? amountNet : null,\n amountGross: Number.isFinite(amountGross) ? amountGross : null,\n currencyCode: currency,\n position:\n typeof item.position === 'number'\n ? item.position\n : typeof (item as any).position === 'string'\n ? Number((item as any).position)\n : 0,\n customFields: Object.keys(customFields).length ? customFields : null,\n customFieldSetId,\n metadata,\n }\n })\n .filter((entry): entry is AdjustmentRow => Boolean(entry))\n const ordered = [...mapped].sort((a, b) => (a.position ?? 0) - (b.position ?? 0))\n setRows(ordered)\n if (onRowsChange) onRowsChange(ordered)\n } catch (err) {\n logger.error('sales.document.adjustments.load', { err })\n setError(t('sales.documents.adjustments.errorLoad', 'Failed to load adjustments.'))\n } finally {\n setLoading(false)\n }\n }, [apiResourcePath, currencyCode, documentId, documentKey, onRowsChange, t])\n\n React.useEffect(() => {\n void loadAdjustments()\n }, [loadAdjustments])\n\n React.useEffect(\n () =>\n subscribeSalesDocumentTotalsRefresh((detail) => {\n if (detail.documentId !== documentId) return\n if (detail.kind && detail.kind !== kind) return\n void loadAdjustments()\n }),\n [documentId, kind, loadAdjustments],\n )\n\n const resolveKindLabel = React.useCallback(\n (kindValue: SalesAdjustmentKind) => {\n const option = kindOptionMap[kindValue]\n if (option) return option.label\n return t(`sales.documents.adjustments.kindLabels.${kindValue}`, typeof kindValue === 'string' ? kindValue : String(kindValue))\n },\n [kindOptionMap, t]\n )\n\n const handleOpenCreate = React.useCallback(() => {\n setActiveAdjustment(null)\n setDialogOpen(true)\n }, [])\n\n const handleEdit = React.useCallback((row: AdjustmentRow) => {\n setActiveAdjustment(row)\n setDialogOpen(true)\n }, [])\n\n const handleCloseDialog = React.useCallback(() => {\n setDialogOpen(false)\n setActiveAdjustment(null)\n }, [])\n\n React.useEffect(() => {\n if (!onActionChange) return\n onActionChange({\n label: t('sales.documents.adjustments.add', 'Add adjustment'),\n onClick: handleOpenCreate,\n disabled: false,\n })\n return () => onActionChange(null)\n }, [handleOpenCreate, onActionChange, t])\n\n const handleFormSubmit = React.useCallback(\n async (values: AdjustmentSubmitPayload) => {\n if (!resolvedOrganizationId || !resolvedTenantId) {\n throw createCrudFormError(\n t('sales.documents.adjustments.errorScope', 'Organization and tenant are required.')\n )\n }\n const payload: Record<string, unknown> = {\n [documentKey]: String(documentId),\n organizationId: String(resolvedOrganizationId),\n tenantId: String(resolvedTenantId),\n scope: 'order',\n kind: values.kind ?? 'custom',\n code: values.code ?? undefined,\n label: values.label ?? undefined,\n calculatorKey: values.calculatorKey ?? undefined,\n rate: Number.isFinite(values.rate) ? values.rate : undefined,\n amountNet: Number.isFinite(values.amountNet) ? values.amountNet : undefined,\n amountGross: Number.isFinite(values.amountGross) ? values.amountGross : undefined,\n currencyCode: (values.currencyCode ?? currencyCode ?? '').toUpperCase(),\n position: Number.isFinite(values.position) ? values.position : undefined,\n customFields: values.customFields ?? undefined,\n metadata: values.metadata ?? undefined,\n }\n\n const action = values.id ? updateCrud : createCrud\n try {\n const result = await withScopedApiRequestHeaders(\n buildOptimisticLockHeader(documentUpdatedAt),\n () =>\n action(\n crudResourcePath,\n values.id ? { id: values.id, ...payload } : payload,\n {\n successMessage: values.id\n ? t('sales.documents.adjustments.updated', 'Adjustment updated.')\n : t('sales.documents.adjustments.created', 'Adjustment added.'),\n errorMessage: t('sales.documents.adjustments.errorSave', 'Failed to save adjustment.'),\n }\n )\n )\n if (result.ok) {\n await loadAdjustments()\n emitSalesDocumentTotalsRefresh({ documentId, kind })\n setDialogOpen(false)\n setActiveAdjustment(null)\n }\n } catch (err) {\n if (\n handleSectionMutationError(err, t, () => void loadAdjustments())\n ) {\n setDialogOpen(false)\n setActiveAdjustment(null)\n return\n }\n throw err\n }\n },\n [\n currencyCode,\n documentId,\n documentKey,\n documentUpdatedAt,\n kind,\n loadAdjustments,\n crudResourcePath,\n resolvedOrganizationId,\n resolvedTenantId,\n t,\n ]\n )\n\n const handleDelete = React.useCallback(\n async (row: AdjustmentRow) => {\n try {\n const result = await withScopedApiRequestHeaders(\n buildOptimisticLockHeader(documentUpdatedAt),\n () =>\n deleteCrud(crudResourcePath, {\n body: {\n id: row.id,\n [documentKey]: documentId,\n organizationId: resolvedOrganizationId ?? undefined,\n tenantId: resolvedTenantId ?? undefined,\n },\n errorMessage: t('sales.documents.adjustments.errorDelete', 'Failed to delete adjustment.'),\n })\n )\n if (result.ok) {\n await loadAdjustments()\n emitSalesDocumentTotalsRefresh({ documentId, kind })\n }\n } catch (err) {\n if (handleSectionMutationError(err, t, () => void loadAdjustments())) return\n logger.error('sales.document.adjustments.delete', { err })\n flash(t('sales.documents.adjustments.errorDelete', 'Failed to delete adjustment.'), 'error')\n }\n },\n [crudResourcePath, documentId, documentKey, documentUpdatedAt, kind, loadAdjustments, resolvedOrganizationId, resolvedTenantId, t]\n )\n\n const columns = React.useMemo<ColumnDef<AdjustmentRow>[]>(\n () => [\n {\n id: 'label',\n header: t('sales.documents.adjustments.label', 'Label'),\n cell: ({ row }) => (\n <div className=\"flex flex-col\">\n <span className=\"font-medium text-foreground\">{row.original.label ?? t('sales.documents.adjustments.untitled', 'Untitled')}</span>\n {row.original.code ? <span className=\"text-xs text-muted-foreground\">{row.original.code}</span> : null}\n </div>\n ),\n },\n {\n id: 'kind',\n header: t('sales.documents.adjustments.kindLabel', 'Kind'),\n cell: ({ row }) => <Badge variant=\"outline\">{resolveKindLabel(row.original.kind)}</Badge>,\n },\n {\n id: 'amountNet',\n header: t('sales.documents.adjustments.amountNet', 'Net amount'),\n cell: ({ row }) => (\n <PriceWithCurrency amount={row.original.amountNet} currency={row.original.currencyCode ?? currencyCode} className=\"font-mono text-sm\" />\n ),\n },\n {\n id: 'amountGross',\n header: t('sales.documents.adjustments.amountGross', 'Gross amount'),\n cell: ({ row }) => (\n <PriceWithCurrency amount={row.original.amountGross} currency={row.original.currencyCode ?? currencyCode} className=\"font-mono text-sm\" />\n ),\n },\n {\n id: 'rate',\n header: t('sales.documents.adjustments.rate', 'Rate'),\n cell: ({ row }) => <span className=\"font-mono text-sm text-muted-foreground\">{formatPercent(row.original.rate)}</span>,\n },\n {\n id: 'position',\n header: t('sales.documents.adjustments.position', 'Position'),\n cell: ({ row }) => <span className=\"text-sm text-muted-foreground\">{row.original.position}</span>,\n },\n ],\n [currencyCode, resolveKindLabel, t]\n )\n\n const showLoadingState = loading && rows.length === 0\n\n const renderRowActions = React.useCallback(\n (row: AdjustmentRow) => (\n <RowActions\n items={[\n {\n id: 'edit',\n label: t('ui.actions.edit', 'Edit'),\n onSelect: () => handleEdit(row),\n },\n {\n id: 'delete',\n label: t('ui.actions.delete', 'Delete'),\n destructive: true,\n onSelect: () => handleDelete(row),\n },\n ]}\n />\n ),\n [handleDelete, handleEdit, t]\n )\n\n return (\n <div className=\"space-y-4\">\n {error ? (\n <ErrorMessage title={t('sales.documents.adjustments.errorLoad', 'Failed to load adjustments.')} description={error} onRetry={() => void loadAdjustments()} />\n ) : null}\n {showLoadingState ? (\n <LoadingMessage\n label={t('sales.documents.adjustments.loading', 'Loading adjustments\u2026')}\n className=\"border-0 bg-transparent p-0 py-8 justify-center\"\n />\n ) : (\n <DataTable<AdjustmentRow>\n data={rows}\n columns={columns}\n isLoading={loading && rows.length > 0}\n embedded\n onRowClick={handleEdit}\n rowActions={renderRowActions}\n emptyState={\n <TabEmptyState\n title={t('sales.documents.empty.adjustments.title', 'No adjustments yet.')}\n description={t('sales.documents.empty.adjustments.description', 'Add discounts, fees, or taxes to refine totals.')}\n actionLabel={t('sales.documents.adjustments.add', 'Add adjustment')}\n onAction={handleOpenCreate}\n />\n }\n />\n )}\n\n <AdjustmentDialog\n open={dialogOpen}\n onOpenChange={(open) => {\n if (!open) {\n handleCloseDialog()\n } else {\n setDialogOpen(true)\n }\n }}\n kind={kind}\n currencyCode={currencyCode ?? null}\n kindOptions={kindOptions.length ? kindOptions : fallbackKindOptions}\n loadKindOptions={loadKindOptions}\n labels={{\n addTitle: t('sales.documents.adjustments.addTitle', 'Add adjustment'),\n editTitle: t('sales.documents.adjustments.editTitle', 'Edit adjustment'),\n submitCreate: t('sales.documents.adjustments.submitCreate', 'Add adjustment'),\n submitUpdate: t('sales.documents.adjustments.submitUpdate', 'Save changes'),\n }}\n initialAdjustment={activeAdjustment}\n onSubmit={handleFormSubmit}\n />\n </div>\n )\n}\n"],
|
|
5
|
-
"mappings": ";AAuZU,SACE,KADF;AAnZV,YAAY,WAAW;AAEvB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,cAAc,gBAAgB,qBAAqB;AAC5D,SAAS,aAAa;AACtB,SAAS,SAAS,mCAAmC;AACrD,SAAS,iCAAiC;AAC1C,SAAS,YAAY,YAAY,kBAAkB;AACnD,SAAS,2BAA2B;AACpC,SAAS,kCAAkC;AAC3C,SAAS,kBAAkB;AAE3B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAGP,SAAS,yBAAyB;AAClC,SAAS,wBAA8E;AACvF,SAAS,YAAY;AACrB,SAAS,kCAAkC;AAC3C,SAAS,gCAAgC;AACzC,SAAS,oBAAoB;AAE7B,MAAM,SAAS,aAAa,OA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AAa,OAAO,EAAE,yCAAyC,6BAA6B,GAAG,aAAa,OAAO,SAAS,MAAM,KAAK,gBAAgB,GAAG,IACzJ;AAAA,IACH,mBACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,EAAE,uCAAuC,2BAAsB;AAAA,QACtE,WAAU;AAAA;AAAA,IACZ,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN;AAAA,QACA,WAAW,WAAW,KAAK,SAAS;AAAA,QACpC,UAAQ;AAAA,QACR,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,YACE;AAAA,UAAC;AAAA;AAAA,YACC,OAAO,EAAE,2CAA2C,qBAAqB;AAAA,YACzE,aAAa,EAAE,iDAAiD,iDAAiD;AAAA,YACjH,aAAa,EAAE,mCAAmC,gBAAgB;AAAA,YAClE,UAAU;AAAA;AAAA,QACZ;AAAA;AAAA,IAEJ;AAAA,IAGF;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,cAAc,CAAC,SAAS;AACtB,cAAI,CAAC,MAAM;AACT,8BAAkB;AAAA,UACpB,OAAO;AACL,0BAAc,IAAI;AAAA,UACpB;AAAA,QACF;AAAA,QACA;AAAA,QACA,cAAc,gBAAgB;AAAA,QAC9B,aAAa,YAAY,SAAS,cAAc;AAAA,QAChD;AAAA,QACA,QAAQ;AAAA,UACN,UAAU,EAAE,wCAAwC,gBAAgB;AAAA,UACpE,WAAW,EAAE,yCAAyC,iBAAiB;AAAA,UACvE,cAAc,EAAE,4CAA4C,gBAAgB;AAAA,UAC5E,cAAc,EAAE,4CAA4C,cAAc;AAAA,QAC5E;AAAA,QACA,mBAAmB;AAAA,QACnB,UAAU;AAAA;AAAA,IACZ;AAAA,KACF;AAEJ;",
|
|
4
|
+
"sourcesContent": ["// @ts-nocheck\n\n\"use client\"\n\nimport * as React from 'react'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport { Badge } from '@open-mercato/ui/primitives/badge'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport { ErrorMessage, LoadingMessage, TabEmptyState } from '@open-mercato/ui/backend/detail'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { apiCall, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { createCrud, deleteCrud, updateCrud } from '@open-mercato/ui/backend/utils/crud'\nimport { createCrudFormError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { handleSectionMutationError } from './optimisticLock'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { type DictionaryOption } from '@open-mercato/core/modules/dictionaries/components/DictionaryEntrySelect'\nimport {\n emitSalesDocumentTotalsRefresh,\n subscribeSalesDocumentTotalsRefresh,\n} from '@open-mercato/core/modules/sales/lib/frontend/documentTotalsEvents'\nimport type { SectionAction } from '@open-mercato/core/modules/customers/components/detail/types'\nimport type { SalesAdjustmentKind } from '../../data/entities'\nimport { PriceWithCurrency } from '../PriceWithCurrency'\nimport { AdjustmentDialog, type AdjustmentRowData, type AdjustmentSubmitPayload } from './AdjustmentDialog'\nimport { useT, useLocale } from '@open-mercato/shared/lib/i18n/context'\nimport { useOrganizationScopeDetail } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { extractCustomFieldValues } from './customFieldHelpers'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('sales')\n\ntype AdjustmentRow = AdjustmentRowData\n\ntype SalesDocumentAdjustmentsSectionProps = {\n documentId: string\n kind: 'order' | 'quote'\n currencyCode: string | null | undefined\n documentUpdatedAt?: string | null\n organizationId?: string | null\n tenantId?: string | null\n onActionChange?: (action: SectionAction | null) => void\n onRowsChange?: (rows: AdjustmentRow[]) => void\n}\n\nconst FALLBACK_ADJUSTMENT_KIND_VALUES: SalesAdjustmentKind[] = [\n 'discount',\n 'tax',\n 'shipping',\n 'surcharge',\n 'custom',\n]\n\nfunction normalizeNumber(value: unknown, fallback = 0): number {\n if (typeof value === 'number' && Number.isFinite(value)) return value\n if (typeof value === 'string' && value.trim().length) {\n const parsed = Number(value)\n if (!Number.isNaN(parsed)) return parsed\n }\n return fallback\n}\n\nexport function formatPercent(value: number | null | undefined, locale?: string): string {\n if (value === null || value === undefined) return '\u2014'\n const formatter = new Intl.NumberFormat(locale, { style: 'percent', maximumFractionDigits: 2 })\n return formatter.format(value / 100)\n}\n\nexport function SalesDocumentAdjustmentsSection({\n documentId,\n kind,\n currencyCode,\n documentUpdatedAt,\n organizationId: orgFromProps,\n tenantId: tenantFromProps,\n onActionChange,\n onRowsChange,\n}: SalesDocumentAdjustmentsSectionProps) {\n const t = useT()\n const locale = useLocale()\n const { organizationId, tenantId } = useOrganizationScopeDetail()\n const resolvedOrganizationId = orgFromProps ?? organizationId ?? null\n const resolvedTenantId = tenantFromProps ?? tenantId ?? null\n const [rows, setRows] = React.useState<AdjustmentRow[]>([])\n const [loading, setLoading] = React.useState(false)\n const [error, setError] = React.useState<string | null>(null)\n const [dialogOpen, setDialogOpen] = React.useState(false)\n const [activeAdjustment, setActiveAdjustment] = React.useState<AdjustmentRow | null>(null)\n const [kindOptions, setKindOptions] = React.useState<DictionaryOption[]>([])\n const kindLoadingRef = React.useRef(false)\n\n const apiResourcePath = React.useMemo(\n () => (kind === 'order' ? '/api/sales/order-adjustments' : '/api/sales/quote-adjustments'),\n [kind]\n )\n const crudResourcePath = React.useMemo(\n () => (kind === 'order' ? 'sales/order-adjustments' : 'sales/quote-adjustments'),\n [kind]\n )\n const documentKey = kind === 'order' ? 'orderId' : 'quoteId'\n const fallbackKindOptions = React.useMemo<DictionaryOption[]>(\n () =>\n FALLBACK_ADJUSTMENT_KIND_VALUES.map((value) => ({\n value,\n label: t(`sales.documents.adjustments.kindLabels.${value}`, value),\n color: null,\n icon: null,\n })),\n [t]\n )\n const kindOptionMap = React.useMemo(\n () =>\n kindOptions.reduce<Record<string, DictionaryOption>>((acc, entry) => {\n acc[entry.value] = entry\n return acc\n }, {}),\n [kindOptions]\n )\n const loadKindOptions = React.useCallback(async (): Promise<DictionaryOption[]> => {\n if (kindOptions.length) return kindOptions\n if (kindLoadingRef.current) return kindOptions.length ? kindOptions : fallbackKindOptions\n kindLoadingRef.current = true\n try {\n const params = new URLSearchParams({ page: '1', pageSize: '100' })\n const response = await apiCall<{ items?: Array<Record<string, unknown>> }>(\n `/api/sales/adjustment-kinds?${params.toString()}`,\n undefined,\n { fallback: { items: [] } }\n )\n const items = Array.isArray(response.result?.items) ? response.result.items : []\n const parsed = items\n .map((item) => {\n const value = typeof (item as any).value === 'string' ? (item as any).value.trim() : ''\n if (!value) return null\n const label =\n typeof (item as any).label === 'string' && (item as any).label.trim().length\n ? (item as any).label.trim()\n : value\n const color =\n typeof (item as any).color === 'string' && /^#([0-9a-fA-F]{6})$/.test((item as any).color)\n ? `#${(item as any).color.slice(1).toLowerCase()}`\n : null\n const icon =\n typeof (item as any).icon === 'string' && (item as any).icon.trim().length\n ? (item as any).icon.trim()\n : null\n return { value, label, color, icon }\n })\n .filter((entry): entry is DictionaryOption => Boolean(entry))\n const merged = new Map<string, DictionaryOption>()\n fallbackKindOptions.forEach((entry) => merged.set(entry.value, entry))\n parsed.forEach((entry) => merged.set(entry.value, entry))\n const options = Array.from(merged.values()).sort((a, b) =>\n a.label.localeCompare(b.label, undefined, { sensitivity: 'base' })\n )\n setKindOptions(options)\n kindLoadingRef.current = false\n return options\n } catch (err) {\n logger.error('sales.adjustment-kinds.fetch', { err })\n kindLoadingRef.current = false\n setKindOptions(fallbackKindOptions)\n return fallbackKindOptions\n }\n }, [fallbackKindOptions, kindOptions])\n\n React.useEffect(() => {\n loadKindOptions().catch(() => {})\n }, [loadKindOptions, resolvedOrganizationId, resolvedTenantId])\n\n const loadAdjustments = React.useCallback(async () => {\n setLoading(true)\n setError(null)\n try {\n const params = new URLSearchParams({ page: '1', pageSize: '100', [documentKey]: documentId })\n const response = await apiCall<{ items?: Array<Record<string, unknown>> }>(\n `${apiResourcePath}?${params.toString()}`,\n undefined,\n { fallback: { items: [] } }\n )\n const items = Array.isArray(response.result?.items) ? response.result.items : []\n const mapped: AdjustmentRow[] = items\n .map((item) => {\n const id = typeof item.id === 'string' ? item.id : null\n if (!id) return null\n const amountNet = normalizeNumber(\n (item as any).amount_net ?? (item as any).amountNet ?? (item as any).amount_net_amount,\n NaN\n )\n const amountGross = normalizeNumber(\n (item as any).amount_gross ?? (item as any).amountGross ?? (item as any).amount_gross_amount,\n NaN\n )\n const rateRaw = normalizeNumber((item as any).rate, NaN)\n const kindValue =\n typeof item.kind === 'string' && item.kind.trim().length\n ? (item.kind.trim() as SalesAdjustmentKind)\n : 'custom'\n const currency =\n typeof (item as any).currency_code === 'string'\n ? (item as any).currency_code\n : typeof (item as any).currencyCode === 'string'\n ? (item as any).currencyCode\n : currencyCode ?? null\n const customFields = extractCustomFieldValues(item as Record<string, unknown>)\n const customFieldSetId =\n typeof (item as any).custom_field_set_id === 'string'\n ? (item as any).custom_field_set_id\n : typeof (item as any).customFieldSetId === 'string'\n ? (item as any).customFieldSetId\n : null\n const metadata =\n typeof (item as any).metadata === 'object' && (item as any).metadata\n ? ((item as any).metadata as Record<string, unknown>)\n : null\n return {\n id,\n label: typeof item.label === 'string' ? item.label : null,\n code: typeof item.code === 'string' ? item.code : null,\n kind: kindValue,\n calculatorKey:\n typeof (item as any).calculator_key === 'string'\n ? (item as any).calculator_key\n : typeof (item as any).calculatorKey === 'string'\n ? (item as any).calculatorKey\n : null,\n rate: Number.isFinite(rateRaw) ? rateRaw : null,\n amountNet: Number.isFinite(amountNet) ? amountNet : null,\n amountGross: Number.isFinite(amountGross) ? amountGross : null,\n currencyCode: currency,\n position:\n typeof item.position === 'number'\n ? item.position\n : typeof (item as any).position === 'string'\n ? Number((item as any).position)\n : 0,\n customFields: Object.keys(customFields).length ? customFields : null,\n customFieldSetId,\n metadata,\n }\n })\n .filter((entry): entry is AdjustmentRow => Boolean(entry))\n const ordered = [...mapped].sort((a, b) => (a.position ?? 0) - (b.position ?? 0))\n setRows(ordered)\n if (onRowsChange) onRowsChange(ordered)\n } catch (err) {\n logger.error('sales.document.adjustments.load', { err })\n setError(t('sales.documents.adjustments.errorLoad', 'Failed to load adjustments.'))\n } finally {\n setLoading(false)\n }\n }, [apiResourcePath, currencyCode, documentId, documentKey, onRowsChange, t])\n\n React.useEffect(() => {\n void loadAdjustments()\n }, [loadAdjustments])\n\n React.useEffect(\n () =>\n subscribeSalesDocumentTotalsRefresh((detail) => {\n if (detail.documentId !== documentId) return\n if (detail.kind && detail.kind !== kind) return\n void loadAdjustments()\n }),\n [documentId, kind, loadAdjustments],\n )\n\n const resolveKindLabel = React.useCallback(\n (kindValue: SalesAdjustmentKind) => {\n const option = kindOptionMap[kindValue]\n if (option) return option.label\n return t(`sales.documents.adjustments.kindLabels.${kindValue}`, typeof kindValue === 'string' ? kindValue : String(kindValue))\n },\n [kindOptionMap, t]\n )\n\n const handleOpenCreate = React.useCallback(() => {\n setActiveAdjustment(null)\n setDialogOpen(true)\n }, [])\n\n const handleEdit = React.useCallback((row: AdjustmentRow) => {\n setActiveAdjustment(row)\n setDialogOpen(true)\n }, [])\n\n const handleCloseDialog = React.useCallback(() => {\n setDialogOpen(false)\n setActiveAdjustment(null)\n }, [])\n\n React.useEffect(() => {\n if (!onActionChange) return\n onActionChange({\n label: t('sales.documents.adjustments.add', 'Add adjustment'),\n onClick: handleOpenCreate,\n disabled: false,\n })\n return () => onActionChange(null)\n }, [handleOpenCreate, onActionChange, t])\n\n const handleFormSubmit = React.useCallback(\n async (values: AdjustmentSubmitPayload) => {\n if (!resolvedOrganizationId || !resolvedTenantId) {\n throw createCrudFormError(\n t('sales.documents.adjustments.errorScope', 'Organization and tenant are required.')\n )\n }\n const payload: Record<string, unknown> = {\n [documentKey]: String(documentId),\n organizationId: String(resolvedOrganizationId),\n tenantId: String(resolvedTenantId),\n scope: 'order',\n kind: values.kind ?? 'custom',\n code: values.code ?? undefined,\n label: values.label ?? undefined,\n calculatorKey: values.calculatorKey ?? undefined,\n rate: Number.isFinite(values.rate) ? values.rate : undefined,\n amountNet: Number.isFinite(values.amountNet) ? values.amountNet : undefined,\n amountGross: Number.isFinite(values.amountGross) ? values.amountGross : undefined,\n currencyCode: (values.currencyCode ?? currencyCode ?? '').toUpperCase(),\n position: Number.isFinite(values.position) ? values.position : undefined,\n customFields: values.customFields ?? undefined,\n metadata: values.metadata ?? undefined,\n }\n\n const action = values.id ? updateCrud : createCrud\n try {\n const result = await withScopedApiRequestHeaders(\n buildOptimisticLockHeader(documentUpdatedAt),\n () =>\n action(\n crudResourcePath,\n values.id ? { id: values.id, ...payload } : payload,\n {\n successMessage: values.id\n ? t('sales.documents.adjustments.updated', 'Adjustment updated.')\n : t('sales.documents.adjustments.created', 'Adjustment added.'),\n errorMessage: t('sales.documents.adjustments.errorSave', 'Failed to save adjustment.'),\n }\n )\n )\n if (result.ok) {\n await loadAdjustments()\n emitSalesDocumentTotalsRefresh({ documentId, kind })\n setDialogOpen(false)\n setActiveAdjustment(null)\n }\n } catch (err) {\n if (\n handleSectionMutationError(err, t, () => void loadAdjustments())\n ) {\n setDialogOpen(false)\n setActiveAdjustment(null)\n return\n }\n throw err\n }\n },\n [\n currencyCode,\n documentId,\n documentKey,\n documentUpdatedAt,\n kind,\n loadAdjustments,\n crudResourcePath,\n resolvedOrganizationId,\n resolvedTenantId,\n t,\n ]\n )\n\n const handleDelete = React.useCallback(\n async (row: AdjustmentRow) => {\n try {\n const result = await withScopedApiRequestHeaders(\n buildOptimisticLockHeader(documentUpdatedAt),\n () =>\n deleteCrud(crudResourcePath, {\n body: {\n id: row.id,\n [documentKey]: documentId,\n organizationId: resolvedOrganizationId ?? undefined,\n tenantId: resolvedTenantId ?? undefined,\n },\n errorMessage: t('sales.documents.adjustments.errorDelete', 'Failed to delete adjustment.'),\n })\n )\n if (result.ok) {\n await loadAdjustments()\n emitSalesDocumentTotalsRefresh({ documentId, kind })\n }\n } catch (err) {\n if (handleSectionMutationError(err, t, () => void loadAdjustments())) return\n logger.error('sales.document.adjustments.delete', { err })\n flash(t('sales.documents.adjustments.errorDelete', 'Failed to delete adjustment.'), 'error')\n }\n },\n [crudResourcePath, documentId, documentKey, documentUpdatedAt, kind, loadAdjustments, resolvedOrganizationId, resolvedTenantId, t]\n )\n\n const columns = React.useMemo<ColumnDef<AdjustmentRow>[]>(\n () => [\n {\n id: 'label',\n header: t('sales.documents.adjustments.label', 'Label'),\n cell: ({ row }) => (\n <div className=\"flex flex-col\">\n <span className=\"font-medium text-foreground\">{row.original.label ?? t('sales.documents.adjustments.untitled', 'Untitled')}</span>\n {row.original.code ? <span className=\"text-xs text-muted-foreground\">{row.original.code}</span> : null}\n </div>\n ),\n },\n {\n id: 'kind',\n header: t('sales.documents.adjustments.kindLabel', 'Kind'),\n cell: ({ row }) => <Badge variant=\"outline\">{resolveKindLabel(row.original.kind)}</Badge>,\n },\n {\n id: 'amountNet',\n header: t('sales.documents.adjustments.amountNet', 'Net amount'),\n cell: ({ row }) => (\n <PriceWithCurrency amount={row.original.amountNet} currency={row.original.currencyCode ?? currencyCode} className=\"font-mono text-sm\" />\n ),\n },\n {\n id: 'amountGross',\n header: t('sales.documents.adjustments.amountGross', 'Gross amount'),\n cell: ({ row }) => (\n <PriceWithCurrency amount={row.original.amountGross} currency={row.original.currencyCode ?? currencyCode} className=\"font-mono text-sm\" />\n ),\n },\n {\n id: 'rate',\n header: t('sales.documents.adjustments.rate', 'Rate'),\n cell: ({ row }) => <span className=\"font-mono text-sm text-muted-foreground\">{formatPercent(row.original.rate, locale)}</span>,\n },\n {\n id: 'position',\n header: t('sales.documents.adjustments.position', 'Position'),\n cell: ({ row }) => <span className=\"text-sm text-muted-foreground\">{row.original.position}</span>,\n },\n ],\n [currencyCode, locale, resolveKindLabel, t]\n )\n\n const showLoadingState = loading && rows.length === 0\n\n const renderRowActions = React.useCallback(\n (row: AdjustmentRow) => (\n <RowActions\n items={[\n {\n id: 'edit',\n label: t('ui.actions.edit', 'Edit'),\n onSelect: () => handleEdit(row),\n },\n {\n id: 'delete',\n label: t('ui.actions.delete', 'Delete'),\n destructive: true,\n onSelect: () => handleDelete(row),\n },\n ]}\n />\n ),\n [handleDelete, handleEdit, t]\n )\n\n return (\n <div className=\"space-y-4\">\n {error ? (\n <ErrorMessage title={t('sales.documents.adjustments.errorLoad', 'Failed to load adjustments.')} description={error} onRetry={() => void loadAdjustments()} />\n ) : null}\n {showLoadingState ? (\n <LoadingMessage\n label={t('sales.documents.adjustments.loading', 'Loading adjustments\u2026')}\n className=\"border-0 bg-transparent p-0 py-8 justify-center\"\n />\n ) : (\n <DataTable<AdjustmentRow>\n data={rows}\n columns={columns}\n isLoading={loading && rows.length > 0}\n embedded\n onRowClick={handleEdit}\n rowActions={renderRowActions}\n emptyState={\n <TabEmptyState\n title={t('sales.documents.empty.adjustments.title', 'No adjustments yet.')}\n description={t('sales.documents.empty.adjustments.description', 'Add discounts, fees, or taxes to refine totals.')}\n actionLabel={t('sales.documents.adjustments.add', 'Add adjustment')}\n onAction={handleOpenCreate}\n />\n }\n />\n )}\n\n <AdjustmentDialog\n open={dialogOpen}\n onOpenChange={(open) => {\n if (!open) {\n handleCloseDialog()\n } else {\n setDialogOpen(true)\n }\n }}\n kind={kind}\n currencyCode={currencyCode ?? null}\n kindOptions={kindOptions.length ? kindOptions : fallbackKindOptions}\n loadKindOptions={loadKindOptions}\n labels={{\n addTitle: t('sales.documents.adjustments.addTitle', 'Add adjustment'),\n editTitle: t('sales.documents.adjustments.editTitle', 'Edit adjustment'),\n submitCreate: t('sales.documents.adjustments.submitCreate', 'Add adjustment'),\n submitUpdate: t('sales.documents.adjustments.submitUpdate', 'Save changes'),\n }}\n initialAdjustment={activeAdjustment}\n onSubmit={handleFormSubmit}\n />\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAwZU,SACE,KADF;AApZV,YAAY,WAAW;AAEvB,SAAS,aAAa;AACtB,SAAS,iBAAiB;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AAS,cAAc;AAAA,QAChD;AAAA,QACA,QAAQ;AAAA,UACN,UAAU,EAAE,wCAAwC,gBAAgB;AAAA,UACpE,WAAW,EAAE,yCAAyC,iBAAiB;AAAA,UACvE,cAAc,EAAE,4CAA4C,gBAAgB;AAAA,UAC5E,cAAc,EAAE,4CAA4C,cAAc;AAAA,QAC5E;AAAA,QACA,mBAAmB;AAAA,QACnB,UAAU;AAAA;AAAA,IACZ;AAAA,KACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
createDictionaryMap,
|
|
16
16
|
normalizeDictionaryEntries
|
|
17
17
|
} from "@open-mercato/core/modules/dictionaries/components/dictionaryAppearance";
|
|
18
|
-
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
18
|
+
import { useT, useLocale } from "@open-mercato/shared/lib/i18n/context";
|
|
19
19
|
import { useOrganizationScopeDetail } from "@open-mercato/shared/lib/frontend/useOrganizationScope";
|
|
20
20
|
import { useConfirmDialog } from "@open-mercato/ui/backend/confirm-dialog";
|
|
21
21
|
import { emitSalesDocumentTotalsRefresh } from "@open-mercato/core/modules/sales/lib/frontend/documentTotalsEvents";
|
|
@@ -76,6 +76,8 @@ function resolveInjectedColumnValue(row, accessorKey) {
|
|
|
76
76
|
}
|
|
77
77
|
return current;
|
|
78
78
|
}
|
|
79
|
+
const SHIPMENTS_PAGE_SIZE = 100;
|
|
80
|
+
const SHIPMENTS_MAX_PAGES = 50;
|
|
79
81
|
function SalesDocumentItemsSection({
|
|
80
82
|
documentId,
|
|
81
83
|
kind,
|
|
@@ -87,6 +89,7 @@ function SalesDocumentItemsSection({
|
|
|
87
89
|
onItemsChange
|
|
88
90
|
}) {
|
|
89
91
|
const t = useT();
|
|
92
|
+
const locale = useLocale();
|
|
90
93
|
const { organizationId, tenantId } = useOrganizationScopeDetail();
|
|
91
94
|
const { confirm, ConfirmDialogElement } = useConfirmDialog();
|
|
92
95
|
const resolvedOrganizationId = orgFromProps ?? organizationId ?? null;
|
|
@@ -102,6 +105,9 @@ function SalesDocumentItemsSection({
|
|
|
102
105
|
const [shippedTotals, setShippedTotals] = React.useState(
|
|
103
106
|
/* @__PURE__ */ new Map()
|
|
104
107
|
);
|
|
108
|
+
const [shippedTotalsResolved, setShippedTotalsResolved] = React.useState(
|
|
109
|
+
kind !== "order"
|
|
110
|
+
);
|
|
105
111
|
const { widgets: allColumnWidgets } = useInjectionDataWidgets(
|
|
106
112
|
extensionPoints.hosts.orderItemColumns.spotId
|
|
107
113
|
);
|
|
@@ -250,20 +256,28 @@ function SalesDocumentItemsSection({
|
|
|
250
256
|
const loadShippedTotals = React.useCallback(async () => {
|
|
251
257
|
if (kind !== "order") {
|
|
252
258
|
setShippedTotals(/* @__PURE__ */ new Map());
|
|
259
|
+
setShippedTotalsResolved(true);
|
|
253
260
|
return;
|
|
254
261
|
}
|
|
262
|
+
setShippedTotals(/* @__PURE__ */ new Map());
|
|
263
|
+
setShippedTotalsResolved(false);
|
|
255
264
|
try {
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
response.
|
|
265
|
+
const totals = /* @__PURE__ */ new Map();
|
|
266
|
+
let page = 1;
|
|
267
|
+
let collected = 0;
|
|
268
|
+
let complete = false;
|
|
269
|
+
while (page <= SHIPMENTS_MAX_PAGES) {
|
|
270
|
+
const params = new URLSearchParams({
|
|
271
|
+
page: String(page),
|
|
272
|
+
pageSize: String(SHIPMENTS_PAGE_SIZE),
|
|
273
|
+
orderId: documentId
|
|
274
|
+
});
|
|
275
|
+
const response = await apiCall(`/api/sales/shipments?${params.toString()}`, void 0, {
|
|
276
|
+
fallback: { items: [] }
|
|
277
|
+
});
|
|
278
|
+
if (!response.ok || !Array.isArray(response.result?.items)) return;
|
|
279
|
+
const shipments = response.result.items;
|
|
280
|
+
shipments.forEach((shipment) => {
|
|
267
281
|
const entries = Array.isArray(shipment.items) ? shipment.items : [];
|
|
268
282
|
entries.forEach((entry) => {
|
|
269
283
|
const lineId = typeof entry.orderLineId === "string" ? entry.orderLineId : typeof entry.order_line_id === "string" ? entry.order_line_id : null;
|
|
@@ -274,13 +288,20 @@ function SalesDocumentItemsSection({
|
|
|
274
288
|
totals.set(lineId, current + quantity);
|
|
275
289
|
});
|
|
276
290
|
});
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
291
|
+
collected += shipments.length;
|
|
292
|
+
const reportedTotal = normalizeNumber(response.result?.total, Number.NaN);
|
|
293
|
+
const hasMore = shipments.length >= SHIPMENTS_PAGE_SIZE && (!Number.isFinite(reportedTotal) || collected < reportedTotal);
|
|
294
|
+
if (!hasMore) {
|
|
295
|
+
complete = true;
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
page += 1;
|
|
280
299
|
}
|
|
300
|
+
if (!complete) return;
|
|
301
|
+
setShippedTotals(totals);
|
|
302
|
+
setShippedTotalsResolved(true);
|
|
281
303
|
} catch (err) {
|
|
282
304
|
logger.error("sales.document.shipments.load", { err });
|
|
283
|
-
setShippedTotals(/* @__PURE__ */ new Map());
|
|
284
305
|
}
|
|
285
306
|
}, [documentId, kind]);
|
|
286
307
|
React.useEffect(() => {
|
|
@@ -298,6 +319,7 @@ function SalesDocumentItemsSection({
|
|
|
298
319
|
if (kind !== "order") {
|
|
299
320
|
shipmentsLoadedForDocument.current = null;
|
|
300
321
|
setShippedTotals(/* @__PURE__ */ new Map());
|
|
322
|
+
setShippedTotalsResolved(true);
|
|
301
323
|
return;
|
|
302
324
|
}
|
|
303
325
|
const key = `${kind}:${documentId}`;
|
|
@@ -531,7 +553,8 @@ function SalesDocumentItemsSection({
|
|
|
531
553
|
/* @__PURE__ */ jsxs("span", { className: "font-mono text-sm", children: [
|
|
532
554
|
formatMoney(
|
|
533
555
|
item.unitPriceGross,
|
|
534
|
-
item.currencyCode ?? currencyCode ?? void 0
|
|
556
|
+
item.currencyCode ?? currencyCode ?? void 0,
|
|
557
|
+
locale
|
|
535
558
|
),
|
|
536
559
|
" ",
|
|
537
560
|
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t("sales.documents.items.table.gross", "gross") })
|
|
@@ -539,7 +562,8 @@ function SalesDocumentItemsSection({
|
|
|
539
562
|
/* @__PURE__ */ jsxs("span", { className: "font-mono text-xs text-muted-foreground", children: [
|
|
540
563
|
formatMoney(
|
|
541
564
|
item.unitPriceNet,
|
|
542
|
-
item.currencyCode ?? currencyCode ?? void 0
|
|
565
|
+
item.currencyCode ?? currencyCode ?? void 0,
|
|
566
|
+
locale
|
|
543
567
|
),
|
|
544
568
|
" ",
|
|
545
569
|
t("sales.documents.items.table.net", "net")
|
|
@@ -550,7 +574,8 @@ function SalesDocumentItemsSection({
|
|
|
550
574
|
{
|
|
551
575
|
value: formatMoney(
|
|
552
576
|
unitPriceReference.grossPerReference,
|
|
553
|
-
item.currencyCode ?? currencyCode ?? void 0
|
|
577
|
+
item.currencyCode ?? currencyCode ?? void 0,
|
|
578
|
+
locale
|
|
554
579
|
),
|
|
555
580
|
unit: unitPriceReference.referenceUnitCode
|
|
556
581
|
}
|
|
@@ -563,7 +588,8 @@ function SalesDocumentItemsSection({
|
|
|
563
588
|
{
|
|
564
589
|
value: formatMoney(
|
|
565
590
|
discount.amount,
|
|
566
|
-
item.currencyCode ?? currencyCode ?? void 0
|
|
591
|
+
item.currencyCode ?? currencyCode ?? void 0,
|
|
592
|
+
locale
|
|
567
593
|
)
|
|
568
594
|
}
|
|
569
595
|
) }) : null,
|
|
@@ -583,7 +609,8 @@ function SalesDocumentItemsSection({
|
|
|
583
609
|
/* @__PURE__ */ jsxs("span", { children: [
|
|
584
610
|
formatMoney(
|
|
585
611
|
item.totalGross,
|
|
586
|
-
item.currencyCode ?? currencyCode ?? void 0
|
|
612
|
+
item.currencyCode ?? currencyCode ?? void 0,
|
|
613
|
+
locale
|
|
587
614
|
),
|
|
588
615
|
" ",
|
|
589
616
|
/* @__PURE__ */ jsx("span", { className: "text-xs font-normal text-muted-foreground", children: t("sales.documents.items.table.gross", "gross") })
|
|
@@ -591,7 +618,8 @@ function SalesDocumentItemsSection({
|
|
|
591
618
|
/* @__PURE__ */ jsxs("span", { className: "text-xs font-medium text-muted-foreground", children: [
|
|
592
619
|
formatMoney(
|
|
593
620
|
item.totalNet,
|
|
594
|
-
item.currencyCode ?? currencyCode ?? void 0
|
|
621
|
+
item.currencyCode ?? currencyCode ?? void 0,
|
|
622
|
+
locale
|
|
595
623
|
),
|
|
596
624
|
" ",
|
|
597
625
|
t("sales.documents.items.table.net", "net")
|
|
@@ -672,6 +700,7 @@ function SalesDocumentItemsSection({
|
|
|
672
700
|
tenantId: resolvedTenantId,
|
|
673
701
|
initialLine: lineForEdit,
|
|
674
702
|
shippedQuantity: lineForEdit ? Math.max(0, shippedTotals.get(lineForEdit.id) ?? 0) : 0,
|
|
703
|
+
shippedQuantityResolved: shippedTotalsResolved,
|
|
675
704
|
onSaved: async () => {
|
|
676
705
|
await loadItems();
|
|
677
706
|
emitSalesDocumentTotalsRefresh({ documentId, kind });
|