@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,389 @@
|
|
|
1
|
+
import i18n from "@zenify-omni/chat-js/lib/i18n/index.js";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import {
|
|
4
|
+
getAllAgent,
|
|
5
|
+
getAllFieldTicket,
|
|
6
|
+
getAllQueues
|
|
7
|
+
} from "@zenify-omni/chat-js/api/report.js";
|
|
8
|
+
import {
|
|
9
|
+
getCustomerExtraFields,
|
|
10
|
+
getCustomerGroups
|
|
11
|
+
} from "@zenify-omni/chat-js/api/customer.js";
|
|
12
|
+
import { getCities, getDistrictsByCityId } from "@zenify-omni/chat-js/api/settings.js";
|
|
13
|
+
import { getUserGroups } from "@zenify-omni/chat-js/api/user.js";
|
|
14
|
+
import { getZalosAllocated } from "@zenify-omni/chat-js/api/settings/channel.js";
|
|
15
|
+
import { getSettingUserConfig } from "@zenify-omni/chat-js/api/settings/common.js";
|
|
16
|
+
import { getUser } from "@zenify-omni/chat-js/utils/auth.js";
|
|
17
|
+
import { throwException } from "../exceptions/throw-exception.js";
|
|
18
|
+
import QUERY_KEY from "@zenify-omni/chat-js/constants/use-query-key.js";
|
|
19
|
+
import { getZaloGroupInfo } from "@zenify-omni/chat-js/api/chat.js";
|
|
20
|
+
import { getDistricts } from "@zenify-omni/chat-js/api/settings.js";
|
|
21
|
+
import { getListSocialPage } from "@zenify-omni/chat-js/api/chat.js";
|
|
22
|
+
import {
|
|
23
|
+
getQueue as getAllQueueV3,
|
|
24
|
+
getQueueDetail
|
|
25
|
+
} from "@zenify-omni/chat-js/api/settings/queue-v3.js";
|
|
26
|
+
const emptyData = [];
|
|
27
|
+
function useAllAgent() {
|
|
28
|
+
const { data: queryData } = useQuery({
|
|
29
|
+
queryKey: [QUERY_KEY.GET_ALL_AGENTS],
|
|
30
|
+
queryFn: async () => {
|
|
31
|
+
try {
|
|
32
|
+
const resp = await getAllAgent();
|
|
33
|
+
return resp.data.list;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
throwException(error);
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
staleTime: 60 * 1e3 * 30
|
|
40
|
+
// 30 minutes
|
|
41
|
+
});
|
|
42
|
+
return queryData || emptyData;
|
|
43
|
+
}
|
|
44
|
+
function useAllFieldTicket(systemType = "dynamic", options = {}) {
|
|
45
|
+
const { data: queryData } = useQuery({
|
|
46
|
+
...options,
|
|
47
|
+
queryKey: [
|
|
48
|
+
QUERY_KEY.GET_ALL_TICKET_FIELDS,
|
|
49
|
+
{
|
|
50
|
+
system_type: systemType
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
queryFn: async () => {
|
|
54
|
+
try {
|
|
55
|
+
const params = {
|
|
56
|
+
target: "ticket"
|
|
57
|
+
};
|
|
58
|
+
if (systemType === "all") {
|
|
59
|
+
params.system_type = systemType;
|
|
60
|
+
}
|
|
61
|
+
const resp = await getAllFieldTicket({ params });
|
|
62
|
+
return (resp?.data || []).sort(
|
|
63
|
+
(a, b) => (a.order ?? 0) - (b.order ?? 0)
|
|
64
|
+
);
|
|
65
|
+
} catch (error) {
|
|
66
|
+
throwException(error);
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
staleTime: 60 * 1e3 * 30
|
|
71
|
+
// 30 minutes
|
|
72
|
+
});
|
|
73
|
+
return queryData || emptyData;
|
|
74
|
+
}
|
|
75
|
+
function useAllFieldUser(refreshField = null, systemType = "dynamic") {
|
|
76
|
+
const { data: queryData } = useQuery({
|
|
77
|
+
queryKey: [
|
|
78
|
+
QUERY_KEY.GET_ALL_USER_FIELDS,
|
|
79
|
+
...refreshField ? [refreshField] : [],
|
|
80
|
+
{ system_type: systemType }
|
|
81
|
+
],
|
|
82
|
+
queryFn: async () => {
|
|
83
|
+
try {
|
|
84
|
+
const params = {
|
|
85
|
+
target: "user"
|
|
86
|
+
};
|
|
87
|
+
if (systemType === "all") {
|
|
88
|
+
params.system_type = "all";
|
|
89
|
+
}
|
|
90
|
+
const resp = await getCustomerExtraFields({ params });
|
|
91
|
+
return (resp?.data || []).sort(
|
|
92
|
+
(a, b) => (a.order ?? 0) - (b.order ?? 0)
|
|
93
|
+
);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
throwException(error);
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
staleTime: 60 * 1e3 * 30
|
|
100
|
+
// 30 minutes
|
|
101
|
+
});
|
|
102
|
+
return queryData || emptyData;
|
|
103
|
+
}
|
|
104
|
+
function useAllFieldContact(systemType = "dynamic") {
|
|
105
|
+
const { data: queryData } = useQuery({
|
|
106
|
+
queryKey: [QUERY_KEY.GET_ALL_CONTACT_FIELDS, { system_type: systemType }],
|
|
107
|
+
queryFn: async () => {
|
|
108
|
+
try {
|
|
109
|
+
const params = {
|
|
110
|
+
target: "contact"
|
|
111
|
+
};
|
|
112
|
+
if (systemType === "all") {
|
|
113
|
+
params.system_type = "all";
|
|
114
|
+
}
|
|
115
|
+
const resp = await getCustomerExtraFields({ params });
|
|
116
|
+
return (resp?.data || []).sort(
|
|
117
|
+
(a, b) => (a.order ?? 0) - (b.order ?? 0)
|
|
118
|
+
);
|
|
119
|
+
} catch (error) {
|
|
120
|
+
throwException(error);
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
staleTime: 60 * 1e3 * 30
|
|
125
|
+
// 30 minutes
|
|
126
|
+
});
|
|
127
|
+
return queryData || emptyData;
|
|
128
|
+
}
|
|
129
|
+
function useAllQueues({
|
|
130
|
+
service_id,
|
|
131
|
+
queue_manager_id,
|
|
132
|
+
type,
|
|
133
|
+
is_count_agent = false
|
|
134
|
+
} = {}) {
|
|
135
|
+
const { data: queryData } = useQuery({
|
|
136
|
+
queryKey: [
|
|
137
|
+
QUERY_KEY.GET_ALL_QUEUES,
|
|
138
|
+
service_id,
|
|
139
|
+
queue_manager_id,
|
|
140
|
+
is_count_agent
|
|
141
|
+
],
|
|
142
|
+
queryFn: async () => {
|
|
143
|
+
try {
|
|
144
|
+
const resp = await getAllQueues({
|
|
145
|
+
service_id,
|
|
146
|
+
queue_manager_id,
|
|
147
|
+
type,
|
|
148
|
+
is_count_agent
|
|
149
|
+
});
|
|
150
|
+
return resp.data;
|
|
151
|
+
} catch (error) {
|
|
152
|
+
throwException(error);
|
|
153
|
+
return [];
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
staleTime: 60 * 1e3 * 30
|
|
157
|
+
// 30 minutes
|
|
158
|
+
});
|
|
159
|
+
return queryData || emptyData;
|
|
160
|
+
}
|
|
161
|
+
function useAllCustomerGroups() {
|
|
162
|
+
const { data: queryData } = useQuery({
|
|
163
|
+
queryKey: [QUERY_KEY.GET_ALL_CUSTOMER_GROUPS],
|
|
164
|
+
queryFn: async () => {
|
|
165
|
+
try {
|
|
166
|
+
const resp = await getCustomerGroups();
|
|
167
|
+
return resp.data.map((item) => {
|
|
168
|
+
return {
|
|
169
|
+
id: String(item.id),
|
|
170
|
+
text: item.name
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
} catch (error) {
|
|
174
|
+
throwException(error);
|
|
175
|
+
return [];
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
staleTime: 60 * 1e3 * 30
|
|
179
|
+
// 30 minutes
|
|
180
|
+
});
|
|
181
|
+
return queryData || emptyData;
|
|
182
|
+
}
|
|
183
|
+
function useAllUserGroups() {
|
|
184
|
+
const { data: queryData } = useQuery({
|
|
185
|
+
queryKey: [QUERY_KEY.GET_ALL_USER_GROUPS],
|
|
186
|
+
queryFn: async () => {
|
|
187
|
+
try {
|
|
188
|
+
const resp = await getUserGroups();
|
|
189
|
+
return resp.data.map((item) => {
|
|
190
|
+
return {
|
|
191
|
+
id: String(item.id),
|
|
192
|
+
text: item.name
|
|
193
|
+
};
|
|
194
|
+
});
|
|
195
|
+
} catch (error) {
|
|
196
|
+
throwException(error);
|
|
197
|
+
return [];
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
staleTime: 60 * 1e3 * 30
|
|
201
|
+
// 30 minutes
|
|
202
|
+
});
|
|
203
|
+
return queryData || emptyData;
|
|
204
|
+
}
|
|
205
|
+
function useAllCities(params) {
|
|
206
|
+
const { data: queryData } = useQuery({
|
|
207
|
+
queryKey: [QUERY_KEY.GET_ALL_CITIES, params],
|
|
208
|
+
queryFn: async () => {
|
|
209
|
+
try {
|
|
210
|
+
const resp = await getCities(params);
|
|
211
|
+
return resp.data.cities.map((item) => {
|
|
212
|
+
return {
|
|
213
|
+
id: String(item.id),
|
|
214
|
+
text: item.name
|
|
215
|
+
};
|
|
216
|
+
});
|
|
217
|
+
} catch (error) {
|
|
218
|
+
throwException(error);
|
|
219
|
+
return [];
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
staleTime: 60 * 1e3 * 30
|
|
223
|
+
// 30 minutes
|
|
224
|
+
});
|
|
225
|
+
return queryData || emptyData;
|
|
226
|
+
}
|
|
227
|
+
function useAllDistricts() {
|
|
228
|
+
const { data: queryData } = useQuery({
|
|
229
|
+
queryKey: [QUERY_KEY.GET_ALL_DISTRICTS],
|
|
230
|
+
queryFn: async () => {
|
|
231
|
+
try {
|
|
232
|
+
const { data } = await getDistricts({
|
|
233
|
+
params: {}
|
|
234
|
+
});
|
|
235
|
+
return data?.districts ?? [];
|
|
236
|
+
} catch (error) {
|
|
237
|
+
throwException(error);
|
|
238
|
+
return [];
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
staleTime: 60 * 1e3 * 30
|
|
242
|
+
// 30 minutes
|
|
243
|
+
});
|
|
244
|
+
return queryData || emptyData;
|
|
245
|
+
}
|
|
246
|
+
function useUserConfig() {
|
|
247
|
+
const baseData = {
|
|
248
|
+
report_user_group_table_columns: "",
|
|
249
|
+
ticket_table_columns: "",
|
|
250
|
+
user_table_columns: "",
|
|
251
|
+
detail_user_table_columns: "",
|
|
252
|
+
campaign_report_columns: "",
|
|
253
|
+
agent_campaign_table_columns: "",
|
|
254
|
+
contact_campaign_table_columns: "",
|
|
255
|
+
ad_funnel_report_columns: "",
|
|
256
|
+
ad_funnel_report_by_source_columns: "",
|
|
257
|
+
chat_show_info_contact: "",
|
|
258
|
+
survey_columns: ""
|
|
259
|
+
};
|
|
260
|
+
const user = getUser();
|
|
261
|
+
const { data: queryData } = useQuery({
|
|
262
|
+
queryKey: [QUERY_KEY.GET_USER_CONFIGURATION, { userId: user?._id }],
|
|
263
|
+
queryFn: async () => {
|
|
264
|
+
try {
|
|
265
|
+
const { data, error } = await getSettingUserConfig();
|
|
266
|
+
return error || !data ? {} : data;
|
|
267
|
+
} catch (error) {
|
|
268
|
+
throwException(error);
|
|
269
|
+
return {};
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
staleTime: 60 * 1e3 * 30
|
|
273
|
+
// 30 minutes
|
|
274
|
+
});
|
|
275
|
+
return queryData || baseData;
|
|
276
|
+
}
|
|
277
|
+
function useGetDistrictsByCityId(cityId, options = {}) {
|
|
278
|
+
return useQuery({
|
|
279
|
+
enabled: !!cityId,
|
|
280
|
+
queryKey: [`${QUERY_KEY.GET_ALL_DISTRICT_BY_CITY_ID}/${cityId}`],
|
|
281
|
+
queryFn: () => getDistrictsByCityId({ city_id: cityId }).then(
|
|
282
|
+
(response) => response?.data?.districts ?? []
|
|
283
|
+
),
|
|
284
|
+
...options
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
function useGetListSocialPage() {
|
|
288
|
+
return useQuery({
|
|
289
|
+
queryKey: [QUERY_KEY.GET_LIST_SOCIAL_PAGE],
|
|
290
|
+
queryFn: async () => {
|
|
291
|
+
const { data } = await getListSocialPage();
|
|
292
|
+
return data;
|
|
293
|
+
},
|
|
294
|
+
staleTime: 60 * 1e3 * 30
|
|
295
|
+
// 30 minutes
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
function useGetZaloAllocatedList(user) {
|
|
299
|
+
return useQuery({
|
|
300
|
+
enabled: !!user?._id,
|
|
301
|
+
queryKey: [QUERY_KEY.GET_ZALOS_ALLOCATED, user?._id],
|
|
302
|
+
// Danh sách zalo được cấp phát gần như tĩnh trong phiên -> cache vô thời hạn,
|
|
303
|
+
// không refetch khi remount. Khi đổi (add-friend...) đã có invalidateQueries
|
|
304
|
+
// ép refetch nên không lo cache cũ.
|
|
305
|
+
staleTime: Infinity,
|
|
306
|
+
queryFn: async () => {
|
|
307
|
+
try {
|
|
308
|
+
const { data } = await getZalosAllocated({
|
|
309
|
+
user_id: user?._id,
|
|
310
|
+
agent_id: user?.agent_id,
|
|
311
|
+
tenant_id: user?.tenant_id
|
|
312
|
+
});
|
|
313
|
+
return data?.data || [];
|
|
314
|
+
} catch (error) {
|
|
315
|
+
throwException({ message: error.response.data?.error?.message });
|
|
316
|
+
return [];
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
function useGetZaloGroupInfo({ zaloId, groupId, ...options }) {
|
|
322
|
+
return useQuery({
|
|
323
|
+
enabled: !!groupId && !!zaloId,
|
|
324
|
+
queryKey: ["ZaloGroupPanel", groupId],
|
|
325
|
+
staleTime: 30 * 60 * 1e3,
|
|
326
|
+
queryFn: async () => {
|
|
327
|
+
try {
|
|
328
|
+
const { data } = await getZaloGroupInfo({
|
|
329
|
+
zaloId,
|
|
330
|
+
groupId
|
|
331
|
+
});
|
|
332
|
+
return data?.data;
|
|
333
|
+
} catch (error) {
|
|
334
|
+
if (error.response?.data?.error?.error_code === "GROUP_NOT_FOUND" && options?.onGroupNotFound && typeof options.onGroupNotFound === "function") {
|
|
335
|
+
options.onGroupNotFound(error);
|
|
336
|
+
throwException({
|
|
337
|
+
message: i18n.t("common:message.groupNotFound", {
|
|
338
|
+
defaultValue: "Nh\xF3m kh\xF4ng t\u1ED3n t\u1EA1i"
|
|
339
|
+
})
|
|
340
|
+
});
|
|
341
|
+
return null;
|
|
342
|
+
} else {
|
|
343
|
+
throwException({ message: error.response?.data?.error?.message });
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
...options
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
function useGetAllQueuesV3({ params, options = {} }) {
|
|
352
|
+
return useQuery({
|
|
353
|
+
queryKey: [QUERY_KEY.GET_LIST_QUEUE],
|
|
354
|
+
queryFn: async () => {
|
|
355
|
+
const data = await getAllQueueV3({ params });
|
|
356
|
+
return data?.items || [];
|
|
357
|
+
},
|
|
358
|
+
...options
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
function useGetQueueDetail({ queueId, options = {} } = {}) {
|
|
362
|
+
return useQuery({
|
|
363
|
+
enabled: !!queueId,
|
|
364
|
+
queryKey: [QUERY_KEY.GET_LIST_QUEUE, { queueId }],
|
|
365
|
+
queryFn: async () => {
|
|
366
|
+
const data = await getQueueDetail({ id: queueId });
|
|
367
|
+
return data;
|
|
368
|
+
},
|
|
369
|
+
...options
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
export {
|
|
373
|
+
useAllAgent,
|
|
374
|
+
useAllCities,
|
|
375
|
+
useAllCustomerGroups,
|
|
376
|
+
useAllDistricts,
|
|
377
|
+
useAllFieldContact,
|
|
378
|
+
useAllFieldTicket,
|
|
379
|
+
useAllFieldUser,
|
|
380
|
+
useAllQueues,
|
|
381
|
+
useAllUserGroups,
|
|
382
|
+
useGetAllQueuesV3,
|
|
383
|
+
useGetDistrictsByCityId,
|
|
384
|
+
useGetListSocialPage,
|
|
385
|
+
useGetQueueDetail,
|
|
386
|
+
useGetZaloAllocatedList,
|
|
387
|
+
useGetZaloGroupInfo,
|
|
388
|
+
useUserConfig
|
|
389
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { getSettings } from "@zenify-omni/chat-js/api/settings.js";
|
|
3
|
+
import { throwException } from "../exceptions/throw-exception.js";
|
|
4
|
+
import QUERY_KEY from "@zenify-omni/chat-js/constants/use-query-key.js";
|
|
5
|
+
import { setMaskDataConfig } from "@zenify-omni/chat-js/utils/data.js";
|
|
6
|
+
const emptyData = {
|
|
7
|
+
priorities: [],
|
|
8
|
+
agent_status: [],
|
|
9
|
+
feedback_templates: [],
|
|
10
|
+
types: [],
|
|
11
|
+
groups: [],
|
|
12
|
+
organizations: [],
|
|
13
|
+
ticket_status: [],
|
|
14
|
+
macro_comment: [],
|
|
15
|
+
source: [],
|
|
16
|
+
source_detail: [],
|
|
17
|
+
data_masking_config: []
|
|
18
|
+
};
|
|
19
|
+
function useSettings() {
|
|
20
|
+
const { data: queryData } = useQuery({
|
|
21
|
+
queryKey: [QUERY_KEY.GET_SETTING_DASHBOARD],
|
|
22
|
+
queryFn: async () => {
|
|
23
|
+
try {
|
|
24
|
+
const resp = await getSettings();
|
|
25
|
+
return resp.data;
|
|
26
|
+
} catch (error) {
|
|
27
|
+
throwException(error);
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
staleTime: 60 * 1e3 * 30
|
|
32
|
+
// 30 minutes
|
|
33
|
+
});
|
|
34
|
+
if (queryData?.data_masking_config) {
|
|
35
|
+
setMaskDataConfig(queryData.data_masking_config);
|
|
36
|
+
}
|
|
37
|
+
return queryData || emptyData;
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
useSettings
|
|
41
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useShallow } from "zustand/react/shallow";
|
|
2
|
+
import { useCrmOrganizationListFilterStore } from "../store/crm-organization-list-filter-store.js";
|
|
3
|
+
import { useCustomerListFilterStore } from "../store/customer-list-filter-store.js";
|
|
4
|
+
import { useSmartQcListFilterStore } from "../store/smart-qc-store/smart-qc-list-filter-store.js";
|
|
5
|
+
import { useLeadListFilterStore } from "../store/lead-list-filter-store.js";
|
|
6
|
+
import { useFacebookListStore } from "../store/settings-store/multi-channel/facebook-list-store.js";
|
|
7
|
+
import { useZaloUserListStore } from "../store/settings-store/multi-channel/zalo-user-list-store.js";
|
|
8
|
+
import { useInstagramListStore } from "../store/settings-store/multi-channel/instagram-list-store.js";
|
|
9
|
+
import { useTiktokBusinessListStore } from "../store/settings-store/multi-channel/tiktok-business-list-store.js";
|
|
10
|
+
import { useShopeeOrderListStore } from "../store/settings-store/multi-channel/shopee-order-list-store.js";
|
|
11
|
+
const selectSort = (s) => ({ sortBy: s.sortBy, setSort: s.setSort });
|
|
12
|
+
useCrmOrganizationListFilterStore(useShallow(selectSort));
|
|
13
|
+
const useContactSort = () => useCustomerListFilterStore(useShallow(selectSort));
|
|
14
|
+
useSmartQcListFilterStore(useShallow(selectSort));
|
|
15
|
+
const useLeadSort = () => useLeadListFilterStore(useShallow(selectSort));
|
|
16
|
+
useFacebookListStore(useShallow(selectSort));
|
|
17
|
+
useZaloUserListStore(useShallow(selectSort));
|
|
18
|
+
useInstagramListStore(useShallow(selectSort));
|
|
19
|
+
useTiktokBusinessListStore(useShallow(selectSort));
|
|
20
|
+
useShopeeOrderListStore(useShallow(selectSort));
|
|
21
|
+
export {
|
|
22
|
+
useContactSort,
|
|
23
|
+
useLeadSort
|
|
24
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import QUERY_KEY from "@zenify-omni/chat-js/constants/use-query-key.js";
|
|
3
|
+
import { getConfigs } from "@zenify-omni/chat-js/api/settings/config.js";
|
|
4
|
+
import { TenantConfigType } from "@zenify-omni/chat-js/constants/tenant_config.js";
|
|
5
|
+
import { throwException } from "../exceptions/throw-exception.js";
|
|
6
|
+
const emptyData = [];
|
|
7
|
+
const CATALOG_STALE_TIME = Infinity;
|
|
8
|
+
function useGetViewTenantConfig() {
|
|
9
|
+
const { data: queryData, isLoading } = useQuery({
|
|
10
|
+
queryKey: [QUERY_KEY.GET_VIEW_TENANT_CONFIG],
|
|
11
|
+
queryFn: async () => {
|
|
12
|
+
try {
|
|
13
|
+
const resp = await getConfigs({ type: TenantConfigType.VIEW });
|
|
14
|
+
return resp.data;
|
|
15
|
+
} catch (error) {
|
|
16
|
+
throwException(error);
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
staleTime: CATALOG_STALE_TIME
|
|
21
|
+
});
|
|
22
|
+
return { data: queryData || emptyData, isLoading };
|
|
23
|
+
}
|
|
24
|
+
function useGetActionTenantConfig() {
|
|
25
|
+
const { data: queryData, isLoading } = useQuery({
|
|
26
|
+
// Must be GET_ACTION_TENANT_CONFIG, not GET_DATA_*: the ACTION save site
|
|
27
|
+
// (configs/view/index.jsx) invalidates [GET_ACTION_TENANT_CONFIG]. With the
|
|
28
|
+
// wrong key + staleTime:Infinity this query never saw its own save and the
|
|
29
|
+
// action-permission catalog stayed stale for the whole session.
|
|
30
|
+
queryKey: [QUERY_KEY.GET_ACTION_TENANT_CONFIG, TenantConfigType.ACTION],
|
|
31
|
+
queryFn: async () => {
|
|
32
|
+
try {
|
|
33
|
+
const resp = await getConfigs({ type: TenantConfigType.ACTION });
|
|
34
|
+
return resp.data;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
throwException(error);
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
staleTime: CATALOG_STALE_TIME
|
|
41
|
+
});
|
|
42
|
+
return { data: queryData || emptyData, isLoading };
|
|
43
|
+
}
|
|
44
|
+
function useGetFeatureTenantConfig(tenantId) {
|
|
45
|
+
const { data: queryData, isLoading } = useQuery({
|
|
46
|
+
queryKey: [
|
|
47
|
+
QUERY_KEY.GET_FEATURE_TENANT_CONFIG,
|
|
48
|
+
{ tenant_id: tenantId || "local" }
|
|
49
|
+
],
|
|
50
|
+
queryFn: async () => {
|
|
51
|
+
try {
|
|
52
|
+
const resp = await getConfigs({
|
|
53
|
+
type: TenantConfigType.FEATURE,
|
|
54
|
+
...tenantId ? { tenant_id: tenantId } : {}
|
|
55
|
+
});
|
|
56
|
+
return resp.data;
|
|
57
|
+
} catch (error) {
|
|
58
|
+
throwException(error);
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
staleTime: CATALOG_STALE_TIME
|
|
63
|
+
});
|
|
64
|
+
return { data: queryData || emptyData, isLoading };
|
|
65
|
+
}
|
|
66
|
+
function useGetConfigTenantConfig(tenantId) {
|
|
67
|
+
const { data: queryData, isLoading } = useQuery({
|
|
68
|
+
queryKey: [
|
|
69
|
+
QUERY_KEY.GET_CONFIG_TENANT_CONFIG,
|
|
70
|
+
{ tenant_id: tenantId || "local" }
|
|
71
|
+
],
|
|
72
|
+
queryFn: async () => {
|
|
73
|
+
try {
|
|
74
|
+
const resp = await getConfigs({
|
|
75
|
+
type: TenantConfigType.CONFIG,
|
|
76
|
+
...tenantId ? { tenant_id: tenantId } : {}
|
|
77
|
+
});
|
|
78
|
+
return resp.data;
|
|
79
|
+
} catch (error) {
|
|
80
|
+
throwException(error);
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
staleTime: CATALOG_STALE_TIME
|
|
85
|
+
});
|
|
86
|
+
return { data: queryData || emptyData, isLoading };
|
|
87
|
+
}
|
|
88
|
+
function useGetConfigByKey(key) {
|
|
89
|
+
const { data: queryData, isLoading } = useGetConfigTenantConfig();
|
|
90
|
+
const res = queryData.find((config) => config.key === key);
|
|
91
|
+
return { data: res || null, isLoading };
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
useGetActionTenantConfig,
|
|
95
|
+
useGetConfigByKey,
|
|
96
|
+
useGetConfigTenantConfig,
|
|
97
|
+
useGetFeatureTenantConfig,
|
|
98
|
+
useGetViewTenantConfig
|
|
99
|
+
};
|