@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,277 @@
|
|
|
1
|
+
import { useState, useRef } from "react";
|
|
2
|
+
import { toast } from "sonner";
|
|
3
|
+
import { getUser } from "@zenify-omni/chat-js/utils/auth.js";
|
|
4
|
+
import {
|
|
5
|
+
addFriendZalo,
|
|
6
|
+
findUserZalo,
|
|
7
|
+
sendMessageZalo
|
|
8
|
+
} from "@zenify-omni/chat-js/api/settings/channel.js";
|
|
9
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
10
|
+
import QUERY_KEY from "@zenify-omni/chat-js/constants/use-query-key.js";
|
|
11
|
+
import i18n from "@zenify-omni/chat-js/lib/i18n/index.js";
|
|
12
|
+
const TypeModelAddZalo = {
|
|
13
|
+
AddFriendDefault: 1,
|
|
14
|
+
SendMessage: 2,
|
|
15
|
+
ZaloInfo: 3,
|
|
16
|
+
AddFriendInChat: 4
|
|
17
|
+
};
|
|
18
|
+
const isAddFriendType = (type) => {
|
|
19
|
+
return [
|
|
20
|
+
TypeModelAddZalo.AddFriendDefault,
|
|
21
|
+
TypeModelAddZalo.AddFriendInChat
|
|
22
|
+
].includes(type);
|
|
23
|
+
};
|
|
24
|
+
const useModelAddZalo = ({
|
|
25
|
+
setPageSelectPop = () => {
|
|
26
|
+
},
|
|
27
|
+
ticket,
|
|
28
|
+
contact,
|
|
29
|
+
ticketId,
|
|
30
|
+
onSendMessageSuccess,
|
|
31
|
+
setLoadingZalo = () => {
|
|
32
|
+
},
|
|
33
|
+
setLoadingSendMess = () => {
|
|
34
|
+
},
|
|
35
|
+
onFindUserFinished = () => {
|
|
36
|
+
},
|
|
37
|
+
onSubmitFinished = () => {
|
|
38
|
+
},
|
|
39
|
+
isCheckAddFriendOnFindUser = true
|
|
40
|
+
}) => {
|
|
41
|
+
const user = getUser();
|
|
42
|
+
const queryClient = useQueryClient();
|
|
43
|
+
const handleFindUserZalo = async (phone, type = TypeModelAddZalo.AddFriendDefault, options = {}, showNotify = true) => {
|
|
44
|
+
const {
|
|
45
|
+
isCheckFriendly = false,
|
|
46
|
+
personal_zalo_id,
|
|
47
|
+
sendFromPage,
|
|
48
|
+
zalosAllocated,
|
|
49
|
+
_openModalAddFriend = false,
|
|
50
|
+
_pzaloType = null
|
|
51
|
+
} = options;
|
|
52
|
+
setLoadingZalo(true);
|
|
53
|
+
try {
|
|
54
|
+
if (!phone && type !== TypeModelAddZalo.AddFriendInChat) {
|
|
55
|
+
setLoadingZalo(false);
|
|
56
|
+
if (showNotify) {
|
|
57
|
+
toast.error(
|
|
58
|
+
i18n.t("customer:message.invalidZaloPhone", {
|
|
59
|
+
defaultValue: "S\u1ED1 \u0111i\u1EC7n tho\u1EA1i Zalo kh\xF4ng h\u1EE3p l\u1EC7"
|
|
60
|
+
})
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const payloadFindUserZalo = {
|
|
66
|
+
user_id: user._id
|
|
67
|
+
};
|
|
68
|
+
if (type === TypeModelAddZalo.AddFriendInChat) {
|
|
69
|
+
payloadFindUserZalo.zalo_customer_id = personal_zalo_id;
|
|
70
|
+
payloadFindUserZalo.page_id = ticket.source_id;
|
|
71
|
+
} else {
|
|
72
|
+
payloadFindUserZalo.phone = phone;
|
|
73
|
+
payloadFindUserZalo.page_id = sendFromPage;
|
|
74
|
+
}
|
|
75
|
+
console.log("payloadFindUserZalo", payloadFindUserZalo);
|
|
76
|
+
const userZalo = await findUserZalo(payloadFindUserZalo);
|
|
77
|
+
if (userZalo) {
|
|
78
|
+
const name = userZalo?.data?.data?.me?.displayName;
|
|
79
|
+
let zalo_data = userZalo?.data?.data?.user;
|
|
80
|
+
setLoadingZalo(false);
|
|
81
|
+
if (type === TypeModelAddZalo.SendMessage) {
|
|
82
|
+
isCheckAddFriendOnFindUser = false;
|
|
83
|
+
}
|
|
84
|
+
if (isCheckAddFriendOnFindUser || isCheckFriendly) {
|
|
85
|
+
if (zalo_data?.isFr === 1) {
|
|
86
|
+
return toast.error(
|
|
87
|
+
i18n.t("customer:message.alreadyFriend", {
|
|
88
|
+
defaultValue: "User \u0111\xE3 l\xE0 b\u1EA1n b\xE8"
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
if (isAddFriendType(type) && userZalo?.data?.data?.is_friend_request_sent) {
|
|
93
|
+
return toast.error(
|
|
94
|
+
i18n.t("customer:message.friendRequestAlreadySent", {
|
|
95
|
+
defaultValue: "L\u1EDDi m\u1EDDi k\u1EBFt b\u1EA1n \u0111\xE3 \u0111\u01B0\u1EE3c g\u1EEDi tr\u01B0\u1EDBc \u0111\xF3"
|
|
96
|
+
})
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const data = {
|
|
101
|
+
zalo_data: {
|
|
102
|
+
...zalo_data,
|
|
103
|
+
is_friend_request_sent: userZalo?.data?.data?.is_friend_request_sent
|
|
104
|
+
},
|
|
105
|
+
modal_type: type || TypeModelAddZalo.AddFriendDefault,
|
|
106
|
+
phone,
|
|
107
|
+
sendFromPage,
|
|
108
|
+
zalosAllocated,
|
|
109
|
+
defaultMessage: isAddFriendType(type) ? i18n.t("customer:message.friendRequestGreeting", {
|
|
110
|
+
name,
|
|
111
|
+
defaultValue: "Xin ch\xE0o, m\xECnh l\xE0 {name}. K\u1EBFt b\u1EA1n v\u1EDBi m\xECnh nh\xE9"
|
|
112
|
+
}) : ``,
|
|
113
|
+
_pzaloType
|
|
114
|
+
};
|
|
115
|
+
setZaloPop(data);
|
|
116
|
+
setPageSelectPop(null);
|
|
117
|
+
onFindUserFinished(true, data, { _openModalAddFriend });
|
|
118
|
+
} else {
|
|
119
|
+
setLoadingZalo(false);
|
|
120
|
+
onFindUserFinished(false, null, { _openModalAddFriend });
|
|
121
|
+
if (showNotify) {
|
|
122
|
+
toast.error(
|
|
123
|
+
i18n.t("customer:message.zaloUserNotFound", {
|
|
124
|
+
defaultValue: "Kh\xF4ng t\xECm th\u1EA5y ng\u01B0\u1EDDi d\xF9ng Zalo v\u1EDBi s\u1ED1 \u0111i\u1EC7n tho\u1EA1i n\xE0y"
|
|
125
|
+
})
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
} catch (error) {
|
|
130
|
+
setLoadingZalo(false);
|
|
131
|
+
toast.error(
|
|
132
|
+
error?.response?.data?.error?.message || i18n.t("common:toast.errorOccurred", {
|
|
133
|
+
defaultValue: "\u0110\xE3 x\u1EA3y ra l\u1ED7i"
|
|
134
|
+
})
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const textareaRef = useRef(null);
|
|
139
|
+
const getAllZaloLocate = () => {
|
|
140
|
+
if ([
|
|
141
|
+
TypeModelAddZalo.AddFriendDefault,
|
|
142
|
+
TypeModelAddZalo.AddFriendInChat
|
|
143
|
+
].includes(zaloPop.modal_type)) {
|
|
144
|
+
queryClient.invalidateQueries({
|
|
145
|
+
queryKey: [QUERY_KEY.GET_ZALOS_ALLOCATED]
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const handleSubmit = async () => {
|
|
150
|
+
setLoadingSendMess(true);
|
|
151
|
+
try {
|
|
152
|
+
const user2 = getUser();
|
|
153
|
+
const user_id = user2._id;
|
|
154
|
+
const phone = zaloPop.phone;
|
|
155
|
+
const sendFromPage = zaloPop.sendFromPage;
|
|
156
|
+
const valueMessage = textareaRef.current?.value;
|
|
157
|
+
const message = valueMessage || zaloPop.defaultMessage;
|
|
158
|
+
if (!valueMessage?.trim()) {
|
|
159
|
+
setLoadingSendMess(false);
|
|
160
|
+
return toast.error(
|
|
161
|
+
i18n.t("customer:message.messageRequired", {
|
|
162
|
+
defaultValue: "Tin nh\u1EAFn kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng"
|
|
163
|
+
})
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
const fn = [
|
|
167
|
+
TypeModelAddZalo.AddFriendDefault,
|
|
168
|
+
TypeModelAddZalo.AddFriendInChat
|
|
169
|
+
].includes(zaloPop.modal_type) ? addFriendZalo : sendMessageZalo;
|
|
170
|
+
const successMessage = [
|
|
171
|
+
TypeModelAddZalo.AddFriendDefault,
|
|
172
|
+
TypeModelAddZalo.AddFriendInChat
|
|
173
|
+
].includes(zaloPop.modal_type) ? i18n.t("chat:toast.sendZaloFriendRequestSuccess", {
|
|
174
|
+
defaultValue: "\u0110\xE3 g\u1EEDi l\u1EDDi m\u1EDDi k\u1EBFt b\u1EA1n Zalo th\xE0nh c\xF4ng"
|
|
175
|
+
}) : i18n.t("chat:toast.sendZaloMessageSuccess", {
|
|
176
|
+
defaultValue: "\u0110\xE3 g\u1EEDi tin nh\u1EAFn Zalo th\xE0nh c\xF4ng"
|
|
177
|
+
});
|
|
178
|
+
const errorMessage = [
|
|
179
|
+
TypeModelAddZalo.AddFriendDefault,
|
|
180
|
+
TypeModelAddZalo.AddFriendInChat
|
|
181
|
+
].includes(zaloPop.modal_type) ? i18n.t("chat:label.anErrorOccurredPleaseDouble", {
|
|
182
|
+
defaultValue: "C\xF3 l\u1ED7i x\u1EA3y ra, h\xE3y ki\u1EC3m tra l\u1EA1i th\xF4ng tin zalo"
|
|
183
|
+
}) : i18n.t("chat:toast.sendZaloMessageFail", {
|
|
184
|
+
defaultValue: "Kh\xF4ng th\u1EC3 g\u1EEDi tin nh\u1EAFn Zalo, h\xE3y ki\u1EC3m tra l\u1EA1i th\xF4ng tin zalo"
|
|
185
|
+
});
|
|
186
|
+
const payload = {
|
|
187
|
+
user_id,
|
|
188
|
+
first_message: message?.trim()
|
|
189
|
+
};
|
|
190
|
+
if (zaloPop.modal_type === TypeModelAddZalo.AddFriendInChat) {
|
|
191
|
+
payload.customer_id = contact?._id;
|
|
192
|
+
payload.zalo_user_id = contact?.personal_zalo_ids?.[0] || zaloPop?.zalo_data?.uid || zaloPop?.zalo_data?.userId;
|
|
193
|
+
payload.page_id = ticket.source_id;
|
|
194
|
+
} else {
|
|
195
|
+
payload.old_ticket_id = ticketId;
|
|
196
|
+
payload.phone = phone;
|
|
197
|
+
}
|
|
198
|
+
if ([
|
|
199
|
+
TypeModelAddZalo.SendMessage,
|
|
200
|
+
TypeModelAddZalo.AddFriendDefault
|
|
201
|
+
].includes(zaloPop.modal_type)) {
|
|
202
|
+
payload.page_id = sendFromPage;
|
|
203
|
+
}
|
|
204
|
+
const data = await fn(payload);
|
|
205
|
+
setZaloPop(false);
|
|
206
|
+
onSubmitFinished(true, data);
|
|
207
|
+
if (data) {
|
|
208
|
+
setLoadingSendMess(false);
|
|
209
|
+
getAllZaloLocate();
|
|
210
|
+
toast.success(successMessage);
|
|
211
|
+
if (onSendMessageSuccess && zaloPop.modal_type !== 1) {
|
|
212
|
+
if (!data?.data?.data?.is_hidden) {
|
|
213
|
+
onSendMessageSuccess(
|
|
214
|
+
data?.data?.data?.msgId,
|
|
215
|
+
data?.data?.data?.source_id
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
} else {
|
|
219
|
+
queryClient.invalidateQueries({
|
|
220
|
+
queryKey: [QUERY_KEY.GET_TICKET_COMMENTS]
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
} else {
|
|
224
|
+
setLoadingSendMess(false);
|
|
225
|
+
toast.error(errorMessage);
|
|
226
|
+
}
|
|
227
|
+
} catch (error) {
|
|
228
|
+
getAllZaloLocate();
|
|
229
|
+
onSubmitFinished(true, null);
|
|
230
|
+
setLoadingSendMess(false);
|
|
231
|
+
toast.error(
|
|
232
|
+
error.response?.data?.error?.message || i18n.t("chat:label.anErrorOccurredPleaseDouble", {
|
|
233
|
+
defaultValue: "C\xF3 l\u1ED7i x\u1EA3y ra, h\xE3y ki\u1EC3m tra l\u1EA1i th\xF4ng tin zalo"
|
|
234
|
+
})
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
const [zaloPop, setZaloPop] = useState(false);
|
|
239
|
+
const getTitleButon = (type) => {
|
|
240
|
+
switch (type) {
|
|
241
|
+
case TypeModelAddZalo.AddFriendDefault:
|
|
242
|
+
case TypeModelAddZalo.AddFriendInChat:
|
|
243
|
+
return "K\u1EBFt b\u1EA1n";
|
|
244
|
+
case TypeModelAddZalo.SendMessage:
|
|
245
|
+
return "G\u1EEDi tin nh\u1EAFn";
|
|
246
|
+
default:
|
|
247
|
+
return "";
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
const getTitle = (type) => {
|
|
251
|
+
switch (type) {
|
|
252
|
+
case TypeModelAddZalo.AddFriendDefault:
|
|
253
|
+
case TypeModelAddZalo.AddFriendInChat:
|
|
254
|
+
return "G\u1EEDi k\u1EBFt b\u1EA1n Zalo";
|
|
255
|
+
case TypeModelAddZalo.SendMessage:
|
|
256
|
+
return "G\u1EEDi tin nh\u1EAFn Zalo";
|
|
257
|
+
case TypeModelAddZalo.ZaloInfo:
|
|
258
|
+
return "Th\xF4ng tin Zalo";
|
|
259
|
+
default:
|
|
260
|
+
return "";
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
return {
|
|
264
|
+
handleFindUserZalo,
|
|
265
|
+
zaloPop,
|
|
266
|
+
setZaloPop,
|
|
267
|
+
textareaRef,
|
|
268
|
+
handleSubmit,
|
|
269
|
+
getTitle,
|
|
270
|
+
getTitleButon
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
var modal_add_friend_zalo_default = useModelAddZalo;
|
|
274
|
+
export {
|
|
275
|
+
TypeModelAddZalo,
|
|
276
|
+
modal_add_friend_zalo_default as default
|
|
277
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../lib/utils.js";
|
|
3
|
+
import DOMPurify from "dompurify";
|
|
4
|
+
import { useRef, useEffect } from "react";
|
|
5
|
+
import { applyZaloEmojiStyles } from "../../utils/replaceZaloSprite.js";
|
|
6
|
+
function isVisiblyEmpty(html = "") {
|
|
7
|
+
const temp = document.createElement("div");
|
|
8
|
+
temp.innerHTML = html;
|
|
9
|
+
return temp.children.length === 0 && !temp.textContent?.trim();
|
|
10
|
+
}
|
|
11
|
+
function SafeHTML({
|
|
12
|
+
html,
|
|
13
|
+
className,
|
|
14
|
+
isReply,
|
|
15
|
+
/** Allow inline `style` (e.g. Zalo RTF colors) — only pass for trusted server/FE-generated HTML */
|
|
16
|
+
allowStyledRtf = false
|
|
17
|
+
}) {
|
|
18
|
+
const ref = useRef(null);
|
|
19
|
+
const original = typeof html === "string" ? html.replace(/\r\n?/g, "\n").trim() : "";
|
|
20
|
+
const sanitized = allowStyledRtf ? DOMPurify.sanitize(original, { ADD_ATTR: ["style", "target"] }) : DOMPurify.sanitize(original, { ADD_ATTR: ["target"] });
|
|
21
|
+
const shouldFallback = !sanitized || isVisiblyEmpty(sanitized);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
applyZaloEmojiStyles(ref.current);
|
|
24
|
+
}, [sanitized]);
|
|
25
|
+
return shouldFallback ? /* @__PURE__ */ jsx(
|
|
26
|
+
"div",
|
|
27
|
+
{
|
|
28
|
+
ref,
|
|
29
|
+
className: cn("w-full break-words py-2", className),
|
|
30
|
+
style: { whiteSpace: !isReply && "pre-wrap" },
|
|
31
|
+
children: original
|
|
32
|
+
}
|
|
33
|
+
) : /* @__PURE__ */ jsx(
|
|
34
|
+
"div",
|
|
35
|
+
{
|
|
36
|
+
ref,
|
|
37
|
+
className: cn("w-full break-words py-2", className),
|
|
38
|
+
style: { whiteSpace: !isReply && "pre-wrap" },
|
|
39
|
+
dangerouslySetInnerHTML: { __html: sanitized }
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
SafeHTML as default
|
|
45
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useEffect } from "react";
|
|
3
|
+
import { Slider } from "../ui/slider.js";
|
|
4
|
+
import { Button } from "../ui/button.js";
|
|
5
|
+
import { Play, Pause, SkipBack, SkipForward } from "lucide-react";
|
|
6
|
+
function AudioPlayer({ src }) {
|
|
7
|
+
const [isPlaying, setIsPlaying] = useState(false);
|
|
8
|
+
const [duration, setDuration] = useState(0);
|
|
9
|
+
const [currentTime, setCurrentTime] = useState(0);
|
|
10
|
+
const audioRef = useRef(null);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const audio = audioRef.current;
|
|
13
|
+
audio.addEventListener("loadedmetadata", onLoadedMetadata);
|
|
14
|
+
audio.addEventListener("timeupdate", onTimeUpdate);
|
|
15
|
+
audio.addEventListener("ended", onEnded);
|
|
16
|
+
return () => {
|
|
17
|
+
audio.removeEventListener("loadedmetadata", onLoadedMetadata);
|
|
18
|
+
audio.removeEventListener("timeupdate", onTimeUpdate);
|
|
19
|
+
audio.removeEventListener("ended", onEnded);
|
|
20
|
+
};
|
|
21
|
+
}, []);
|
|
22
|
+
const onLoadedMetadata = () => {
|
|
23
|
+
setDuration(audioRef.current.duration);
|
|
24
|
+
};
|
|
25
|
+
const onTimeUpdate = () => {
|
|
26
|
+
setCurrentTime(audioRef.current.currentTime);
|
|
27
|
+
};
|
|
28
|
+
const onEnded = () => {
|
|
29
|
+
setIsPlaying(false);
|
|
30
|
+
setCurrentTime(0);
|
|
31
|
+
};
|
|
32
|
+
const togglePlayPause = () => {
|
|
33
|
+
if (isPlaying) {
|
|
34
|
+
audioRef.current.pause();
|
|
35
|
+
} else {
|
|
36
|
+
audioRef.current.play();
|
|
37
|
+
}
|
|
38
|
+
setIsPlaying(!isPlaying);
|
|
39
|
+
};
|
|
40
|
+
const onSliderChange = (value) => {
|
|
41
|
+
const time = value[0];
|
|
42
|
+
audioRef.current.currentTime = time;
|
|
43
|
+
setCurrentTime(time);
|
|
44
|
+
};
|
|
45
|
+
const skipBackward = () => {
|
|
46
|
+
audioRef.current.currentTime -= 10;
|
|
47
|
+
};
|
|
48
|
+
const skipForward = () => {
|
|
49
|
+
audioRef.current.currentTime += 10;
|
|
50
|
+
};
|
|
51
|
+
const formatTime = (time) => {
|
|
52
|
+
const minutes = Math.floor(time / 60);
|
|
53
|
+
const seconds = Math.floor(time % 60);
|
|
54
|
+
return `${minutes}:${seconds.toString().padStart(2, "0")}`;
|
|
55
|
+
};
|
|
56
|
+
return /* @__PURE__ */ jsxs("div", { className: "mx-auto w-full rounded-lg bg-card p-4 shadow-md", children: [
|
|
57
|
+
/* @__PURE__ */ jsx("audio", { ref: audioRef, src }),
|
|
58
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-2 flex justify-between text-sm text-muted-foreground", children: [
|
|
59
|
+
/* @__PURE__ */ jsx("span", { children: formatTime(currentTime) }),
|
|
60
|
+
/* @__PURE__ */ jsx("span", { children: formatTime(duration) })
|
|
61
|
+
] }),
|
|
62
|
+
/* @__PURE__ */ jsx(
|
|
63
|
+
Slider,
|
|
64
|
+
{
|
|
65
|
+
value: [currentTime],
|
|
66
|
+
max: duration,
|
|
67
|
+
step: 0.1,
|
|
68
|
+
onValueChange: onSliderChange,
|
|
69
|
+
className: "w-full"
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-4 flex items-center justify-between", children: [
|
|
73
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", onClick: skipBackward, children: /* @__PURE__ */ jsx(SkipBack, { className: "h-4 w-4" }) }),
|
|
74
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "icon", onClick: togglePlayPause, children: isPlaying ? /* @__PURE__ */ jsx(Pause, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(Play, { className: "h-4 w-4" }) }),
|
|
75
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", onClick: skipForward, children: /* @__PURE__ */ jsx(SkipForward, { className: "h-4 w-4" }) })
|
|
76
|
+
] })
|
|
77
|
+
] });
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
AudioPlayer
|
|
81
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
|
4
|
+
import { cn } from "../../lib/utils.js";
|
|
5
|
+
import { Edit } from "lucide-react";
|
|
6
|
+
const _failedAvatarSrcs = /* @__PURE__ */ new Set();
|
|
7
|
+
function normalizeAvatarUrl(src) {
|
|
8
|
+
if (!src) return src;
|
|
9
|
+
try {
|
|
10
|
+
const url = new URL(src);
|
|
11
|
+
url.searchParams.delete("_r");
|
|
12
|
+
return url.toString();
|
|
13
|
+
} catch {
|
|
14
|
+
return src;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const Avatar = React.forwardRef(
|
|
18
|
+
({ className, statusColor, edit, ...props }, ref) => /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
19
|
+
/* @__PURE__ */ jsx(
|
|
20
|
+
AvatarPrimitive.Root,
|
|
21
|
+
{
|
|
22
|
+
ref,
|
|
23
|
+
className: cn(
|
|
24
|
+
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
|
|
25
|
+
className
|
|
26
|
+
),
|
|
27
|
+
...props
|
|
28
|
+
}
|
|
29
|
+
),
|
|
30
|
+
statusColor && !edit && /* @__PURE__ */ jsx(
|
|
31
|
+
"span",
|
|
32
|
+
{
|
|
33
|
+
className: cn(
|
|
34
|
+
"absolute bottom-0 right-0 h-3 w-3 rounded-full border-2 border-card",
|
|
35
|
+
statusColor || "bg-muted-foreground"
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
edit && /* @__PURE__ */ jsx(
|
|
40
|
+
Edit,
|
|
41
|
+
{
|
|
42
|
+
className: cn("absolute bottom-1 right-1 h-3 w-3", statusColor)
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
] })
|
|
46
|
+
);
|
|
47
|
+
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
|
48
|
+
const AvatarImage = React.forwardRef(
|
|
49
|
+
({ className, src, onLoadingStatusChange, ...props }, ref) => {
|
|
50
|
+
const normalized = normalizeAvatarUrl(src);
|
|
51
|
+
const effectiveSrc = _failedAvatarSrcs.has(normalized) ? void 0 : src;
|
|
52
|
+
return /* @__PURE__ */ jsx(
|
|
53
|
+
AvatarPrimitive.Image,
|
|
54
|
+
{
|
|
55
|
+
ref,
|
|
56
|
+
className: cn("aspect-square h-full w-full", className),
|
|
57
|
+
src: effectiveSrc,
|
|
58
|
+
onLoadingStatusChange: (status) => {
|
|
59
|
+
if (status === "error" && normalized) _failedAvatarSrcs.add(normalized);
|
|
60
|
+
onLoadingStatusChange?.(status);
|
|
61
|
+
},
|
|
62
|
+
...props
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
|
68
|
+
const AvatarFallback = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
69
|
+
AvatarPrimitive.Fallback,
|
|
70
|
+
{
|
|
71
|
+
ref,
|
|
72
|
+
className: cn(
|
|
73
|
+
"flex h-full w-full items-center justify-center rounded-full border-2 border-card bg-muted",
|
|
74
|
+
className
|
|
75
|
+
),
|
|
76
|
+
...props
|
|
77
|
+
}
|
|
78
|
+
));
|
|
79
|
+
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
|
80
|
+
const generateAvatarFallback = (name) => {
|
|
81
|
+
if (!name) return "";
|
|
82
|
+
const words = name.trim().split(" ");
|
|
83
|
+
if (words.length === 1) {
|
|
84
|
+
return words[0].slice(0, 2)?.toUpperCase();
|
|
85
|
+
}
|
|
86
|
+
const firstLetter = words[0][0]?.toUpperCase();
|
|
87
|
+
const lastLetter = words[words.length - 1][0]?.toUpperCase();
|
|
88
|
+
return firstLetter + lastLetter;
|
|
89
|
+
};
|
|
90
|
+
export {
|
|
91
|
+
Avatar,
|
|
92
|
+
AvatarFallback,
|
|
93
|
+
AvatarImage,
|
|
94
|
+
generateAvatarFallback
|
|
95
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import DateTimePicker from "../date-time-picker/index.js";
|
|
3
|
+
import { cn } from "../../../lib/utils.js";
|
|
4
|
+
import { isSameDay } from "date-fns";
|
|
5
|
+
function BetweenDatePicker({
|
|
6
|
+
value,
|
|
7
|
+
onChange,
|
|
8
|
+
disabled,
|
|
9
|
+
direction = "column",
|
|
10
|
+
showTimeComponent = true,
|
|
11
|
+
classNames,
|
|
12
|
+
size
|
|
13
|
+
}) {
|
|
14
|
+
const from = value?.from ? new Date(value.from) : void 0;
|
|
15
|
+
const to = value?.to ? new Date(value.to) : void 0;
|
|
16
|
+
const isRow = direction === "row";
|
|
17
|
+
const handleChange = (key, date) => {
|
|
18
|
+
const next = {
|
|
19
|
+
...value || {},
|
|
20
|
+
[key]: date ? date.toISOString() : null
|
|
21
|
+
};
|
|
22
|
+
if (key === "from" && date && next.to && date > new Date(next.to)) {
|
|
23
|
+
next.to = null;
|
|
24
|
+
}
|
|
25
|
+
onChange(next);
|
|
26
|
+
};
|
|
27
|
+
return /* @__PURE__ */ jsxs(
|
|
28
|
+
"div",
|
|
29
|
+
{
|
|
30
|
+
className: cn("flex gap-2", isRow ? "flex-row items-center" : "flex-col"),
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ jsx("div", { className: cn(isRow && "flex-1"), children: /* @__PURE__ */ jsx(
|
|
33
|
+
DateTimePicker,
|
|
34
|
+
{
|
|
35
|
+
date: from,
|
|
36
|
+
onChange: (date) => handleChange("from", date),
|
|
37
|
+
showTimeComponent,
|
|
38
|
+
disabled,
|
|
39
|
+
classNames,
|
|
40
|
+
size,
|
|
41
|
+
disabledDate: to ? { after: to } : void 0,
|
|
42
|
+
disabledHourFunc: (hour) => {
|
|
43
|
+
if (!to || !from || !isSameDay(from, to)) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return Number(hour) > to.getHours();
|
|
47
|
+
},
|
|
48
|
+
disabledMinuteFunc: (minute) => {
|
|
49
|
+
if (!to || !from || !isSameDay(from, to)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
return from.getHours() < to.getHours() ? false : Number(minute) > to.getMinutes();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
) }),
|
|
56
|
+
/* @__PURE__ */ jsx("div", { className: cn(isRow && "flex-1"), children: /* @__PURE__ */ jsx(
|
|
57
|
+
DateTimePicker,
|
|
58
|
+
{
|
|
59
|
+
date: to,
|
|
60
|
+
onChange: (date) => handleChange("to", date),
|
|
61
|
+
showTimeComponent,
|
|
62
|
+
disabled,
|
|
63
|
+
classNames,
|
|
64
|
+
size,
|
|
65
|
+
disabledDate: from ? { before: from } : void 0,
|
|
66
|
+
disabledHourFunc: (hour) => {
|
|
67
|
+
if (!from || !to || !isSameDay(to, from)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return Number(hour) < from.getHours();
|
|
71
|
+
},
|
|
72
|
+
disabledMinuteFunc: (minute) => {
|
|
73
|
+
if (!from || !to || !isSameDay(to, from)) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return from.getHours() < to.getHours() ? false : Number(minute) < from.getMinutes();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
) })
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
BetweenDatePicker as default
|
|
86
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import i18n from "@zenify-omni/chat-js/lib/i18n/index.js";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { Button } from "./button.js";
|
|
5
|
+
const ButtonClose = forwardRef(({ onClose, title, ...props }, ref) => {
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
Button,
|
|
8
|
+
{
|
|
9
|
+
ref,
|
|
10
|
+
type: "button",
|
|
11
|
+
variant: "outlet",
|
|
12
|
+
onClick: (e) => {
|
|
13
|
+
onClose?.();
|
|
14
|
+
props.onClick?.(e);
|
|
15
|
+
},
|
|
16
|
+
...props,
|
|
17
|
+
className: "border border-muted bg-surface-subtle text-foreground shadow-sm",
|
|
18
|
+
children: title || i18n.t("common:action.close", {
|
|
19
|
+
defaultValue: "\u0110\xF3ng"
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
ButtonClose.displayName = "ButtonClose";
|
|
25
|
+
var button_close_default = ButtonClose;
|
|
26
|
+
export {
|
|
27
|
+
button_close_default as default
|
|
28
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
+
import { LoaderCircle } from "lucide-react";
|
|
5
|
+
import { cva } from "class-variance-authority";
|
|
6
|
+
import { cn } from "../../lib/utils.js";
|
|
7
|
+
const buttonVariants = cva(
|
|
8
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
13
|
+
destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
|
|
14
|
+
outline: "border border-border bg-card shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
15
|
+
success: "bg-success text-primary-foreground shadow hover:bg-success/90",
|
|
16
|
+
secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
17
|
+
["outline-secondary"]: "border border-[hsl(var(--border-secondary))] bg-card text-secondary-foreground shadow-sm hover:bg-accent",
|
|
18
|
+
["eye-viewer"]: "border border-[hsl(var(--border-eye-viewer))] bg-card text-[hsl(var(--icon-eye-viewer))] shadow-sm hover:bg-accent",
|
|
19
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
20
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
21
|
+
action: "bg-card border border-primary text-primary hover:bg-secondary rounded-[5px]"
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
default: "h-9 px-4 py-2",
|
|
25
|
+
sm: "h-8 rounded-md px-3 text-xs",
|
|
26
|
+
lg: "h-10 rounded-md px-8",
|
|
27
|
+
icon: "h-9 w-9",
|
|
28
|
+
action: "h-[40px] w-[40px]"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: {
|
|
32
|
+
variant: "default",
|
|
33
|
+
size: "default"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
const Button = React.forwardRef(
|
|
38
|
+
({ className, variant, size, children, ...props }, ref) => {
|
|
39
|
+
const { asChild, ...rest } = props;
|
|
40
|
+
if (asChild) {
|
|
41
|
+
return /* @__PURE__ */ jsx(
|
|
42
|
+
Slot,
|
|
43
|
+
{
|
|
44
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
45
|
+
ref,
|
|
46
|
+
...rest,
|
|
47
|
+
children
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
const {
|
|
52
|
+
loading = false,
|
|
53
|
+
leftSection,
|
|
54
|
+
rightSection,
|
|
55
|
+
disabled,
|
|
56
|
+
...otherProps
|
|
57
|
+
} = props;
|
|
58
|
+
return /* @__PURE__ */ jsxs(
|
|
59
|
+
"button",
|
|
60
|
+
{
|
|
61
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
62
|
+
disabled: loading || disabled,
|
|
63
|
+
ref,
|
|
64
|
+
...otherProps,
|
|
65
|
+
children: [
|
|
66
|
+
(leftSection && loading || !leftSection && !rightSection && loading) && /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 w-4 animate-spin" }),
|
|
67
|
+
!loading && leftSection && /* @__PURE__ */ jsx("div", { className: "mr-2", children: leftSection }),
|
|
68
|
+
children,
|
|
69
|
+
!loading && rightSection && /* @__PURE__ */ jsx("div", { className: "ml-2", children: rightSection }),
|
|
70
|
+
rightSection && loading && /* @__PURE__ */ jsx(LoaderCircle, { className: "ml-2 w-4 animate-spin" })
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
Button.displayName = "Button";
|
|
77
|
+
export {
|
|
78
|
+
Button,
|
|
79
|
+
buttonVariants
|
|
80
|
+
};
|