@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.
Files changed (403) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +92 -0
  3. package/assets/asset-url.js +6 -0
  4. package/assets/icons/chatter_agent.js +27 -0
  5. package/assets/icons/chatter_chatbot.js +43 -0
  6. package/assets/icons/chatter_contact.js +36 -0
  7. package/assets/icons/email_icon.png +0 -0
  8. package/assets/icons/emoji/angry.svg +56 -0
  9. package/assets/icons/emoji/haha.svg +20 -0
  10. package/assets/icons/emoji/like.svg +10 -0
  11. package/assets/icons/emoji/like_out_line.png +0 -0
  12. package/assets/icons/emoji/love.svg +10 -0
  13. package/assets/icons/emoji/sad.svg +46 -0
  14. package/assets/icons/emoji/wow.svg +51 -0
  15. package/assets/icons/instagram.js +29 -0
  16. package/assets/icons/not_found.png +0 -0
  17. package/assets/icons/not_found_template.svg +9 -0
  18. package/assets/icons/phone_icon.png +0 -0
  19. package/assets/icons/shopee.js +17 -0
  20. package/assets/icons/sms_icon.png +0 -0
  21. package/assets/icons/tiktok.js +17 -0
  22. package/assets/icons/whatsapp.js +28 -0
  23. package/assets/icons/zalo.js +17 -0
  24. package/assets/icons/zalo_icon.png +0 -0
  25. package/assets/icons/zns_icon.png +0 -0
  26. package/assets/images/emoji.webp +0 -0
  27. package/assets/images/error.png +0 -0
  28. package/assets/images/menu.png +0 -0
  29. package/assets/images/money.png +0 -0
  30. package/assets/images/success.png +0 -0
  31. package/assets/public-urls.js +78 -0
  32. package/components/campaign-detail-route/select/group.js +38 -0
  33. package/components/campaign-detail-route/select/multi-groups.js +43 -0
  34. package/components/chat-route/chat-box/ads-context-card.js +143 -0
  35. package/components/chat-route/chat-box/chat-drop-file.js +18 -0
  36. package/components/chat-route/chat-box/chat-feedback/chat-insight.js +214 -0
  37. package/components/chat-route/chat-box/chat-feedback/index.js +127 -0
  38. package/components/chat-route/chat-box/chat-header-actions-inline.js +1055 -0
  39. package/components/chat-route/chat-box/chat-header.js +465 -0
  40. package/components/chat-route/chat-box/chat-input.js +1164 -0
  41. package/components/chat-route/chat-box/chat-message-action.js +399 -0
  42. package/components/chat-route/chat-box/chat-message-list.js +995 -0
  43. package/components/chat-route/chat-box/chat-message.js +2099 -0
  44. package/components/chat-route/chat-box/chat-reply-preview.js +317 -0
  45. package/components/chat-route/chat-box/common-groups-modal.js +430 -0
  46. package/components/chat-route/chat-box/constants.js +29 -0
  47. package/components/chat-route/chat-box/contact-card/index.js +87 -0
  48. package/components/chat-route/chat-box/edit-customer-alias-dialog.js +197 -0
  49. package/components/chat-route/chat-box/emoji-picker-combined.js +91 -0
  50. package/components/chat-route/chat-box/emoji-sprite.js +45 -0
  51. package/components/chat-route/chat-box/emojiMap.js +92 -0
  52. package/components/chat-route/chat-box/facebook-reconnect-notice.js +49 -0
  53. package/components/chat-route/chat-box/forward-message-modal.js +659 -0
  54. package/components/chat-route/chat-box/index.js +165 -0
  55. package/components/chat-route/chat-box/message-time.js +44 -0
  56. package/components/chat-route/chat-box/message-viewers.js +114 -0
  57. package/components/chat-route/chat-box/pasted-file-preview.js +138 -0
  58. package/components/chat-route/chat-box/pinned-messages.js +255 -0
  59. package/components/chat-route/chat-box/react-message/react-preview.js +83 -0
  60. package/components/chat-route/chat-box/react-message/reaction-button.js +200 -0
  61. package/components/chat-route/chat-box/right-side/chat-history.js +142 -0
  62. package/components/chat-route/chat-box/right-side/chat-tag-selector.js +232 -0
  63. package/components/chat-route/chat-box/right-side/create-personal-tag-modal.js +458 -0
  64. package/components/chat-route/chat-box/right-side/customer/customer-info-item.js +60 -0
  65. package/components/chat-route/chat-box/right-side/in-room-dialog.js +225 -0
  66. package/components/chat-route/chat-box/right-side/zalo-group/add-friend-dialog.js +154 -0
  67. package/components/chat-route/chat-box/right-side/zalo-group/send-message-dialog.js +165 -0
  68. package/components/chat-route/chat-box/send-contact-card-modal.js +102 -0
  69. package/components/chat-route/chat-box/send-contact-card.js +80 -0
  70. package/components/chat-route/chat-box/text-content.js +400 -0
  71. package/components/chat-route/chat-box/use-facebook-page-invalid.js +22 -0
  72. package/components/chat-route/chat-box/zalo-emoji-decoration.js +98 -0
  73. package/components/chat-route/chat-box/zalo-emoji-picker.js +74 -0
  74. package/components/chat-route/chat-box/zalo-personal-editor.js +590 -0
  75. package/components/chat-route/chat-box/zalo-reminder/create-zalo-reminder.js +868 -0
  76. package/components/chat-route/chat-box/zalo-reminder/use-send-zalo-reminder.js +98 -0
  77. package/components/chat-route/chat-box/zalo-reminder/zalo-reminder-content.js +294 -0
  78. package/components/chat-route/chat-box/zalo-rtf-utils.js +422 -0
  79. package/components/chat-route/chat-list/action-chat-item.js +116 -0
  80. package/components/chat-route/chat-list/assign-agent-dialog.js +170 -0
  81. package/components/chat-route/chat-list/assign-tag-dialog.js +242 -0
  82. package/components/chat-route/chat-list/chat-item-tags.js +105 -0
  83. package/components/chat-route/chat-list/chat-item.js +749 -0
  84. package/components/chat-route/chat-list/chat-list-item.js +370 -0
  85. package/components/chat-route/chat-list/chat-list-selection-bar.js +426 -0
  86. package/components/chat-route/chat-list/chat-search-preview.js +48 -0
  87. package/components/chat-route/chat-list/chat-sort-menu.js +89 -0
  88. package/components/chat-route/chat-list/edit-filter-modal.js +468 -0
  89. package/components/chat-route/chat-list/filter-chat-sources.js +222 -0
  90. package/components/chat-route/chat-list/filter-chat.js +501 -0
  91. package/components/chat-route/chat-list/filter-criteria-rows.js +845 -0
  92. package/components/chat-route/chat-list/filter-group-select.js +66 -0
  93. package/components/chat-route/chat-list/filter-pin-menu.js +165 -0
  94. package/components/chat-route/chat-list/friend-request/list-friend-request.js +287 -0
  95. package/components/chat-route/chat-list/index.js +243 -0
  96. package/components/chat-route/chat-list/inline-search-results.js +178 -0
  97. package/components/chat-route/chat-list/post-ids-field.js +104 -0
  98. package/components/chat-route/chat-list/quick-filter-bar.js +391 -0
  99. package/components/chat-route/chat-list/save-filter-popover.js +258 -0
  100. package/components/chat-route/chat-list/search-messages/index.js +225 -0
  101. package/components/chat-route/chat-list/search-result-header.js +51 -0
  102. package/components/chat-route/chat-list/util.js +604 -0
  103. package/components/chat-route/chat-toolbar.js +108 -0
  104. package/components/chat-route/hooks/use-reassign.js +111 -0
  105. package/components/chat-route/shared/close-conversation-dialog.js +111 -0
  106. package/components/chat-route/shared/force-transfer-dialog.js +109 -0
  107. package/components/chat-route/shared/in-queue-confirm-dialog.js +40 -0
  108. package/components/chat-route/util.js +146 -0
  109. package/components/chat-route/zalo/modal-action-zalo.js +76 -0
  110. package/components/chat-route/zalo/modal-add-friend-zalo.js +277 -0
  111. package/components/custom/SafeHTML.js +45 -0
  112. package/components/custom/audio-player.js +81 -0
  113. package/components/custom/avatar.js +95 -0
  114. package/components/custom/between-date-picker/index.js +86 -0
  115. package/components/custom/button-close.js +28 -0
  116. package/components/custom/button.js +80 -0
  117. package/components/custom/color-picker.js +81 -0
  118. package/components/custom/combobox.js +168 -0
  119. package/components/custom/custom-dialog.js +44 -0
  120. package/components/custom/custom-select.js +256 -0
  121. package/components/custom/cycle-value-helpers.js +11 -0
  122. package/components/custom/cycle-value.js +93 -0
  123. package/components/custom/date-time-picker/components/date-time-group.js +44 -0
  124. package/components/custom/date-time-picker/components/date-time-input.js +383 -0
  125. package/components/custom/date-time-picker/components/date-time-unit-input.js +138 -0
  126. package/components/custom/date-time-picker/components/month-year-picker.js +232 -0
  127. package/components/custom/date-time-picker/hooks/use-merge-refs.js +18 -0
  128. package/components/custom/date-time-picker/hooks/use-scroll-to-center.js +18 -0
  129. package/components/custom/date-time-picker/index.js +348 -0
  130. package/components/custom/field-file-upload/files-upload.js +87 -0
  131. package/components/custom/field-file-upload/image-upload.js +115 -0
  132. package/components/custom/field-file-upload/preview-images-modal.js +284 -0
  133. package/components/custom/field-file-upload/preview-list-file.js +134 -0
  134. package/components/custom/field-file-upload/preview-list-image.js +108 -0
  135. package/components/custom/field-file-upload/upload-custom.js +222 -0
  136. package/components/custom/field-generator.js +639 -0
  137. package/components/custom/field-layout-popover.js +304 -0
  138. package/components/custom/file-preview-modal.js +351 -0
  139. package/components/custom/html-edtior.js +100 -0
  140. package/components/custom/icon.js +49 -0
  141. package/components/custom/infinite-scroll-combobox.js +253 -0
  142. package/components/custom/inline-edit-popover.js +90 -0
  143. package/components/custom/inputs/calendar-input.js +0 -0
  144. package/components/custom/inputs/chip-input.js +136 -0
  145. package/components/custom/inputs/file-input.js +71 -0
  146. package/components/custom/inputs/mask-data/mask-data-input.js +80 -0
  147. package/components/custom/inputs/mask-data/mask-data-select.js +78 -0
  148. package/components/custom/inputs/mask-data/mask-data-textarea.js +75 -0
  149. package/components/custom/inputs/mask-data/reconcile-masked-edit.js +20 -0
  150. package/components/custom/jxl-decode.js +34 -0
  151. package/components/custom/jxl-image.js +68 -0
  152. package/components/custom/jxl-worker.js +12 -0
  153. package/components/custom/label.js +55 -0
  154. package/components/custom/layout.js +30 -0
  155. package/components/custom/multi-select-search-cc.js +179 -0
  156. package/components/custom/multiple-select-setting-tags.js +404 -0
  157. package/components/custom/multiple-selector.js +821 -0
  158. package/components/custom/pagination.js +95 -0
  159. package/components/custom/popup-confirm.js +120 -0
  160. package/components/custom/previews/facebook/facebook-appointment-booking-preview.js +83 -0
  161. package/components/custom/previews/facebook/facebook-audio-preview.js +130 -0
  162. package/components/custom/previews/facebook/facebook-event-preview.js +72 -0
  163. package/components/custom/previews/facebook/facebook-file-preview.js +95 -0
  164. package/components/custom/previews/facebook/facebook-group-preview.js +103 -0
  165. package/components/custom/previews/facebook/facebook-image-preview.js +81 -0
  166. package/components/custom/previews/facebook/facebook-page-preview.js +85 -0
  167. package/components/custom/previews/facebook/facebook-post-preview.js +77 -0
  168. package/components/custom/previews/facebook/facebook-reel-preview.js +83 -0
  169. package/components/custom/previews/facebook/facebook-sticker-preview.js +23 -0
  170. package/components/custom/previews/facebook/facebook-video-preview.js +114 -0
  171. package/components/custom/previews/facebook/index.js +24 -0
  172. package/components/custom/previews/file-preview.js +747 -0
  173. package/components/custom/previews/image-preview.js +288 -0
  174. package/components/custom/previews/instagram/index.js +4 -0
  175. package/components/custom/previews/instagram/instagram-share-post-preview.js +77 -0
  176. package/components/custom/previews/link-preview.js +166 -0
  177. package/components/custom/previews/product-preview.js +334 -0
  178. package/components/custom/previews/tiktok-order-preview.js +278 -0
  179. package/components/custom/previews/tiktok-product-preview.js +321 -0
  180. package/components/custom/previews/tiktok-voucher-preview.js +151 -0
  181. package/components/custom/previews/whatsapp/index.js +10 -0
  182. package/components/custom/previews/whatsapp/whatsapp-contact-card-preview.js +150 -0
  183. package/components/custom/previews/whatsapp/whatsapp-order-preview.js +38 -0
  184. package/components/custom/previews/whatsapp/whatsapp-poll-preview.js +29 -0
  185. package/components/custom/previews/whatsapp/whatsapp-product-preview.js +29 -0
  186. package/components/custom/retry-image.js +44 -0
  187. package/components/custom/search-input.js +26 -0
  188. package/components/custom/separator-with-text.js +14 -0
  189. package/components/custom/showToast.js +21 -0
  190. package/components/custom/sortable-header.js +62 -0
  191. package/components/custom/table-resize-line.js +92 -0
  192. package/components/custom/time-picker/index.js +73 -0
  193. package/components/custom/time-picker/time-picker-input.js +159 -0
  194. package/components/custom/time-picker/time-picker-utils.js +152 -0
  195. package/components/custom/viewers/audio-player.js +192 -0
  196. package/components/custom/viewers/code-viewer.js +140 -0
  197. package/components/custom/viewers/csv-viewer.js +174 -0
  198. package/components/custom/viewers/docx-viewer.js +145 -0
  199. package/components/custom/viewers/image-viewer.js +104 -0
  200. package/components/custom/viewers/markdown-viewer.js +124 -0
  201. package/components/custom/viewers/pdf-viewer.js +333 -0
  202. package/components/custom/viewers/spreadsheet-viewer.js +232 -0
  203. package/components/custom/viewers/unsupported-viewer.js +85 -0
  204. package/components/custom/viewers/video-player.js +241 -0
  205. package/components/customers-route/change-owner-modal.js +430 -0
  206. package/components/customers-route/contact-note-button.js +212 -0
  207. package/components/customers-route/customer-source.js +37 -0
  208. package/components/customers-route/table/columns.js +675 -0
  209. package/components/customers-route/table/edit-fields.js +125 -0
  210. package/components/customers-route/table/editable-cell.js +218 -0
  211. package/components/customers-route/table/note-cell.js +77 -0
  212. package/components/dialogs/invite-agent.js +677 -0
  213. package/components/error-boundary.js +53 -0
  214. package/components/leads-route/duplicate-phone-warning-toast.js +96 -0
  215. package/components/leads-route/table/columns.js +523 -0
  216. package/components/leads-route/table/contact-cell-name.js +82 -0
  217. package/components/leads-route/table/edit-fields.js +142 -0
  218. package/components/leads-route/table/editable-cell.js +228 -0
  219. package/components/org-tree/group-name-display.js +36 -0
  220. package/components/org-tree/group-tree-multi-select.js +208 -0
  221. package/components/org-tree/group-tree-select.js +220 -0
  222. package/components/posts-route/dialog-select-posts.js +284 -0
  223. package/components/reports-route/agents/multi-select-agents.js +55 -0
  224. package/components/reports-route/agents/multi-select-search-agents.js +43 -0
  225. package/components/settings-route/chat-layout/detail/constants.js +353 -0
  226. package/components/settings-route/chat-layout/detail/form.js +43 -0
  227. package/components/settings-route/chat-timeout/channel-multi-select.js +119 -0
  228. package/components/settings-route/multi-channel/facebook/hooks/use-facebook-sdk.js +3 -0
  229. package/components/settings-route/object-rule/util.js +79 -0
  230. package/components/settings-route/routing/settings-dialog.js +561 -0
  231. package/components/settings-route/switchboard/queue-new/constant.js +9 -0
  232. package/components/shared/linked-customer-fields/LinkedCustomerFields.js +91 -0
  233. package/components/shared/linked-customer-fields/use-linked-customer-fields.js +123 -0
  234. package/components/smartqc-route/qc-form/controls/multi-select-search-agents.js +50 -0
  235. package/components/ui/alert-dialog.js +112 -0
  236. package/components/ui/avatar.js +44 -0
  237. package/components/ui/badge.js +54 -0
  238. package/components/ui/button.js +48 -0
  239. package/components/ui/calendar.js +70 -0
  240. package/components/ui/card.js +58 -0
  241. package/components/ui/carousel.js +238 -0
  242. package/components/ui/checkbox.js +27 -0
  243. package/components/ui/command.js +111 -0
  244. package/components/ui/context-menu.js +154 -0
  245. package/components/ui/dialog.js +104 -0
  246. package/components/ui/dropdown-menu.js +169 -0
  247. package/components/ui/form.js +104 -0
  248. package/components/ui/input.js +115 -0
  249. package/components/ui/label.js +20 -0
  250. package/components/ui/popover.js +29 -0
  251. package/components/ui/radio-group.js +53 -0
  252. package/components/ui/scroll-area.js +38 -0
  253. package/components/ui/select.js +147 -0
  254. package/components/ui/separator.js +24 -0
  255. package/components/ui/sheet.js +113 -0
  256. package/components/ui/skeleton.js +17 -0
  257. package/components/ui/slider.js +26 -0
  258. package/components/ui/sonner.js +76 -0
  259. package/components/ui/switch.js +54 -0
  260. package/components/ui/table-v2.js +269 -0
  261. package/components/ui/table.js +245 -0
  262. package/components/ui/tabs.js +89 -0
  263. package/components/ui/textarea.js +33 -0
  264. package/components/ui/tooltip.js +40 -0
  265. package/components/workflow-editor/nodes/ticket/picker-field.js +233 -0
  266. package/components/zalo-login-qr.js +237 -0
  267. package/components/zalo-login-status-modal.js +45 -0
  268. package/config/env.js +27 -0
  269. package/config/hmr.js +8 -0
  270. package/config/navigation.js +54 -0
  271. package/config/runtime.js +46 -0
  272. package/config/theme.js +274 -0
  273. package/constants/brand-colors.js +32 -0
  274. package/constants/chat-icon.js +34 -0
  275. package/dist/chat.css +1 -0
  276. package/exceptions/throw-exception.js +15 -0
  277. package/hooks/use-chat-attachments.js +106 -0
  278. package/hooks/use-chat-configs.js +62 -0
  279. package/hooks/use-chat-customer.js +33 -0
  280. package/hooks/use-chat-display-config-sync.js +72 -0
  281. package/hooks/use-chat-permission.js +68 -0
  282. package/hooks/use-chat-room-detail.js +44 -0
  283. package/hooks/use-chat-selection.js +26 -0
  284. package/hooks/use-chat-sort.js +69 -0
  285. package/hooks/use-chat-surface.js +8 -0
  286. package/hooks/use-common-filter-options.js +70 -0
  287. package/hooks/use-crm-organization-filter-options.js +0 -0
  288. package/hooks/use-crm-organizations-data.js +23 -0
  289. package/hooks/use-debounce.js +14 -0
  290. package/hooks/use-dynamic-fields.js +7 -0
  291. package/hooks/use-facebook-notice.js +24 -0
  292. package/hooks/use-feature-flags.js +6 -0
  293. package/hooks/use-field-layout-override.js +46 -0
  294. package/hooks/use-file-upload.js +119 -0
  295. package/hooks/use-file-viewer.js +93 -0
  296. package/hooks/use-frozen-columns.js +29 -0
  297. package/hooks/use-horizontal-scroll.js +41 -0
  298. package/hooks/use-image-preview-queue.js +101 -0
  299. package/hooks/use-inline-editable-cell.js +97 -0
  300. package/hooks/use-intersection-observer.js +24 -0
  301. package/hooks/use-interval.js +20 -0
  302. package/hooks/use-latest-message-id.js +13 -0
  303. package/hooks/use-lead-filter-options.js +0 -0
  304. package/hooks/use-logout-listener.js +43 -0
  305. package/hooks/use-org-tree.js +43 -0
  306. package/hooks/use-permission.js +33 -0
  307. package/hooks/use-quick-filters.js +175 -0
  308. package/hooks/use-resizable-table.js +0 -0
  309. package/hooks/use-setting-common.js +389 -0
  310. package/hooks/use-settings.js +41 -0
  311. package/hooks/use-sort-bindings.js +24 -0
  312. package/hooks/use-table-display-config.js +0 -0
  313. package/hooks/use-tenant-config.js +99 -0
  314. package/hooks/use-update-user-config.js +150 -0
  315. package/hooks/use-zalo-connection.js +57 -0
  316. package/hooks/use-zalo-mention-list.js +31 -0
  317. package/index.css +624 -0
  318. package/index.js +100 -0
  319. package/lib/deal-name.js +27 -0
  320. package/lib/i18n/react.js +7 -0
  321. package/lib/i18n/use-language.js +0 -0
  322. package/lib/query-client.js +34 -0
  323. package/lib/utils.js +25 -0
  324. package/package.json +108 -0
  325. package/provider/chat-context.js +9 -0
  326. package/provider/chat-provider.js +177 -0
  327. package/provider/chat-room-context.js +9 -0
  328. package/provider/chat-room-hooks.js +8 -0
  329. package/provider/chat-room-provider.js +84 -0
  330. package/provider/hooks.js +22 -0
  331. package/provider/index.js +42 -0
  332. package/public/contact-card-user.svg +25 -0
  333. package/public/images/icons/facebook.svg +1 -0
  334. package/public/images/icons/instagram.svg +1 -0
  335. package/public/images/icons/shopee.svg +1 -0
  336. package/public/images/icons/whatsapp.svg +1 -0
  337. package/public/images/icons/zalo.png +0 -0
  338. package/public/images/images.jpg +0 -0
  339. package/public/images/ticket_sources/api.png +0 -0
  340. package/public/images/ticket_sources/email.png +0 -0
  341. package/public/images/ticket_sources/facebook.png +0 -0
  342. package/public/images/ticket_sources/hand.png +0 -0
  343. package/public/images/ticket_sources/instagram.png +0 -0
  344. package/public/images/ticket_sources/livechat.png +0 -0
  345. package/public/images/ticket_sources/shopee.svg +1 -0
  346. package/public/images/ticket_sources/sms.png +0 -0
  347. package/public/images/ticket_sources/telephone-call-in.png +0 -0
  348. package/public/images/ticket_sources/telephone-call-out.png +0 -0
  349. package/public/images/ticket_sources/tiktok.png +0 -0
  350. package/public/images/ticket_sources/tiktok_shop.png +0 -0
  351. package/public/images/ticket_sources/whatsapp.png +0 -0
  352. package/public/images/ticket_sources/whatsapp.svg +1 -0
  353. package/public/images/ticket_sources/zalo.png +0 -0
  354. package/public/placeholder.svg +13 -0
  355. package/store/app-status-store.js +17 -0
  356. package/store/chat-display-config-store.js +182 -0
  357. package/store/chat-display-config.resolvers.js +88 -0
  358. package/store/chat-store-helpers.js +62 -0
  359. package/store/chat-store.js +931 -0
  360. package/store/crm-organization-list-filter-store.js +126 -0
  361. package/store/customer-list-filter-store.js +139 -0
  362. package/store/devtools.js +9 -0
  363. package/store/duplicate-phone-warning-store.js +18 -0
  364. package/store/entity-extract-store.js +72 -0
  365. package/store/file-preview-store.js +27 -0
  366. package/store/filter-store.js +289 -0
  367. package/store/index.js +22 -0
  368. package/store/knowledge-crawl-store.js +53 -0
  369. package/store/lead-list-filter-store.js +142 -0
  370. package/store/list-pagination-state.js +44 -0
  371. package/store/lumi-learn-from-chat-store.js +69 -0
  372. package/store/merge-suggestion-store.js +27 -0
  373. package/store/notification-store.js +63 -0
  374. package/store/preview-image-store.js +22 -0
  375. package/store/settings-store/multi-channel/email-list-store.js +20 -0
  376. package/store/settings-store/multi-channel/facebook-list-store.js +22 -0
  377. package/store/settings-store/multi-channel/google-list-store.js +20 -0
  378. package/store/settings-store/multi-channel/instagram-list-store.js +20 -0
  379. package/store/settings-store/multi-channel/misa-list-store.js +20 -0
  380. package/store/settings-store/multi-channel/nhanhvn-list-store.js +20 -0
  381. package/store/settings-store/multi-channel/shopee-list-store.js +20 -0
  382. package/store/settings-store/multi-channel/shopee-order-list-store.js +20 -0
  383. package/store/settings-store/multi-channel/sms-list-store.js +20 -0
  384. package/store/settings-store/multi-channel/tiktok-business-list-store.js +20 -0
  385. package/store/settings-store/multi-channel/tiktok-list-store.js +20 -0
  386. package/store/settings-store/multi-channel/zalo-list-store.js +22 -0
  387. package/store/settings-store/multi-channel/zalo-user-list-store.js +25 -0
  388. package/store/smart-qc-store/smart-qc-list-filter-store.js +70 -0
  389. package/store/tenant-config-store.js +21 -0
  390. package/store/user-detail-store.js +17 -0
  391. package/store/user-status-store.js +33 -0
  392. package/store/workflow-store.js +24 -0
  393. package/store/workspace-store.js +32 -0
  394. package/tailwind-preset.js +129 -0
  395. package/utils/chat-actions.js +414 -0
  396. package/utils/chat_socket.js +1225 -0
  397. package/utils/extra-columns.js +108 -0
  398. package/utils/file.js +316 -0
  399. package/utils/html-to-plain-text.js +12 -0
  400. package/utils/notification.js +71 -0
  401. package/utils/replaceZaloSprite.js +64 -0
  402. package/utils/show-be-error.js +17 -0
  403. package/utils/typing_socket.js +101 -0
@@ -0,0 +1,845 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { useFormState } from "react-hook-form";
4
+ import { isSameDay } from "date-fns";
5
+ import { Info, Trash2 } from "lucide-react";
6
+ import { FormControl, FormField } from "../../ui/form.js";
7
+ import { Input } from "../../ui/input.js";
8
+ import {
9
+ Tooltip,
10
+ TooltipContent,
11
+ TooltipProvider,
12
+ TooltipTrigger
13
+ } from "../../ui/tooltip.js";
14
+ import MultipleSelector from "../../custom/multiple-selector.js";
15
+ import MultipleSelectSettingTags from "../../custom/multiple-select-setting-tags.js";
16
+ import DateTimePicker from "../../custom/date-time-picker/index.js";
17
+ import { Combobox } from "../../custom/combobox.js";
18
+ import { CustomSelect } from "../../custom/custom-select.js";
19
+ import PostIdsField from "./post-ids-field.js";
20
+ import {
21
+ Select,
22
+ SelectContent,
23
+ SelectItem,
24
+ SelectTrigger,
25
+ SelectValue
26
+ } from "../../ui/select.js";
27
+ import { searchUser } from "@zenify-omni/chat-js/api/user.js";
28
+ import { cn } from "../../../lib/utils.js";
29
+ import { SettingTags } from "@zenify-omni/chat-js/constants/setting.js";
30
+ import {
31
+ ChatFilterSourceLabel,
32
+ ChatFilterStatusOptions
33
+ } from "@zenify-omni/chat-js/constants/chat-message.js";
34
+ import {
35
+ CRM_TYPE_OPTIONS,
36
+ DATE_FILTER_TYPE_OPTIONS,
37
+ DateFilterType,
38
+ HAS_FB_ADS_OPTIONS,
39
+ IS_GROUP_OPTIONS,
40
+ IS_UNHANDLED_OPTIONS,
41
+ PHONE_STATUS_OPTIONS,
42
+ TAG_MATCH_MODE_OPTIONS,
43
+ TagMatchMode
44
+ } from "./util.js";
45
+ import FilterGroupSelect from "./filter-group-select.js";
46
+ import {
47
+ getUser,
48
+ isAdmin,
49
+ isSupervisor,
50
+ isRoleTeamLeader,
51
+ isRoleTeamLeaderSale
52
+ } from "@zenify-omni/chat-js/utils/auth.js";
53
+ import i18n from "@zenify-omni/chat-js/lib/i18n/index.js";
54
+ const IS_UNANSWERED_OPTIONS = [
55
+ {
56
+ value: "true",
57
+ get label() {
58
+ return i18n.t("chat:status.unanswered", {
59
+ defaultValue: "Ch\u01B0a tr\u1EA3 l\u1EDDi"
60
+ });
61
+ }
62
+ },
63
+ {
64
+ value: "false",
65
+ get label() {
66
+ return i18n.t("common:status.replied", {
67
+ defaultValue: "\u0110\xE3 tr\u1EA3 l\u1EDDi"
68
+ });
69
+ }
70
+ }
71
+ ];
72
+ const boolToSelectValue = (value) => {
73
+ switch (value) {
74
+ case true:
75
+ return "true";
76
+ case false:
77
+ return "false";
78
+ case "post":
79
+ return "post";
80
+ default:
81
+ return "all";
82
+ }
83
+ };
84
+ const selectValueToBool = (value) => {
85
+ switch (value) {
86
+ case "true":
87
+ return true;
88
+ case "false":
89
+ return false;
90
+ case "post":
91
+ return "post";
92
+ default:
93
+ return "all";
94
+ }
95
+ };
96
+ function RangeDateMessage({ control }) {
97
+ const { errors } = useFormState({ control, name: "range_date.from" });
98
+ const message = errors?.range_date?.from?.message;
99
+ if (!message) return null;
100
+ return /* @__PURE__ */ jsx("p", { className: "text-[0.8rem] text-destructive", children: message });
101
+ }
102
+ function buildCriteriaFields({
103
+ form,
104
+ sourceOptions,
105
+ filterSocialPageList,
106
+ includePersonal
107
+ }) {
108
+ const user = getUser();
109
+ const searchUserParams = () => {
110
+ const groupIds = (form.getValues("group_ids") || []).filter(Boolean);
111
+ if (groupIds.length > 0) {
112
+ return { group_ids: JSON.stringify(groupIds.map(Number)) };
113
+ }
114
+ return isRoleTeamLeader() || isRoleTeamLeaderSale() ? { group_id: user.group_id } : {};
115
+ };
116
+ const canFilterByDepartment = isAdmin() || isSupervisor() || isRoleTeamLeader() || isRoleTeamLeaderSale();
117
+ const fields = [
118
+ {
119
+ key: "read_statuses",
120
+ label: i18n.t("chat:label.conversationStatus", {
121
+ defaultValue: "Tr\u1EA1ng th\xE1i cu\u1ED9c h\u1ED9i tho\u1EA1i"
122
+ }),
123
+ isActive: (v) => v.read_statuses?.length > 0,
124
+ reset: () => form.setValue("read_statuses", []),
125
+ renderValue: () => /* @__PURE__ */ jsx(
126
+ FormField,
127
+ {
128
+ control: form.control,
129
+ name: "read_statuses",
130
+ render: ({ field }) => /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
131
+ MultipleSelector,
132
+ {
133
+ ...field,
134
+ placeholder: i18n.t("chat:field.selectConversationStatus", {
135
+ defaultValue: "Ch\u1ECDn tr\u1EA1ng th\xE1i cu\u1ED9c h\u1ED9i tho\u1EA1i"
136
+ }),
137
+ inputProps: { tabIndex: -1, className: "px-1" },
138
+ options: ChatFilterStatusOptions,
139
+ commandProps: {
140
+ filter: (value, search, keywords) => keywords[0].toLowerCase().includes(search.trim().toLowerCase())
141
+ }
142
+ }
143
+ ) })
144
+ }
145
+ )
146
+ },
147
+ {
148
+ key: "sources",
149
+ label: i18n.t("chat:filter.filterBySource", {
150
+ defaultValue: "L\u1ECDc theo ngu\u1ED3n"
151
+ }),
152
+ isActive: (v) => !v.sources?.includes("all"),
153
+ reset: () => {
154
+ form.setValue("sources", ["all"]);
155
+ form.setValue("page_ids", []);
156
+ form.setValue("ad_id", "");
157
+ },
158
+ renderValue: () => /* @__PURE__ */ jsx(
159
+ FormField,
160
+ {
161
+ control: form.control,
162
+ name: "sources",
163
+ render: ({ field }) => {
164
+ const realOptions = sourceOptions.filter((o) => o.value !== "all");
165
+ const selected = realOptions.filter(
166
+ (o) => field.value.includes(o.value)
167
+ );
168
+ return /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
169
+ MultipleSelector,
170
+ {
171
+ value: selected,
172
+ placeholder: i18n.t("chat:placeholder.selectSource", {
173
+ defaultValue: "Ch\u1ECDn ngu\u1ED3n"
174
+ }),
175
+ inputProps: { className: "px-1" },
176
+ options: realOptions,
177
+ onChange: (next) => {
178
+ const newSources = next.map((o) => o.value);
179
+ if (!newSources.length) {
180
+ field.onChange(["all"]);
181
+ form.setValue("page_ids", []);
182
+ form.setValue("ad_id", "");
183
+ return;
184
+ }
185
+ field.onChange(newSources);
186
+ const newPageIds = form.getValues("page_ids").filter((p) => newSources.includes(p.source));
187
+ form.setValue("page_ids", newPageIds);
188
+ if (!newSources.includes("facebook")) {
189
+ form.setValue("ad_id", "");
190
+ }
191
+ }
192
+ }
193
+ ) });
194
+ }
195
+ }
196
+ )
197
+ },
198
+ {
199
+ key: "has_fb_ads",
200
+ label: i18n.t("campaign:field.messageType", {
201
+ defaultValue: "Lo\u1EA1i tin nh\u1EAFn"
202
+ }),
203
+ isActive: (v) => v.has_fb_ads !== void 0 && v.has_fb_ads !== "all",
204
+ reset: () => {
205
+ form.setValue("has_fb_ads", "all");
206
+ form.setValue("ad_id", "");
207
+ form.setValue("post_ids", []);
208
+ },
209
+ renderValue: () => /* @__PURE__ */ jsx(
210
+ FormField,
211
+ {
212
+ control: form.control,
213
+ name: "has_fb_ads",
214
+ render: ({ field }) => /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsxs(
215
+ Select,
216
+ {
217
+ value: boolToSelectValue(field.value) === "all" ? "" : boolToSelectValue(field.value),
218
+ onValueChange: (value) => {
219
+ const boolValue = selectValueToBool(value);
220
+ field.onChange(boolValue);
221
+ if (boolValue !== true) form.setValue("ad_id", "");
222
+ if (boolValue !== "post") form.setValue("post_ids", []);
223
+ },
224
+ children: [
225
+ /* @__PURE__ */ jsx(
226
+ SelectTrigger,
227
+ {
228
+ className: cn(
229
+ boolToSelectValue(field.value) === "all" && "text-muted-foreground"
230
+ ),
231
+ children: /* @__PURE__ */ jsx(
232
+ SelectValue,
233
+ {
234
+ placeholder: i18n.t("chat:placeholder.selectMessageType", {
235
+ defaultValue: "Ch\u1ECDn lo\u1EA1i tin nh\u1EAFn"
236
+ })
237
+ }
238
+ )
239
+ }
240
+ ),
241
+ /* @__PURE__ */ jsx(SelectContent, { children: HAS_FB_ADS_OPTIONS.filter((o) => o.value !== "all").map(
242
+ (option) => /* @__PURE__ */ jsx(
243
+ SelectItem,
244
+ {
245
+ value: boolToSelectValue(option.value),
246
+ children: option.label
247
+ },
248
+ String(option.value)
249
+ )
250
+ ) })
251
+ ]
252
+ }
253
+ ) })
254
+ }
255
+ )
256
+ },
257
+ {
258
+ key: "ad_id",
259
+ label: "Ads ID",
260
+ isActive: (v) => !!v.ad_id && v.ad_id.trim().length > 0,
261
+ reset: () => form.setValue("ad_id", ""),
262
+ renderValue: () => {
263
+ const sources = form.watch("sources");
264
+ const hasFbAds = form.watch("has_fb_ads");
265
+ const enabled = sources.includes("facebook") && hasFbAds === true;
266
+ return /* @__PURE__ */ jsx(
267
+ FormField,
268
+ {
269
+ control: form.control,
270
+ name: "ad_id",
271
+ render: ({ field }) => /* @__PURE__ */ jsxs("div", { className: "relative", children: [
272
+ /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
273
+ Input,
274
+ {
275
+ value: field.value || "",
276
+ onChange: (e) => field.onChange(e.target.value),
277
+ onBlur: field.onBlur,
278
+ disabled: !enabled,
279
+ placeholder: i18n.t("chat:placeholder.adsId", {
280
+ defaultValue: "Nh\u1EADp Ads ID"
281
+ }),
282
+ className: cn("py-2", !enabled && "pr-8")
283
+ }
284
+ ) }),
285
+ !enabled && /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsxs(Tooltip, { children: [
286
+ /* @__PURE__ */ jsx(
287
+ TooltipTrigger,
288
+ {
289
+ type: "button",
290
+ className: "absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground",
291
+ children: /* @__PURE__ */ jsx(Info, { className: "h-3.5 w-3.5" })
292
+ }
293
+ ),
294
+ /* @__PURE__ */ jsx(TooltipContent, { children: i18n.t("chat:hint.onlyAppliesWhenFacebookAndAds", {
295
+ defaultValue: "Ch\u1EC9 \xE1p d\u1EE5ng khi Ngu\u1ED3n c\xF3 Facebook v\xE0 Lo\u1EA1i tin nh\u1EAFn l\xE0\n Ads"
296
+ }) })
297
+ ] }) })
298
+ ] })
299
+ }
300
+ );
301
+ }
302
+ },
303
+ {
304
+ key: "post_ids",
305
+ label: i18n.t("chat:label.post", {
306
+ defaultValue: "B\xE0i vi\u1EBFt"
307
+ }),
308
+ isActive: (v) => v.post_ids?.length > 0,
309
+ reset: () => form.setValue("post_ids", []),
310
+ renderValue: () => /* @__PURE__ */ jsx(PostIdsField, { form })
311
+ },
312
+ {
313
+ key: "page_ids",
314
+ label: i18n.t("common:label.detailedSource", {
315
+ defaultValue: "Ngu\u1ED3n chi ti\u1EBFt"
316
+ }),
317
+ isActive: (v) => v.page_ids?.length > 0,
318
+ reset: () => form.setValue("page_ids", []),
319
+ renderValue: () => /* @__PURE__ */ jsx(
320
+ FormField,
321
+ {
322
+ control: form.control,
323
+ name: "page_ids",
324
+ render: ({ field }) => /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
325
+ MultipleSelector,
326
+ {
327
+ ...field,
328
+ placeholder: i18n.t("chat:field.selectDetailedSource", {
329
+ defaultValue: "Ch\u1ECDn ngu\u1ED3n chi ti\u1EBFt"
330
+ }),
331
+ inputProps: { className: "px-1" },
332
+ options: filterSocialPageList,
333
+ groupBy: "source",
334
+ renderGroupHeading: (source) => ChatFilterSourceLabel[source],
335
+ commandProps: {
336
+ filter: (value, search, keywords) => keywords.length > 0 && keywords[0].toLowerCase().includes(search.trim().toLowerCase())
337
+ }
338
+ }
339
+ ) })
340
+ }
341
+ )
342
+ },
343
+ {
344
+ key: "agents_in_room",
345
+ label: i18n.t("common:label.agent", {
346
+ defaultValue: "Chuy\xEAn vi\xEAn"
347
+ }),
348
+ isActive: (v) => v.agents_in_room?.length > 0,
349
+ reset: () => form.setValue("agents_in_room", []),
350
+ renderValue: () => /* @__PURE__ */ jsx(
351
+ FormField,
352
+ {
353
+ control: form.control,
354
+ name: "agents_in_room",
355
+ render: ({ field }) => /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
356
+ MultipleSelector,
357
+ {
358
+ placeholder: i18n.t("common:placeholder.searchAgent", {
359
+ defaultValue: "Nh\u1EADp \u0111\u1EC3 t\xECm chuy\xEAn vi\xEAn"
360
+ }),
361
+ ...field,
362
+ inputProps: { className: "px-1" },
363
+ buildOption: (u) => ({ label: u.name, value: u._id }),
364
+ onSearch: (value) => searchUser({ searchText: value, ...searchUserParams() })
365
+ }
366
+ ) })
367
+ }
368
+ )
369
+ },
370
+ {
371
+ key: "assigned",
372
+ label: i18n.t("common:label.assignee", {
373
+ defaultValue: "Ng\u01B0\u1EDDi ph\u1EE5 tr\xE1ch"
374
+ }),
375
+ isActive: (v) => !!v.assigned,
376
+ reset: () => form.setValue("assigned", null),
377
+ renderValue: () => /* @__PURE__ */ jsx(
378
+ FormField,
379
+ {
380
+ control: form.control,
381
+ name: "assigned",
382
+ render: ({ field }) => /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
383
+ Combobox,
384
+ {
385
+ searchKey: "assigned",
386
+ placeholder: i18n.t("chat:placeholder.searchAssignee", {
387
+ defaultValue: "Nh\u1EADp \u0111\u1EC3 t\xECm ng\u01B0\u1EDDi ph\u1EE5 tr\xE1ch"
388
+ }),
389
+ ...field,
390
+ buildOption: (u) => ({ label: u.name, value: u._id }),
391
+ onSearch: (value) => searchUser({ searchText: value, ...searchUserParams() })
392
+ }
393
+ ) })
394
+ }
395
+ )
396
+ },
397
+ {
398
+ key: "group_ids",
399
+ label: i18n.t("common:label.department", {
400
+ defaultValue: "B\u1ED9 ph\u1EADn"
401
+ }),
402
+ isActive: (v) => v.group_ids?.length > 0,
403
+ reset: () => form.setValue("group_ids", []),
404
+ renderValue: () => /* @__PURE__ */ jsx(
405
+ FormField,
406
+ {
407
+ control: form.control,
408
+ name: "group_ids",
409
+ render: ({ field }) => /* @__PURE__ */ jsx(
410
+ FilterGroupSelect,
411
+ {
412
+ value: field.value || [],
413
+ onChange: field.onChange,
414
+ placeholder: i18n.t("common:placeholder.selectDepartment", {
415
+ defaultValue: "Ch\u1ECDn b\u1ED9 ph\u1EADn"
416
+ })
417
+ }
418
+ )
419
+ }
420
+ )
421
+ },
422
+ {
423
+ key: "crm_type",
424
+ label: i18n.t("common:label.customerStatus", {
425
+ defaultValue: "Tr\u1EA1ng th\xE1i kh\xE1ch h\xE0ng"
426
+ }),
427
+ isActive: (v) => !!v.crm_type,
428
+ reset: () => form.setValue("crm_type", ""),
429
+ renderValue: () => /* @__PURE__ */ jsx(
430
+ FormField,
431
+ {
432
+ control: form.control,
433
+ name: "crm_type",
434
+ render: ({ field }) => /* @__PURE__ */ jsx(
435
+ CustomSelect,
436
+ {
437
+ value: field.value,
438
+ onChange: field.onChange,
439
+ options: CRM_TYPE_OPTIONS,
440
+ placeholder: i18n.t("common:placeholder.selectCustomerStatus", {
441
+ defaultValue: "Ch\u1ECDn tr\u1EA1ng th\xE1i kh\xE1ch h\xE0ng"
442
+ })
443
+ }
444
+ )
445
+ }
446
+ )
447
+ },
448
+ {
449
+ key: "phone_status",
450
+ label: i18n.t("common:label.phone", {
451
+ defaultValue: "S\u1ED1 \u0111i\u1EC7n tho\u1EA1i"
452
+ }),
453
+ isActive: (v) => v.phone_status && v.phone_status !== "all",
454
+ reset: () => form.setValue("phone_status", "all"),
455
+ renderValue: () => /* @__PURE__ */ jsx(
456
+ FormField,
457
+ {
458
+ control: form.control,
459
+ name: "phone_status",
460
+ render: ({ field }) => /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsxs(
461
+ Select,
462
+ {
463
+ value: field.value === "all" ? "" : field.value,
464
+ onValueChange: field.onChange,
465
+ children: [
466
+ /* @__PURE__ */ jsx(
467
+ SelectTrigger,
468
+ {
469
+ className: cn(
470
+ field.value === "all" && "text-muted-foreground"
471
+ ),
472
+ children: /* @__PURE__ */ jsx(
473
+ SelectValue,
474
+ {
475
+ placeholder: i18n.t("chat:placeholder.selectPhoneNumber", {
476
+ defaultValue: "Ch\u1ECDn s\u1ED1 \u0111i\u1EC7n tho\u1EA1i"
477
+ })
478
+ }
479
+ )
480
+ }
481
+ ),
482
+ /* @__PURE__ */ jsx(SelectContent, { children: PHONE_STATUS_OPTIONS.filter((o) => o.value !== "all").map(
483
+ (option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: option.label }, option.value)
484
+ ) })
485
+ ]
486
+ }
487
+ ) })
488
+ }
489
+ )
490
+ },
491
+ {
492
+ key: "is_unanswered",
493
+ label: i18n.t("common:label.answerStatus", {
494
+ defaultValue: "Tr\u1EA1ng th\xE1i tr\u1EA3 l\u1EDDi"
495
+ }),
496
+ isActive: (v) => v.is_unanswered && v.is_unanswered !== "all",
497
+ reset: () => form.setValue("is_unanswered", "all"),
498
+ renderValue: () => /* @__PURE__ */ jsx(
499
+ FormField,
500
+ {
501
+ control: form.control,
502
+ name: "is_unanswered",
503
+ render: ({ field }) => /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsxs(
504
+ Select,
505
+ {
506
+ value: field.value === "all" ? "" : field.value,
507
+ onValueChange: field.onChange,
508
+ children: [
509
+ /* @__PURE__ */ jsx(
510
+ SelectTrigger,
511
+ {
512
+ className: cn(
513
+ field.value === "all" && "text-muted-foreground"
514
+ ),
515
+ children: /* @__PURE__ */ jsx(
516
+ SelectValue,
517
+ {
518
+ placeholder: i18n.t("chat:placeholder.selectReplyStatus", {
519
+ defaultValue: "Ch\u1ECDn tr\u1EA1ng th\xE1i tr\u1EA3 l\u1EDDi"
520
+ })
521
+ }
522
+ )
523
+ }
524
+ ),
525
+ /* @__PURE__ */ jsx(SelectContent, { children: IS_UNANSWERED_OPTIONS.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: option.label }, option.value)) })
526
+ ]
527
+ }
528
+ ) })
529
+ }
530
+ )
531
+ },
532
+ {
533
+ key: "is_group",
534
+ label: i18n.t("common:label.group", {
535
+ defaultValue: "Nh\xF3m"
536
+ }),
537
+ isActive: (v) => v.is_group && v.is_group !== "all",
538
+ reset: () => form.setValue("is_group", "all"),
539
+ renderValue: () => /* @__PURE__ */ jsx(
540
+ FormField,
541
+ {
542
+ control: form.control,
543
+ name: "is_group",
544
+ render: ({ field }) => /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsxs(
545
+ Select,
546
+ {
547
+ value: field.value === "all" ? "" : field.value,
548
+ onValueChange: field.onChange,
549
+ children: [
550
+ /* @__PURE__ */ jsx(
551
+ SelectTrigger,
552
+ {
553
+ className: cn(
554
+ field.value === "all" && "text-muted-foreground"
555
+ ),
556
+ children: /* @__PURE__ */ jsx(
557
+ SelectValue,
558
+ {
559
+ placeholder: i18n.t("chat:placeholder.selectGroup", {
560
+ defaultValue: "Ch\u1ECDn nh\xF3m"
561
+ })
562
+ }
563
+ )
564
+ }
565
+ ),
566
+ /* @__PURE__ */ jsx(SelectContent, { children: IS_GROUP_OPTIONS.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: option.label }, option.value)) })
567
+ ]
568
+ }
569
+ ) })
570
+ }
571
+ )
572
+ },
573
+ {
574
+ key: "is_unhandled",
575
+ label: i18n.t("chat:label.interaction", {
576
+ defaultValue: "T\u01B0\u01A1ng t\xE1c"
577
+ }),
578
+ isActive: (v) => !!v.is_unhandled,
579
+ reset: () => form.setValue("is_unhandled", ""),
580
+ renderValue: () => /* @__PURE__ */ jsx(
581
+ FormField,
582
+ {
583
+ control: form.control,
584
+ name: "is_unhandled",
585
+ render: ({ field }) => /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsxs(Select, { value: field.value, onValueChange: field.onChange, children: [
586
+ /* @__PURE__ */ jsx(
587
+ SelectTrigger,
588
+ {
589
+ className: cn(!field.value && "text-muted-foreground"),
590
+ children: /* @__PURE__ */ jsx(
591
+ SelectValue,
592
+ {
593
+ placeholder: i18n.t(
594
+ "chat:placeholder.selectInteractionStatus",
595
+ { defaultValue: "Ch\u1ECDn tr\u1EA1ng th\xE1i t\u01B0\u01A1ng t\xE1c" }
596
+ )
597
+ }
598
+ )
599
+ }
600
+ ),
601
+ /* @__PURE__ */ jsx(SelectContent, { children: IS_UNHANDLED_OPTIONS.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: option.label }, option.value)) })
602
+ ] }) })
603
+ }
604
+ )
605
+ },
606
+ {
607
+ key: "tags",
608
+ label: "Tags",
609
+ isActive: (v) => v.tags?.length > 0,
610
+ reset: () => {
611
+ form.setValue("tags", []);
612
+ form.setValue("tag_match_mode", TagMatchMode.Includes);
613
+ },
614
+ renderValue: () => /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
615
+ /* @__PURE__ */ jsx(
616
+ FormField,
617
+ {
618
+ control: form.control,
619
+ name: "tag_match_mode",
620
+ render: ({ field }) => {
621
+ const tags = form.watch("tags") || [];
622
+ const disabled = tags.length === 0;
623
+ return /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsxs(
624
+ Select,
625
+ {
626
+ value: field.value || TagMatchMode.Includes,
627
+ onValueChange: field.onChange,
628
+ disabled,
629
+ children: [
630
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-[110px] shrink-0", children: /* @__PURE__ */ jsx(
631
+ SelectValue,
632
+ {
633
+ placeholder: i18n.t("chat:label.tagMatchMode", {
634
+ defaultValue: "\u0110i\u1EC1u ki\u1EC7n tag"
635
+ })
636
+ }
637
+ ) }),
638
+ /* @__PURE__ */ jsx(SelectContent, { children: TAG_MATCH_MODE_OPTIONS.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: option.label }, option.value)) })
639
+ ]
640
+ }
641
+ ) });
642
+ }
643
+ }
644
+ ),
645
+ /* @__PURE__ */ jsx(
646
+ FormField,
647
+ {
648
+ control: form.control,
649
+ name: "tags",
650
+ render: ({ field }) => /* @__PURE__ */ jsx(FormControl, { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx(
651
+ MultipleSelectSettingTags,
652
+ {
653
+ target: SettingTags.Chat,
654
+ selected: field.value || [],
655
+ onChange: field.onChange,
656
+ placeholder: i18n.t("common:placeholder.selectTags", {
657
+ defaultValue: "Ch\u1ECDn tags"
658
+ }),
659
+ size: "default",
660
+ inputClassName: "my-0",
661
+ includePersonal
662
+ }
663
+ ) })
664
+ }
665
+ )
666
+ ] })
667
+ },
668
+ {
669
+ key: "range_date",
670
+ label: i18n.t("common:label.time", {
671
+ defaultValue: "Th\u1EDDi gian"
672
+ }),
673
+ isActive: (v) => !!(v.range_date?.from || v.range_date?.to),
674
+ reset: () => {
675
+ form.setValue("range_date", { from: null, to: null });
676
+ form.setValue("date_filter_type", DateFilterType.LastMsgTime);
677
+ },
678
+ renderValue: () => /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
679
+ /* @__PURE__ */ jsx(
680
+ FormField,
681
+ {
682
+ control: form.control,
683
+ name: "date_filter_type",
684
+ render: ({ field }) => /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsxs(Select, { value: field.value, onValueChange: field.onChange, children: [
685
+ /* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(
686
+ SelectValue,
687
+ {
688
+ placeholder: i18n.t("chat:placeholder.selectTimeType", {
689
+ defaultValue: "Ch\u1ECDn lo\u1EA1i th\u1EDDi gian"
690
+ })
691
+ }
692
+ ) }),
693
+ /* @__PURE__ */ jsx(SelectContent, { children: DATE_FILTER_TYPE_OPTIONS.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: option.label }, option.value)) })
694
+ ] }) })
695
+ }
696
+ ),
697
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
698
+ /* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsx(
699
+ FormField,
700
+ {
701
+ control: form.control,
702
+ name: "range_date.from",
703
+ render: ({ field }) => {
704
+ const toDate = form.watch("range_date.to");
705
+ return /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
706
+ DateTimePicker,
707
+ {
708
+ date: field.value,
709
+ onChange: field.onChange,
710
+ classNames: {
711
+ container: "pl-3 pr-6",
712
+ icon: "right-2"
713
+ },
714
+ disabledDate: toDate ? { after: toDate } : void 0,
715
+ disabledHourFunc: (hour) => {
716
+ if (!toDate || !isSameDay(field.value, toDate))
717
+ return false;
718
+ return Number(hour) > toDate.getHours();
719
+ },
720
+ disabledMinuteFunc: (minute) => {
721
+ if (!toDate || !isSameDay(field.value, toDate))
722
+ return false;
723
+ return field.value.getHours() < toDate.getHours() ? false : Number(minute) >= toDate.getMinutes();
724
+ }
725
+ }
726
+ ) });
727
+ }
728
+ }
729
+ ) }),
730
+ /* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsx(
731
+ FormField,
732
+ {
733
+ control: form.control,
734
+ name: "range_date.to",
735
+ render: ({ field }) => {
736
+ const fromDate = form.watch("range_date.from");
737
+ return /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
738
+ DateTimePicker,
739
+ {
740
+ date: field.value,
741
+ onChange: field.onChange,
742
+ classNames: {
743
+ container: "pl-3 pr-6",
744
+ icon: "right-1.5"
745
+ },
746
+ disabledDate: fromDate ? { before: fromDate } : void 0,
747
+ disabledHourFunc: (hour) => {
748
+ if (!fromDate || !isSameDay(field.value, fromDate))
749
+ return false;
750
+ return Number(hour) < fromDate.getHours();
751
+ },
752
+ disabledMinuteFunc: (minute) => {
753
+ if (!fromDate || !isSameDay(field.value, fromDate))
754
+ return false;
755
+ return fromDate.getHours() < field.value.getHours() ? false : Number(minute) <= fromDate.getMinutes();
756
+ }
757
+ }
758
+ ) });
759
+ }
760
+ }
761
+ ) })
762
+ ] }),
763
+ /* @__PURE__ */ jsx(RangeDateMessage, { control: form.control })
764
+ ] })
765
+ }
766
+ ];
767
+ return canFilterByDepartment ? fields : fields.filter((field) => field.key !== "group_ids");
768
+ }
769
+ function getActiveCriteriaKeys(fieldDefs, values) {
770
+ return fieldDefs.filter((f) => f.isActive(values)).map((f) => f.key);
771
+ }
772
+ function FilterCriteriaRows({
773
+ form,
774
+ sourceOptions,
775
+ filterSocialPageList,
776
+ includePersonal = false,
777
+ activeKeys,
778
+ onRemoveCriteria,
779
+ onChangeCriteriaType
780
+ }) {
781
+ const fieldDefs = useMemo(
782
+ () => buildCriteriaFields({
783
+ form,
784
+ sourceOptions,
785
+ filterSocialPageList,
786
+ includePersonal
787
+ }),
788
+ [form, sourceOptions, filterSocialPageList, includePersonal]
789
+ );
790
+ const fieldMap = useMemo(() => {
791
+ const map = {};
792
+ fieldDefs.forEach((f) => {
793
+ map[f.key] = f;
794
+ });
795
+ return map;
796
+ }, [fieldDefs]);
797
+ const availableFieldDefs = (excludeKey) => fieldDefs.filter(
798
+ (f) => f.key === excludeKey || !activeKeys.includes(f.key)
799
+ );
800
+ return /* @__PURE__ */ jsx("div", { className: "space-y-2 sm:space-y-3", children: activeKeys.map((key) => {
801
+ const field = fieldMap[key];
802
+ if (!field) return null;
803
+ return /* @__PURE__ */ jsxs(
804
+ "div",
805
+ {
806
+ "data-criteria-key": key,
807
+ className: "flex flex-col gap-1.5 rounded-lg border border-border-subtle p-2 sm:flex-row sm:items-start sm:gap-2 sm:border-0 sm:p-0",
808
+ children: [
809
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 sm:contents", children: [
810
+ /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1 sm:flex-initial", children: /* @__PURE__ */ jsxs(
811
+ Select,
812
+ {
813
+ value: key,
814
+ onValueChange: (newKey) => onChangeCriteriaType(key, newKey),
815
+ children: [
816
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full sm:w-[240px] sm:shrink-0", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
817
+ /* @__PURE__ */ jsx(SelectContent, { children: availableFieldDefs(key).map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.key, children: /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-1.5", children: [
818
+ option.icon,
819
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: option.label })
820
+ ] }) }, option.key)) })
821
+ ]
822
+ }
823
+ ) }),
824
+ /* @__PURE__ */ jsx(
825
+ "button",
826
+ {
827
+ type: "button",
828
+ className: "shrink-0 text-destructive hover:text-destructive sm:order-1",
829
+ onClick: () => onRemoveCriteria(key),
830
+ children: /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" })
831
+ }
832
+ )
833
+ ] }),
834
+ /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: field.renderValue() })
835
+ ]
836
+ },
837
+ key
838
+ );
839
+ }) });
840
+ }
841
+ export {
842
+ buildCriteriaFields,
843
+ FilterCriteriaRows as default,
844
+ getActiveCriteriaKeys
845
+ };