@open-mercato/core 0.6.5-develop.4384.1.ce2ec6eaaa → 0.6.5-develop.4393.1.de282b5dfd
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 +2 -2
- package/dist/generated/entities/channel_ingest_dead_letter/index.js +25 -0
- package/dist/generated/entities/channel_ingest_dead_letter/index.js.map +7 -0
- package/dist/generated/entities/channel_thread_mapping/index.js +25 -0
- package/dist/generated/entities/channel_thread_mapping/index.js.map +7 -0
- package/dist/generated/entities/channel_thread_token/index.js +17 -0
- package/dist/generated/entities/channel_thread_token/index.js.map +7 -0
- package/dist/generated/entities/communication_channel/index.js +43 -0
- package/dist/generated/entities/communication_channel/index.js.map +7 -0
- package/dist/generated/entities/customer_interaction/index.js +4 -0
- package/dist/generated/entities/customer_interaction/index.js.map +2 -2
- package/dist/generated/entities/external_conversation/index.js +25 -0
- package/dist/generated/entities/external_conversation/index.js.map +7 -0
- package/dist/generated/entities/external_message/index.js +25 -0
- package/dist/generated/entities/external_message/index.js.map +7 -0
- package/dist/generated/entities/integration_credentials/index.js +3 -1
- package/dist/generated/entities/integration_credentials/index.js.map +2 -2
- package/dist/generated/entities/message/index.js +2 -0
- package/dist/generated/entities/message/index.js.map +2 -2
- package/dist/generated/entities/message_channel_link/index.js +33 -0
- package/dist/generated/entities/message_channel_link/index.js.map +7 -0
- package/dist/generated/entities/message_reaction/index.js +25 -0
- package/dist/generated/entities/message_reaction/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +11 -0
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +117 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/helpers/integration/authFixtures.js +2 -1
- package/dist/helpers/integration/authFixtures.js.map +2 -2
- package/dist/helpers/integration/communicationChannelsFixtures.js +58 -0
- package/dist/helpers/integration/communicationChannelsFixtures.js.map +7 -0
- package/dist/modules/communication_channels/acl.js +47 -0
- package/dist/modules/communication_channels/acl.js.map +7 -0
- package/dist/modules/communication_channels/api/delete/channels/[id]/route.js +133 -0
- package/dist/modules/communication_channels/api/delete/channels/[id]/route.js.map +7 -0
- package/dist/modules/communication_channels/api/delete/messages/[messageId]/reactions/[reactionId]/route.js +113 -0
- package/dist/modules/communication_channels/api/delete/messages/[messageId]/reactions/[reactionId]/route.js.map +7 -0
- package/dist/modules/communication_channels/api/get/channels/[id]/health/route.js +138 -0
- package/dist/modules/communication_channels/api/get/channels/[id]/health/route.js.map +7 -0
- package/dist/modules/communication_channels/api/get/channels/[id]/route.js +93 -0
- package/dist/modules/communication_channels/api/get/channels/[id]/route.js.map +7 -0
- package/dist/modules/communication_channels/api/get/channels/route.js +96 -0
- package/dist/modules/communication_channels/api/get/channels/route.js.map +7 -0
- package/dist/modules/communication_channels/api/get/me/channels/route.js +82 -0
- package/dist/modules/communication_channels/api/get/me/channels/route.js.map +7 -0
- package/dist/modules/communication_channels/api/get/oauth/[provider]/callback/route.js +274 -0
- package/dist/modules/communication_channels/api/get/oauth/[provider]/callback/route.js.map +7 -0
- package/dist/modules/communication_channels/api/post/channels/[id]/import-history/route.js +168 -0
- package/dist/modules/communication_channels/api/post/channels/[id]/import-history/route.js.map +7 -0
- package/dist/modules/communication_channels/api/post/channels/[id]/poll-now/route.js +143 -0
- package/dist/modules/communication_channels/api/post/channels/[id]/poll-now/route.js.map +7 -0
- package/dist/modules/communication_channels/api/post/channels/[id]/push/register/route.js +127 -0
- package/dist/modules/communication_channels/api/post/channels/[id]/push/register/route.js.map +7 -0
- package/dist/modules/communication_channels/api/post/channels/[id]/set-primary/route.js +99 -0
- package/dist/modules/communication_channels/api/post/channels/[id]/set-primary/route.js.map +7 -0
- package/dist/modules/communication_channels/api/post/channels/[id]/test-send/route.js +197 -0
- package/dist/modules/communication_channels/api/post/channels/[id]/test-send/route.js.map +7 -0
- package/dist/modules/communication_channels/api/post/channels/connect/credentials/route.js +124 -0
- package/dist/modules/communication_channels/api/post/channels/connect/credentials/route.js.map +7 -0
- package/dist/modules/communication_channels/api/post/messages/[messageId]/reactions/route.js +120 -0
- package/dist/modules/communication_channels/api/post/messages/[messageId]/reactions/route.js.map +7 -0
- package/dist/modules/communication_channels/api/post/oauth/[provider]/initiate/route.js +157 -0
- package/dist/modules/communication_channels/api/post/oauth/[provider]/initiate/route.js.map +7 -0
- package/dist/modules/communication_channels/api/post/send-as-user/route.js +115 -0
- package/dist/modules/communication_channels/api/post/send-as-user/route.js.map +7 -0
- package/dist/modules/communication_channels/api/post/test-seed/route.js +217 -0
- package/dist/modules/communication_channels/api/post/test-seed/route.js.map +7 -0
- package/dist/modules/communication_channels/api/post/webhook/[provider]/route.js +175 -0
- package/dist/modules/communication_channels/api/post/webhook/[provider]/route.js.map +7 -0
- package/dist/modules/communication_channels/api/post/webhooks/gmail/route.js +123 -0
- package/dist/modules/communication_channels/api/post/webhooks/gmail/route.js.map +7 -0
- package/dist/modules/communication_channels/api/put/threads/[threadId]/assign/route.js +117 -0
- package/dist/modules/communication_channels/api/put/threads/[threadId]/assign/route.js.map +7 -0
- package/dist/modules/communication_channels/backend/communication_channels/channels/[id]/page.js +180 -0
- package/dist/modules/communication_channels/backend/communication_channels/channels/[id]/page.js.map +7 -0
- package/dist/modules/communication_channels/backend/communication_channels/channels/[id]/page.meta.js +36 -0
- package/dist/modules/communication_channels/backend/communication_channels/channels/[id]/page.meta.js.map +7 -0
- package/dist/modules/communication_channels/backend/communication_channels/channels/page.js +107 -0
- package/dist/modules/communication_channels/backend/communication_channels/channels/page.js.map +7 -0
- package/dist/modules/communication_channels/backend/communication_channels/channels/page.meta.js +38 -0
- package/dist/modules/communication_channels/backend/communication_channels/channels/page.meta.js.map +7 -0
- package/dist/modules/communication_channels/backend/profile/communication-channels/page.js +727 -0
- package/dist/modules/communication_channels/backend/profile/communication-channels/page.js.map +7 -0
- package/dist/modules/communication_channels/backend/profile/communication-channels/page.meta.js +38 -0
- package/dist/modules/communication_channels/backend/profile/communication-channels/page.meta.js.map +7 -0
- package/dist/modules/communication_channels/commands/connect-credential-channel.js +154 -0
- package/dist/modules/communication_channels/commands/connect-credential-channel.js.map +7 -0
- package/dist/modules/communication_channels/commands/delete-channel.js +137 -0
- package/dist/modules/communication_channels/commands/delete-channel.js.map +7 -0
- package/dist/modules/communication_channels/commands/deliver-outbound-message.js +400 -0
- package/dist/modules/communication_channels/commands/deliver-outbound-message.js.map +7 -0
- package/dist/modules/communication_channels/commands/disconnect-channel.js +163 -0
- package/dist/modules/communication_channels/commands/disconnect-channel.js.map +7 -0
- package/dist/modules/communication_channels/commands/ingest-inbound-message.js +413 -0
- package/dist/modules/communication_channels/commands/ingest-inbound-message.js.map +7 -0
- package/dist/modules/communication_channels/commands/interceptors.js +68 -0
- package/dist/modules/communication_channels/commands/interceptors.js.map +7 -0
- package/dist/modules/communication_channels/commands/process-inbound-reaction.js +198 -0
- package/dist/modules/communication_channels/commands/process-inbound-reaction.js.map +7 -0
- package/dist/modules/communication_channels/commands/push-register.js +146 -0
- package/dist/modules/communication_channels/commands/push-register.js.map +7 -0
- package/dist/modules/communication_channels/commands/push-renew.js +23 -0
- package/dist/modules/communication_channels/commands/push-renew.js.map +7 -0
- package/dist/modules/communication_channels/commands/push-unregister.js +108 -0
- package/dist/modules/communication_channels/commands/push-unregister.js.map +7 -0
- package/dist/modules/communication_channels/commands/queue-import-history.js +113 -0
- package/dist/modules/communication_channels/commands/queue-import-history.js.map +7 -0
- package/dist/modules/communication_channels/commands/reassign-conversation.js +193 -0
- package/dist/modules/communication_channels/commands/reassign-conversation.js.map +7 -0
- package/dist/modules/communication_channels/commands/set-primary-channel.js +114 -0
- package/dist/modules/communication_channels/commands/set-primary-channel.js.map +7 -0
- package/dist/modules/communication_channels/commands/toggle-outbound-reaction.js +260 -0
- package/dist/modules/communication_channels/commands/toggle-outbound-reaction.js.map +7 -0
- package/dist/modules/communication_channels/data/enrichers.js +286 -0
- package/dist/modules/communication_channels/data/enrichers.js.map +7 -0
- package/dist/modules/communication_channels/data/entities.js +447 -0
- package/dist/modules/communication_channels/data/entities.js.map +7 -0
- package/dist/modules/communication_channels/data/extensions.js +67 -0
- package/dist/modules/communication_channels/data/extensions.js.map +7 -0
- package/dist/modules/communication_channels/data/validators.js +123 -0
- package/dist/modules/communication_channels/data/validators.js.map +7 -0
- package/dist/modules/communication_channels/di.js +35 -0
- package/dist/modules/communication_channels/di.js.map +7 -0
- package/dist/modules/communication_channels/encryption.js +12 -0
- package/dist/modules/communication_channels/encryption.js.map +7 -0
- package/dist/modules/communication_channels/events.js +124 -0
- package/dist/modules/communication_channels/events.js.map +7 -0
- package/dist/modules/communication_channels/index.js +20 -0
- package/dist/modules/communication_channels/index.js.map +7 -0
- package/dist/modules/communication_channels/lib/access-control.js +43 -0
- package/dist/modules/communication_channels/lib/access-control.js.map +7 -0
- package/dist/modules/communication_channels/lib/adapter-compat.js +36 -0
- package/dist/modules/communication_channels/lib/adapter-compat.js.map +7 -0
- package/dist/modules/communication_channels/lib/adapter-registry-singleton.js +22 -0
- package/dist/modules/communication_channels/lib/adapter-registry-singleton.js.map +7 -0
- package/dist/modules/communication_channels/lib/adapter.js +1 -0
- package/dist/modules/communication_channels/lib/adapter.js.map +7 -0
- package/dist/modules/communication_channels/lib/connect-channel.js +95 -0
- package/dist/modules/communication_channels/lib/connect-channel.js.map +7 -0
- package/dist/modules/communication_channels/lib/contact-resolver.js +79 -0
- package/dist/modules/communication_channels/lib/contact-resolver.js.map +7 -0
- package/dist/modules/communication_channels/lib/credential-refresh.js +97 -0
- package/dist/modules/communication_channels/lib/credential-refresh.js.map +7 -0
- package/dist/modules/communication_channels/lib/dead-letter.js +62 -0
- package/dist/modules/communication_channels/lib/dead-letter.js.map +7 -0
- package/dist/modules/communication_channels/lib/email-capabilities.js +47 -0
- package/dist/modules/communication_channels/lib/email-capabilities.js.map +7 -0
- package/dist/modules/communication_channels/lib/email-contact.js +14 -0
- package/dist/modules/communication_channels/lib/email-contact.js.map +7 -0
- package/dist/modules/communication_channels/lib/email-mime.js +259 -0
- package/dist/modules/communication_channels/lib/email-mime.js.map +7 -0
- package/dist/modules/communication_channels/lib/error-classification.js +101 -0
- package/dist/modules/communication_channels/lib/error-classification.js.map +7 -0
- package/dist/modules/communication_channels/lib/gmail-pubsub-jwt.js +185 -0
- package/dist/modules/communication_channels/lib/gmail-pubsub-jwt.js.map +7 -0
- package/dist/modules/communication_channels/lib/mutation-guards.js +114 -0
- package/dist/modules/communication_channels/lib/mutation-guards.js.map +7 -0
- package/dist/modules/communication_channels/lib/oauth-client-config.js +32 -0
- package/dist/modules/communication_channels/lib/oauth-client-config.js.map +7 -0
- package/dist/modules/communication_channels/lib/oauth-state.js +128 -0
- package/dist/modules/communication_channels/lib/oauth-state.js.map +7 -0
- package/dist/modules/communication_channels/lib/oauth-token.js +45 -0
- package/dist/modules/communication_channels/lib/oauth-token.js.map +7 -0
- package/dist/modules/communication_channels/lib/pg-errors.js +11 -0
- package/dist/modules/communication_channels/lib/pg-errors.js.map +7 -0
- package/dist/modules/communication_channels/lib/provider-health.js +24 -0
- package/dist/modules/communication_channels/lib/provider-health.js.map +7 -0
- package/dist/modules/communication_channels/lib/push-state.js +19 -0
- package/dist/modules/communication_channels/lib/push-state.js.map +7 -0
- package/dist/modules/communication_channels/lib/queue.js +54 -0
- package/dist/modules/communication_channels/lib/queue.js.map +7 -0
- package/dist/modules/communication_channels/lib/reaction-processor-types.js +5 -0
- package/dist/modules/communication_channels/lib/reaction-processor-types.js.map +7 -0
- package/dist/modules/communication_channels/lib/reaction-semantics.js +11 -0
- package/dist/modules/communication_channels/lib/reaction-semantics.js.map +7 -0
- package/dist/modules/communication_channels/lib/registry.js +67 -0
- package/dist/modules/communication_channels/lib/registry.js.map +7 -0
- package/dist/modules/communication_channels/lib/route-mutation-guard.js +43 -0
- package/dist/modules/communication_channels/lib/route-mutation-guard.js.map +7 -0
- package/dist/modules/communication_channels/lib/sanitize-channel-html.js +96 -0
- package/dist/modules/communication_channels/lib/sanitize-channel-html.js.map +7 -0
- package/dist/modules/communication_channels/lib/send-as-user.js +194 -0
- package/dist/modules/communication_channels/lib/send-as-user.js.map +7 -0
- package/dist/modules/communication_channels/lib/system-user.js +22 -0
- package/dist/modules/communication_channels/lib/system-user.js.map +7 -0
- package/dist/modules/communication_channels/lib/test-seed.js +68 -0
- package/dist/modules/communication_channels/lib/test-seed.js.map +7 -0
- package/dist/modules/communication_channels/lib/thread-matcher.js +263 -0
- package/dist/modules/communication_channels/lib/thread-matcher.js.map +7 -0
- package/dist/modules/communication_channels/lib/thread-token.js +219 -0
- package/dist/modules/communication_channels/lib/thread-token.js.map +7 -0
- package/dist/modules/communication_channels/lib/use-connect-channel.js +61 -0
- package/dist/modules/communication_channels/lib/use-connect-channel.js.map +7 -0
- package/dist/modules/communication_channels/migrations/Migration20260526134719_communication_channels.js +50 -0
- package/dist/modules/communication_channels/migrations/Migration20260526134719_communication_channels.js.map +7 -0
- package/dist/modules/communication_channels/migrations/Migration20260527195446_communication_channels.js +19 -0
- package/dist/modules/communication_channels/migrations/Migration20260527195446_communication_channels.js.map +7 -0
- package/dist/modules/communication_channels/migrations/Migration20260529231848_communication_channels.js +13 -0
- package/dist/modules/communication_channels/migrations/Migration20260529231848_communication_channels.js.map +7 -0
- package/dist/modules/communication_channels/migrations/Migration20260531120000_communication_channels.js +17 -0
- package/dist/modules/communication_channels/migrations/Migration20260531120000_communication_channels.js.map +7 -0
- package/dist/modules/communication_channels/notifications.client.js +51 -0
- package/dist/modules/communication_channels/notifications.client.js.map +7 -0
- package/dist/modules/communication_channels/notifications.handlers.js +53 -0
- package/dist/modules/communication_channels/notifications.handlers.js.map +7 -0
- package/dist/modules/communication_channels/notifications.js +56 -0
- package/dist/modules/communication_channels/notifications.js.map +7 -0
- package/dist/modules/communication_channels/setup.js +105 -0
- package/dist/modules/communication_channels/setup.js.map +7 -0
- package/dist/modules/communication_channels/subscribers/channel-requires-reauth-notification.js +71 -0
- package/dist/modules/communication_channels/subscribers/channel-requires-reauth-notification.js.map +7 -0
- package/dist/modules/communication_channels/subscribers/outbound-bridge.js +103 -0
- package/dist/modules/communication_channels/subscribers/outbound-bridge.js.map +7 -0
- package/dist/modules/communication_channels/subscribers/user-deleted-cascade.js +51 -0
- package/dist/modules/communication_channels/subscribers/user-deleted-cascade.js.map +7 -0
- package/dist/modules/communication_channels/widgets/components.js +7 -0
- package/dist/modules/communication_channels/widgets/components.js.map +7 -0
- package/dist/modules/communication_channels/widgets/injection/channel-badge/widget.client.js +18 -0
- package/dist/modules/communication_channels/widgets/injection/channel-badge/widget.client.js.map +7 -0
- package/dist/modules/communication_channels/widgets/injection/channel-badge/widget.js +30 -0
- package/dist/modules/communication_channels/widgets/injection/channel-badge/widget.js.map +7 -0
- package/dist/modules/communication_channels/widgets/injection/channel-info-panel/widget.client.js +185 -0
- package/dist/modules/communication_channels/widgets/injection/channel-info-panel/widget.client.js.map +7 -0
- package/dist/modules/communication_channels/widgets/injection/channel-info-panel/widget.js +17 -0
- package/dist/modules/communication_channels/widgets/injection/channel-info-panel/widget.js.map +7 -0
- package/dist/modules/communication_channels/widgets/injection/channel-payload-renderer/widget.client.js +44 -0
- package/dist/modules/communication_channels/widgets/injection/channel-payload-renderer/widget.client.js.map +7 -0
- package/dist/modules/communication_channels/widgets/injection/channel-payload-renderer/widget.js +17 -0
- package/dist/modules/communication_channels/widgets/injection/channel-payload-renderer/widget.js.map +7 -0
- package/dist/modules/communication_channels/widgets/injection/profile-channels-menu/widget.js +23 -0
- package/dist/modules/communication_channels/widgets/injection/profile-channels-menu/widget.js.map +7 -0
- package/dist/modules/communication_channels/widgets/injection/reaction-bar/widget.client.js +141 -0
- package/dist/modules/communication_channels/widgets/injection/reaction-bar/widget.client.js.map +7 -0
- package/dist/modules/communication_channels/widgets/injection/reaction-bar/widget.js +17 -0
- package/dist/modules/communication_channels/widgets/injection/reaction-bar/widget.js.map +7 -0
- package/dist/modules/communication_channels/widgets/injection-table.js +38 -0
- package/dist/modules/communication_channels/widgets/injection-table.js.map +7 -0
- package/dist/modules/communication_channels/widgets/notifications/ChannelRequiresReauthRenderer.js +25 -0
- package/dist/modules/communication_channels/widgets/notifications/ChannelRequiresReauthRenderer.js.map +7 -0
- package/dist/modules/communication_channels/widgets/notifications/MessageReceivedRenderer.js +19 -0
- package/dist/modules/communication_channels/widgets/notifications/MessageReceivedRenderer.js.map +7 -0
- package/dist/modules/communication_channels/widgets/notifications/index.js +7 -0
- package/dist/modules/communication_channels/widgets/notifications/index.js.map +7 -0
- package/dist/modules/communication_channels/workers/channel-import-history.js +185 -0
- package/dist/modules/communication_channels/workers/channel-import-history.js.map +7 -0
- package/dist/modules/communication_channels/workers/gmail-history-sync.js +154 -0
- package/dist/modules/communication_channels/workers/gmail-history-sync.js.map +7 -0
- package/dist/modules/communication_channels/workers/gmail-renew-watch.js +95 -0
- package/dist/modules/communication_channels/workers/gmail-renew-watch.js.map +7 -0
- package/dist/modules/communication_channels/workers/inbound-processor.js +56 -0
- package/dist/modules/communication_channels/workers/inbound-processor.js.map +7 -0
- package/dist/modules/communication_channels/workers/outbound-delivery.js +85 -0
- package/dist/modules/communication_channels/workers/outbound-delivery.js.map +7 -0
- package/dist/modules/communication_channels/workers/poll-channel.js +240 -0
- package/dist/modules/communication_channels/workers/poll-channel.js.map +7 -0
- package/dist/modules/communication_channels/workers/poll-tick.js +132 -0
- package/dist/modules/communication_channels/workers/poll-tick.js.map +7 -0
- package/dist/modules/communication_channels/workers/reaction-processor.js +192 -0
- package/dist/modules/communication_channels/workers/reaction-processor.js.map +7 -0
- package/dist/modules/customers/acl.js +18 -0
- package/dist/modules/customers/acl.js.map +2 -2
- package/dist/modules/customers/api/activities/route.js +9 -0
- package/dist/modules/customers/api/activities/route.js.map +2 -2
- package/dist/modules/customers/api/companies/[id]/route.js +18 -7
- package/dist/modules/customers/api/companies/[id]/route.js.map +2 -2
- package/dist/modules/customers/api/interactions/[id]/visibility/route.js +151 -0
- package/dist/modules/customers/api/interactions/[id]/visibility/route.js.map +7 -0
- package/dist/modules/customers/api/interactions/counts/route.js +6 -0
- package/dist/modules/customers/api/interactions/counts/route.js.map +2 -2
- package/dist/modules/customers/api/interactions/route.js +26 -7
- package/dist/modules/customers/api/interactions/route.js.map +2 -2
- package/dist/modules/customers/api/people/[id]/email-threads/route.js +82 -0
- package/dist/modules/customers/api/people/[id]/email-threads/route.js.map +7 -0
- package/dist/modules/customers/api/people/[id]/emails/route.js +157 -0
- package/dist/modules/customers/api/people/[id]/emails/route.js.map +7 -0
- package/dist/modules/customers/api/people/[id]/route.js +12 -4
- package/dist/modules/customers/api/people/[id]/route.js.map +2 -2
- package/dist/modules/customers/backend/customers/people-v2/[id]/page.js +10 -0
- package/dist/modules/customers/backend/customers/people-v2/[id]/page.js.map +2 -2
- package/dist/modules/customers/commands/deals.js +46 -5
- package/dist/modules/customers/commands/deals.js.map +2 -2
- package/dist/modules/customers/commands/interactions.js +16 -0
- package/dist/modules/customers/commands/interactions.js.map +2 -2
- package/dist/modules/customers/components/detail/ActivityCard.js +32 -0
- package/dist/modules/customers/components/detail/ActivityCard.js.map +2 -2
- package/dist/modules/customers/components/detail/ComposeEmailDialog.js +242 -0
- package/dist/modules/customers/components/detail/ComposeEmailDialog.js.map +7 -0
- package/dist/modules/customers/components/detail/DealForm.js +2 -1
- package/dist/modules/customers/components/detail/DealForm.js.map +2 -2
- package/dist/modules/customers/components/detail/DealsSection.js +10 -0
- package/dist/modules/customers/components/detail/DealsSection.js.map +2 -2
- package/dist/modules/customers/components/detail/EmailCardActions.js +179 -0
- package/dist/modules/customers/components/detail/EmailCardActions.js.map +7 -0
- package/dist/modules/customers/components/detail/EmailReplyForwardActions.js +52 -0
- package/dist/modules/customers/components/detail/EmailReplyForwardActions.js.map +7 -0
- package/dist/modules/customers/components/detail/PersonDetailTabs.js +7 -1
- package/dist/modules/customers/components/detail/PersonDetailTabs.js.map +2 -2
- package/dist/modules/customers/components/detail/PersonEmailThreadsTab.js +366 -0
- package/dist/modules/customers/components/detail/PersonEmailThreadsTab.js.map +7 -0
- package/dist/modules/customers/data/enrichers.js +133 -2
- package/dist/modules/customers/data/enrichers.js.map +2 -2
- package/dist/modules/customers/data/entities.js +18 -0
- package/dist/modules/customers/data/entities.js.map +2 -2
- package/dist/modules/customers/data/extensions.js +16 -0
- package/dist/modules/customers/data/extensions.js.map +7 -0
- package/dist/modules/customers/encryption.js +11 -0
- package/dist/modules/customers/encryption.js.map +2 -2
- package/dist/modules/customers/events.js +4 -1
- package/dist/modules/customers/events.js.map +2 -2
- package/dist/modules/customers/lib/findPeopleByAddresses.js +64 -0
- package/dist/modules/customers/lib/findPeopleByAddresses.js.map +7 -0
- package/dist/modules/customers/lib/kysely.js.map +2 -2
- package/dist/modules/customers/lib/link-channel-message-handler.js +303 -0
- package/dist/modules/customers/lib/link-channel-message-handler.js.map +7 -0
- package/dist/modules/customers/lib/personEmailThreads.js +205 -0
- package/dist/modules/customers/lib/personEmailThreads.js.map +7 -0
- package/dist/modules/customers/lib/visibilityFilter.js +51 -0
- package/dist/modules/customers/lib/visibilityFilter.js.map +7 -0
- package/dist/modules/customers/migrations/Migration20260527012240_customers.js +20 -0
- package/dist/modules/customers/migrations/Migration20260527012240_customers.js.map +7 -0
- package/dist/modules/customers/setup.js +2 -1
- package/dist/modules/customers/setup.js.map +2 -2
- package/dist/modules/customers/subscribers/link-channel-message-received.js +12 -0
- package/dist/modules/customers/subscribers/link-channel-message-received.js.map +7 -0
- package/dist/modules/customers/subscribers/link-channel-message-sent.js +12 -0
- package/dist/modules/customers/subscribers/link-channel-message-sent.js.map +7 -0
- package/dist/modules/integrations/data/entities.js +8 -1
- package/dist/modules/integrations/data/entities.js.map +2 -2
- package/dist/modules/integrations/lib/credentials-service.js +29 -14
- package/dist/modules/integrations/lib/credentials-service.js.map +2 -2
- package/dist/modules/integrations/migrations/Migration20260526154136_integrations.js +15 -0
- package/dist/modules/integrations/migrations/Migration20260526154136_integrations.js.map +7 -0
- package/dist/modules/messages/commands/messages.js +70 -8
- package/dist/modules/messages/commands/messages.js.map +2 -2
- package/dist/modules/messages/components/ComposeMessagePageClient.js +24 -13
- package/dist/modules/messages/components/ComposeMessagePageClient.js.map +2 -2
- package/dist/modules/messages/components/MessageDetailPageClient.js +39 -2
- package/dist/modules/messages/components/MessageDetailPageClient.js.map +2 -2
- package/dist/modules/messages/components/MessagesInboxPageClient.js +1 -0
- package/dist/modules/messages/components/MessagesInboxPageClient.js.map +2 -2
- package/dist/modules/messages/data/entities.js +8 -1
- package/dist/modules/messages/data/entities.js.map +2 -2
- package/dist/modules/messages/migrations/Migration20260531130000.js +15 -0
- package/dist/modules/messages/migrations/Migration20260531130000.js.map +7 -0
- package/dist/modules/messages/widgets/injection-table.js +7 -0
- package/dist/modules/messages/widgets/injection-table.js.map +7 -0
- package/generated/entities/channel_ingest_dead_letter/index.ts +11 -0
- package/generated/entities/channel_thread_mapping/index.ts +11 -0
- package/generated/entities/channel_thread_token/index.ts +7 -0
- package/generated/entities/communication_channel/index.ts +20 -0
- package/generated/entities/customer_interaction/index.ts +2 -0
- package/generated/entities/external_conversation/index.ts +11 -0
- package/generated/entities/external_message/index.ts +11 -0
- package/generated/entities/integration_credentials/index.ts +1 -0
- package/generated/entities/message/index.ts +1 -0
- package/generated/entities/message_channel_link/index.ts +15 -0
- package/generated/entities/message_reaction/index.ts +11 -0
- package/generated/entities.ids.generated.ts +11 -0
- package/generated/entity-fields-registry.ts +117 -0
- package/package.json +9 -7
- package/src/helpers/integration/authFixtures.ts +4 -1
- package/src/helpers/integration/communicationChannelsFixtures.ts +124 -0
- package/src/modules/communication_channels/acl.ts +43 -0
- package/src/modules/communication_channels/api/delete/channels/[id]/route.ts +163 -0
- package/src/modules/communication_channels/api/delete/messages/[messageId]/reactions/[reactionId]/route.ts +143 -0
- package/src/modules/communication_channels/api/get/channels/[id]/health/route.ts +173 -0
- package/src/modules/communication_channels/api/get/channels/[id]/route.ts +111 -0
- package/src/modules/communication_channels/api/get/channels/route.ts +109 -0
- package/src/modules/communication_channels/api/get/me/channels/route.ts +100 -0
- package/src/modules/communication_channels/api/get/oauth/[provider]/callback/route.ts +355 -0
- package/src/modules/communication_channels/api/post/channels/[id]/import-history/route.ts +206 -0
- package/src/modules/communication_channels/api/post/channels/[id]/poll-now/route.ts +174 -0
- package/src/modules/communication_channels/api/post/channels/[id]/push/register/route.ts +158 -0
- package/src/modules/communication_channels/api/post/channels/[id]/set-primary/route.ts +114 -0
- package/src/modules/communication_channels/api/post/channels/[id]/test-send/route.ts +241 -0
- package/src/modules/communication_channels/api/post/channels/connect/credentials/route.ts +134 -0
- package/src/modules/communication_channels/api/post/messages/[messageId]/reactions/route.ts +143 -0
- package/src/modules/communication_channels/api/post/oauth/[provider]/initiate/route.ts +192 -0
- package/src/modules/communication_channels/api/post/send-as-user/route.ts +125 -0
- package/src/modules/communication_channels/api/post/test-seed/route.ts +267 -0
- package/src/modules/communication_channels/api/post/webhook/[provider]/route.ts +227 -0
- package/src/modules/communication_channels/api/post/webhooks/gmail/route.ts +161 -0
- package/src/modules/communication_channels/api/put/threads/[threadId]/assign/route.ts +132 -0
- package/src/modules/communication_channels/backend/communication_channels/channels/[id]/page.meta.ts +34 -0
- package/src/modules/communication_channels/backend/communication_channels/channels/[id]/page.tsx +250 -0
- package/src/modules/communication_channels/backend/communication_channels/channels/page.meta.ts +36 -0
- package/src/modules/communication_channels/backend/communication_channels/channels/page.tsx +137 -0
- package/src/modules/communication_channels/backend/profile/communication-channels/page.meta.ts +36 -0
- package/src/modules/communication_channels/backend/profile/communication-channels/page.tsx +907 -0
- package/src/modules/communication_channels/commands/connect-credential-channel.ts +243 -0
- package/src/modules/communication_channels/commands/delete-channel.ts +193 -0
- package/src/modules/communication_channels/commands/deliver-outbound-message.ts +579 -0
- package/src/modules/communication_channels/commands/disconnect-channel.ts +241 -0
- package/src/modules/communication_channels/commands/ingest-inbound-message.ts +602 -0
- package/src/modules/communication_channels/commands/interceptors.ts +104 -0
- package/src/modules/communication_channels/commands/process-inbound-reaction.ts +265 -0
- package/src/modules/communication_channels/commands/push-register.ts +203 -0
- package/src/modules/communication_channels/commands/push-renew.ts +49 -0
- package/src/modules/communication_channels/commands/push-unregister.ts +168 -0
- package/src/modules/communication_channels/commands/queue-import-history.ts +180 -0
- package/src/modules/communication_channels/commands/reassign-conversation.ts +273 -0
- package/src/modules/communication_channels/commands/set-primary-channel.ts +154 -0
- package/src/modules/communication_channels/commands/toggle-outbound-reaction.ts +347 -0
- package/src/modules/communication_channels/data/enrichers.ts +413 -0
- package/src/modules/communication_channels/data/entities.ts +546 -0
- package/src/modules/communication_channels/data/extensions.ts +76 -0
- package/src/modules/communication_channels/data/validators.ts +138 -0
- package/src/modules/communication_channels/di.ts +40 -0
- package/src/modules/communication_channels/encryption.ts +44 -0
- package/src/modules/communication_channels/events.ts +122 -0
- package/src/modules/communication_channels/i18n/de.json +138 -0
- package/src/modules/communication_channels/i18n/en.json +138 -0
- package/src/modules/communication_channels/i18n/es.json +138 -0
- package/src/modules/communication_channels/i18n/pl.json +138 -0
- package/src/modules/communication_channels/index.ts +19 -0
- package/src/modules/communication_channels/lib/access-control.ts +110 -0
- package/src/modules/communication_channels/lib/adapter-compat.ts +57 -0
- package/src/modules/communication_channels/lib/adapter-registry-singleton.ts +35 -0
- package/src/modules/communication_channels/lib/adapter.ts +605 -0
- package/src/modules/communication_channels/lib/connect-channel.ts +163 -0
- package/src/modules/communication_channels/lib/contact-resolver.ts +162 -0
- package/src/modules/communication_channels/lib/credential-refresh.ts +197 -0
- package/src/modules/communication_channels/lib/dead-letter.ts +87 -0
- package/src/modules/communication_channels/lib/email-capabilities.ts +60 -0
- package/src/modules/communication_channels/lib/email-contact.ts +17 -0
- package/src/modules/communication_channels/lib/email-mime.ts +425 -0
- package/src/modules/communication_channels/lib/error-classification.ts +144 -0
- package/src/modules/communication_channels/lib/gmail-pubsub-jwt.ts +278 -0
- package/src/modules/communication_channels/lib/mutation-guards.ts +215 -0
- package/src/modules/communication_channels/lib/oauth-client-config.ts +79 -0
- package/src/modules/communication_channels/lib/oauth-state.ts +228 -0
- package/src/modules/communication_channels/lib/oauth-token.ts +81 -0
- package/src/modules/communication_channels/lib/pg-errors.ts +12 -0
- package/src/modules/communication_channels/lib/provider-health.ts +47 -0
- package/src/modules/communication_channels/lib/push-state.ts +38 -0
- package/src/modules/communication_channels/lib/queue.ts +66 -0
- package/src/modules/communication_channels/lib/reaction-processor-types.ts +51 -0
- package/src/modules/communication_channels/lib/reaction-semantics.ts +48 -0
- package/src/modules/communication_channels/lib/registry.ts +99 -0
- package/src/modules/communication_channels/lib/route-mutation-guard.ts +68 -0
- package/src/modules/communication_channels/lib/sanitize-channel-html.ts +129 -0
- package/src/modules/communication_channels/lib/send-as-user.ts +284 -0
- package/src/modules/communication_channels/lib/system-user.ts +74 -0
- package/src/modules/communication_channels/lib/test-seed.ts +140 -0
- package/src/modules/communication_channels/lib/thread-matcher.ts +430 -0
- package/src/modules/communication_channels/lib/thread-token.ts +355 -0
- package/src/modules/communication_channels/lib/use-connect-channel.ts +73 -0
- package/src/modules/communication_channels/migrations/.snapshot-open-mercato.json +2142 -0
- package/src/modules/communication_channels/migrations/Migration20260526134719_communication_channels.ts +55 -0
- package/src/modules/communication_channels/migrations/Migration20260527195446_communication_channels.ts +20 -0
- package/src/modules/communication_channels/migrations/Migration20260529231848_communication_channels.ts +13 -0
- package/src/modules/communication_channels/migrations/Migration20260531120000_communication_channels.ts +24 -0
- package/src/modules/communication_channels/notifications.client.ts +50 -0
- package/src/modules/communication_channels/notifications.handlers.ts +86 -0
- package/src/modules/communication_channels/notifications.ts +52 -0
- package/src/modules/communication_channels/setup.ts +158 -0
- package/src/modules/communication_channels/subscribers/channel-requires-reauth-notification.ts +118 -0
- package/src/modules/communication_channels/subscribers/outbound-bridge.ts +175 -0
- package/src/modules/communication_channels/subscribers/user-deleted-cascade.ts +100 -0
- package/src/modules/communication_channels/widgets/components.ts +36 -0
- package/src/modules/communication_channels/widgets/injection/channel-badge/widget.client.tsx +38 -0
- package/src/modules/communication_channels/widgets/injection/channel-badge/widget.ts +51 -0
- package/src/modules/communication_channels/widgets/injection/channel-info-panel/widget.client.tsx +278 -0
- package/src/modules/communication_channels/widgets/injection/channel-info-panel/widget.ts +24 -0
- package/src/modules/communication_channels/widgets/injection/channel-payload-renderer/widget.client.tsx +63 -0
- package/src/modules/communication_channels/widgets/injection/channel-payload-renderer/widget.ts +29 -0
- package/src/modules/communication_channels/widgets/injection/profile-channels-menu/widget.ts +34 -0
- package/src/modules/communication_channels/widgets/injection/reaction-bar/widget.client.tsx +177 -0
- package/src/modules/communication_channels/widgets/injection/reaction-bar/widget.ts +26 -0
- package/src/modules/communication_channels/widgets/injection-table.ts +47 -0
- package/src/modules/communication_channels/widgets/notifications/ChannelRequiresReauthRenderer.tsx +48 -0
- package/src/modules/communication_channels/widgets/notifications/MessageReceivedRenderer.tsx +45 -0
- package/src/modules/communication_channels/widgets/notifications/index.ts +2 -0
- package/src/modules/communication_channels/workers/channel-import-history.ts +252 -0
- package/src/modules/communication_channels/workers/gmail-history-sync.ts +223 -0
- package/src/modules/communication_channels/workers/gmail-renew-watch.ts +141 -0
- package/src/modules/communication_channels/workers/inbound-processor.ts +114 -0
- package/src/modules/communication_channels/workers/outbound-delivery.ts +155 -0
- package/src/modules/communication_channels/workers/poll-channel.ts +391 -0
- package/src/modules/communication_channels/workers/poll-tick.ts +210 -0
- package/src/modules/communication_channels/workers/reaction-processor.ts +264 -0
- package/src/modules/customers/acl.ts +18 -0
- package/src/modules/customers/api/activities/route.ts +13 -0
- package/src/modules/customers/api/companies/[id]/route.ts +21 -1
- package/src/modules/customers/api/interactions/[id]/visibility/route.ts +179 -0
- package/src/modules/customers/api/interactions/counts/route.ts +10 -0
- package/src/modules/customers/api/interactions/route.ts +51 -5
- package/src/modules/customers/api/people/[id]/email-threads/route.ts +92 -0
- package/src/modules/customers/api/people/[id]/emails/route.ts +184 -0
- package/src/modules/customers/api/people/[id]/route.ts +17 -2
- package/src/modules/customers/backend/customers/people-v2/[id]/page.tsx +11 -1
- package/src/modules/customers/commands/deals.ts +65 -6
- package/src/modules/customers/commands/interactions.ts +30 -0
- package/src/modules/customers/components/detail/ActivityCard.tsx +48 -0
- package/src/modules/customers/components/detail/ComposeEmailDialog.tsx +329 -0
- package/src/modules/customers/components/detail/DealForm.tsx +2 -1
- package/src/modules/customers/components/detail/DealsSection.tsx +26 -0
- package/src/modules/customers/components/detail/EmailCardActions.tsx +258 -0
- package/src/modules/customers/components/detail/EmailReplyForwardActions.tsx +53 -0
- package/src/modules/customers/components/detail/PersonDetailTabs.tsx +8 -1
- package/src/modules/customers/components/detail/PersonEmailThreadsTab.tsx +448 -0
- package/src/modules/customers/data/enrichers.ts +252 -1
- package/src/modules/customers/data/entities.ts +46 -1
- package/src/modules/customers/data/extensions.ts +26 -0
- package/src/modules/customers/encryption.ts +11 -0
- package/src/modules/customers/events.ts +4 -0
- package/src/modules/customers/i18n/de.json +41 -0
- package/src/modules/customers/i18n/en.json +41 -0
- package/src/modules/customers/i18n/es.json +41 -0
- package/src/modules/customers/i18n/pl.json +41 -0
- package/src/modules/customers/lib/findPeopleByAddresses.ts +107 -0
- package/src/modules/customers/lib/kysely.ts +16 -0
- package/src/modules/customers/lib/link-channel-message-handler.ts +571 -0
- package/src/modules/customers/lib/personEmailThreads.ts +325 -0
- package/src/modules/customers/lib/visibilityFilter.ts +152 -0
- package/src/modules/customers/migrations/.snapshot-open-mercato.json +61 -0
- package/src/modules/customers/migrations/Migration20260527012240_customers.ts +23 -0
- package/src/modules/customers/setup.ts +1 -0
- package/src/modules/customers/subscribers/link-channel-message-received.ts +21 -0
- package/src/modules/customers/subscribers/link-channel-message-sent.ts +21 -0
- package/src/modules/integrations/AGENTS.md +9 -0
- package/src/modules/integrations/data/entities.ts +21 -1
- package/src/modules/integrations/lib/credentials-service.ts +49 -13
- package/src/modules/integrations/migrations/.snapshot-open-mercato.json +26 -1
- package/src/modules/integrations/migrations/Migration20260526154136_integrations.ts +15 -0
- package/src/modules/messages/commands/messages.ts +101 -8
- package/src/modules/messages/components/ComposeMessagePageClient.tsx +17 -0
- package/src/modules/messages/components/MessageDetailPageClient.tsx +43 -0
- package/src/modules/messages/components/MessagesInboxPageClient.tsx +4 -0
- package/src/modules/messages/data/entities.ts +11 -0
- package/src/modules/messages/migrations/.snapshot-open-mercato.json +18 -0
- package/src/modules/messages/migrations/Migration20260531130000.ts +15 -0
- package/src/modules/messages/widgets/injection-table.ts +29 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/modules/customers/components/detail/DealsSection.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { Link2, Pencil, Plus } from 'lucide-react'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { createCrud, updateCrud } from '@open-mercato/ui/backend/utils/crud'\nimport { LinkEntityDialog } from '../linking/LinkEntityDialog'\nimport { createDealLinkAdapter } from '../linking/adapters/dealAdapter'\nimport { LoadingMessage, TabEmptyState } from '@open-mercato/ui/backend/detail'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { E } from '#generated/entities.ids.generated'\nimport type { DealCustomFieldEntry, DealSummary, SectionAction, TabEmptyStateConfig, Translator } from './types'\nimport { createTranslatorWithFallback } from '@open-mercato/shared/lib/i18n/translate'\nimport { formatDate } from './utils'\nimport { DealDialog } from './DealDialog'\nimport type { DealFormBaseValues, DealFormSubmitPayload } from './DealForm'\nimport { generateTempId } from '@open-mercato/core/modules/customers/lib/detailHelpers'\nimport { useCurrencyDictionary } from './hooks/useCurrencyDictionary'\nimport { useCustomerDictionary } from './hooks/useCustomerDictionary'\nimport { CustomFieldValuesList } from './CustomFieldValuesList'\nimport { useCustomFieldDisplay } from './hooks/useCustomFieldDisplay'\nimport { normalizeCustomFieldKey } from './customFieldUtils'\n\nconst DEALS_PAGE_SIZE = 10\n\ntype DealsScope =\n | { kind: 'person'; entityId: string }\n | { kind: 'company'; entityId: string }\n\ntype GuardedMutationRunner = <T,>(\n operation: () => Promise<T>,\n mutationPayload?: Record<string, unknown>,\n) => Promise<T>\n\ntype PendingAction =\n | { kind: 'create' }\n | { kind: 'update'; id: string }\n | { kind: 'remove'; id: string }\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction sanitizeCustomValues(input: unknown): Record<string, unknown> | null {\n if (!isPlainObject(input)) return null\n const result: Record<string, unknown> = {}\n Object.entries(input).forEach(([key, value]) => {\n const trimmedKey = key.trim()\n if (!trimmedKey.length) return\n result[trimmedKey] = value\n })\n return Object.keys(result).length ? result : null\n}\n\nfunction sanitizeCustomFieldEntries(\n entries: unknown,\n values: Record<string, unknown> | null,\n): DealCustomFieldEntry[] {\n const map = new Map<string, DealCustomFieldEntry>()\n if (Array.isArray(entries)) {\n entries.forEach((entry) => {\n if (!entry || typeof entry !== 'object') return\n const record = entry as Record<string, unknown>\n const keyRaw =\n typeof record.key === 'string'\n ? record.key\n : typeof record.id === 'string'\n ? record.id\n : null\n if (!keyRaw) return\n const key = keyRaw.trim()\n if (!key.length) return\n const normalizedKey = normalizeCustomFieldKey(key)\n if (!normalizedKey) return\n const label =\n typeof record.label === 'string' && record.label.trim().length\n ? record.label.trim()\n : null\n const kind =\n typeof record.kind === 'string' && record.kind.trim().length\n ? record.kind.trim()\n : null\n const multi =\n typeof record.multi === 'boolean' ? record.multi : Array.isArray(record.value) ? true : undefined\n map.set(normalizedKey, {\n key,\n label,\n value: record.value,\n kind,\n multi,\n })\n })\n }\n\n if (values) {\n Object.entries(values).forEach(([rawKey, value]) => {\n const key = rawKey.trim()\n if (!key.length) return\n const normalizedKey = normalizeCustomFieldKey(key)\n if (!normalizedKey) return\n const existing = map.get(normalizedKey)\n if (existing) {\n existing.value = value\n if (existing.multi === undefined) existing.multi = Array.isArray(value)\n } else {\n map.set(normalizedKey, {\n key,\n label: null,\n value,\n kind: null,\n multi: Array.isArray(value) ? true : undefined,\n })\n }\n })\n }\n\n return Array.from(map.values())\n}\n\ntype NormalizedDeal = Omit<\n DealSummary,\n 'valueAmount' | 'probability' | 'expectedCloseAt' | 'customValues' | 'customFields' | 'personIds' | 'companyIds'\n> & {\n valueAmount: number | null\n probability: number | null\n expectedCloseAt: string | null\n personIds: string[]\n companyIds: string[]\n customValues: Record<string, unknown> | null\n customFields: DealCustomFieldEntry[]\n}\n\nfunction toNumber(value: unknown): number | null {\n if (typeof value === 'number' && Number.isFinite(value)) return value\n if (typeof value === 'string') {\n const trimmed = value.trim()\n if (!trimmed.length) return null\n const parsed = Number(trimmed)\n return Number.isNaN(parsed) ? null : parsed\n }\n return null\n}\n\nfunction toIso(value: unknown): string | null {\n if (typeof value === 'string') {\n const trimmed = value.trim()\n if (!trimmed.length) return null\n const parsed = new Date(trimmed)\n return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString()\n }\n if (value instanceof Date) {\n return Number.isNaN(value.getTime()) ? null : value.toISOString()\n }\n return null\n}\n\nfunction mergeIds(...sources: Array<unknown>): string[] {\n const set = new Set<string>()\n sources.forEach((source) => {\n if (Array.isArray(source)) {\n source.forEach((value) => {\n if (typeof value !== 'string') return\n const trimmed = value.trim()\n if (!trimmed.length) return\n set.add(trimmed)\n })\n }\n })\n return Array.from(set)\n}\n\nfunction normalizeDeal(deal: Partial<DealSummary> & { id: string; title?: string }): NormalizedDeal {\n const title = typeof deal.title === 'string' && deal.title.trim().length ? deal.title.trim() : ''\n const normalizeIdList = (list: unknown): string[] => {\n if (!Array.isArray(list)) return []\n const seen = new Set<string>()\n const result: string[] = []\n list.forEach((candidate) => {\n if (typeof candidate !== 'string') return\n const trimmed = candidate.trim()\n if (!trimmed.length || seen.has(trimmed)) return\n seen.add(trimmed)\n result.push(trimmed)\n })\n return result\n }\n\n const normalizeAssignees = (entries: unknown, fallbackIds: string[]): { id: string; label: string }[] => {\n if (!Array.isArray(entries)) {\n return fallbackIds.map((id) => ({ id, label: '' }))\n }\n const seen = new Set<string>()\n const resolved: { id: string; label: string }[] = []\n entries.forEach((entry) => {\n if (!entry || typeof entry !== 'object') return\n const data = entry as Record<string, unknown>\n const id = typeof data.id === 'string' ? data.id.trim() : ''\n if (!id || seen.has(id)) return\n const label = typeof data.label === 'string' ? data.label : ''\n seen.add(id)\n resolved.push({ id, label })\n })\n if (!resolved.length && fallbackIds.length) {\n return fallbackIds.map((id) => ({ id, label: '' }))\n }\n return resolved\n }\n\n const personIds = normalizeIdList(deal.personIds ?? null)\n const companyIds = normalizeIdList(deal.companyIds ?? null)\n const people = normalizeAssignees(deal.people ?? null, personIds)\n const companies = normalizeAssignees(deal.companies ?? null, companyIds)\n\n const customValues = sanitizeCustomValues(deal.customValues ?? null)\n const customFields = sanitizeCustomFieldEntries(deal.customFields ?? null, customValues)\n\n return {\n id: deal.id,\n title,\n status: typeof deal.status === 'string' ? deal.status : deal.status ?? null,\n pipelineStage:\n typeof deal.pipelineStage === 'string' ? deal.pipelineStage : deal.pipelineStage ?? null,\n valueAmount: toNumber(deal.valueAmount ?? null),\n valueCurrency:\n typeof deal.valueCurrency === 'string' && deal.valueCurrency.trim().length\n ? deal.valueCurrency.trim().toUpperCase()\n : null,\n probability: toNumber(deal.probability ?? null),\n expectedCloseAt: toIso(deal.expectedCloseAt ?? null),\n description:\n typeof deal.description === 'string' && deal.description.trim().length\n ? deal.description\n : deal.description ?? null,\n ownerUserId:\n typeof deal.ownerUserId === 'string' && deal.ownerUserId.trim().length\n ? deal.ownerUserId\n : deal.ownerUserId ?? null,\n source:\n typeof deal.source === 'string' && deal.source.trim().length ? deal.source : deal.source ?? null,\n closureOutcome:\n typeof deal.closureOutcome === 'string' && deal.closureOutcome.trim().length\n ? deal.closureOutcome\n : deal.closureOutcome ?? null,\n lossReasonId:\n typeof deal.lossReasonId === 'string' && deal.lossReasonId.trim().length\n ? deal.lossReasonId\n : deal.lossReasonId ?? null,\n lossNotes:\n typeof deal.lossNotes === 'string' && deal.lossNotes.trim().length\n ? deal.lossNotes\n : deal.lossNotes ?? null,\n createdAt: toIso(deal.createdAt ?? null),\n updatedAt: toIso(deal.updatedAt ?? null),\n personIds,\n companyIds,\n people,\n companies,\n customValues,\n customFields,\n }\n}\n\nfunction formatValueLabel(amount: number | null, currency: string | null, emptyLabel: string): string {\n if (typeof amount === 'number') {\n const formatter = new Intl.NumberFormat(undefined, {\n style: currency ? 'currency' : 'decimal',\n currency: currency ?? undefined,\n maximumFractionDigits: 2,\n })\n try {\n return formatter.format(amount)\n } catch {\n return currency ? `${amount} ${currency}` : `${amount}`\n }\n }\n return emptyLabel\n}\n\nexport type DealsSectionProps = {\n scope: DealsScope | null\n addActionLabel: string\n emptyLabel: string\n emptyState: TabEmptyStateConfig\n onCountDelta?: (delta: number) => void\n onActionChange?: (action: SectionAction | null) => void\n onLoadingChange?: (isLoading: boolean) => void\n onDataRefresh?: () => Promise<void> | void\n translator?: Translator\n runGuardedMutation?: GuardedMutationRunner\n}\n\nexport function DealsSection({\n scope,\n addActionLabel,\n emptyLabel,\n emptyState,\n onCountDelta,\n onActionChange,\n onLoadingChange,\n onDataRefresh,\n translator,\n runGuardedMutation,\n}: DealsSectionProps) {\n const tHook = useT()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const fallbackTranslator = React.useMemo<Translator>(() => createTranslatorWithFallback(tHook), [tHook])\n const t: Translator = React.useMemo(() => translator ?? fallbackTranslator, [translator, fallbackTranslator])\n useCurrencyDictionary()\n const scopeVersion = useOrganizationScopeVersion()\n const statusDictionaryQuery = useCustomerDictionary('deal-statuses', scopeVersion)\n const statusDictionaryMap = statusDictionaryQuery.data?.map ?? null\n const customFieldResources = useCustomFieldDisplay(E.customers.customer_deal)\n\n const [deals, setDeals] = React.useState<NormalizedDeal[]>([])\n const [isLoading, setIsLoading] = React.useState<boolean>(() => Boolean(scope))\n const [loadError, setLoadError] = React.useState<string | null>(null)\n const [pendingAction, setPendingAction] = React.useState<PendingAction | null>(null)\n const [hasMore, setHasMore] = React.useState(false)\n const pageRef = React.useRef(0)\n const hasMoreRef = React.useRef(true)\n const [dialogOpen, setDialogOpen] = React.useState(false)\n const [initialValues, setInitialValues] = React.useState<\n Partial<DealFormBaseValues & Record<string, unknown>> | undefined\n >(undefined)\n const pendingCounterRef = React.useRef(0)\n\n const pushLoading = React.useCallback(() => {\n pendingCounterRef.current += 1\n if (pendingCounterRef.current === 1) onLoadingChange?.(true)\n }, [onLoadingChange])\n\n const popLoading = React.useCallback(() => {\n pendingCounterRef.current = Math.max(0, pendingCounterRef.current - 1)\n if (pendingCounterRef.current === 0) onLoadingChange?.(false)\n }, [onLoadingChange])\n\n const translate = React.useCallback(\n (key: string, fallback: string, params?: Record<string, string | number>) => {\n const value = t(key, fallback, params)\n return value === key && fallback ? fallback : value\n },\n [t],\n )\n const runWriteMutation = React.useCallback(\n async <T,>(operation: () => Promise<T>, mutationPayload?: Record<string, unknown>): Promise<T> => {\n if (!runGuardedMutation) {\n return operation()\n }\n return runGuardedMutation(operation, mutationPayload)\n },\n [runGuardedMutation],\n )\n const refreshParentData = React.useCallback(async () => {\n await Promise.resolve(onDataRefresh?.())\n }, [onDataRefresh])\n\n const loadDeals = React.useCallback(async ({ append }: { append: boolean }) => {\n if (!scope) {\n setDeals([])\n setLoadError(null)\n setHasMore(false)\n setIsLoading(false)\n pendingCounterRef.current = 0\n onLoadingChange?.(false)\n pageRef.current = 0\n hasMoreRef.current = false\n return\n }\n if (append && !hasMoreRef.current) return\n const nextPage = append ? pageRef.current + 1 : 1\n if (!append) {\n pageRef.current = 0\n hasMoreRef.current = true\n setHasMore(true)\n setDeals([])\n }\n pushLoading()\n setIsLoading(true)\n try {\n const params = new URLSearchParams({\n page: String(nextPage),\n pageSize: String(DEALS_PAGE_SIZE),\n sortField: 'updatedAt',\n sortDir: 'desc',\n })\n if (scope.kind === 'person') params.set('personEntityId', scope.entityId)\n if (scope.kind === 'company') params.set('companyEntityId', scope.entityId)\n const payload = await readApiResultOrThrow<Record<string, unknown>>(\n `/api/customers/deals?${params.toString()}`,\n undefined,\n { errorMessage: translate('customers.people.detail.deals.loadError', 'Failed to load deals.') },\n )\n const rawItems = Array.isArray(payload?.items) ? payload.items : []\n const mapped: NormalizedDeal[] = rawItems.map((item: unknown) => {\n const record = (item && typeof item === 'object') ? (item as Record<string, unknown>) : {}\n const id =\n typeof record.id === 'string' && record.id.trim().length ? record.id : generateTempId()\n const title =\n typeof record.title === 'string' && record.title.trim().length ? record.title.trim() : ''\n const status =\n typeof record.status === 'string' && record.status.trim().length\n ? record.status.trim()\n : null\n const pipelineStage =\n typeof record.pipelineStage === 'string' && record.pipelineStage.trim().length\n ? record.pipelineStage.trim()\n : typeof record.pipeline_stage === 'string' && record.pipeline_stage.trim().length\n ? record.pipeline_stage.trim()\n : null\n const valueAmount = toNumber(record.valueAmount ?? record.value_amount)\n const valueCurrencyRaw = record.valueCurrency ?? record.value_currency ?? null\n const valueCurrency =\n typeof valueCurrencyRaw === 'string' && valueCurrencyRaw.trim().length\n ? valueCurrencyRaw.trim().toUpperCase()\n : null\n const probability = toNumber(record.probability)\n const expectedCloseAt =\n typeof record.expectedCloseAt === 'string' && record.expectedCloseAt.trim().length\n ? record.expectedCloseAt\n : typeof record.expected_close_at === 'string' && record.expected_close_at.trim().length\n ? record.expected_close_at\n : null\n const description =\n typeof record.description === 'string' && record.description.trim().length\n ? record.description\n : null\n const ownerUserId =\n typeof record.ownerUserId === 'string' && record.ownerUserId.trim().length\n ? record.ownerUserId\n : typeof record.owner_user_id === 'string' && record.owner_user_id.trim().length\n ? record.owner_user_id\n : null\n const source =\n typeof record.source === 'string' && record.source.trim().length\n ? record.source\n : null\n const closureOutcome =\n typeof record.closureOutcome === 'string' && record.closureOutcome.trim().length\n ? record.closureOutcome\n : typeof record.closure_outcome === 'string' && record.closure_outcome.trim().length\n ? record.closure_outcome\n : null\n const lossReasonId =\n typeof record.lossReasonId === 'string' && record.lossReasonId.trim().length\n ? record.lossReasonId\n : typeof record.loss_reason_id === 'string' && record.loss_reason_id.trim().length\n ? record.loss_reason_id\n : null\n const lossNotes =\n typeof record.lossNotes === 'string' && record.lossNotes.trim().length\n ? record.lossNotes\n : typeof record.loss_notes === 'string' && record.loss_notes.trim().length\n ? record.loss_notes\n : null\n const createdAt =\n typeof record.createdAt === 'string' && record.createdAt.trim().length\n ? record.createdAt\n : typeof record.created_at === 'string' && record.created_at.trim().length\n ? record.created_at\n : null\n const updatedAt =\n typeof record.updatedAt === 'string' && record.updatedAt.trim().length\n ? record.updatedAt\n : typeof record.updated_at === 'string' && record.updated_at.trim().length\n ? record.updated_at\n : null\n const personIds = Array.isArray(record.personIds)\n ? record.personIds\n : Array.isArray(record.person_ids)\n ? record.person_ids\n : []\n const people = Array.isArray(record.people) ? record.people : []\n const companyIds = Array.isArray(record.companyIds)\n ? record.companyIds\n : Array.isArray(record.company_ids)\n ? record.company_ids\n : []\n const companies = Array.isArray(record.companies) ? record.companies : []\n const customValues = sanitizeCustomValues(\n record.customValues ?? record.custom_values ?? null,\n )\n const customFieldEntries = sanitizeCustomFieldEntries(\n record.customFields ?? record.custom_fields ?? null,\n customValues,\n )\n return normalizeDeal({\n id,\n title,\n status,\n pipelineStage,\n valueAmount,\n valueCurrency,\n probability,\n expectedCloseAt,\n description,\n ownerUserId,\n source,\n closureOutcome,\n lossReasonId,\n lossNotes,\n createdAt,\n updatedAt,\n personIds: personIds as string[] | undefined,\n people: people as { id: string; label: string }[] | undefined,\n companyIds: companyIds as string[] | undefined,\n companies: companies as { id: string; label: string }[] | undefined,\n customValues,\n customFields: customFieldEntries,\n })\n })\n setDeals((prev) => {\n if (!append) return mapped\n const mappedById = new Map(mapped.map((deal) => [deal.id, deal]))\n const prevIds = new Set(prev.map((deal) => deal.id))\n const updatedPrev = prev.map((deal) => mappedById.get(deal.id) ?? deal)\n const appended = mapped.filter((deal) => !prevIds.has(deal.id))\n return [...updatedPrev, ...appended]\n })\n pageRef.current = nextPage\n const totalPagesRaw = payload?.totalPages\n const totalPages =\n typeof totalPagesRaw === 'number'\n ? totalPagesRaw\n : typeof totalPagesRaw === 'string' && totalPagesRaw.trim().length\n ? Number(totalPagesRaw)\n : null\n const nextHasMore =\n totalPages && Number.isFinite(totalPages)\n ? nextPage < totalPages\n : mapped.length === DEALS_PAGE_SIZE\n hasMoreRef.current = nextHasMore\n setHasMore(nextHasMore)\n setLoadError(null)\n } catch (err) {\n const message =\n err instanceof Error\n ? err.message\n : translate('customers.people.detail.deals.loadError', 'Failed to load deals.')\n setLoadError(message)\n if (!append) {\n setHasMore(false)\n hasMoreRef.current = false\n }\n } finally {\n setIsLoading(false)\n popLoading()\n }\n }, [popLoading, pushLoading, scope, translate])\n\n React.useEffect(() => {\n loadDeals({ append: false }).catch(() => {})\n }, [loadDeals, scope])\n\n const openCreateDialog = React.useCallback(() => {\n if (!scope) return\n setInitialValues({\n personIds: scope.kind === 'person' ? [scope.entityId] : [],\n companyIds: scope.kind === 'company' ? [scope.entityId] : [],\n })\n setDialogOpen(true)\n }, [scope])\n\n const [linkDialogOpen, setLinkDialogOpen] = React.useState(false)\n const openLinkDialog = React.useCallback(() => {\n if (!scope) return\n setLinkDialogOpen(true)\n }, [scope])\n\n const existingDealIds = React.useMemo(() => deals.map((deal) => deal.id), [deals])\n\n const dealLinkAdapter = React.useMemo(\n () =>\n createDealLinkAdapter({\n dialogTitle: t('customers.linking.deal.dialogTitle', 'Link deal'),\n dialogSubtitle: t(\n 'customers.linking.deal.dialogSubtitle',\n 'Link an existing deal to this record',\n ),\n sectionLabel: t('customers.linking.deal.sectionLabel', 'MATCHING DEALS'),\n searchPlaceholder: t('customers.linking.deal.searchPlaceholder', 'Search all deals\u2026'),\n searchEmptyHint: t('customers.linking.deal.searchEmpty', 'No matching deals found.'),\n selectedEmptyHint: t('customers.linking.deal.selectedEmpty', 'No deals selected.'),\n confirmButtonLabel: t('customers.linking.deal.confirmButton', 'Link deal'),\n orphanWarningTitle: t('customers.linking.deal.orphanWarningTitle', 'Deal without company'),\n orphanWarningMessage: t(\n 'customers.linking.deal.orphanWarning',\n 'This deal has no other linked entities. If you unlink it later, it will become unreachable.',\n ),\n contextEntityId: scope?.entityId,\n }),\n [scope?.entityId, t],\n )\n\n const handleLinkConfirm = React.useCallback(\n async ({\n addedIds,\n removedIds,\n }: {\n addedIds: string[]\n removedIds: string[]\n }) => {\n if (!scope) return\n if (!addedIds.length && !removedIds.length) return\n pushLoading()\n try {\n for (const dealId of addedIds) {\n const payload = await readApiResultOrThrow<Record<string, unknown>>(\n `/api/customers/deals/${encodeURIComponent(dealId)}`,\n )\n const currentPersonIds = Array.isArray(payload.personIds)\n ? (payload.personIds as string[]).filter((id) => typeof id === 'string')\n : []\n const currentCompanyIds = Array.isArray(payload.companyIds)\n ? (payload.companyIds as string[]).filter((id) => typeof id === 'string')\n : []\n const nextPersonIds =\n scope.kind === 'person' && !currentPersonIds.includes(scope.entityId)\n ? [...currentPersonIds, scope.entityId]\n : currentPersonIds\n const nextCompanyIds =\n scope.kind === 'company' && !currentCompanyIds.includes(scope.entityId)\n ? [...currentCompanyIds, scope.entityId]\n : currentCompanyIds\n await runWriteMutation(\n () =>\n updateCrud(\n 'customers/deals',\n { id: dealId, personIds: nextPersonIds, companyIds: nextCompanyIds },\n {\n errorMessage: t(\n 'customers.people.detail.deals.linkError',\n 'Failed to link deal.',\n ),\n },\n ),\n { dealId, scopeKind: scope.kind, scopeEntityId: scope.entityId, operation: 'linkDeal' },\n )\n }\n for (const dealId of removedIds) {\n const payload = await readApiResultOrThrow<Record<string, unknown>>(\n `/api/customers/deals/${encodeURIComponent(dealId)}`,\n )\n const currentPersonIds = Array.isArray(payload.personIds)\n ? (payload.personIds as string[]).filter((id) => typeof id === 'string')\n : []\n const currentCompanyIds = Array.isArray(payload.companyIds)\n ? (payload.companyIds as string[]).filter((id) => typeof id === 'string')\n : []\n const nextPersonIds =\n scope.kind === 'person'\n ? currentPersonIds.filter((id) => id !== scope.entityId)\n : currentPersonIds\n const nextCompanyIds =\n scope.kind === 'company'\n ? currentCompanyIds.filter((id) => id !== scope.entityId)\n : currentCompanyIds\n await runWriteMutation(\n () =>\n updateCrud(\n 'customers/deals',\n { id: dealId, personIds: nextPersonIds, companyIds: nextCompanyIds },\n {\n errorMessage: t(\n 'customers.people.detail.deals.unlinkError',\n 'Failed to unlink deal.',\n ),\n },\n ),\n { dealId, scopeKind: scope.kind, scopeEntityId: scope.entityId, operation: 'unlinkDeal' },\n )\n }\n await loadDeals({ append: false })\n await refreshParentData()\n if (addedIds.length + removedIds.length > 0) {\n onCountDelta?.(addedIds.length - removedIds.length)\n }\n flash(\n addedIds.length > 0\n ? t('customers.people.detail.deals.linkSuccess', 'Deal linked.')\n : t('customers.people.detail.deals.unlinkSuccess', 'Deal unlinked.'),\n 'success',\n )\n } catch (error) {\n const message =\n error instanceof Error\n ? error.message\n : t('customers.people.detail.deals.linkError', 'Failed to link deal.')\n flash(message, 'error')\n } finally {\n popLoading()\n }\n },\n [loadDeals, onCountDelta, popLoading, pushLoading, refreshParentData, runWriteMutation, scope, t],\n )\n\n const closeDialog = React.useCallback(() => {\n setDialogOpen(false)\n setInitialValues(undefined)\n }, [])\n\n const handleDialogOpenChange = React.useCallback(\n (next: boolean) => {\n if (!next) closeDialog()\n else setDialogOpen(true)\n },\n [closeDialog],\n )\n\n const handleCreate = React.useCallback(\n async ({ base, custom }: DealFormSubmitPayload) => {\n if (!scope) {\n throw new Error(translate('customers.people.detail.deals.error', 'Failed to save deal.'))\n }\n setPendingAction({ kind: 'create' })\n pushLoading()\n try {\n const personIds = mergeIds(base.personIds)\n const companyIds = mergeIds(base.companyIds)\n\n const payload: Record<string, unknown> = {\n title: base.title,\n status: base.status ?? undefined,\n pipelineStage: base.pipelineStage ?? undefined,\n valueAmount: typeof base.valueAmount === 'number' ? base.valueAmount : undefined,\n valueCurrency: base.valueCurrency ?? undefined,\n probability: typeof base.probability === 'number' ? base.probability : undefined,\n expectedCloseAt: base.expectedCloseAt ?? undefined,\n description: base.description ?? undefined,\n personIds,\n companyIds,\n }\n if (Object.keys(custom).length) payload.customFields = custom\n const { result } = await runWriteMutation(\n () =>\n createCrud<{ id?: string }>('customers/deals', payload, {\n errorMessage: translate('customers.people.detail.deals.error', 'Failed to save deal.'),\n }),\n {\n ...payload,\n operation: 'createDeal',\n },\n )\n const dealId =\n typeof result?.id === 'string' && result.id.trim().length ? result.id : generateTempId()\n const belongsToScope =\n (scope.kind !== 'person' || personIds.includes(scope.entityId)) &&\n (scope.kind !== 'company' || companyIds.includes(scope.entityId))\n if (belongsToScope) {\n const customValuesForState = sanitizeCustomValues(\n Object.keys(custom).length ? custom : null,\n )\n const timestamp = new Date().toISOString()\n const normalized = normalizeDeal({\n id: dealId,\n title: base.title,\n status: base.status ?? null,\n pipelineStage: base.pipelineStage ?? null,\n valueAmount: base.valueAmount ?? null,\n valueCurrency: base.valueCurrency ?? null,\n probability: base.probability ?? null,\n expectedCloseAt: base.expectedCloseAt ?? null,\n description: base.description ?? null,\n personIds,\n companyIds,\n customValues: customValuesForState,\n createdAt: timestamp,\n updatedAt: timestamp,\n })\n setDeals((prev) => [normalized, ...prev])\n onCountDelta?.(1)\n }\n await refreshParentData()\n flash(translate('customers.people.detail.deals.success', 'Deal created.'), 'success')\n } finally {\n setPendingAction(null)\n popLoading()\n }\n },\n [onCountDelta, popLoading, pushLoading, refreshParentData, runWriteMutation, scope, translate],\n )\n\n const handleUnlink = React.useCallback(\n async (deal: NormalizedDeal) => {\n if (!scope) return\n\n const nextPersonIds =\n scope.kind === 'person'\n ? deal.personIds.filter((id) => id !== scope.entityId)\n : deal.personIds\n const nextCompanyIds =\n scope.kind === 'company'\n ? deal.companyIds.filter((id) => id !== scope.entityId)\n : deal.companyIds\n\n const confirmed = await confirm({\n title:\n scope.kind === 'person'\n ? translate('customers.people.detail.deals.unlinkConfirmPerson', 'Unlink this deal from this person?')\n : translate('customers.people.detail.deals.unlinkConfirmCompany', 'Unlink this deal from this company?'),\n description: translate(\n 'customers.people.detail.deals.unlinkDescription',\n 'The deal will remain available from its own detail page.',\n ),\n confirmText: translate('customers.people.card.unlink', 'Unlink'),\n cancelText: translate('customers.people.detail.deals.cancel', 'Cancel'),\n })\n if (!confirmed) return\n\n setPendingAction({ kind: 'remove', id: deal.id })\n pushLoading()\n try {\n const payload: Record<string, unknown> = {\n id: deal.id,\n personIds: nextPersonIds,\n companyIds: nextCompanyIds,\n }\n await runWriteMutation(\n () =>\n updateCrud('customers/deals', payload, {\n errorMessage: translate('customers.people.detail.deals.unlinkError', 'Failed to unlink deal.'),\n }),\n {\n ...payload,\n operation: 'unlinkDeal',\n },\n )\n setDeals((prev) => prev.filter((item) => item.id !== deal.id))\n onCountDelta?.(-1)\n await refreshParentData()\n flash(translate('customers.people.detail.deals.unlinkSuccess', 'Deal unlinked.'), 'success')\n } catch (error) {\n const message =\n error instanceof Error\n ? error.message\n : translate('customers.people.detail.deals.unlinkError', 'Failed to unlink deal.')\n flash(message, 'error')\n } finally {\n setPendingAction(null)\n popLoading()\n }\n },\n [confirm, onCountDelta, popLoading, pushLoading, refreshParentData, runWriteMutation, scope, translate],\n )\n\n const handleDialogSubmit = React.useCallback(\n async (payload: DealFormSubmitPayload) => {\n try {\n await handleCreate(payload)\n closeDialog()\n } catch (err) {\n const message =\n err instanceof Error\n ? err.message\n : translate('customers.people.detail.deals.error', 'Failed to save deal.')\n flash(message, 'error')\n }\n },\n [closeDialog, handleCreate, translate],\n )\n\n React.useEffect(() => {\n if (!onActionChange) return\n const disabled = !scope || isLoading || pendingAction !== null\n const action: SectionAction = {\n label: addActionLabel,\n onClick: () => {\n if (!disabled) openCreateDialog()\n },\n disabled,\n }\n onActionChange(action)\n return () => {\n onActionChange(null)\n }\n }, [addActionLabel, isLoading, onActionChange, openCreateDialog, pendingAction, scope])\n\n const isFormPending = pendingAction?.kind === 'create'\n\n const sortedDeals = React.useMemo(() => {\n return [...deals].sort((a, b) => {\n const timeA = a.updatedAt ?? a.createdAt ?? ''\n const timeB = b.updatedAt ?? b.createdAt ?? ''\n return timeB.localeCompare(timeA)\n })\n }, [deals])\n\n return (\n <div className=\"mt-4 space-y-4\">\n {loadError ? (\n <div className=\"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive\">\n {loadError}\n </div>\n ) : null}\n <div className=\"flex flex-wrap items-center justify-end gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={openLinkDialog}\n disabled={!scope || pendingAction !== null}\n >\n <Link2 className=\"mr-1.5 size-3.5\" />\n {t('customers.people.detail.deals.linkExisting', 'Link existing deal')}\n </Button>\n <Button\n type=\"button\"\n variant=\"default\"\n size=\"sm\"\n onClick={openCreateDialog}\n disabled={!scope || pendingAction !== null}\n >\n <Plus className=\"mr-1.5 size-3.5\" />\n {addActionLabel}\n </Button>\n </div>\n {isLoading && sortedDeals.length === 0 ? (\n <LoadingMessage\n label={t('customers.people.detail.deals.loading', 'Loading deals\u2026')}\n className=\"border-0 bg-transparent p-0 py-8 justify-center\"\n />\n ) : (\n <>\n {!isLoading && sortedDeals.length === 0 ? (\n <TabEmptyState\n title={emptyState.title}\n action={{\n label: emptyState.actionLabel,\n onClick: openCreateDialog,\n disabled: !scope || pendingAction !== null,\n }}\n />\n ) : null}\n <div className=\"space-y-4\">\n {sortedDeals.map((deal) => {\n const valueLabel = formatValueLabel(deal.valueAmount, deal.valueCurrency ?? null, emptyLabel)\n const expectedLabel = deal.expectedCloseAt ? formatDate(deal.expectedCloseAt) ?? emptyLabel : emptyLabel\n const probabilityLabel =\n typeof deal.probability === 'number' ? `${deal.probability}%` : emptyLabel\n const isUnlinkPending = pendingAction?.kind === 'remove' && pendingAction.id === deal.id\n const statusLabel =\n deal.status && statusDictionaryMap\n ? statusDictionaryMap[deal.status]?.label ?? deal.status\n : deal.status ?? emptyLabel\n return (\n <article key={deal.id} className=\"group rounded-lg border bg-card p-4 shadow-xs transition hover:border-border/70\">\n <header className=\"flex flex-wrap items-center justify-between gap-2\">\n <div>\n <Link\n href={`/backend/customers/deals/${encodeURIComponent(deal.id)}`}\n className=\"text-base font-semibold text-foreground transition hover:text-primary hover:underline\"\n >\n {deal.title || emptyLabel}\n </Link>\n {deal.description ? (\n <p className=\"mt-1 text-sm text-muted-foreground whitespace-pre-wrap\">{deal.description}</p>\n ) : null}\n </div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs font-medium uppercase text-muted-foreground\">\n {statusLabel}\n </span>\n <div className=\"flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100\">\n <IconButton asChild variant=\"ghost\" size=\"sm\" className=\"h-8 w-8\">\n <Link\n href={`/backend/customers/deals/${encodeURIComponent(deal.id)}`}\n aria-label={t('customers.people.detail.deals.edit', 'Open deal details')}\n >\n <Pencil className=\"size-4\" />\n </Link>\n </IconButton>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n className=\"h-8 rounded-lg px-3 text-xs\"\n onClick={(event) => {\n event.preventDefault()\n void handleUnlink(deal)\n }}\n disabled={pendingAction !== null}\n >\n {isUnlinkPending\n ? t('customers.people.detail.deals.unlinking', 'Unlinking\u2026')\n : t('customers.people.card.unlink', 'Unlink')}\n </Button>\n </div>\n </div>\n </header>\n <dl className=\"mt-3 grid gap-2 text-xs text-muted-foreground sm:grid-cols-2\">\n <div className=\"flex flex-col gap-0.5\">\n <dt className=\"font-medium\">\n {t('customers.people.detail.deals.fields.pipelineStage', 'Pipeline stage')}\n </dt>\n <dd>{deal.pipelineStage ?? emptyLabel}</dd>\n </div>\n <div className=\"flex flex-col gap-0.5\">\n <dt className=\"font-medium\">\n {t('customers.people.detail.deals.fields.probability', 'Probability')}\n </dt>\n <dd>{probabilityLabel}</dd>\n </div>\n <div className=\"flex flex-col gap-0.5\">\n <dt className=\"font-medium\">\n {t('customers.people.detail.deals.fields.valueAmount', 'Value')}\n </dt>\n <dd>{valueLabel}</dd>\n </div>\n <div className=\"flex flex-col gap-0.5\">\n <dt className=\"font-medium\">\n {t('customers.people.detail.deals.fields.expectedCloseAt', 'Expected close')}\n </dt>\n <dd>{expectedLabel}</dd>\n </div>\n </dl>\n <CustomFieldValuesList\n entries={deal.customFields?.map((entry) => ({\n key: entry.key,\n value: entry.value,\n label: entry.label ?? undefined,\n }))}\n values={deal.customValues ?? undefined}\n resources={customFieldResources}\n emptyLabel={emptyLabel}\n itemKeyPrefix={`deal-${deal.id}-field`}\n className=\"mt-3\"\n />\n </article>\n )\n })}\n {isLoading && deals.length > 0 ? (\n <div className=\"flex justify-center\">\n <LoadingMessage\n label={t('customers.people.detail.deals.loading', 'Loading deals\u2026')}\n className=\"border-0 bg-transparent p-0 justify-center [&_span[role='status']]:h-5 [&_span[role='status']]:w-5\"\n />\n </div>\n ) : null}\n {!isLoading && hasMore ? (\n <div className=\"flex justify-center\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => {\n loadDeals({ append: true }).catch(() => {})\n }}\n disabled={pendingAction !== null || isLoading}\n >\n {t('customers.people.detail.deals.loadMore', 'Load more deals')}\n </Button>\n </div>\n ) : null}\n </div>\n </>\n )}\n\n <DealDialog\n open={dialogOpen}\n mode=\"create\"\n onOpenChange={handleDialogOpenChange}\n initialValues={initialValues}\n onSubmit={async (payload) => {\n await handleDialogSubmit(payload)\n }}\n isSubmitting={Boolean(isFormPending)}\n />\n <LinkEntityDialog\n open={linkDialogOpen}\n onOpenChange={setLinkDialogOpen}\n adapter={dealLinkAdapter}\n initialSelectedIds={existingDealIds}\n onConfirm={handleLinkConfirm}\n />\n {ConfirmDialogElement}\n </div>\n )\n}\n\nexport default Deals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AAAA,YACZ;AAAA,eAjFY,KAAK,EAkFnB;AAAA,QAEA,CAAC;AAAA,QACA,aAAa,MAAM,SAAS,IAC3B,oBAAC,SAAI,WAAU,uBACb;AAAA,UAAC;AAAA;AAAA,YACC,OAAO,EAAE,yCAAyC,qBAAgB;AAAA,YAClE,WAAU;AAAA;AAAA,QACZ,GACF,IACE;AAAA,QACH,CAAC,aAAa,UACb,oBAAC,SAAI,WAAU,uBACb;AAAA,UAAC;AAAA;AAAA,YACC,SAAQ;AAAA,YACR,MAAK;AAAA,YACL,SAAS,MAAM;AACb,wBAAU,EAAE,QAAQ,KAAK,CAAC,EAAE,MAAM,MAAM;AAAA,cAAC,CAAC;AAAA,YAC5C;AAAA,YACA,UAAU,kBAAkB,QAAQ;AAAA,YAEnC,YAAE,0CAA0C,iBAAiB;AAAA;AAAA,QAChE,GACF,IACE;AAAA,SACN;AAAA,OACF;AAAA,IAGF;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,MAAK;AAAA,QACL,cAAc;AAAA,QACd;AAAA,QACA,UAAU,OAAO,YAAY;AAC3B,gBAAM,mBAAmB,OAAO;AAAA,QAClC;AAAA,QACA,cAAc,QAAQ,aAAa;AAAA;AAAA,IACrC;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,cAAc;AAAA,QACd,SAAS;AAAA,QACT,oBAAoB;AAAA,QACpB,WAAW;AAAA;AAAA,IACb;AAAA,IACC;AAAA,KACH;AAEJ;AAEA,IAAO,uBAAQ;",
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { Link2, Pencil, Plus } from 'lucide-react'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { createCrud, updateCrud } from '@open-mercato/ui/backend/utils/crud'\nimport { LinkEntityDialog } from '../linking/LinkEntityDialog'\nimport { createDealLinkAdapter } from '../linking/adapters/dealAdapter'\nimport { LoadingMessage, TabEmptyState } from '@open-mercato/ui/backend/detail'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { E } from '#generated/entities.ids.generated'\nimport type { DealCustomFieldEntry, DealSummary, SectionAction, TabEmptyStateConfig, Translator } from './types'\nimport { createTranslatorWithFallback } from '@open-mercato/shared/lib/i18n/translate'\nimport { formatDate } from './utils'\nimport { DealDialog } from './DealDialog'\nimport type { DealFormBaseValues, DealFormSubmitPayload } from './DealForm'\nimport { generateTempId } from '@open-mercato/core/modules/customers/lib/detailHelpers'\nimport { useCurrencyDictionary } from './hooks/useCurrencyDictionary'\nimport { useCustomerDictionary } from './hooks/useCustomerDictionary'\nimport { CustomFieldValuesList } from './CustomFieldValuesList'\nimport { useCustomFieldDisplay } from './hooks/useCustomFieldDisplay'\nimport { normalizeCustomFieldKey } from './customFieldUtils'\n\nconst DEALS_PAGE_SIZE = 10\n\ntype DealsScope =\n | { kind: 'person'; entityId: string }\n | { kind: 'company'; entityId: string }\n\ntype GuardedMutationRunner = <T,>(\n operation: () => Promise<T>,\n mutationPayload?: Record<string, unknown>,\n) => Promise<T>\n\ntype PendingAction =\n | { kind: 'create' }\n | { kind: 'update'; id: string }\n | { kind: 'remove'; id: string }\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction sanitizeCustomValues(input: unknown): Record<string, unknown> | null {\n if (!isPlainObject(input)) return null\n const result: Record<string, unknown> = {}\n Object.entries(input).forEach(([key, value]) => {\n const trimmedKey = key.trim()\n if (!trimmedKey.length) return\n result[trimmedKey] = value\n })\n return Object.keys(result).length ? result : null\n}\n\nfunction sanitizeCustomFieldEntries(\n entries: unknown,\n values: Record<string, unknown> | null,\n): DealCustomFieldEntry[] {\n const map = new Map<string, DealCustomFieldEntry>()\n if (Array.isArray(entries)) {\n entries.forEach((entry) => {\n if (!entry || typeof entry !== 'object') return\n const record = entry as Record<string, unknown>\n const keyRaw =\n typeof record.key === 'string'\n ? record.key\n : typeof record.id === 'string'\n ? record.id\n : null\n if (!keyRaw) return\n const key = keyRaw.trim()\n if (!key.length) return\n const normalizedKey = normalizeCustomFieldKey(key)\n if (!normalizedKey) return\n const label =\n typeof record.label === 'string' && record.label.trim().length\n ? record.label.trim()\n : null\n const kind =\n typeof record.kind === 'string' && record.kind.trim().length\n ? record.kind.trim()\n : null\n const multi =\n typeof record.multi === 'boolean' ? record.multi : Array.isArray(record.value) ? true : undefined\n map.set(normalizedKey, {\n key,\n label,\n value: record.value,\n kind,\n multi,\n })\n })\n }\n\n if (values) {\n Object.entries(values).forEach(([rawKey, value]) => {\n const key = rawKey.trim()\n if (!key.length) return\n const normalizedKey = normalizeCustomFieldKey(key)\n if (!normalizedKey) return\n const existing = map.get(normalizedKey)\n if (existing) {\n existing.value = value\n if (existing.multi === undefined) existing.multi = Array.isArray(value)\n } else {\n map.set(normalizedKey, {\n key,\n label: null,\n value,\n kind: null,\n multi: Array.isArray(value) ? true : undefined,\n })\n }\n })\n }\n\n return Array.from(map.values())\n}\n\ntype NormalizedDeal = Omit<\n DealSummary,\n 'valueAmount' | 'probability' | 'expectedCloseAt' | 'customValues' | 'customFields' | 'personIds' | 'companyIds'\n> & {\n valueAmount: number | null\n probability: number | null\n expectedCloseAt: string | null\n personIds: string[]\n companyIds: string[]\n customValues: Record<string, unknown> | null\n customFields: DealCustomFieldEntry[]\n}\n\nfunction toNumber(value: unknown): number | null {\n if (typeof value === 'number' && Number.isFinite(value)) return value\n if (typeof value === 'string') {\n const trimmed = value.trim()\n if (!trimmed.length) return null\n const parsed = Number(trimmed)\n return Number.isNaN(parsed) ? null : parsed\n }\n return null\n}\n\nfunction toIso(value: unknown): string | null {\n if (typeof value === 'string') {\n const trimmed = value.trim()\n if (!trimmed.length) return null\n const parsed = new Date(trimmed)\n return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString()\n }\n if (value instanceof Date) {\n return Number.isNaN(value.getTime()) ? null : value.toISOString()\n }\n return null\n}\n\nfunction mergeIds(...sources: Array<unknown>): string[] {\n const set = new Set<string>()\n sources.forEach((source) => {\n if (Array.isArray(source)) {\n source.forEach((value) => {\n if (typeof value !== 'string') return\n const trimmed = value.trim()\n if (!trimmed.length) return\n set.add(trimmed)\n })\n }\n })\n return Array.from(set)\n}\n\nfunction normalizeDeal(deal: Partial<DealSummary> & { id: string; title?: string }): NormalizedDeal {\n const title = typeof deal.title === 'string' && deal.title.trim().length ? deal.title.trim() : ''\n const normalizeIdList = (list: unknown): string[] => {\n if (!Array.isArray(list)) return []\n const seen = new Set<string>()\n const result: string[] = []\n list.forEach((candidate) => {\n if (typeof candidate !== 'string') return\n const trimmed = candidate.trim()\n if (!trimmed.length || seen.has(trimmed)) return\n seen.add(trimmed)\n result.push(trimmed)\n })\n return result\n }\n\n const normalizeAssignees = (entries: unknown, fallbackIds: string[]): { id: string; label: string }[] => {\n if (!Array.isArray(entries)) {\n return fallbackIds.map((id) => ({ id, label: '' }))\n }\n const seen = new Set<string>()\n const resolved: { id: string; label: string }[] = []\n entries.forEach((entry) => {\n if (!entry || typeof entry !== 'object') return\n const data = entry as Record<string, unknown>\n const id = typeof data.id === 'string' ? data.id.trim() : ''\n if (!id || seen.has(id)) return\n const label = typeof data.label === 'string' ? data.label : ''\n seen.add(id)\n resolved.push({ id, label })\n })\n if (!resolved.length && fallbackIds.length) {\n return fallbackIds.map((id) => ({ id, label: '' }))\n }\n return resolved\n }\n\n const personIds = normalizeIdList(deal.personIds ?? null)\n const companyIds = normalizeIdList(deal.companyIds ?? null)\n const people = normalizeAssignees(deal.people ?? null, personIds)\n const companies = normalizeAssignees(deal.companies ?? null, companyIds)\n\n const customValues = sanitizeCustomValues(deal.customValues ?? null)\n const customFields = sanitizeCustomFieldEntries(deal.customFields ?? null, customValues)\n\n return {\n id: deal.id,\n title,\n status: typeof deal.status === 'string' ? deal.status : deal.status ?? null,\n pipelineStage:\n typeof deal.pipelineStage === 'string' ? deal.pipelineStage : deal.pipelineStage ?? null,\n pipelineId:\n typeof deal.pipelineId === 'string' && deal.pipelineId.trim().length\n ? deal.pipelineId.trim()\n : deal.pipelineId ?? null,\n pipelineStageId:\n typeof deal.pipelineStageId === 'string' && deal.pipelineStageId.trim().length\n ? deal.pipelineStageId.trim()\n : deal.pipelineStageId ?? null,\n valueAmount: toNumber(deal.valueAmount ?? null),\n valueCurrency:\n typeof deal.valueCurrency === 'string' && deal.valueCurrency.trim().length\n ? deal.valueCurrency.trim().toUpperCase()\n : null,\n probability: toNumber(deal.probability ?? null),\n expectedCloseAt: toIso(deal.expectedCloseAt ?? null),\n description:\n typeof deal.description === 'string' && deal.description.trim().length\n ? deal.description\n : deal.description ?? null,\n ownerUserId:\n typeof deal.ownerUserId === 'string' && deal.ownerUserId.trim().length\n ? deal.ownerUserId\n : deal.ownerUserId ?? null,\n source:\n typeof deal.source === 'string' && deal.source.trim().length ? deal.source : deal.source ?? null,\n closureOutcome:\n typeof deal.closureOutcome === 'string' && deal.closureOutcome.trim().length\n ? deal.closureOutcome\n : deal.closureOutcome ?? null,\n lossReasonId:\n typeof deal.lossReasonId === 'string' && deal.lossReasonId.trim().length\n ? deal.lossReasonId\n : deal.lossReasonId ?? null,\n lossNotes:\n typeof deal.lossNotes === 'string' && deal.lossNotes.trim().length\n ? deal.lossNotes\n : deal.lossNotes ?? null,\n createdAt: toIso(deal.createdAt ?? null),\n updatedAt: toIso(deal.updatedAt ?? null),\n personIds,\n companyIds,\n people,\n companies,\n customValues,\n customFields,\n }\n}\n\nfunction formatValueLabel(amount: number | null, currency: string | null, emptyLabel: string): string {\n if (typeof amount === 'number') {\n const formatter = new Intl.NumberFormat(undefined, {\n style: currency ? 'currency' : 'decimal',\n currency: currency ?? undefined,\n maximumFractionDigits: 2,\n })\n try {\n return formatter.format(amount)\n } catch {\n return currency ? `${amount} ${currency}` : `${amount}`\n }\n }\n return emptyLabel\n}\n\nexport type DealsSectionProps = {\n scope: DealsScope | null\n addActionLabel: string\n emptyLabel: string\n emptyState: TabEmptyStateConfig\n onCountDelta?: (delta: number) => void\n onActionChange?: (action: SectionAction | null) => void\n onLoadingChange?: (isLoading: boolean) => void\n onDataRefresh?: () => Promise<void> | void\n translator?: Translator\n runGuardedMutation?: GuardedMutationRunner\n}\n\nexport function DealsSection({\n scope,\n addActionLabel,\n emptyLabel,\n emptyState,\n onCountDelta,\n onActionChange,\n onLoadingChange,\n onDataRefresh,\n translator,\n runGuardedMutation,\n}: DealsSectionProps) {\n const tHook = useT()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const fallbackTranslator = React.useMemo<Translator>(() => createTranslatorWithFallback(tHook), [tHook])\n const t: Translator = React.useMemo(() => translator ?? fallbackTranslator, [translator, fallbackTranslator])\n useCurrencyDictionary()\n const scopeVersion = useOrganizationScopeVersion()\n const statusDictionaryQuery = useCustomerDictionary('deal-statuses', scopeVersion)\n const statusDictionaryMap = statusDictionaryQuery.data?.map ?? null\n const customFieldResources = useCustomFieldDisplay(E.customers.customer_deal)\n\n const [deals, setDeals] = React.useState<NormalizedDeal[]>([])\n const [isLoading, setIsLoading] = React.useState<boolean>(() => Boolean(scope))\n const [loadError, setLoadError] = React.useState<string | null>(null)\n const [pendingAction, setPendingAction] = React.useState<PendingAction | null>(null)\n const [hasMore, setHasMore] = React.useState(false)\n const pageRef = React.useRef(0)\n const hasMoreRef = React.useRef(true)\n const [dialogOpen, setDialogOpen] = React.useState(false)\n const [initialValues, setInitialValues] = React.useState<\n Partial<DealFormBaseValues & Record<string, unknown>> | undefined\n >(undefined)\n const pendingCounterRef = React.useRef(0)\n\n const pushLoading = React.useCallback(() => {\n pendingCounterRef.current += 1\n if (pendingCounterRef.current === 1) onLoadingChange?.(true)\n }, [onLoadingChange])\n\n const popLoading = React.useCallback(() => {\n pendingCounterRef.current = Math.max(0, pendingCounterRef.current - 1)\n if (pendingCounterRef.current === 0) onLoadingChange?.(false)\n }, [onLoadingChange])\n\n const translate = React.useCallback(\n (key: string, fallback: string, params?: Record<string, string | number>) => {\n const value = t(key, fallback, params)\n return value === key && fallback ? fallback : value\n },\n [t],\n )\n const runWriteMutation = React.useCallback(\n async <T,>(operation: () => Promise<T>, mutationPayload?: Record<string, unknown>): Promise<T> => {\n if (!runGuardedMutation) {\n return operation()\n }\n return runGuardedMutation(operation, mutationPayload)\n },\n [runGuardedMutation],\n )\n const refreshParentData = React.useCallback(async () => {\n await Promise.resolve(onDataRefresh?.())\n }, [onDataRefresh])\n\n const loadDeals = React.useCallback(async ({ append }: { append: boolean }) => {\n if (!scope) {\n setDeals([])\n setLoadError(null)\n setHasMore(false)\n setIsLoading(false)\n pendingCounterRef.current = 0\n onLoadingChange?.(false)\n pageRef.current = 0\n hasMoreRef.current = false\n return\n }\n if (append && !hasMoreRef.current) return\n const nextPage = append ? pageRef.current + 1 : 1\n if (!append) {\n pageRef.current = 0\n hasMoreRef.current = true\n setHasMore(true)\n setDeals([])\n }\n pushLoading()\n setIsLoading(true)\n try {\n const params = new URLSearchParams({\n page: String(nextPage),\n pageSize: String(DEALS_PAGE_SIZE),\n sortField: 'updatedAt',\n sortDir: 'desc',\n })\n if (scope.kind === 'person') params.set('personEntityId', scope.entityId)\n if (scope.kind === 'company') params.set('companyEntityId', scope.entityId)\n const payload = await readApiResultOrThrow<Record<string, unknown>>(\n `/api/customers/deals?${params.toString()}`,\n undefined,\n { errorMessage: translate('customers.people.detail.deals.loadError', 'Failed to load deals.') },\n )\n const rawItems = Array.isArray(payload?.items) ? payload.items : []\n const mapped: NormalizedDeal[] = rawItems.map((item: unknown) => {\n const record = (item && typeof item === 'object') ? (item as Record<string, unknown>) : {}\n const id =\n typeof record.id === 'string' && record.id.trim().length ? record.id : generateTempId()\n const title =\n typeof record.title === 'string' && record.title.trim().length ? record.title.trim() : ''\n const status =\n typeof record.status === 'string' && record.status.trim().length\n ? record.status.trim()\n : null\n const pipelineStage =\n typeof record.pipelineStage === 'string' && record.pipelineStage.trim().length\n ? record.pipelineStage.trim()\n : typeof record.pipeline_stage === 'string' && record.pipeline_stage.trim().length\n ? record.pipeline_stage.trim()\n : null\n const pipelineId =\n typeof record.pipelineId === 'string' && record.pipelineId.trim().length\n ? record.pipelineId.trim()\n : typeof record.pipeline_id === 'string' && record.pipeline_id.trim().length\n ? record.pipeline_id.trim()\n : null\n const pipelineStageId =\n typeof record.pipelineStageId === 'string' && record.pipelineStageId.trim().length\n ? record.pipelineStageId.trim()\n : typeof record.pipeline_stage_id === 'string' && record.pipeline_stage_id.trim().length\n ? record.pipeline_stage_id.trim()\n : null\n const valueAmount = toNumber(record.valueAmount ?? record.value_amount)\n const valueCurrencyRaw = record.valueCurrency ?? record.value_currency ?? null\n const valueCurrency =\n typeof valueCurrencyRaw === 'string' && valueCurrencyRaw.trim().length\n ? valueCurrencyRaw.trim().toUpperCase()\n : null\n const probability = toNumber(record.probability)\n const expectedCloseAt =\n typeof record.expectedCloseAt === 'string' && record.expectedCloseAt.trim().length\n ? record.expectedCloseAt\n : typeof record.expected_close_at === 'string' && record.expected_close_at.trim().length\n ? record.expected_close_at\n : null\n const description =\n typeof record.description === 'string' && record.description.trim().length\n ? record.description\n : null\n const ownerUserId =\n typeof record.ownerUserId === 'string' && record.ownerUserId.trim().length\n ? record.ownerUserId\n : typeof record.owner_user_id === 'string' && record.owner_user_id.trim().length\n ? record.owner_user_id\n : null\n const source =\n typeof record.source === 'string' && record.source.trim().length\n ? record.source\n : null\n const closureOutcome =\n typeof record.closureOutcome === 'string' && record.closureOutcome.trim().length\n ? record.closureOutcome\n : typeof record.closure_outcome === 'string' && record.closure_outcome.trim().length\n ? record.closure_outcome\n : null\n const lossReasonId =\n typeof record.lossReasonId === 'string' && record.lossReasonId.trim().length\n ? record.lossReasonId\n : typeof record.loss_reason_id === 'string' && record.loss_reason_id.trim().length\n ? record.loss_reason_id\n : null\n const lossNotes =\n typeof record.lossNotes === 'string' && record.lossNotes.trim().length\n ? record.lossNotes\n : typeof record.loss_notes === 'string' && record.loss_notes.trim().length\n ? record.loss_notes\n : null\n const createdAt =\n typeof record.createdAt === 'string' && record.createdAt.trim().length\n ? record.createdAt\n : typeof record.created_at === 'string' && record.created_at.trim().length\n ? record.created_at\n : null\n const updatedAt =\n typeof record.updatedAt === 'string' && record.updatedAt.trim().length\n ? record.updatedAt\n : typeof record.updated_at === 'string' && record.updated_at.trim().length\n ? record.updated_at\n : null\n const personIds = Array.isArray(record.personIds)\n ? record.personIds\n : Array.isArray(record.person_ids)\n ? record.person_ids\n : []\n const people = Array.isArray(record.people) ? record.people : []\n const companyIds = Array.isArray(record.companyIds)\n ? record.companyIds\n : Array.isArray(record.company_ids)\n ? record.company_ids\n : []\n const companies = Array.isArray(record.companies) ? record.companies : []\n const customValues = sanitizeCustomValues(\n record.customValues ?? record.custom_values ?? null,\n )\n const customFieldEntries = sanitizeCustomFieldEntries(\n record.customFields ?? record.custom_fields ?? null,\n customValues,\n )\n return normalizeDeal({\n id,\n title,\n status,\n pipelineStage,\n pipelineId,\n pipelineStageId,\n valueAmount,\n valueCurrency,\n probability,\n expectedCloseAt,\n description,\n ownerUserId,\n source,\n closureOutcome,\n lossReasonId,\n lossNotes,\n createdAt,\n updatedAt,\n personIds: personIds as string[] | undefined,\n people: people as { id: string; label: string }[] | undefined,\n companyIds: companyIds as string[] | undefined,\n companies: companies as { id: string; label: string }[] | undefined,\n customValues,\n customFields: customFieldEntries,\n })\n })\n setDeals((prev) => {\n if (!append) return mapped\n const mappedById = new Map(mapped.map((deal) => [deal.id, deal]))\n const prevIds = new Set(prev.map((deal) => deal.id))\n const updatedPrev = prev.map((deal) => mappedById.get(deal.id) ?? deal)\n const appended = mapped.filter((deal) => !prevIds.has(deal.id))\n return [...updatedPrev, ...appended]\n })\n pageRef.current = nextPage\n const totalPagesRaw = payload?.totalPages\n const totalPages =\n typeof totalPagesRaw === 'number'\n ? totalPagesRaw\n : typeof totalPagesRaw === 'string' && totalPagesRaw.trim().length\n ? Number(totalPagesRaw)\n : null\n const nextHasMore =\n totalPages && Number.isFinite(totalPages)\n ? nextPage < totalPages\n : mapped.length === DEALS_PAGE_SIZE\n hasMoreRef.current = nextHasMore\n setHasMore(nextHasMore)\n setLoadError(null)\n } catch (err) {\n const message =\n err instanceof Error\n ? err.message\n : translate('customers.people.detail.deals.loadError', 'Failed to load deals.')\n setLoadError(message)\n if (!append) {\n setHasMore(false)\n hasMoreRef.current = false\n }\n } finally {\n setIsLoading(false)\n popLoading()\n }\n }, [popLoading, pushLoading, scope, translate])\n\n React.useEffect(() => {\n loadDeals({ append: false }).catch(() => {})\n }, [loadDeals, scope])\n\n const openCreateDialog = React.useCallback(() => {\n if (!scope) return\n setInitialValues({\n personIds: scope.kind === 'person' ? [scope.entityId] : [],\n companyIds: scope.kind === 'company' ? [scope.entityId] : [],\n })\n setDialogOpen(true)\n }, [scope])\n\n const [linkDialogOpen, setLinkDialogOpen] = React.useState(false)\n const openLinkDialog = React.useCallback(() => {\n if (!scope) return\n setLinkDialogOpen(true)\n }, [scope])\n\n const existingDealIds = React.useMemo(() => deals.map((deal) => deal.id), [deals])\n\n const dealLinkAdapter = React.useMemo(\n () =>\n createDealLinkAdapter({\n dialogTitle: t('customers.linking.deal.dialogTitle', 'Link deal'),\n dialogSubtitle: t(\n 'customers.linking.deal.dialogSubtitle',\n 'Link an existing deal to this record',\n ),\n sectionLabel: t('customers.linking.deal.sectionLabel', 'MATCHING DEALS'),\n searchPlaceholder: t('customers.linking.deal.searchPlaceholder', 'Search all deals\u2026'),\n searchEmptyHint: t('customers.linking.deal.searchEmpty', 'No matching deals found.'),\n selectedEmptyHint: t('customers.linking.deal.selectedEmpty', 'No deals selected.'),\n confirmButtonLabel: t('customers.linking.deal.confirmButton', 'Link deal'),\n orphanWarningTitle: t('customers.linking.deal.orphanWarningTitle', 'Deal without company'),\n orphanWarningMessage: t(\n 'customers.linking.deal.orphanWarning',\n 'This deal has no other linked entities. If you unlink it later, it will become unreachable.',\n ),\n contextEntityId: scope?.entityId,\n }),\n [scope?.entityId, t],\n )\n\n const handleLinkConfirm = React.useCallback(\n async ({\n addedIds,\n removedIds,\n }: {\n addedIds: string[]\n removedIds: string[]\n }) => {\n if (!scope) return\n if (!addedIds.length && !removedIds.length) return\n pushLoading()\n try {\n for (const dealId of addedIds) {\n const payload = await readApiResultOrThrow<Record<string, unknown>>(\n `/api/customers/deals/${encodeURIComponent(dealId)}`,\n )\n const currentPersonIds = Array.isArray(payload.personIds)\n ? (payload.personIds as string[]).filter((id) => typeof id === 'string')\n : []\n const currentCompanyIds = Array.isArray(payload.companyIds)\n ? (payload.companyIds as string[]).filter((id) => typeof id === 'string')\n : []\n const nextPersonIds =\n scope.kind === 'person' && !currentPersonIds.includes(scope.entityId)\n ? [...currentPersonIds, scope.entityId]\n : currentPersonIds\n const nextCompanyIds =\n scope.kind === 'company' && !currentCompanyIds.includes(scope.entityId)\n ? [...currentCompanyIds, scope.entityId]\n : currentCompanyIds\n await runWriteMutation(\n () =>\n updateCrud(\n 'customers/deals',\n { id: dealId, personIds: nextPersonIds, companyIds: nextCompanyIds },\n {\n errorMessage: t(\n 'customers.people.detail.deals.linkError',\n 'Failed to link deal.',\n ),\n },\n ),\n { dealId, scopeKind: scope.kind, scopeEntityId: scope.entityId, operation: 'linkDeal' },\n )\n }\n for (const dealId of removedIds) {\n const payload = await readApiResultOrThrow<Record<string, unknown>>(\n `/api/customers/deals/${encodeURIComponent(dealId)}`,\n )\n const currentPersonIds = Array.isArray(payload.personIds)\n ? (payload.personIds as string[]).filter((id) => typeof id === 'string')\n : []\n const currentCompanyIds = Array.isArray(payload.companyIds)\n ? (payload.companyIds as string[]).filter((id) => typeof id === 'string')\n : []\n const nextPersonIds =\n scope.kind === 'person'\n ? currentPersonIds.filter((id) => id !== scope.entityId)\n : currentPersonIds\n const nextCompanyIds =\n scope.kind === 'company'\n ? currentCompanyIds.filter((id) => id !== scope.entityId)\n : currentCompanyIds\n await runWriteMutation(\n () =>\n updateCrud(\n 'customers/deals',\n { id: dealId, personIds: nextPersonIds, companyIds: nextCompanyIds },\n {\n errorMessage: t(\n 'customers.people.detail.deals.unlinkError',\n 'Failed to unlink deal.',\n ),\n },\n ),\n { dealId, scopeKind: scope.kind, scopeEntityId: scope.entityId, operation: 'unlinkDeal' },\n )\n }\n await loadDeals({ append: false })\n await refreshParentData()\n if (addedIds.length + removedIds.length > 0) {\n onCountDelta?.(addedIds.length - removedIds.length)\n }\n flash(\n addedIds.length > 0\n ? t('customers.people.detail.deals.linkSuccess', 'Deal linked.')\n : t('customers.people.detail.deals.unlinkSuccess', 'Deal unlinked.'),\n 'success',\n )\n } catch (error) {\n const message =\n error instanceof Error\n ? error.message\n : t('customers.people.detail.deals.linkError', 'Failed to link deal.')\n flash(message, 'error')\n } finally {\n popLoading()\n }\n },\n [loadDeals, onCountDelta, popLoading, pushLoading, refreshParentData, runWriteMutation, scope, t],\n )\n\n const closeDialog = React.useCallback(() => {\n setDialogOpen(false)\n setInitialValues(undefined)\n }, [])\n\n const handleDialogOpenChange = React.useCallback(\n (next: boolean) => {\n if (!next) closeDialog()\n else setDialogOpen(true)\n },\n [closeDialog],\n )\n\n const handleCreate = React.useCallback(\n async ({ base, custom }: DealFormSubmitPayload) => {\n if (!scope) {\n throw new Error(translate('customers.people.detail.deals.error', 'Failed to save deal.'))\n }\n setPendingAction({ kind: 'create' })\n pushLoading()\n try {\n const personIds = mergeIds(base.personIds)\n const companyIds = mergeIds(base.companyIds)\n\n const payload: Record<string, unknown> = {\n title: base.title,\n status: base.status ?? undefined,\n pipelineStage: base.pipelineStage ?? undefined,\n pipelineId: base.pipelineId ?? undefined,\n pipelineStageId: base.pipelineStageId ?? undefined,\n valueAmount: typeof base.valueAmount === 'number' ? base.valueAmount : undefined,\n valueCurrency: base.valueCurrency ?? undefined,\n probability: typeof base.probability === 'number' ? base.probability : undefined,\n expectedCloseAt: base.expectedCloseAt ?? undefined,\n description: base.description ?? undefined,\n personIds,\n companyIds,\n }\n if (Object.keys(custom).length) payload.customFields = custom\n const { result } = await runWriteMutation(\n () =>\n createCrud<{ id?: string }>('customers/deals', payload, {\n errorMessage: translate('customers.people.detail.deals.error', 'Failed to save deal.'),\n }),\n {\n ...payload,\n operation: 'createDeal',\n },\n )\n const dealId =\n typeof result?.id === 'string' && result.id.trim().length ? result.id : generateTempId()\n const belongsToScope =\n (scope.kind !== 'person' || personIds.includes(scope.entityId)) &&\n (scope.kind !== 'company' || companyIds.includes(scope.entityId))\n if (belongsToScope) {\n const customValuesForState = sanitizeCustomValues(\n Object.keys(custom).length ? custom : null,\n )\n const timestamp = new Date().toISOString()\n const normalized = normalizeDeal({\n id: dealId,\n title: base.title,\n status: base.status ?? null,\n pipelineStage: base.pipelineStage ?? null,\n pipelineId: base.pipelineId ?? null,\n pipelineStageId: base.pipelineStageId ?? null,\n valueAmount: base.valueAmount ?? null,\n valueCurrency: base.valueCurrency ?? null,\n probability: base.probability ?? null,\n expectedCloseAt: base.expectedCloseAt ?? null,\n description: base.description ?? null,\n personIds,\n companyIds,\n customValues: customValuesForState,\n createdAt: timestamp,\n updatedAt: timestamp,\n })\n setDeals((prev) => [normalized, ...prev])\n onCountDelta?.(1)\n }\n await refreshParentData()\n flash(translate('customers.people.detail.deals.success', 'Deal created.'), 'success')\n } finally {\n setPendingAction(null)\n popLoading()\n }\n },\n [onCountDelta, popLoading, pushLoading, refreshParentData, runWriteMutation, scope, translate],\n )\n\n const handleUnlink = React.useCallback(\n async (deal: NormalizedDeal) => {\n if (!scope) return\n\n const nextPersonIds =\n scope.kind === 'person'\n ? deal.personIds.filter((id) => id !== scope.entityId)\n : deal.personIds\n const nextCompanyIds =\n scope.kind === 'company'\n ? deal.companyIds.filter((id) => id !== scope.entityId)\n : deal.companyIds\n\n const confirmed = await confirm({\n title:\n scope.kind === 'person'\n ? translate('customers.people.detail.deals.unlinkConfirmPerson', 'Unlink this deal from this person?')\n : translate('customers.people.detail.deals.unlinkConfirmCompany', 'Unlink this deal from this company?'),\n description: translate(\n 'customers.people.detail.deals.unlinkDescription',\n 'The deal will remain available from its own detail page.',\n ),\n confirmText: translate('customers.people.card.unlink', 'Unlink'),\n cancelText: translate('customers.people.detail.deals.cancel', 'Cancel'),\n })\n if (!confirmed) return\n\n setPendingAction({ kind: 'remove', id: deal.id })\n pushLoading()\n try {\n const payload: Record<string, unknown> = {\n id: deal.id,\n personIds: nextPersonIds,\n companyIds: nextCompanyIds,\n }\n await runWriteMutation(\n () =>\n updateCrud('customers/deals', payload, {\n errorMessage: translate('customers.people.detail.deals.unlinkError', 'Failed to unlink deal.'),\n }),\n {\n ...payload,\n operation: 'unlinkDeal',\n },\n )\n setDeals((prev) => prev.filter((item) => item.id !== deal.id))\n onCountDelta?.(-1)\n await refreshParentData()\n flash(translate('customers.people.detail.deals.unlinkSuccess', 'Deal unlinked.'), 'success')\n } catch (error) {\n const message =\n error instanceof Error\n ? error.message\n : translate('customers.people.detail.deals.unlinkError', 'Failed to unlink deal.')\n flash(message, 'error')\n } finally {\n setPendingAction(null)\n popLoading()\n }\n },\n [confirm, onCountDelta, popLoading, pushLoading, refreshParentData, runWriteMutation, scope, translate],\n )\n\n const handleDialogSubmit = React.useCallback(\n async (payload: DealFormSubmitPayload) => {\n try {\n await handleCreate(payload)\n closeDialog()\n } catch (err) {\n const message =\n err instanceof Error\n ? err.message\n : translate('customers.people.detail.deals.error', 'Failed to save deal.')\n flash(message, 'error')\n }\n },\n [closeDialog, handleCreate, translate],\n )\n\n React.useEffect(() => {\n if (!onActionChange) return\n const disabled = !scope || isLoading || pendingAction !== null\n const action: SectionAction = {\n label: addActionLabel,\n onClick: () => {\n if (!disabled) openCreateDialog()\n },\n disabled,\n }\n onActionChange(action)\n return () => {\n onActionChange(null)\n }\n }, [addActionLabel, isLoading, onActionChange, openCreateDialog, pendingAction, scope])\n\n const isFormPending = pendingAction?.kind === 'create'\n\n const sortedDeals = React.useMemo(() => {\n return [...deals].sort((a, b) => {\n const timeA = a.updatedAt ?? a.createdAt ?? ''\n const timeB = b.updatedAt ?? b.createdAt ?? ''\n return timeB.localeCompare(timeA)\n })\n }, [deals])\n\n return (\n <div className=\"mt-4 space-y-4\">\n {loadError ? (\n <div className=\"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive\">\n {loadError}\n </div>\n ) : null}\n <div className=\"flex flex-wrap items-center justify-end gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={openLinkDialog}\n disabled={!scope || pendingAction !== null}\n >\n <Link2 className=\"mr-1.5 size-3.5\" />\n {t('customers.people.detail.deals.linkExisting', 'Link existing deal')}\n </Button>\n <Button\n type=\"button\"\n variant=\"default\"\n size=\"sm\"\n onClick={openCreateDialog}\n disabled={!scope || pendingAction !== null}\n >\n <Plus className=\"mr-1.5 size-3.5\" />\n {addActionLabel}\n </Button>\n </div>\n {isLoading && sortedDeals.length === 0 ? (\n <LoadingMessage\n label={t('customers.people.detail.deals.loading', 'Loading deals\u2026')}\n className=\"border-0 bg-transparent p-0 py-8 justify-center\"\n />\n ) : (\n <>\n {!isLoading && sortedDeals.length === 0 ? (\n <TabEmptyState\n title={emptyState.title}\n action={{\n label: emptyState.actionLabel,\n onClick: openCreateDialog,\n disabled: !scope || pendingAction !== null,\n }}\n />\n ) : null}\n <div className=\"space-y-4\">\n {sortedDeals.map((deal) => {\n const valueLabel = formatValueLabel(deal.valueAmount, deal.valueCurrency ?? null, emptyLabel)\n const expectedLabel = deal.expectedCloseAt ? formatDate(deal.expectedCloseAt) ?? emptyLabel : emptyLabel\n const probabilityLabel =\n typeof deal.probability === 'number' ? `${deal.probability}%` : emptyLabel\n const isUnlinkPending = pendingAction?.kind === 'remove' && pendingAction.id === deal.id\n const statusLabel =\n deal.status && statusDictionaryMap\n ? statusDictionaryMap[deal.status]?.label ?? deal.status\n : deal.status ?? emptyLabel\n return (\n <article key={deal.id} className=\"group rounded-lg border bg-card p-4 shadow-xs transition hover:border-border/70\">\n <header className=\"flex flex-wrap items-center justify-between gap-2\">\n <div>\n <Link\n href={`/backend/customers/deals/${encodeURIComponent(deal.id)}`}\n className=\"text-base font-semibold text-foreground transition hover:text-primary hover:underline\"\n >\n {deal.title || emptyLabel}\n </Link>\n {deal.description ? (\n <p className=\"mt-1 text-sm text-muted-foreground whitespace-pre-wrap\">{deal.description}</p>\n ) : null}\n </div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs font-medium uppercase text-muted-foreground\">\n {statusLabel}\n </span>\n <div className=\"flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100\">\n <IconButton asChild variant=\"ghost\" size=\"sm\" className=\"h-8 w-8\">\n <Link\n href={`/backend/customers/deals/${encodeURIComponent(deal.id)}`}\n aria-label={t('customers.people.detail.deals.edit', 'Open deal details')}\n >\n <Pencil className=\"size-4\" />\n </Link>\n </IconButton>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n className=\"h-8 rounded-lg px-3 text-xs\"\n onClick={(event) => {\n event.preventDefault()\n void handleUnlink(deal)\n }}\n disabled={pendingAction !== null}\n >\n {isUnlinkPending\n ? t('customers.people.detail.deals.unlinking', 'Unlinking\u2026')\n : t('customers.people.card.unlink', 'Unlink')}\n </Button>\n </div>\n </div>\n </header>\n <dl className=\"mt-3 grid gap-2 text-xs text-muted-foreground sm:grid-cols-2\">\n <div className=\"flex flex-col gap-0.5\">\n <dt className=\"font-medium\">\n {t('customers.people.detail.deals.fields.pipelineStage', 'Pipeline stage')}\n </dt>\n <dd>{deal.pipelineStage ?? emptyLabel}</dd>\n </div>\n <div className=\"flex flex-col gap-0.5\">\n <dt className=\"font-medium\">\n {t('customers.people.detail.deals.fields.probability', 'Probability')}\n </dt>\n <dd>{probabilityLabel}</dd>\n </div>\n <div className=\"flex flex-col gap-0.5\">\n <dt className=\"font-medium\">\n {t('customers.people.detail.deals.fields.valueAmount', 'Value')}\n </dt>\n <dd>{valueLabel}</dd>\n </div>\n <div className=\"flex flex-col gap-0.5\">\n <dt className=\"font-medium\">\n {t('customers.people.detail.deals.fields.expectedCloseAt', 'Expected close')}\n </dt>\n <dd>{expectedLabel}</dd>\n </div>\n </dl>\n <CustomFieldValuesList\n entries={deal.customFields?.map((entry) => ({\n key: entry.key,\n value: entry.value,\n label: entry.label ?? undefined,\n }))}\n values={deal.customValues ?? undefined}\n resources={customFieldResources}\n emptyLabel={emptyLabel}\n itemKeyPrefix={`deal-${deal.id}-field`}\n className=\"mt-3\"\n />\n </article>\n )\n })}\n {isLoading && deals.length > 0 ? (\n <div className=\"flex justify-center\">\n <LoadingMessage\n label={t('customers.people.detail.deals.loading', 'Loading deals\u2026')}\n className=\"border-0 bg-transparent p-0 justify-center [&_span[role='status']]:h-5 [&_span[role='status']]:w-5\"\n />\n </div>\n ) : null}\n {!isLoading && hasMore ? (\n <div className=\"flex justify-center\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => {\n loadDeals({ append: true }).catch(() => {})\n }}\n disabled={pendingAction !== null || isLoading}\n >\n {t('customers.people.detail.deals.loadMore', 'Load more deals')}\n </Button>\n </div>\n ) : null}\n </div>\n </>\n )}\n\n <DealDialog\n open={dialogOpen}\n mode=\"create\"\n onOpenChange={handleDialogOpenChange}\n initialValues={initialValues}\n onSubmit={async (payload) => {\n await handleDialogSubmit(payload)\n }}\n isSubmitting={Boolean(isFormPending)}\n />\n <LinkEntityDialog\n open={linkDialogOpen}\n onOpenChange={setLinkDialogOpen}\n adapter={dealLinkAdapter}\n initialSelectedIds={existingDealIds}\n onConfirm={handleLinkConfirm}\n />\n {ConfirmDialogElement}\n </div>\n )\n}\n\nexport default DealsSection\n"],
|
|
5
|
+
"mappings": ";AAy5BQ,SAgCA,UAhCA,KAKA,YALA;AAv5BR,YAAY,WAAW;AACvB,OAAO,UAAU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AAAA;AAAA,QACC,MAAM;AAAA,QACN,MAAK;AAAA,QACL,cAAc;AAAA,QACd;AAAA,QACA,UAAU,OAAO,YAAY;AAC3B,gBAAM,mBAAmB,OAAO;AAAA,QAClC;AAAA,QACA,cAAc,QAAQ,aAAa;AAAA;AAAA,IACrC;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,cAAc;AAAA,QACd,SAAS;AAAA,QACT,oBAAoB;AAAA,QACpB,WAAW;AAAA;AAAA,IACb;AAAA,IACC;AAAA,KACH;AAEJ;AAEA,IAAO,uBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useRouter } from "next/navigation";
|
|
5
|
+
import { Lock, Users } from "lucide-react";
|
|
6
|
+
import { EmailReplyForwardActions } from "./EmailReplyForwardActions.js";
|
|
7
|
+
import {
|
|
8
|
+
ComposeEmailDialog
|
|
9
|
+
} from "./ComposeEmailDialog.js";
|
|
10
|
+
import { IconButton } from "@open-mercato/ui/primitives/icon-button";
|
|
11
|
+
import { apiCall } from "@open-mercato/ui/backend/utils/apiCall";
|
|
12
|
+
import { useGuardedMutation } from "@open-mercato/ui/backend/injection/useGuardedMutation";
|
|
13
|
+
import { useAppEvent } from "@open-mercato/ui/backend/injection/useAppEvent";
|
|
14
|
+
import { flash } from "@open-mercato/ui/backend/FlashMessages";
|
|
15
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
16
|
+
const PERSON_EMAIL_CARD_ACTIONS_CONTEXT_ID = "customers-person-email-card-actions";
|
|
17
|
+
function EmailCardActions({ data }) {
|
|
18
|
+
const t = useT();
|
|
19
|
+
const router = useRouter();
|
|
20
|
+
const { runMutation, retryLastMutation } = useGuardedMutation({
|
|
21
|
+
contextId: PERSON_EMAIL_CARD_ACTIONS_CONTEXT_ID,
|
|
22
|
+
blockedMessage: t("ui.forms.flash.saveBlocked", "Save blocked by validation")
|
|
23
|
+
});
|
|
24
|
+
const personId = data.personId ?? null;
|
|
25
|
+
const rfcMessageId = data.rfcMessageId ?? null;
|
|
26
|
+
const fromAddress = data.fromAddress ?? null;
|
|
27
|
+
const [mode, setMode] = React.useState(null);
|
|
28
|
+
const [channels, setChannels] = React.useState(null);
|
|
29
|
+
React.useEffect(() => {
|
|
30
|
+
let cancelled = false;
|
|
31
|
+
apiCall("/api/communication_channels/me/channels", {
|
|
32
|
+
method: "GET",
|
|
33
|
+
// Mount-time chrome fetch: degrade silently on an expired session.
|
|
34
|
+
headers: { "x-om-forbidden-redirect": "0", "x-om-unauthorized-redirect": "0" }
|
|
35
|
+
}).then((r) => {
|
|
36
|
+
if (cancelled) return;
|
|
37
|
+
const allItems = Array.isArray(r.result?.items) ? r.result.items : [];
|
|
38
|
+
const connected = allItems.filter(
|
|
39
|
+
(item) => item !== null && typeof item === "object" && item.status === "connected"
|
|
40
|
+
);
|
|
41
|
+
setChannels(connected);
|
|
42
|
+
}).catch(() => {
|
|
43
|
+
if (!cancelled) setChannels([]);
|
|
44
|
+
});
|
|
45
|
+
return () => {
|
|
46
|
+
cancelled = true;
|
|
47
|
+
};
|
|
48
|
+
}, []);
|
|
49
|
+
const refreshTimeline = React.useCallback(() => {
|
|
50
|
+
router.refresh();
|
|
51
|
+
}, [router]);
|
|
52
|
+
useAppEvent("customers.email.linked", refreshTimeline, [refreshTimeline]);
|
|
53
|
+
useAppEvent("messages.message.sent", refreshTimeline, [refreshTimeline]);
|
|
54
|
+
if (!personId || !rfcMessageId) return null;
|
|
55
|
+
if (channels === null) return null;
|
|
56
|
+
const subjectBase = data.subject ?? "";
|
|
57
|
+
const reSubject = subjectBase.toLowerCase().startsWith("re:") ? subjectBase : `Re: ${subjectBase}`.trim();
|
|
58
|
+
const fwdSubject = subjectBase.toLowerCase().startsWith("fwd:") ? subjectBase : `Fwd: ${subjectBase}`.trim();
|
|
59
|
+
const replyTo = mode == null ? null : {
|
|
60
|
+
inReplyTo: rfcMessageId,
|
|
61
|
+
references: Array.from(/* @__PURE__ */ new Set([...data.references ?? [], rfcMessageId])),
|
|
62
|
+
to: mode === "forward" ? [] : fromAddress ? [fromAddress] : [],
|
|
63
|
+
cc: mode === "replyAll" ? data.ccAddresses ?? void 0 : void 0,
|
|
64
|
+
subject: mode === "forward" ? fwdSubject : reSubject
|
|
65
|
+
};
|
|
66
|
+
const onSend = async (values) => {
|
|
67
|
+
const operation = async () => {
|
|
68
|
+
const response = await apiCall(
|
|
69
|
+
`/api/customers/people/${encodeURIComponent(personId)}/emails`,
|
|
70
|
+
{
|
|
71
|
+
method: "POST",
|
|
72
|
+
headers: { "content-type": "application/json" },
|
|
73
|
+
body: JSON.stringify(values)
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
const err = response.result;
|
|
78
|
+
throw new Error(err?.error ?? t("customers.email.errors.sendFailed", "Send failed"));
|
|
79
|
+
}
|
|
80
|
+
return response.result?.messageId ?? null;
|
|
81
|
+
};
|
|
82
|
+
const messageId = await runMutation({
|
|
83
|
+
operation,
|
|
84
|
+
context: {
|
|
85
|
+
formId: PERSON_EMAIL_CARD_ACTIONS_CONTEXT_ID,
|
|
86
|
+
resourceKind: "customers.person",
|
|
87
|
+
resourceId: personId,
|
|
88
|
+
retryLastMutation
|
|
89
|
+
},
|
|
90
|
+
mutationPayload: values
|
|
91
|
+
});
|
|
92
|
+
flash(t("customers.email.compose.sent", "Email sent"), "success");
|
|
93
|
+
return { messageId };
|
|
94
|
+
};
|
|
95
|
+
const noChannels = channels.length === 0;
|
|
96
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
97
|
+
/* @__PURE__ */ jsx(
|
|
98
|
+
EmailReplyForwardActions,
|
|
99
|
+
{
|
|
100
|
+
onReply: () => setMode("reply"),
|
|
101
|
+
onReplyAll: () => setMode("replyAll"),
|
|
102
|
+
onForward: () => setMode("forward"),
|
|
103
|
+
disabled: noChannels
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
data.isAuthor === true && data.currentVisibility ? /* @__PURE__ */ jsx(
|
|
107
|
+
IconButton,
|
|
108
|
+
{
|
|
109
|
+
type: "button",
|
|
110
|
+
variant: "ghost",
|
|
111
|
+
size: "sm",
|
|
112
|
+
"aria-label": data.currentVisibility === "private" ? t("customers.email.visibility.flipToShared.label", "Share with teammates") : t("customers.email.visibility.flipToPrivate.label", "Make private"),
|
|
113
|
+
title: data.currentVisibility === "private" ? t("customers.email.visibility.flipToShared.label", "Share with teammates") : t("customers.email.visibility.flipToPrivate.label", "Make private"),
|
|
114
|
+
onClick: async (e) => {
|
|
115
|
+
e.stopPropagation();
|
|
116
|
+
const interactionId = data.interactionId;
|
|
117
|
+
if (!interactionId) return;
|
|
118
|
+
const next = data.currentVisibility === "private" ? "shared" : "private";
|
|
119
|
+
try {
|
|
120
|
+
await runMutation({
|
|
121
|
+
operation: async () => {
|
|
122
|
+
const r = await apiCall(
|
|
123
|
+
`/api/customers/interactions/${interactionId}/visibility`,
|
|
124
|
+
{
|
|
125
|
+
method: "PATCH",
|
|
126
|
+
headers: { "content-type": "application/json" },
|
|
127
|
+
body: JSON.stringify({ visibility: next })
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
if (!r.ok) {
|
|
131
|
+
const err = r.result;
|
|
132
|
+
throw new Error(
|
|
133
|
+
err?.error ?? t("customers.email.errors.flipFailed", "Visibility update failed")
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
context: {
|
|
138
|
+
formId: PERSON_EMAIL_CARD_ACTIONS_CONTEXT_ID,
|
|
139
|
+
resourceKind: "customers.interaction",
|
|
140
|
+
resourceId: interactionId,
|
|
141
|
+
retryLastMutation
|
|
142
|
+
},
|
|
143
|
+
mutationPayload: { visibility: next }
|
|
144
|
+
});
|
|
145
|
+
} catch (err) {
|
|
146
|
+
flash(
|
|
147
|
+
err instanceof Error ? err.message : t("customers.email.errors.flipFailed", "Visibility update failed"),
|
|
148
|
+
"error"
|
|
149
|
+
);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
flash(
|
|
153
|
+
next === "shared" ? t("customers.email.visibility.flipToShared.success", "Email shared with teammates") : t("customers.email.visibility.flipToPrivate.success", "Email made private"),
|
|
154
|
+
"success"
|
|
155
|
+
);
|
|
156
|
+
router.refresh();
|
|
157
|
+
},
|
|
158
|
+
children: data.currentVisibility === "private" ? /* @__PURE__ */ jsx(Lock, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(Users, { className: "h-4 w-4" })
|
|
159
|
+
}
|
|
160
|
+
) : null,
|
|
161
|
+
mode != null && /* @__PURE__ */ jsx(
|
|
162
|
+
ComposeEmailDialog,
|
|
163
|
+
{
|
|
164
|
+
open: mode != null,
|
|
165
|
+
onOpenChange: (open) => setMode(open ? mode : null),
|
|
166
|
+
defaultRecipient: fromAddress,
|
|
167
|
+
channels,
|
|
168
|
+
replyTo,
|
|
169
|
+
onSend
|
|
170
|
+
}
|
|
171
|
+
)
|
|
172
|
+
] });
|
|
173
|
+
}
|
|
174
|
+
var EmailCardActions_default = EmailCardActions;
|
|
175
|
+
export {
|
|
176
|
+
EmailCardActions,
|
|
177
|
+
EmailCardActions_default as default
|
|
178
|
+
};
|
|
179
|
+
//# sourceMappingURL=EmailCardActions.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/modules/customers/components/detail/EmailCardActions.tsx"],
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { useRouter } from 'next/navigation'\nimport { Lock, Users } from 'lucide-react'\nimport { EmailReplyForwardActions } from './EmailReplyForwardActions'\nimport {\n ComposeEmailDialog,\n type ComposeEmailChannel,\n type ComposeEmailValues,\n} from './ComposeEmailDialog'\nimport { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'\nimport { useAppEvent } from '@open-mercato/ui/backend/injection/useAppEvent'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\n\nexport type EmailCardWidgetData = {\n interactionId?: string | null\n externalMessageId?: string | null\n rfcMessageId?: string | null\n personId?: string | null\n fromAddress?: string | null\n toAddresses?: string[] | null\n ccAddresses?: string[] | null\n subject?: string | null\n inReplyTo?: string | null\n references?: string[] | null\n /** Current visibility state of the email row, for toggling. */\n currentVisibility?: 'private' | 'shared' | null\n /** True when authorUserId === currentUserId. Drives whether the toggle renders. */\n isAuthor?: boolean | null\n}\n\ntype ReplyMode = 'reply' | 'replyAll' | 'forward'\n\ntype EmailCardActionsProps = {\n data: EmailCardWidgetData\n}\n\nconst PERSON_EMAIL_CARD_ACTIONS_CONTEXT_ID = 'customers-person-email-card-actions'\n\n/**\n * Reply / Reply All / Forward (+ visibility toggle) actions for an email\n * activity card. Composed directly into `ActivityCard` \u2014 the customers module\n * owns the timeline, so this is built in place rather than self-injected (see\n * ARCHITECTURE.md \u00A74 inject-vs-compose).\n */\nexport function EmailCardActions({ data }: EmailCardActionsProps) {\n const t = useT()\n const router = useRouter()\n const { runMutation, retryLastMutation } = useGuardedMutation<{\n formId: string\n resourceKind: string\n resourceId: string\n retryLastMutation: () => Promise<boolean>\n }>({\n contextId: PERSON_EMAIL_CARD_ACTIONS_CONTEXT_ID,\n blockedMessage: t('ui.forms.flash.saveBlocked', 'Save blocked by validation'),\n })\n\n const personId = data.personId ?? null\n const rfcMessageId = data.rfcMessageId ?? null\n const fromAddress = data.fromAddress ?? null\n\n const [mode, setMode] = React.useState<ReplyMode | null>(null)\n const [channels, setChannels] = React.useState<ComposeEmailChannel[] | null>(null)\n\n React.useEffect(() => {\n let cancelled = false\n apiCall<{ items?: unknown[] }>('/api/communication_channels/me/channels', {\n method: 'GET',\n // Mount-time chrome fetch: degrade silently on an expired session.\n headers: { 'x-om-forbidden-redirect': '0', 'x-om-unauthorized-redirect': '0' },\n })\n .then((r) => {\n if (cancelled) return\n const allItems: unknown[] = Array.isArray(r.result?.items) ? r.result!.items! : []\n const connected = allItems.filter(\n (item) =>\n item !== null &&\n typeof item === 'object' &&\n (item as Record<string, unknown>).status === 'connected',\n ) as ComposeEmailChannel[]\n setChannels(connected)\n })\n .catch(() => {\n if (!cancelled) setChannels([])\n })\n return () => {\n cancelled = true\n }\n }, [])\n\n const refreshTimeline = React.useCallback(() => {\n router.refresh()\n }, [router])\n\n // Event-driven refresh so a sent reply/forward surfaces on the activity\n // timeline once the worker links it, without a fixed-timer guess.\n useAppEvent('customers.email.linked', refreshTimeline, [refreshTimeline])\n useAppEvent('messages.message.sent', refreshTimeline, [refreshTimeline])\n\n // Return null when we have neither a person to send to nor an RFC message ID to thread against.\n // The buttons would be non-functional in that case.\n if (!personId || !rfcMessageId) return null\n\n // Channels still loading \u2014 render nothing to avoid a flash of disabled buttons.\n if (channels === null) return null\n\n const subjectBase = data.subject ?? ''\n const reSubject = subjectBase.toLowerCase().startsWith('re:')\n ? subjectBase\n : `Re: ${subjectBase}`.trim()\n const fwdSubject = subjectBase.toLowerCase().startsWith('fwd:')\n ? subjectBase\n : `Fwd: ${subjectBase}`.trim()\n\n const replyTo =\n mode == null\n ? null\n : {\n inReplyTo: rfcMessageId,\n references: Array.from(new Set([...(data.references ?? []), rfcMessageId])),\n to: mode === 'forward' ? [] : fromAddress ? [fromAddress] : [],\n cc: mode === 'replyAll' ? (data.ccAddresses ?? undefined) : undefined,\n subject: mode === 'forward' ? fwdSubject : reSubject,\n }\n\n const onSend = async (values: ComposeEmailValues): Promise<{ messageId: string | null }> => {\n const operation = async () => {\n const response = await apiCall<{ messageId?: string }>(\n `/api/customers/people/${encodeURIComponent(personId)}/emails`,\n {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(values),\n },\n )\n if (!response.ok) {\n const err = response.result as { error?: string } | null\n throw new Error(err?.error ?? t('customers.email.errors.sendFailed', 'Send failed'))\n }\n return response.result?.messageId ?? null\n }\n const messageId = await runMutation({\n operation,\n context: {\n formId: PERSON_EMAIL_CARD_ACTIONS_CONTEXT_ID,\n resourceKind: 'customers.person',\n resourceId: personId,\n retryLastMutation,\n },\n mutationPayload: values as unknown as Record<string, unknown>,\n })\n flash(t('customers.email.compose.sent', 'Email sent'), 'success')\n return { messageId }\n }\n\n const noChannels = channels.length === 0\n\n return (\n <>\n <EmailReplyForwardActions\n onReply={() => setMode('reply')}\n onReplyAll={() => setMode('replyAll')}\n onForward={() => setMode('forward')}\n disabled={noChannels}\n />\n {data.isAuthor === true && data.currentVisibility ? (\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n aria-label={\n data.currentVisibility === 'private'\n ? t('customers.email.visibility.flipToShared.label', 'Share with teammates')\n : t('customers.email.visibility.flipToPrivate.label', 'Make private')\n }\n title={\n data.currentVisibility === 'private'\n ? t('customers.email.visibility.flipToShared.label', 'Share with teammates')\n : t('customers.email.visibility.flipToPrivate.label', 'Make private')\n }\n onClick={async (e) => {\n e.stopPropagation()\n const interactionId = data.interactionId\n if (!interactionId) return\n const next = data.currentVisibility === 'private' ? 'shared' : 'private'\n try {\n await runMutation({\n operation: async () => {\n const r = await apiCall<{ ok?: boolean }>(\n `/api/customers/interactions/${interactionId}/visibility`,\n {\n method: 'PATCH',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ visibility: next }),\n },\n )\n if (!r.ok) {\n const err = r.result as { error?: string } | null\n throw new Error(\n err?.error ?? t('customers.email.errors.flipFailed', 'Visibility update failed'),\n )\n }\n },\n context: {\n formId: PERSON_EMAIL_CARD_ACTIONS_CONTEXT_ID,\n resourceKind: 'customers.interaction',\n resourceId: interactionId,\n retryLastMutation,\n },\n mutationPayload: { visibility: next },\n })\n } catch (err) {\n flash(\n err instanceof Error\n ? err.message\n : t('customers.email.errors.flipFailed', 'Visibility update failed'),\n 'error',\n )\n return\n }\n flash(\n next === 'shared'\n ? t('customers.email.visibility.flipToShared.success', 'Email shared with teammates')\n : t('customers.email.visibility.flipToPrivate.success', 'Email made private'),\n 'success',\n )\n // Refresh the server tree so the activity timeline reflects the new\n // visibility without a full page reload (keeps scroll position).\n router.refresh()\n }}\n >\n {data.currentVisibility === 'private' ? (\n <Lock className=\"h-4 w-4\" />\n ) : (\n <Users className=\"h-4 w-4\" />\n )}\n </IconButton>\n ) : null}\n {mode != null && (\n <ComposeEmailDialog\n open={mode != null}\n onOpenChange={(open) => setMode(open ? mode : null)}\n defaultRecipient={fromAddress}\n channels={channels}\n replyTo={replyTo}\n onSend={onSend}\n />\n )}\n </>\n )\n}\n\nexport default EmailCardActions\n"],
|
|
5
|
+
"mappings": ";AAmKI,mBACE,KADF;AAjKJ,YAAY,WAAW;AACvB,SAAS,iBAAiB;AAC1B,SAAS,MAAM,aAAa;AAC5B,SAAS,gCAAgC;AACzC;AAAA,EACE;AAAA,OAGK;AACP,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,0BAA0B;AACnC,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AACtB,SAAS,YAAY;AAyBrB,MAAM,uCAAuC;AAQtC,SAAS,iBAAiB,EAAE,KAAK,GAA0B;AAChE,QAAM,IAAI,KAAK;AACf,QAAM,SAAS,UAAU;AACzB,QAAM,EAAE,aAAa,kBAAkB,IAAI,mBAKxC;AAAA,IACD,WAAW;AAAA,IACX,gBAAgB,EAAE,8BAA8B,4BAA4B;AAAA,EAC9E,CAAC;AAED,QAAM,WAAW,KAAK,YAAY;AAClC,QAAM,eAAe,KAAK,gBAAgB;AAC1C,QAAM,cAAc,KAAK,eAAe;AAExC,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAA2B,IAAI;AAC7D,QAAM,CAAC,UAAU,WAAW,IAAI,MAAM,SAAuC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;AAAA,QACd,cAAc,CAAC,SAAS,QAAQ,OAAO,OAAO,IAAI;AAAA,QAClD,kBAAkB;AAAA,QAClB;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF;AAAA,KAEJ;AAEJ;AAEA,IAAO,2BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Reply, ReplyAll, Forward } from "lucide-react";
|
|
4
|
+
import { IconButton } from "@open-mercato/ui/primitives/icon-button";
|
|
5
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
6
|
+
function EmailReplyForwardActions(props) {
|
|
7
|
+
const t = useT();
|
|
8
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex gap-1", role: "group", "aria-label": t("customers.email.timeline.actionsAria", "Email actions"), children: [
|
|
9
|
+
/* @__PURE__ */ jsx(
|
|
10
|
+
IconButton,
|
|
11
|
+
{
|
|
12
|
+
type: "button",
|
|
13
|
+
variant: "ghost",
|
|
14
|
+
size: "sm",
|
|
15
|
+
onClick: props.onReply,
|
|
16
|
+
disabled: props.disabled,
|
|
17
|
+
"aria-label": t("customers.email.timeline.reply", "Reply"),
|
|
18
|
+
children: /* @__PURE__ */ jsx(Reply, { className: "h-4 w-4" })
|
|
19
|
+
}
|
|
20
|
+
),
|
|
21
|
+
/* @__PURE__ */ jsx(
|
|
22
|
+
IconButton,
|
|
23
|
+
{
|
|
24
|
+
type: "button",
|
|
25
|
+
variant: "ghost",
|
|
26
|
+
size: "sm",
|
|
27
|
+
onClick: props.onReplyAll,
|
|
28
|
+
disabled: props.disabled,
|
|
29
|
+
"aria-label": t("customers.email.timeline.replyAll", "Reply all"),
|
|
30
|
+
children: /* @__PURE__ */ jsx(ReplyAll, { className: "h-4 w-4" })
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
/* @__PURE__ */ jsx(
|
|
34
|
+
IconButton,
|
|
35
|
+
{
|
|
36
|
+
type: "button",
|
|
37
|
+
variant: "ghost",
|
|
38
|
+
size: "sm",
|
|
39
|
+
onClick: props.onForward,
|
|
40
|
+
disabled: props.disabled,
|
|
41
|
+
"aria-label": t("customers.email.timeline.forward", "Forward"),
|
|
42
|
+
children: /* @__PURE__ */ jsx(Forward, { className: "h-4 w-4" })
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
] });
|
|
46
|
+
}
|
|
47
|
+
var EmailReplyForwardActions_default = EmailReplyForwardActions;
|
|
48
|
+
export {
|
|
49
|
+
EmailReplyForwardActions,
|
|
50
|
+
EmailReplyForwardActions_default as default
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=EmailReplyForwardActions.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/modules/customers/components/detail/EmailReplyForwardActions.tsx"],
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { Reply, ReplyAll, Forward } from 'lucide-react'\nimport { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\n\nexport interface EmailReplyForwardActionsProps {\n onReply: () => void\n onReplyAll: () => void\n onForward: () => void\n disabled?: boolean\n}\n\nexport function EmailReplyForwardActions(props: EmailReplyForwardActionsProps) {\n const t = useT()\n return (\n <div className=\"flex gap-1\" role=\"group\" aria-label={t('customers.email.timeline.actionsAria', 'Email actions')}>\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={props.onReply}\n disabled={props.disabled}\n aria-label={t('customers.email.timeline.reply', 'Reply')}\n >\n <Reply className=\"h-4 w-4\" />\n </IconButton>\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={props.onReplyAll}\n disabled={props.disabled}\n aria-label={t('customers.email.timeline.replyAll', 'Reply all')}\n >\n <ReplyAll className=\"h-4 w-4\" />\n </IconButton>\n <IconButton\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={props.onForward}\n disabled={props.disabled}\n aria-label={t('customers.email.timeline.forward', 'Forward')}\n >\n <Forward className=\"h-4 w-4\" />\n </IconButton>\n </div>\n )\n}\n\nexport default EmailReplyForwardActions\n"],
|
|
5
|
+
"mappings": ";AAiBI,SASI,KATJ;AAdJ,SAAS,OAAO,UAAU,eAAe;AACzC,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AASd,SAAS,yBAAyB,OAAsC;AAC7E,QAAM,IAAI,KAAK;AACf,SACE,qBAAC,SAAI,WAAU,cAAa,MAAK,SAAQ,cAAY,EAAE,wCAAwC,eAAe,GAC5G;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,SAAS,MAAM;AAAA,QACf,UAAU,MAAM;AAAA,QAChB,cAAY,EAAE,kCAAkC,OAAO;AAAA,QAEvD,8BAAC,SAAM,WAAU,WAAU;AAAA;AAAA,IAC7B;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,SAAS,MAAM;AAAA,QACf,UAAU,MAAM;AAAA,QAChB,cAAY,EAAE,qCAAqC,WAAW;AAAA,QAE9D,8BAAC,YAAS,WAAU,WAAU;AAAA;AAAA,IAChC;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,SAAS,MAAM;AAAA,QACf,UAAU,MAAM;AAAA,QAChB,cAAY,EAAE,oCAAoC,SAAS;AAAA,QAE3D,8BAAC,WAAQ,WAAU,WAAU;AAAA;AAAA,IAC/B;AAAA,KACF;AAEJ;AAEA,IAAO,mCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|