@zenify-omni/chat-ui-react-js 0.1.0
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/LICENSE +21 -0
- package/README.md +92 -0
- package/assets/asset-url.js +6 -0
- package/assets/icons/chatter_agent.js +27 -0
- package/assets/icons/chatter_chatbot.js +43 -0
- package/assets/icons/chatter_contact.js +36 -0
- package/assets/icons/email_icon.png +0 -0
- package/assets/icons/emoji/angry.svg +56 -0
- package/assets/icons/emoji/haha.svg +20 -0
- package/assets/icons/emoji/like.svg +10 -0
- package/assets/icons/emoji/like_out_line.png +0 -0
- package/assets/icons/emoji/love.svg +10 -0
- package/assets/icons/emoji/sad.svg +46 -0
- package/assets/icons/emoji/wow.svg +51 -0
- package/assets/icons/instagram.js +29 -0
- package/assets/icons/not_found.png +0 -0
- package/assets/icons/not_found_template.svg +9 -0
- package/assets/icons/phone_icon.png +0 -0
- package/assets/icons/shopee.js +17 -0
- package/assets/icons/sms_icon.png +0 -0
- package/assets/icons/tiktok.js +17 -0
- package/assets/icons/whatsapp.js +28 -0
- package/assets/icons/zalo.js +17 -0
- package/assets/icons/zalo_icon.png +0 -0
- package/assets/icons/zns_icon.png +0 -0
- package/assets/images/emoji.webp +0 -0
- package/assets/images/error.png +0 -0
- package/assets/images/menu.png +0 -0
- package/assets/images/money.png +0 -0
- package/assets/images/success.png +0 -0
- package/assets/public-urls.js +78 -0
- package/components/campaign-detail-route/select/group.js +38 -0
- package/components/campaign-detail-route/select/multi-groups.js +43 -0
- package/components/chat-route/chat-box/ads-context-card.js +143 -0
- package/components/chat-route/chat-box/chat-drop-file.js +18 -0
- package/components/chat-route/chat-box/chat-feedback/chat-insight.js +214 -0
- package/components/chat-route/chat-box/chat-feedback/index.js +127 -0
- package/components/chat-route/chat-box/chat-header-actions-inline.js +1055 -0
- package/components/chat-route/chat-box/chat-header.js +465 -0
- package/components/chat-route/chat-box/chat-input.js +1164 -0
- package/components/chat-route/chat-box/chat-message-action.js +399 -0
- package/components/chat-route/chat-box/chat-message-list.js +995 -0
- package/components/chat-route/chat-box/chat-message.js +2099 -0
- package/components/chat-route/chat-box/chat-reply-preview.js +317 -0
- package/components/chat-route/chat-box/common-groups-modal.js +430 -0
- package/components/chat-route/chat-box/constants.js +29 -0
- package/components/chat-route/chat-box/contact-card/index.js +87 -0
- package/components/chat-route/chat-box/edit-customer-alias-dialog.js +197 -0
- package/components/chat-route/chat-box/emoji-picker-combined.js +91 -0
- package/components/chat-route/chat-box/emoji-sprite.js +45 -0
- package/components/chat-route/chat-box/emojiMap.js +92 -0
- package/components/chat-route/chat-box/facebook-reconnect-notice.js +49 -0
- package/components/chat-route/chat-box/forward-message-modal.js +659 -0
- package/components/chat-route/chat-box/index.js +165 -0
- package/components/chat-route/chat-box/message-time.js +44 -0
- package/components/chat-route/chat-box/message-viewers.js +114 -0
- package/components/chat-route/chat-box/pasted-file-preview.js +138 -0
- package/components/chat-route/chat-box/pinned-messages.js +255 -0
- package/components/chat-route/chat-box/react-message/react-preview.js +83 -0
- package/components/chat-route/chat-box/react-message/reaction-button.js +200 -0
- package/components/chat-route/chat-box/right-side/chat-history.js +142 -0
- package/components/chat-route/chat-box/right-side/chat-tag-selector.js +232 -0
- package/components/chat-route/chat-box/right-side/create-personal-tag-modal.js +458 -0
- package/components/chat-route/chat-box/right-side/customer/customer-info-item.js +60 -0
- package/components/chat-route/chat-box/right-side/in-room-dialog.js +225 -0
- package/components/chat-route/chat-box/right-side/zalo-group/add-friend-dialog.js +154 -0
- package/components/chat-route/chat-box/right-side/zalo-group/send-message-dialog.js +165 -0
- package/components/chat-route/chat-box/send-contact-card-modal.js +102 -0
- package/components/chat-route/chat-box/send-contact-card.js +80 -0
- package/components/chat-route/chat-box/text-content.js +400 -0
- package/components/chat-route/chat-box/use-facebook-page-invalid.js +22 -0
- package/components/chat-route/chat-box/zalo-emoji-decoration.js +98 -0
- package/components/chat-route/chat-box/zalo-emoji-picker.js +74 -0
- package/components/chat-route/chat-box/zalo-personal-editor.js +590 -0
- package/components/chat-route/chat-box/zalo-reminder/create-zalo-reminder.js +868 -0
- package/components/chat-route/chat-box/zalo-reminder/use-send-zalo-reminder.js +98 -0
- package/components/chat-route/chat-box/zalo-reminder/zalo-reminder-content.js +294 -0
- package/components/chat-route/chat-box/zalo-rtf-utils.js +422 -0
- package/components/chat-route/chat-list/action-chat-item.js +116 -0
- package/components/chat-route/chat-list/assign-agent-dialog.js +170 -0
- package/components/chat-route/chat-list/assign-tag-dialog.js +242 -0
- package/components/chat-route/chat-list/chat-item-tags.js +105 -0
- package/components/chat-route/chat-list/chat-item.js +749 -0
- package/components/chat-route/chat-list/chat-list-item.js +370 -0
- package/components/chat-route/chat-list/chat-list-selection-bar.js +426 -0
- package/components/chat-route/chat-list/chat-search-preview.js +48 -0
- package/components/chat-route/chat-list/chat-sort-menu.js +89 -0
- package/components/chat-route/chat-list/edit-filter-modal.js +468 -0
- package/components/chat-route/chat-list/filter-chat-sources.js +222 -0
- package/components/chat-route/chat-list/filter-chat.js +501 -0
- package/components/chat-route/chat-list/filter-criteria-rows.js +845 -0
- package/components/chat-route/chat-list/filter-group-select.js +66 -0
- package/components/chat-route/chat-list/filter-pin-menu.js +165 -0
- package/components/chat-route/chat-list/friend-request/list-friend-request.js +287 -0
- package/components/chat-route/chat-list/index.js +243 -0
- package/components/chat-route/chat-list/inline-search-results.js +178 -0
- package/components/chat-route/chat-list/post-ids-field.js +104 -0
- package/components/chat-route/chat-list/quick-filter-bar.js +391 -0
- package/components/chat-route/chat-list/save-filter-popover.js +258 -0
- package/components/chat-route/chat-list/search-messages/index.js +225 -0
- package/components/chat-route/chat-list/search-result-header.js +51 -0
- package/components/chat-route/chat-list/util.js +604 -0
- package/components/chat-route/chat-toolbar.js +108 -0
- package/components/chat-route/hooks/use-reassign.js +111 -0
- package/components/chat-route/shared/close-conversation-dialog.js +111 -0
- package/components/chat-route/shared/force-transfer-dialog.js +109 -0
- package/components/chat-route/shared/in-queue-confirm-dialog.js +40 -0
- package/components/chat-route/util.js +146 -0
- package/components/chat-route/zalo/modal-action-zalo.js +76 -0
- package/components/chat-route/zalo/modal-add-friend-zalo.js +277 -0
- package/components/custom/SafeHTML.js +45 -0
- package/components/custom/audio-player.js +81 -0
- package/components/custom/avatar.js +95 -0
- package/components/custom/between-date-picker/index.js +86 -0
- package/components/custom/button-close.js +28 -0
- package/components/custom/button.js +80 -0
- package/components/custom/color-picker.js +81 -0
- package/components/custom/combobox.js +168 -0
- package/components/custom/custom-dialog.js +44 -0
- package/components/custom/custom-select.js +256 -0
- package/components/custom/cycle-value-helpers.js +11 -0
- package/components/custom/cycle-value.js +93 -0
- package/components/custom/date-time-picker/components/date-time-group.js +44 -0
- package/components/custom/date-time-picker/components/date-time-input.js +383 -0
- package/components/custom/date-time-picker/components/date-time-unit-input.js +138 -0
- package/components/custom/date-time-picker/components/month-year-picker.js +232 -0
- package/components/custom/date-time-picker/hooks/use-merge-refs.js +18 -0
- package/components/custom/date-time-picker/hooks/use-scroll-to-center.js +18 -0
- package/components/custom/date-time-picker/index.js +348 -0
- package/components/custom/field-file-upload/files-upload.js +87 -0
- package/components/custom/field-file-upload/image-upload.js +115 -0
- package/components/custom/field-file-upload/preview-images-modal.js +284 -0
- package/components/custom/field-file-upload/preview-list-file.js +134 -0
- package/components/custom/field-file-upload/preview-list-image.js +108 -0
- package/components/custom/field-file-upload/upload-custom.js +222 -0
- package/components/custom/field-generator.js +639 -0
- package/components/custom/field-layout-popover.js +304 -0
- package/components/custom/file-preview-modal.js +351 -0
- package/components/custom/html-edtior.js +100 -0
- package/components/custom/icon.js +49 -0
- package/components/custom/infinite-scroll-combobox.js +253 -0
- package/components/custom/inline-edit-popover.js +90 -0
- package/components/custom/inputs/calendar-input.js +0 -0
- package/components/custom/inputs/chip-input.js +136 -0
- package/components/custom/inputs/file-input.js +71 -0
- package/components/custom/inputs/mask-data/mask-data-input.js +80 -0
- package/components/custom/inputs/mask-data/mask-data-select.js +78 -0
- package/components/custom/inputs/mask-data/mask-data-textarea.js +75 -0
- package/components/custom/inputs/mask-data/reconcile-masked-edit.js +20 -0
- package/components/custom/jxl-decode.js +34 -0
- package/components/custom/jxl-image.js +68 -0
- package/components/custom/jxl-worker.js +12 -0
- package/components/custom/label.js +55 -0
- package/components/custom/layout.js +30 -0
- package/components/custom/multi-select-search-cc.js +179 -0
- package/components/custom/multiple-select-setting-tags.js +404 -0
- package/components/custom/multiple-selector.js +821 -0
- package/components/custom/pagination.js +95 -0
- package/components/custom/popup-confirm.js +120 -0
- package/components/custom/previews/facebook/facebook-appointment-booking-preview.js +83 -0
- package/components/custom/previews/facebook/facebook-audio-preview.js +130 -0
- package/components/custom/previews/facebook/facebook-event-preview.js +72 -0
- package/components/custom/previews/facebook/facebook-file-preview.js +95 -0
- package/components/custom/previews/facebook/facebook-group-preview.js +103 -0
- package/components/custom/previews/facebook/facebook-image-preview.js +81 -0
- package/components/custom/previews/facebook/facebook-page-preview.js +85 -0
- package/components/custom/previews/facebook/facebook-post-preview.js +77 -0
- package/components/custom/previews/facebook/facebook-reel-preview.js +83 -0
- package/components/custom/previews/facebook/facebook-sticker-preview.js +23 -0
- package/components/custom/previews/facebook/facebook-video-preview.js +114 -0
- package/components/custom/previews/facebook/index.js +24 -0
- package/components/custom/previews/file-preview.js +747 -0
- package/components/custom/previews/image-preview.js +288 -0
- package/components/custom/previews/instagram/index.js +4 -0
- package/components/custom/previews/instagram/instagram-share-post-preview.js +77 -0
- package/components/custom/previews/link-preview.js +166 -0
- package/components/custom/previews/product-preview.js +334 -0
- package/components/custom/previews/tiktok-order-preview.js +278 -0
- package/components/custom/previews/tiktok-product-preview.js +321 -0
- package/components/custom/previews/tiktok-voucher-preview.js +151 -0
- package/components/custom/previews/whatsapp/index.js +10 -0
- package/components/custom/previews/whatsapp/whatsapp-contact-card-preview.js +150 -0
- package/components/custom/previews/whatsapp/whatsapp-order-preview.js +38 -0
- package/components/custom/previews/whatsapp/whatsapp-poll-preview.js +29 -0
- package/components/custom/previews/whatsapp/whatsapp-product-preview.js +29 -0
- package/components/custom/retry-image.js +44 -0
- package/components/custom/search-input.js +26 -0
- package/components/custom/separator-with-text.js +14 -0
- package/components/custom/showToast.js +21 -0
- package/components/custom/sortable-header.js +62 -0
- package/components/custom/table-resize-line.js +92 -0
- package/components/custom/time-picker/index.js +73 -0
- package/components/custom/time-picker/time-picker-input.js +159 -0
- package/components/custom/time-picker/time-picker-utils.js +152 -0
- package/components/custom/viewers/audio-player.js +192 -0
- package/components/custom/viewers/code-viewer.js +140 -0
- package/components/custom/viewers/csv-viewer.js +174 -0
- package/components/custom/viewers/docx-viewer.js +145 -0
- package/components/custom/viewers/image-viewer.js +104 -0
- package/components/custom/viewers/markdown-viewer.js +124 -0
- package/components/custom/viewers/pdf-viewer.js +333 -0
- package/components/custom/viewers/spreadsheet-viewer.js +232 -0
- package/components/custom/viewers/unsupported-viewer.js +85 -0
- package/components/custom/viewers/video-player.js +241 -0
- package/components/customers-route/change-owner-modal.js +430 -0
- package/components/customers-route/contact-note-button.js +212 -0
- package/components/customers-route/customer-source.js +37 -0
- package/components/customers-route/table/columns.js +675 -0
- package/components/customers-route/table/edit-fields.js +125 -0
- package/components/customers-route/table/editable-cell.js +218 -0
- package/components/customers-route/table/note-cell.js +77 -0
- package/components/dialogs/invite-agent.js +677 -0
- package/components/error-boundary.js +53 -0
- package/components/leads-route/duplicate-phone-warning-toast.js +96 -0
- package/components/leads-route/table/columns.js +523 -0
- package/components/leads-route/table/contact-cell-name.js +82 -0
- package/components/leads-route/table/edit-fields.js +142 -0
- package/components/leads-route/table/editable-cell.js +228 -0
- package/components/org-tree/group-name-display.js +36 -0
- package/components/org-tree/group-tree-multi-select.js +208 -0
- package/components/org-tree/group-tree-select.js +220 -0
- package/components/posts-route/dialog-select-posts.js +284 -0
- package/components/reports-route/agents/multi-select-agents.js +55 -0
- package/components/reports-route/agents/multi-select-search-agents.js +43 -0
- package/components/settings-route/chat-layout/detail/constants.js +353 -0
- package/components/settings-route/chat-layout/detail/form.js +43 -0
- package/components/settings-route/chat-timeout/channel-multi-select.js +119 -0
- package/components/settings-route/multi-channel/facebook/hooks/use-facebook-sdk.js +3 -0
- package/components/settings-route/object-rule/util.js +79 -0
- package/components/settings-route/routing/settings-dialog.js +561 -0
- package/components/settings-route/switchboard/queue-new/constant.js +9 -0
- package/components/shared/linked-customer-fields/LinkedCustomerFields.js +91 -0
- package/components/shared/linked-customer-fields/use-linked-customer-fields.js +123 -0
- package/components/smartqc-route/qc-form/controls/multi-select-search-agents.js +50 -0
- package/components/ui/alert-dialog.js +112 -0
- package/components/ui/avatar.js +44 -0
- package/components/ui/badge.js +54 -0
- package/components/ui/button.js +48 -0
- package/components/ui/calendar.js +70 -0
- package/components/ui/card.js +58 -0
- package/components/ui/carousel.js +238 -0
- package/components/ui/checkbox.js +27 -0
- package/components/ui/command.js +111 -0
- package/components/ui/context-menu.js +154 -0
- package/components/ui/dialog.js +104 -0
- package/components/ui/dropdown-menu.js +169 -0
- package/components/ui/form.js +104 -0
- package/components/ui/input.js +115 -0
- package/components/ui/label.js +20 -0
- package/components/ui/popover.js +29 -0
- package/components/ui/radio-group.js +53 -0
- package/components/ui/scroll-area.js +38 -0
- package/components/ui/select.js +147 -0
- package/components/ui/separator.js +24 -0
- package/components/ui/sheet.js +113 -0
- package/components/ui/skeleton.js +17 -0
- package/components/ui/slider.js +26 -0
- package/components/ui/sonner.js +76 -0
- package/components/ui/switch.js +54 -0
- package/components/ui/table-v2.js +269 -0
- package/components/ui/table.js +245 -0
- package/components/ui/tabs.js +89 -0
- package/components/ui/textarea.js +33 -0
- package/components/ui/tooltip.js +40 -0
- package/components/workflow-editor/nodes/ticket/picker-field.js +233 -0
- package/components/zalo-login-qr.js +237 -0
- package/components/zalo-login-status-modal.js +45 -0
- package/config/env.js +27 -0
- package/config/hmr.js +8 -0
- package/config/navigation.js +54 -0
- package/config/runtime.js +46 -0
- package/config/theme.js +274 -0
- package/constants/brand-colors.js +32 -0
- package/constants/chat-icon.js +34 -0
- package/dist/chat.css +1 -0
- package/exceptions/throw-exception.js +15 -0
- package/hooks/use-chat-attachments.js +106 -0
- package/hooks/use-chat-configs.js +62 -0
- package/hooks/use-chat-customer.js +33 -0
- package/hooks/use-chat-display-config-sync.js +72 -0
- package/hooks/use-chat-permission.js +68 -0
- package/hooks/use-chat-room-detail.js +44 -0
- package/hooks/use-chat-selection.js +26 -0
- package/hooks/use-chat-sort.js +69 -0
- package/hooks/use-chat-surface.js +8 -0
- package/hooks/use-common-filter-options.js +70 -0
- package/hooks/use-crm-organization-filter-options.js +0 -0
- package/hooks/use-crm-organizations-data.js +23 -0
- package/hooks/use-debounce.js +14 -0
- package/hooks/use-dynamic-fields.js +7 -0
- package/hooks/use-facebook-notice.js +24 -0
- package/hooks/use-feature-flags.js +6 -0
- package/hooks/use-field-layout-override.js +46 -0
- package/hooks/use-file-upload.js +119 -0
- package/hooks/use-file-viewer.js +93 -0
- package/hooks/use-frozen-columns.js +29 -0
- package/hooks/use-horizontal-scroll.js +41 -0
- package/hooks/use-image-preview-queue.js +101 -0
- package/hooks/use-inline-editable-cell.js +97 -0
- package/hooks/use-intersection-observer.js +24 -0
- package/hooks/use-interval.js +20 -0
- package/hooks/use-latest-message-id.js +13 -0
- package/hooks/use-lead-filter-options.js +0 -0
- package/hooks/use-logout-listener.js +43 -0
- package/hooks/use-org-tree.js +43 -0
- package/hooks/use-permission.js +33 -0
- package/hooks/use-quick-filters.js +175 -0
- package/hooks/use-resizable-table.js +0 -0
- package/hooks/use-setting-common.js +389 -0
- package/hooks/use-settings.js +41 -0
- package/hooks/use-sort-bindings.js +24 -0
- package/hooks/use-table-display-config.js +0 -0
- package/hooks/use-tenant-config.js +99 -0
- package/hooks/use-update-user-config.js +150 -0
- package/hooks/use-zalo-connection.js +57 -0
- package/hooks/use-zalo-mention-list.js +31 -0
- package/index.css +624 -0
- package/index.js +100 -0
- package/lib/deal-name.js +27 -0
- package/lib/i18n/react.js +7 -0
- package/lib/i18n/use-language.js +0 -0
- package/lib/query-client.js +34 -0
- package/lib/utils.js +25 -0
- package/package.json +108 -0
- package/provider/chat-context.js +9 -0
- package/provider/chat-provider.js +177 -0
- package/provider/chat-room-context.js +9 -0
- package/provider/chat-room-hooks.js +8 -0
- package/provider/chat-room-provider.js +84 -0
- package/provider/hooks.js +22 -0
- package/provider/index.js +42 -0
- package/public/contact-card-user.svg +25 -0
- package/public/images/icons/facebook.svg +1 -0
- package/public/images/icons/instagram.svg +1 -0
- package/public/images/icons/shopee.svg +1 -0
- package/public/images/icons/whatsapp.svg +1 -0
- package/public/images/icons/zalo.png +0 -0
- package/public/images/images.jpg +0 -0
- package/public/images/ticket_sources/api.png +0 -0
- package/public/images/ticket_sources/email.png +0 -0
- package/public/images/ticket_sources/facebook.png +0 -0
- package/public/images/ticket_sources/hand.png +0 -0
- package/public/images/ticket_sources/instagram.png +0 -0
- package/public/images/ticket_sources/livechat.png +0 -0
- package/public/images/ticket_sources/shopee.svg +1 -0
- package/public/images/ticket_sources/sms.png +0 -0
- package/public/images/ticket_sources/telephone-call-in.png +0 -0
- package/public/images/ticket_sources/telephone-call-out.png +0 -0
- package/public/images/ticket_sources/tiktok.png +0 -0
- package/public/images/ticket_sources/tiktok_shop.png +0 -0
- package/public/images/ticket_sources/whatsapp.png +0 -0
- package/public/images/ticket_sources/whatsapp.svg +1 -0
- package/public/images/ticket_sources/zalo.png +0 -0
- package/public/placeholder.svg +13 -0
- package/store/app-status-store.js +17 -0
- package/store/chat-display-config-store.js +182 -0
- package/store/chat-display-config.resolvers.js +88 -0
- package/store/chat-store-helpers.js +62 -0
- package/store/chat-store.js +931 -0
- package/store/crm-organization-list-filter-store.js +126 -0
- package/store/customer-list-filter-store.js +139 -0
- package/store/devtools.js +9 -0
- package/store/duplicate-phone-warning-store.js +18 -0
- package/store/entity-extract-store.js +72 -0
- package/store/file-preview-store.js +27 -0
- package/store/filter-store.js +289 -0
- package/store/index.js +22 -0
- package/store/knowledge-crawl-store.js +53 -0
- package/store/lead-list-filter-store.js +142 -0
- package/store/list-pagination-state.js +44 -0
- package/store/lumi-learn-from-chat-store.js +69 -0
- package/store/merge-suggestion-store.js +27 -0
- package/store/notification-store.js +63 -0
- package/store/preview-image-store.js +22 -0
- package/store/settings-store/multi-channel/email-list-store.js +20 -0
- package/store/settings-store/multi-channel/facebook-list-store.js +22 -0
- package/store/settings-store/multi-channel/google-list-store.js +20 -0
- package/store/settings-store/multi-channel/instagram-list-store.js +20 -0
- package/store/settings-store/multi-channel/misa-list-store.js +20 -0
- package/store/settings-store/multi-channel/nhanhvn-list-store.js +20 -0
- package/store/settings-store/multi-channel/shopee-list-store.js +20 -0
- package/store/settings-store/multi-channel/shopee-order-list-store.js +20 -0
- package/store/settings-store/multi-channel/sms-list-store.js +20 -0
- package/store/settings-store/multi-channel/tiktok-business-list-store.js +20 -0
- package/store/settings-store/multi-channel/tiktok-list-store.js +20 -0
- package/store/settings-store/multi-channel/zalo-list-store.js +22 -0
- package/store/settings-store/multi-channel/zalo-user-list-store.js +25 -0
- package/store/smart-qc-store/smart-qc-list-filter-store.js +70 -0
- package/store/tenant-config-store.js +21 -0
- package/store/user-detail-store.js +17 -0
- package/store/user-status-store.js +33 -0
- package/store/workflow-store.js +24 -0
- package/store/workspace-store.js +32 -0
- package/tailwind-preset.js +129 -0
- package/utils/chat-actions.js +414 -0
- package/utils/chat_socket.js +1225 -0
- package/utils/extra-columns.js +108 -0
- package/utils/file.js +316 -0
- package/utils/html-to-plain-text.js +12 -0
- package/utils/notification.js +71 -0
- package/utils/replaceZaloSprite.js +64 -0
- package/utils/show-be-error.js +17 -0
- package/utils/typing_socket.js +101 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { useQuery } from "@tanstack/react-query";
|
|
4
|
+
import { AlertCircle, Check, Search } from "lucide-react";
|
|
5
|
+
import {
|
|
6
|
+
Dialog,
|
|
7
|
+
DialogContent,
|
|
8
|
+
DialogDescription,
|
|
9
|
+
DialogHeader,
|
|
10
|
+
DialogTitle
|
|
11
|
+
} from "../../ui/dialog.js";
|
|
12
|
+
import { Button } from "../../custom/button.js";
|
|
13
|
+
import { Skeleton } from "../../ui/skeleton.js";
|
|
14
|
+
import { allUser as searchAllUser } from "@zenify-omni/chat-js/api/user.js";
|
|
15
|
+
import { UserRole, UserRoleContext } from "@zenify-omni/chat-js/constants/user.js";
|
|
16
|
+
import useDebounce from "../../../hooks/use-debounce.js";
|
|
17
|
+
import { colorForName, nameInitials } from "@zenify-omni/chat-js/lib/user-avatar.js";
|
|
18
|
+
import { cn } from "../../../lib/utils.js";
|
|
19
|
+
import { maskData } from "@zenify-omni/chat-js/utils/data.js";
|
|
20
|
+
import { useTranslation } from "react-i18next";
|
|
21
|
+
const AGENT_LIST_QUERY_KEY = "assign-agent-dialog-list";
|
|
22
|
+
const ASSIGNABLE_ROLES = [
|
|
23
|
+
UserRole.ADMINISTRATOR,
|
|
24
|
+
UserRole.SUPERVISOR,
|
|
25
|
+
UserRole.AGENT,
|
|
26
|
+
UserRole.SALE,
|
|
27
|
+
UserRole.SALE_TEAM_LEADER,
|
|
28
|
+
UserRole.TEAM_LEADER
|
|
29
|
+
];
|
|
30
|
+
function UserAvatar({ name = "", className }) {
|
|
31
|
+
const color = colorForName(name);
|
|
32
|
+
return /* @__PURE__ */ jsx(
|
|
33
|
+
"span",
|
|
34
|
+
{
|
|
35
|
+
className: cn(
|
|
36
|
+
"flex h-10 w-10 shrink-0 items-center justify-center rounded-full text-sm font-semibold",
|
|
37
|
+
color.bg,
|
|
38
|
+
color.text,
|
|
39
|
+
className
|
|
40
|
+
),
|
|
41
|
+
children: nameInitials(name)
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
function AssignAgentDialog({
|
|
46
|
+
open,
|
|
47
|
+
onOpenChange,
|
|
48
|
+
isSubmitting = false,
|
|
49
|
+
onConfirm
|
|
50
|
+
}) {
|
|
51
|
+
const { t } = useTranslation();
|
|
52
|
+
const [search, setSearch] = useState("");
|
|
53
|
+
const [selectedAgent, setSelectedAgent] = useState(null);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (!open) return;
|
|
56
|
+
setSearch("");
|
|
57
|
+
setSelectedAgent(null);
|
|
58
|
+
}, [open]);
|
|
59
|
+
const debouncedSearch = useDebounce(search, 500);
|
|
60
|
+
const keyword = debouncedSearch.trim();
|
|
61
|
+
const { data: agentList = [], isLoading } = useQuery({
|
|
62
|
+
queryKey: [AGENT_LIST_QUERY_KEY, keyword],
|
|
63
|
+
queryFn: async () => {
|
|
64
|
+
const params = {
|
|
65
|
+
roles: ASSIGNABLE_ROLES,
|
|
66
|
+
...keyword.length > 0 ? { keyword } : {}
|
|
67
|
+
};
|
|
68
|
+
const response = await searchAllUser(params);
|
|
69
|
+
return response.data?.list?.map((u) => ({
|
|
70
|
+
value: u._id,
|
|
71
|
+
label: u.name,
|
|
72
|
+
role: u.role
|
|
73
|
+
})) ?? [];
|
|
74
|
+
},
|
|
75
|
+
enabled: open
|
|
76
|
+
});
|
|
77
|
+
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0 sm:max-w-[420px]", children: [
|
|
78
|
+
/* @__PURE__ */ jsxs(DialogHeader, { className: "space-y-1 p-5 pb-3", children: [
|
|
79
|
+
/* @__PURE__ */ jsx(DialogTitle, { className: "text-base font-semibold", children: t("common:placeholder.selectAssignee", {
|
|
80
|
+
defaultValue: "Ch\u1ECDn ng\u01B0\u1EDDi ph\u1EE5 tr\xE1ch"
|
|
81
|
+
}) }),
|
|
82
|
+
/* @__PURE__ */ jsx(DialogDescription, { className: "text-xs", children: t("chat:dialog.quickAssignForConversations", {
|
|
83
|
+
defaultValue: "Chuy\u1EC3n nhanh ng\u01B0\u1EDDi ph\u1EE5 tr\xE1ch cho c\xE1c h\u1ED9i tho\u1EA1i \u0111\xE3 ch\u1ECDn"
|
|
84
|
+
}) })
|
|
85
|
+
] }),
|
|
86
|
+
/* @__PURE__ */ jsx("div", { className: "px-5 pb-3", children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2 rounded-lg border border-warning/40 bg-[--label-orange] p-3 text-xs leading-5 text-[--label-orange-foreground]", children: [
|
|
87
|
+
/* @__PURE__ */ jsx(AlertCircle, { size: 16, className: "mt-px shrink-0" }),
|
|
88
|
+
/* @__PURE__ */ jsx("p", { children: t("chat:message.zaloPersonalSkippedOnAssign", {
|
|
89
|
+
defaultValue: "H\u1ED9i tho\u1EA1i t\u1EEB t\xE0i kho\u1EA3n Zalo c\xE1 nh\xE2n s\u1EBD \u0111\u01B0\u1EE3c b\u1ECF qua. H\u1ED9i tho\u1EA1i t\u1EEB t\xE0i kho\u1EA3n Zalo t\u1ED5 ch\u1EE9c v\u1EABn h\u1ED7 tr\u1EE3 chuy\u1EC3n ng\u01B0\u1EDDi ph\u1EE5 tr\xE1ch."
|
|
90
|
+
}) })
|
|
91
|
+
] }) }),
|
|
92
|
+
/* @__PURE__ */ jsx("div", { className: "px-5", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-full bg-muted px-3 py-2", children: [
|
|
93
|
+
/* @__PURE__ */ jsx(Search, { size: 16, className: "shrink-0 text-muted-foreground" }),
|
|
94
|
+
/* @__PURE__ */ jsx(
|
|
95
|
+
"input",
|
|
96
|
+
{
|
|
97
|
+
value: search,
|
|
98
|
+
onChange: (e) => setSearch(e.target.value),
|
|
99
|
+
placeholder: t("chat:action.findAgent", {
|
|
100
|
+
defaultValue: "T\xECm chuy\xEAn vi\xEAn"
|
|
101
|
+
}),
|
|
102
|
+
className: "w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] }) }),
|
|
106
|
+
/* @__PURE__ */ jsxs("div", { className: "max-h-[300px] min-h-[200px] min-w-0 overflow-y-auto overflow-x-hidden px-3 py-2", children: [
|
|
107
|
+
isLoading && Array.from({ length: 4 }).map((_, index) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 px-2 py-2.5", children: [
|
|
108
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-10 shrink-0 rounded-full" }),
|
|
109
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-1.5", children: [
|
|
110
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-3.5 w-1/2" }),
|
|
111
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-1/4" })
|
|
112
|
+
] })
|
|
113
|
+
] }, index)),
|
|
114
|
+
!isLoading && agentList.length === 0 && /* @__PURE__ */ jsx("p", { className: "py-10 text-center text-sm text-muted-foreground", children: t("common:empty.noResults", {
|
|
115
|
+
defaultValue: "Kh\xF4ng t\xECm th\u1EA5y k\u1EBFt qu\u1EA3"
|
|
116
|
+
}) }),
|
|
117
|
+
!isLoading && agentList.map((agent) => {
|
|
118
|
+
const isSelected = agent.value === selectedAgent?.value;
|
|
119
|
+
return /* @__PURE__ */ jsxs(
|
|
120
|
+
"button",
|
|
121
|
+
{
|
|
122
|
+
onClick: () => setSelectedAgent(agent),
|
|
123
|
+
className: cn(
|
|
124
|
+
"flex w-full min-w-0 cursor-pointer items-center gap-3 rounded-lg px-2 py-2.5 text-left transition-colors",
|
|
125
|
+
isSelected ? "bg-primary/5 hover:bg-primary/10" : "hover:bg-muted"
|
|
126
|
+
),
|
|
127
|
+
children: [
|
|
128
|
+
/* @__PURE__ */ jsx(UserAvatar, { name: maskData(agent.label) }),
|
|
129
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
130
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-sm font-semibold text-foreground", children: maskData(agent.label) }),
|
|
131
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs text-muted-foreground", children: UserRoleContext[agent.role] || agent.role })
|
|
132
|
+
] }),
|
|
133
|
+
isSelected && /* @__PURE__ */ jsx(Check, { size: 16, className: "shrink-0 text-primary" })
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
agent.value
|
|
137
|
+
);
|
|
138
|
+
})
|
|
139
|
+
] }),
|
|
140
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center justify-between gap-3 border-t p-4", children: [
|
|
141
|
+
/* @__PURE__ */ jsx("p", { className: "min-w-0 flex-1 truncate text-xs text-muted-foreground", children: selectedAgent ? /* @__PURE__ */ jsx("span", { className: "font-medium text-foreground", children: maskData(selectedAgent.label) }) : t("chat:message.selectAgentToContinue", {
|
|
142
|
+
defaultValue: "Ch\u1ECDn m\u1ED9t chuy\xEAn vi\xEAn \u0111\u1EC3 ti\u1EBFp t\u1EE5c"
|
|
143
|
+
}) }),
|
|
144
|
+
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-2", children: [
|
|
145
|
+
/* @__PURE__ */ jsx(
|
|
146
|
+
Button,
|
|
147
|
+
{
|
|
148
|
+
size: "sm",
|
|
149
|
+
variant: "outline",
|
|
150
|
+
onClick: () => onOpenChange?.(false),
|
|
151
|
+
children: t("common:action.cancel", { defaultValue: "H\u1EE7y" })
|
|
152
|
+
}
|
|
153
|
+
),
|
|
154
|
+
/* @__PURE__ */ jsx(
|
|
155
|
+
Button,
|
|
156
|
+
{
|
|
157
|
+
size: "sm",
|
|
158
|
+
loading: isSubmitting,
|
|
159
|
+
disabled: !selectedAgent,
|
|
160
|
+
onClick: () => onConfirm?.(selectedAgent),
|
|
161
|
+
children: t("common:action.confirm", { defaultValue: "X\xE1c nh\u1EADn" })
|
|
162
|
+
}
|
|
163
|
+
)
|
|
164
|
+
] })
|
|
165
|
+
] })
|
|
166
|
+
] }) });
|
|
167
|
+
}
|
|
168
|
+
export {
|
|
169
|
+
AssignAgentDialog as default
|
|
170
|
+
};
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
4
|
+
import { LoaderCircle, Search, Tag, X } from "lucide-react";
|
|
5
|
+
import {
|
|
6
|
+
Dialog,
|
|
7
|
+
DialogContent,
|
|
8
|
+
DialogDescription,
|
|
9
|
+
DialogHeader,
|
|
10
|
+
DialogTitle
|
|
11
|
+
} from "../../ui/dialog.js";
|
|
12
|
+
import { Button } from "../../custom/button.js";
|
|
13
|
+
import { Checkbox } from "../../ui/checkbox.js";
|
|
14
|
+
import { Skeleton } from "../../ui/skeleton.js";
|
|
15
|
+
import { getProductTags } from "@zenify-omni/chat-js/api/tag.js";
|
|
16
|
+
import { ChatRoomTagBatchAction } from "@zenify-omni/chat-js/constants/chat-room-tag.js";
|
|
17
|
+
import { SettingTags } from "@zenify-omni/chat-js/constants/setting.js";
|
|
18
|
+
import QUERY_KEY from "@zenify-omni/chat-js/constants/use-query-key.js";
|
|
19
|
+
import useDebounce from "../../../hooks/use-debounce.js";
|
|
20
|
+
import { cn } from "../../../lib/utils.js";
|
|
21
|
+
import { maskData } from "@zenify-omni/chat-js/utils/data.js";
|
|
22
|
+
import { useTranslation } from "react-i18next";
|
|
23
|
+
const PAGE_SIZE = 20;
|
|
24
|
+
const TAG_LIST_QUERY_KEY = `assign-tag-dialog_${QUERY_KEY.GET_LIST_TAGS}`;
|
|
25
|
+
const withAlpha = (color, alpha) => color ? color + Math.round(255 * alpha).toString(16).padStart(2, "0") : void 0;
|
|
26
|
+
function AssignTagDialog({
|
|
27
|
+
open,
|
|
28
|
+
onOpenChange,
|
|
29
|
+
isSubmitting = false,
|
|
30
|
+
action = ChatRoomTagBatchAction.Add,
|
|
31
|
+
onConfirm
|
|
32
|
+
}) {
|
|
33
|
+
const { t } = useTranslation();
|
|
34
|
+
const [search, setSearch] = useState("");
|
|
35
|
+
const debouncedSearch = useDebounce(search, 400);
|
|
36
|
+
const [selectedTags, setSelectedTags] = useState([]);
|
|
37
|
+
const isRemove = action === ChatRoomTagBatchAction.Remove;
|
|
38
|
+
const copy = isRemove ? {
|
|
39
|
+
title: t("chat:dialog.unassignTagTitle", {
|
|
40
|
+
defaultValue: "B\u1ECF g\xE1n tag"
|
|
41
|
+
}),
|
|
42
|
+
description: t("chat:dialog.quickUnassignTagForConversations", {
|
|
43
|
+
defaultValue: "G\u1EE1 nhanh tag kh\u1ECFi c\xE1c h\u1ED9i tho\u1EA1i \u0111\xE3 ch\u1ECDn"
|
|
44
|
+
}),
|
|
45
|
+
confirm: t("chat:action.unassignTagCount", {
|
|
46
|
+
count: selectedTags.length,
|
|
47
|
+
defaultValue: "B\u1ECF g\xE1n {count} tag"
|
|
48
|
+
})
|
|
49
|
+
} : {
|
|
50
|
+
title: t("chat:dialog.assignTagTitle", { defaultValue: "G\xE1n tag" }),
|
|
51
|
+
description: t("chat:dialog.quickAssignTagForConversations", {
|
|
52
|
+
defaultValue: "G\xE1n tag nhanh cho c\xE1c h\u1ED9i tho\u1EA1i \u0111\xE3 ch\u1ECDn"
|
|
53
|
+
}),
|
|
54
|
+
confirm: t("chat:action.assignTagCount", {
|
|
55
|
+
count: selectedTags.length,
|
|
56
|
+
defaultValue: "G\xE1n {count} tag"
|
|
57
|
+
})
|
|
58
|
+
};
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (!open) return;
|
|
61
|
+
setSearch("");
|
|
62
|
+
setSelectedTags([]);
|
|
63
|
+
}, [open, action]);
|
|
64
|
+
const { data, isLoading, isFetchingNextPage, hasNextPage, fetchNextPage } = useInfiniteQuery({
|
|
65
|
+
queryKey: [TAG_LIST_QUERY_KEY, { search: debouncedSearch.trim() }],
|
|
66
|
+
queryFn: async ({ pageParam = 1 }) => {
|
|
67
|
+
const params = {
|
|
68
|
+
limit: PAGE_SIZE,
|
|
69
|
+
offset: (pageParam - 1) * PAGE_SIZE,
|
|
70
|
+
where: JSON.stringify({ type: SettingTags.Chat }),
|
|
71
|
+
include_personal: true,
|
|
72
|
+
...debouncedSearch.trim() ? { search: debouncedSearch.trim() } : {}
|
|
73
|
+
};
|
|
74
|
+
const { data: response } = await getProductTags(params);
|
|
75
|
+
const tags = response?.tags ?? [];
|
|
76
|
+
return {
|
|
77
|
+
data: tags,
|
|
78
|
+
page: pageParam,
|
|
79
|
+
hasMore: tags.length === PAGE_SIZE
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
initialPageParam: 1,
|
|
83
|
+
getNextPageParam: (lastPage) => lastPage.hasMore ? lastPage.page + 1 : void 0,
|
|
84
|
+
enabled: open
|
|
85
|
+
});
|
|
86
|
+
const tagGroups = data?.pages.flatMap((page) => page.data) ?? [];
|
|
87
|
+
const isEmpty = !isLoading && tagGroups.every((g) => !g.sub_tags?.length);
|
|
88
|
+
const isTagSelected = (tag) => selectedTags.some((x) => x._id === tag._id);
|
|
89
|
+
const toggleTag = (tag) => {
|
|
90
|
+
setSelectedTags(
|
|
91
|
+
(prev) => prev.some((x) => x._id === tag._id) ? prev.filter((x) => x._id !== tag._id) : [
|
|
92
|
+
...prev,
|
|
93
|
+
{
|
|
94
|
+
_id: tag._id,
|
|
95
|
+
name: tag.name,
|
|
96
|
+
color: tag.color,
|
|
97
|
+
...tag.user_id ? { user_id: tag.user_id } : {}
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0 sm:max-w-[420px]", children: [
|
|
103
|
+
/* @__PURE__ */ jsxs(DialogHeader, { className: "flex-row items-start gap-3 space-y-0 p-5 pb-3", children: [
|
|
104
|
+
/* @__PURE__ */ jsx(
|
|
105
|
+
"span",
|
|
106
|
+
{
|
|
107
|
+
className: cn(
|
|
108
|
+
"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg",
|
|
109
|
+
isRemove ? "bg-destructive/10 text-destructive" : "bg-primary/10 text-primary"
|
|
110
|
+
),
|
|
111
|
+
children: /* @__PURE__ */ jsx(Tag, { size: 18 })
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 space-y-1", children: [
|
|
115
|
+
/* @__PURE__ */ jsx(DialogTitle, { className: "text-base font-semibold", children: copy.title }),
|
|
116
|
+
/* @__PURE__ */ jsx(DialogDescription, { className: "text-xs", children: copy.description })
|
|
117
|
+
] })
|
|
118
|
+
] }),
|
|
119
|
+
/* @__PURE__ */ jsx("div", { className: "px-5", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-full bg-muted px-3 py-2", children: [
|
|
120
|
+
/* @__PURE__ */ jsx(Search, { size: 16, className: "shrink-0 text-muted-foreground" }),
|
|
121
|
+
/* @__PURE__ */ jsx(
|
|
122
|
+
"input",
|
|
123
|
+
{
|
|
124
|
+
value: search,
|
|
125
|
+
onChange: (e) => setSearch(e.target.value),
|
|
126
|
+
placeholder: t("common:placeholder.typeToSearch", {
|
|
127
|
+
defaultValue: "Nh\u1EADp \u0111\u1EC3 t\xECm ki\u1EBFm"
|
|
128
|
+
}),
|
|
129
|
+
className: "w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
] }) }),
|
|
133
|
+
selectedTags.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1.5 px-5 pt-3", children: [
|
|
134
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0 text-xs text-muted-foreground", children: t("common:status.selected", { defaultValue: "\u0110\xE3 ch\u1ECDn" }) }),
|
|
135
|
+
selectedTags.map((tag) => /* @__PURE__ */ jsxs(
|
|
136
|
+
"span",
|
|
137
|
+
{
|
|
138
|
+
className: "inline-flex items-center gap-1 rounded-md px-2 py-0.5 text-xs",
|
|
139
|
+
style: {
|
|
140
|
+
backgroundColor: withAlpha(tag.color, 0.2),
|
|
141
|
+
color: tag.color
|
|
142
|
+
},
|
|
143
|
+
children: [
|
|
144
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-[140px] truncate", children: maskData(tag.name) }),
|
|
145
|
+
/* @__PURE__ */ jsx(
|
|
146
|
+
"button",
|
|
147
|
+
{
|
|
148
|
+
type: "button",
|
|
149
|
+
onClick: () => toggleTag(tag),
|
|
150
|
+
className: "shrink-0 opacity-60 hover:opacity-100",
|
|
151
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
tag._id
|
|
157
|
+
))
|
|
158
|
+
] }),
|
|
159
|
+
/* @__PURE__ */ jsxs("div", { className: "max-h-[300px] min-h-[200px] overflow-y-auto overflow-x-hidden px-3 py-2", children: [
|
|
160
|
+
isLoading && Array.from({ length: 5 }).map((_, index) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-2 py-2.5", children: [
|
|
161
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-4 shrink-0 rounded-sm" }),
|
|
162
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-3.5 w-1/2" })
|
|
163
|
+
] }, index)),
|
|
164
|
+
isEmpty && /* @__PURE__ */ jsx("p", { className: "py-10 text-center text-sm text-muted-foreground", children: t("common:empty.noData", { defaultValue: "Kh\xF4ng c\xF3 d\u1EEF li\u1EC7u" }) }),
|
|
165
|
+
!isLoading && tagGroups.map((group) => /* @__PURE__ */ jsxs("div", { className: "mb-1", children: [
|
|
166
|
+
/* @__PURE__ */ jsx("p", { className: "px-2 py-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground", children: group.name }),
|
|
167
|
+
(group.sub_tags ?? []).map((tag) => {
|
|
168
|
+
const checked = isTagSelected(tag);
|
|
169
|
+
return (
|
|
170
|
+
// Bọc bằng label để bấm cả dòng là tick, tránh lồng button
|
|
171
|
+
// trong button (Checkbox của Radix vốn là một button).
|
|
172
|
+
/* @__PURE__ */ jsxs(
|
|
173
|
+
"label",
|
|
174
|
+
{
|
|
175
|
+
className: cn(
|
|
176
|
+
"flex w-full min-w-0 cursor-pointer items-center gap-2 rounded-lg px-2 py-2.5 text-left transition-colors",
|
|
177
|
+
checked ? "bg-primary/5 hover:bg-primary/10" : "hover:bg-muted"
|
|
178
|
+
),
|
|
179
|
+
children: [
|
|
180
|
+
/* @__PURE__ */ jsx(
|
|
181
|
+
Checkbox,
|
|
182
|
+
{
|
|
183
|
+
checked,
|
|
184
|
+
onCheckedChange: () => toggleTag(tag),
|
|
185
|
+
className: "shrink-0"
|
|
186
|
+
}
|
|
187
|
+
),
|
|
188
|
+
/* @__PURE__ */ jsx(
|
|
189
|
+
"span",
|
|
190
|
+
{
|
|
191
|
+
className: "h-2 w-2 shrink-0 rounded-full",
|
|
192
|
+
style: { backgroundColor: tag.color }
|
|
193
|
+
}
|
|
194
|
+
),
|
|
195
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-sm", children: tag.name })
|
|
196
|
+
]
|
|
197
|
+
},
|
|
198
|
+
tag._id
|
|
199
|
+
)
|
|
200
|
+
);
|
|
201
|
+
})
|
|
202
|
+
] }, group._id ?? group.name)),
|
|
203
|
+
hasNextPage && !isFetchingNextPage && /* @__PURE__ */ jsx(
|
|
204
|
+
Button,
|
|
205
|
+
{
|
|
206
|
+
type: "button",
|
|
207
|
+
variant: "link",
|
|
208
|
+
size: "sm",
|
|
209
|
+
className: "w-full",
|
|
210
|
+
onClick: () => fetchNextPage(),
|
|
211
|
+
children: t("common:action.loadMore", { defaultValue: "Xem th\xEAm" })
|
|
212
|
+
}
|
|
213
|
+
),
|
|
214
|
+
isFetchingNextPage && /* @__PURE__ */ jsx("div", { className: "flex justify-center py-2", children: /* @__PURE__ */ jsx(LoaderCircle, { className: "h-4 w-4 animate-spin text-muted-foreground" }) })
|
|
215
|
+
] }),
|
|
216
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-3 border-t p-4", children: /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-2", children: [
|
|
217
|
+
/* @__PURE__ */ jsx(
|
|
218
|
+
Button,
|
|
219
|
+
{
|
|
220
|
+
size: "sm",
|
|
221
|
+
variant: "outline",
|
|
222
|
+
onClick: () => onOpenChange?.(false),
|
|
223
|
+
children: t("common:action.cancel", { defaultValue: "H\u1EE7y" })
|
|
224
|
+
}
|
|
225
|
+
),
|
|
226
|
+
/* @__PURE__ */ jsx(
|
|
227
|
+
Button,
|
|
228
|
+
{
|
|
229
|
+
size: "sm",
|
|
230
|
+
variant: isRemove ? "destructive" : "default",
|
|
231
|
+
loading: isSubmitting,
|
|
232
|
+
disabled: selectedTags.length === 0,
|
|
233
|
+
onClick: () => onConfirm?.(selectedTags, action),
|
|
234
|
+
children: copy.confirm
|
|
235
|
+
}
|
|
236
|
+
)
|
|
237
|
+
] }) })
|
|
238
|
+
] }) });
|
|
239
|
+
}
|
|
240
|
+
export {
|
|
241
|
+
AssignTagDialog as default
|
|
242
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../../lib/utils.js";
|
|
3
|
+
import {
|
|
4
|
+
Tooltip,
|
|
5
|
+
TooltipProvider,
|
|
6
|
+
TooltipTrigger,
|
|
7
|
+
TooltipContent
|
|
8
|
+
} from "../../ui/tooltip.js";
|
|
9
|
+
import { useQuery } from "@tanstack/react-query";
|
|
10
|
+
import QUERY_KEY from "@zenify-omni/chat-js/constants/use-query-key.js";
|
|
11
|
+
import { findUser } from "@zenify-omni/chat-js/api/user.js";
|
|
12
|
+
const DEFAULT_TAG_COLOR = "#f97316";
|
|
13
|
+
function ChatItemTags({ tags = [], _id, assignName }) {
|
|
14
|
+
const visibleTags = tags.slice(0, 3);
|
|
15
|
+
const remainingTagCount = tags.length - 3;
|
|
16
|
+
const { data: fetchedAgent } = useQuery({
|
|
17
|
+
queryKey: [QUERY_KEY.GET_CHAT_ASSIGN_AGENT, { assign_agent_id: _id }],
|
|
18
|
+
queryFn: async () => {
|
|
19
|
+
const { data } = await findUser({ _id });
|
|
20
|
+
return data || null;
|
|
21
|
+
},
|
|
22
|
+
enabled: !!_id && !assignName,
|
|
23
|
+
staleTime: 5 * 60 * 1e3
|
|
24
|
+
});
|
|
25
|
+
const displayName = fetchedAgent?.name ?? assignName;
|
|
26
|
+
if (tags.length === 0 && !displayName) return null;
|
|
27
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-end gap-1.5 px-1", children: [
|
|
28
|
+
visibleTags.map((tag, i) => /* @__PURE__ */ jsx(
|
|
29
|
+
"span",
|
|
30
|
+
{
|
|
31
|
+
title: tag.name,
|
|
32
|
+
className: "block max-w-[80px] truncate rounded px-1.5 py-0.5 text-[10px] font-medium leading-tight",
|
|
33
|
+
style: {
|
|
34
|
+
// KHÔNG token hoá được: `${tag.color}4D` ghép alpha vào hex, nên
|
|
35
|
+
// giá trị dự phòng cũng buộc phải là hex 6 ký tự. `hsl(var(--x))`
|
|
36
|
+
// ghép chuỗi kiểu này sẽ ra CSS vô nghĩa.
|
|
37
|
+
backgroundColor: tag.color ? `${tag.color}4D` : `${DEFAULT_TAG_COLOR}4D`,
|
|
38
|
+
color: tag.color || DEFAULT_TAG_COLOR
|
|
39
|
+
},
|
|
40
|
+
children: tag.name
|
|
41
|
+
},
|
|
42
|
+
tag._id || i
|
|
43
|
+
)),
|
|
44
|
+
remainingTagCount > 0 && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
45
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
46
|
+
"span",
|
|
47
|
+
{
|
|
48
|
+
className: "shrink-0 cursor-default rounded px-1.5 py-0.5 text-[10px] font-medium leading-tight text-muted-foreground",
|
|
49
|
+
style: { backgroundColor: "hsl(var(--border-subtle))" },
|
|
50
|
+
children: [
|
|
51
|
+
"+",
|
|
52
|
+
remainingTagCount
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
) }),
|
|
56
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: tags.slice(3).map((tag, i) => /* @__PURE__ */ jsx("span", { className: "text-xs", children: tag.name }, tag._id || i)) }) })
|
|
57
|
+
] }) }),
|
|
58
|
+
displayName && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
59
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
className: cn(
|
|
63
|
+
"flex shrink-0 items-center gap-1 text-[10px] text-muted-foreground",
|
|
64
|
+
visibleTags.length > 0 && "ml-auto"
|
|
65
|
+
),
|
|
66
|
+
children: [
|
|
67
|
+
/* @__PURE__ */ jsxs(
|
|
68
|
+
"svg",
|
|
69
|
+
{
|
|
70
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
71
|
+
width: "12",
|
|
72
|
+
height: "12",
|
|
73
|
+
viewBox: "0 0 12 12",
|
|
74
|
+
fill: "none",
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ jsx(
|
|
77
|
+
"path",
|
|
78
|
+
{
|
|
79
|
+
d: "M8.25 4.5C8.25 5.74264 7.24264 6.75 6 6.75C4.75736 6.75 3.75 5.74264 3.75 4.5C3.75 3.25736 4.75736 2.25 6 2.25C7.24264 2.25 8.25 3.25736 8.25 4.5Z",
|
|
80
|
+
fill: "hsl(var(--muted-foreground))"
|
|
81
|
+
}
|
|
82
|
+
),
|
|
83
|
+
/* @__PURE__ */ jsx(
|
|
84
|
+
"path",
|
|
85
|
+
{
|
|
86
|
+
fillRule: "evenodd",
|
|
87
|
+
clipRule: "evenodd",
|
|
88
|
+
d: "M0 6C0 2.68629 2.68629 0 6 0C9.31371 0 12 2.68629 12 6C12 9.31371 9.31371 12 6 12C2.68629 12 0 9.31371 0 6ZM6 0.75C3.1005 0.75 0.75 3.1005 0.75 6C0.75 7.24007 1.17994 8.37972 1.8989 9.27802C2.4322 8.41893 3.60348 7.5 6 7.5C8.39653 7.5 9.56781 8.41894 10.1011 9.27803C10.8201 8.37972 11.25 7.24007 11.25 6C11.25 3.1005 8.8995 0.75 6 0.75Z",
|
|
89
|
+
fill: "hsl(var(--muted-foreground))"
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
),
|
|
95
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-[80px] truncate", children: displayName })
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
) }),
|
|
99
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: displayName })
|
|
100
|
+
] }) })
|
|
101
|
+
] });
|
|
102
|
+
}
|
|
103
|
+
export {
|
|
104
|
+
ChatItemTags
|
|
105
|
+
};
|