@droppii-org/chat-sdk 0.1.2 → 0.1.4
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/dist/assets/svg/cannedResponse.d.ts +7 -0
- package/dist/assets/svg/cannedResponse.d.ts.map +1 -0
- package/dist/assets/svg/cannedResponse.js +3 -0
- package/dist/assets/svg/cannedResponse.tsx +48 -0
- package/dist/assets/svg/index.d.ts +1 -0
- package/dist/assets/svg/index.d.ts.map +1 -1
- package/dist/assets/svg/index.js +1 -0
- package/dist/assets/svg/index.ts +1 -0
- package/dist/components/cannedResponse/CannedResponseBody.d.ts +8 -0
- package/dist/components/cannedResponse/CannedResponseBody.d.ts.map +1 -0
- package/dist/components/cannedResponse/CannedResponseBody.js +58 -0
- package/dist/components/cannedResponse/CannedResponseFooter.d.ts +6 -0
- package/dist/components/cannedResponse/CannedResponseFooter.d.ts.map +1 -0
- package/dist/components/cannedResponse/CannedResponseFooter.js +8 -0
- package/dist/components/cannedResponse/CannedResponseHeader.d.ts +8 -0
- package/dist/components/cannedResponse/CannedResponseHeader.d.ts.map +1 -0
- package/dist/components/cannedResponse/CannedResponseHeader.js +11 -0
- package/dist/components/cannedResponse/index.d.ts +8 -0
- package/dist/components/cannedResponse/index.d.ts.map +1 -0
- package/dist/components/cannedResponse/index.js +34 -0
- package/dist/components/cannedResponse/team/TeamItem.d.ts +11 -0
- package/dist/components/cannedResponse/team/TeamItem.d.ts.map +1 -0
- package/dist/components/cannedResponse/team/TeamItem.js +31 -0
- package/dist/components/conversation/ConversationBySessionItem.d.ts.map +1 -1
- package/dist/components/conversation/ConversationBySessionItem.js +6 -2
- package/dist/components/mediaCollection/LinkCollection.js +1 -1
- package/dist/components/message/MediaPreviewIcon.d.ts +7 -0
- package/dist/components/message/MediaPreviewIcon.d.ts.map +1 -0
- package/dist/components/message/MediaPreviewIcon.js +24 -0
- package/dist/components/message/MessageHeader.js +1 -1
- package/dist/components/message/MessageList.d.ts +1 -0
- package/dist/components/message/MessageList.d.ts.map +1 -1
- package/dist/components/message/MessageList.js +49 -6
- package/dist/components/message/footer/ActionBar.d.ts.map +1 -1
- package/dist/components/message/footer/ActionBar.js +15 -86
- package/dist/components/message/footer/CannedResponsePlugin.d.ts +7 -0
- package/dist/components/message/footer/CannedResponsePlugin.d.ts.map +1 -0
- package/dist/components/message/footer/CannedResponsePlugin.js +31 -0
- package/dist/components/message/footer/EmojiPicker.d.ts.map +1 -1
- package/dist/components/message/footer/EmojiPicker.js +9 -5
- package/dist/components/message/footer/EnterHandler.d.ts.map +1 -1
- package/dist/components/message/footer/EnterHandler.js +16 -5
- package/dist/components/message/footer/FilePreview.d.ts +5 -0
- package/dist/components/message/footer/FilePreview.d.ts.map +1 -1
- package/dist/components/message/footer/FilePreview.js +15 -12
- package/dist/components/message/footer/MediaActions.d.ts +10 -0
- package/dist/components/message/footer/MediaActions.d.ts.map +1 -0
- package/dist/components/message/footer/MediaActions.js +98 -0
- package/dist/components/message/footer/QuotedMessage.d.ts +2 -0
- package/dist/components/message/footer/QuotedMessage.d.ts.map +1 -0
- package/dist/components/message/footer/QuotedMessage.js +24 -0
- package/dist/components/message/footer/editorConfig.d.ts +24 -0
- package/dist/components/message/footer/editorConfig.d.ts.map +1 -0
- package/dist/components/message/footer/editorConfig.js +33 -0
- package/dist/components/message/footer/index.d.ts +2 -1
- package/dist/components/message/footer/index.d.ts.map +1 -1
- package/dist/components/message/footer/index.js +33 -28
- package/dist/components/message/item/QuoteMessage.d.ts +9 -0
- package/dist/components/message/item/QuoteMessage.d.ts.map +1 -0
- package/dist/components/message/item/QuoteMessage.js +41 -0
- package/dist/components/message/item/RevokeMessage.d.ts +5 -0
- package/dist/components/message/item/RevokeMessage.d.ts.map +1 -0
- package/dist/components/message/item/RevokeMessage.js +8 -0
- package/dist/components/message/item/TextMessage.js +1 -1
- package/dist/components/message/item/UrlTextMessage.d.ts.map +1 -1
- package/dist/components/message/item/UrlTextMessage.js +3 -3
- package/dist/components/message/item/index.d.ts +6 -1
- package/dist/components/message/item/index.d.ts.map +1 -1
- package/dist/components/message/item/index.js +79 -25
- package/dist/components/richTextEditor/RichTextEditor.d.ts +12 -0
- package/dist/components/richTextEditor/RichTextEditor.d.ts.map +1 -0
- package/dist/components/richTextEditor/RichTextEditor.js +62 -0
- package/dist/components/searchConversation/SearchDrawer.js +1 -1
- package/dist/components/searchConversation/item/SearchItemAsMessage.d.ts +3 -1
- package/dist/components/searchConversation/item/SearchItemAsMessage.d.ts.map +1 -1
- package/dist/components/searchConversation/item/SearchItemAsMessage.js +5 -2
- package/dist/components/thread/AssignConfirmModal.d.ts +12 -0
- package/dist/components/thread/AssignConfirmModal.d.ts.map +1 -0
- package/dist/components/thread/AssignConfirmModal.js +11 -0
- package/dist/components/thread/ManualAssignPopover.d.ts +14 -0
- package/dist/components/thread/ManualAssignPopover.d.ts.map +1 -0
- package/dist/components/thread/ManualAssignPopover.js +83 -0
- package/dist/components/thread/SessionSection.d.ts.map +1 -1
- package/dist/components/thread/SessionSection.js +11 -6
- package/dist/components/thread/UserSection.js +1 -1
- package/dist/hooks/cannedResponse/useFetchCannedCategories.d.ts +3 -0
- package/dist/hooks/cannedResponse/useFetchCannedCategories.d.ts.map +1 -0
- package/dist/hooks/cannedResponse/useFetchCannedCategories.js +13 -0
- package/dist/hooks/cannedResponse/useFetchCannedResponse.d.ts +219 -0
- package/dist/hooks/cannedResponse/useFetchCannedResponse.d.ts.map +1 -0
- package/dist/hooks/cannedResponse/useFetchCannedResponse.js +55 -0
- package/dist/hooks/message/useMessage.d.ts.map +1 -1
- package/dist/hooks/message/useMessage.js +18 -1
- package/dist/hooks/message/useRevokeMessage.d.ts +5 -0
- package/dist/hooks/message/useRevokeMessage.d.ts.map +1 -0
- package/dist/hooks/message/useRevokeMessage.js +16 -0
- package/dist/hooks/message/useSendMessage.d.ts +1 -0
- package/dist/hooks/message/useSendMessage.d.ts.map +1 -1
- package/dist/hooks/message/useSendMessage.js +40 -9
- package/dist/hooks/session/useAssignSession.d.ts +8 -0
- package/dist/hooks/session/useAssignSession.d.ts.map +1 -0
- package/dist/hooks/session/useAssignSession.js +15 -0
- package/dist/hooks/session/useCreateNote.d.ts.map +1 -1
- package/dist/hooks/session/useCreateNote.js +2 -1
- package/dist/hooks/session/useGetTeamSupporters.d.ts +8 -0
- package/dist/hooks/session/useGetTeamSupporters.d.ts.map +1 -0
- package/dist/hooks/session/useGetTeamSupporters.js +20 -0
- package/dist/hooks/team/useFetchMyTeam.d.ts +3 -0
- package/dist/hooks/team/useFetchMyTeam.d.ts.map +1 -0
- package/dist/hooks/team/useFetchMyTeam.js +12 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/locales/vi/common.json +54 -53
- package/dist/screens/deskMessage/index.d.ts +4 -1
- package/dist/screens/deskMessage/index.d.ts.map +1 -1
- package/dist/screens/deskMessage/index.js +2 -2
- package/dist/services/query.d.ts +5 -0
- package/dist/services/query.d.ts.map +1 -1
- package/dist/services/query.js +5 -0
- package/dist/services/routes.d.ts +5 -0
- package/dist/services/routes.d.ts.map +1 -1
- package/dist/services/routes.js +5 -0
- package/dist/store/conversation.d.ts.map +1 -1
- package/dist/store/conversation.js +7 -1
- package/dist/styles/global.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/chat.d.ts +7 -1
- package/dist/types/chat.d.ts.map +1 -1
- package/dist/types/chat.js +5 -0
- package/dist/types/dto.d.ts +53 -1
- package/dist/types/dto.d.ts.map +1 -1
- package/dist/utils/common.d.ts +3 -2
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/common.js +43 -19
- package/dist/utils/fileValidation.d.ts.map +1 -1
- package/dist/utils/fileValidation.js +2 -8
- package/dist/utils/queryHelpers.d.ts +3 -0
- package/dist/utils/queryHelpers.d.ts.map +1 -0
- package/dist/utils/queryHelpers.js +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Popover, Input, Avatar, Spin, Badge } from "antd";
|
|
4
|
+
import { useTranslation } from "react-i18next";
|
|
5
|
+
import clsx from "clsx";
|
|
6
|
+
import { Icon } from "../icon";
|
|
7
|
+
import { useGetTeamSupporters } from "../../hooks/session/useGetTeamSupporters";
|
|
8
|
+
import { useAssignSession } from "../../hooks/session/useAssignSession";
|
|
9
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
10
|
+
import { message as antdMessage } from "antd";
|
|
11
|
+
import { invalidateSessionQueries } from "../../utils/queryHelpers";
|
|
12
|
+
import AssignConfirmModal from "./AssignConfirmModal";
|
|
13
|
+
import { useDebounce } from "ahooks";
|
|
14
|
+
const SEARCH_DEBOUNCE_WAIT = 300;
|
|
15
|
+
const SupporterItem = ({ supporter, onClick, isCurrentAssignee, }) => {
|
|
16
|
+
var _a;
|
|
17
|
+
const { t } = useTranslation();
|
|
18
|
+
const isOnline = supporter.status === "ONLINE";
|
|
19
|
+
return (_jsxs("div", { role: "option", tabIndex: 0, "aria-selected": isCurrentAssignee, className: clsx("flex items-center gap-3 px-3 py-2 rounded-md transition-colors", isCurrentAssignee
|
|
20
|
+
? "bg-blue-50 border border-blue-200 pointer-events-none"
|
|
21
|
+
: "cursor-pointer hover:bg-gray-50"), onClick: () => onClick(supporter), children: [_jsx(Badge, { dot: true, color: isOnline ? "#52c41a" : "#d9d9d9", offset: [-2, 24], children: _jsx(Avatar, { src: supporter.avatar, size: 32, children: ((_a = supporter.displayName) === null || _a === void 0 ? void 0 : _a.charAt(0)) || "A" }) }), _jsx("span", { className: "text-sm truncate flex-1", children: supporter.displayName }), isCurrentAssignee && (_jsx("span", { className: "text-xs text-blue-500 shrink-0", children: t("manual_assign_current") }))] }));
|
|
22
|
+
};
|
|
23
|
+
const ManualAssignPopover = ({ sessionId, supporter, teamId: propTeamId, }) => {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
const { t } = useTranslation();
|
|
26
|
+
const queryClient = useQueryClient();
|
|
27
|
+
const [open, setOpen] = useState(false);
|
|
28
|
+
const [searchText, setSearchText] = useState("");
|
|
29
|
+
const [selectedAgent, setSelectedAgent] = useState(null);
|
|
30
|
+
const [confirmModalOpen, setConfirmModalOpen] = useState(false);
|
|
31
|
+
const debouncedSearch = useDebounce(searchText, {
|
|
32
|
+
wait: SEARCH_DEBOUNCE_WAIT,
|
|
33
|
+
});
|
|
34
|
+
const teamId = propTeamId || "";
|
|
35
|
+
const { data: supporters, isLoading, isFetching, } = useGetTeamSupporters({
|
|
36
|
+
teamId,
|
|
37
|
+
search: debouncedSearch || undefined,
|
|
38
|
+
});
|
|
39
|
+
const { mutate: assignSession, isPending: isAssigning } = useAssignSession();
|
|
40
|
+
const handleSelectAgent = (agent) => {
|
|
41
|
+
if (isAssigning)
|
|
42
|
+
return;
|
|
43
|
+
setSelectedAgent(agent);
|
|
44
|
+
setConfirmModalOpen(true);
|
|
45
|
+
};
|
|
46
|
+
const handleConfirmAssign = () => {
|
|
47
|
+
if (!selectedAgent || isAssigning)
|
|
48
|
+
return;
|
|
49
|
+
assignSession({ sessionId, supporterId: selectedAgent.memberId }, {
|
|
50
|
+
onSuccess: () => {
|
|
51
|
+
antdMessage.success(t("manual_assign_success"));
|
|
52
|
+
setConfirmModalOpen(false);
|
|
53
|
+
setOpen(false);
|
|
54
|
+
setSearchText("");
|
|
55
|
+
invalidateSessionQueries(queryClient);
|
|
56
|
+
},
|
|
57
|
+
onError: () => {
|
|
58
|
+
antdMessage.error(t("manual_assign_failed"));
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
const handleCancelConfirm = () => {
|
|
63
|
+
setConfirmModalOpen(false);
|
|
64
|
+
};
|
|
65
|
+
const handleAfterClose = () => {
|
|
66
|
+
setSelectedAgent(null);
|
|
67
|
+
};
|
|
68
|
+
const handleOpenChange = (newOpen) => {
|
|
69
|
+
if (isAssigning)
|
|
70
|
+
return;
|
|
71
|
+
if (!newOpen && confirmModalOpen)
|
|
72
|
+
return;
|
|
73
|
+
setOpen(newOpen);
|
|
74
|
+
if (!newOpen) {
|
|
75
|
+
setSearchText("");
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const popoverContent = (_jsxs("div", { className: "w-64", children: [_jsx("div", { className: "mb-2", children: _jsx(Input, { autoFocus: true, placeholder: t("manual_assign_search_placeholder"), value: searchText, onChange: (e) => setSearchText(e.target.value), prefix: _jsx(Icon, { icon: "search-o", size: 16, className: "text-gray-400" }), className: "rounded-lg border-gray-300 focus-within:border-[#3278f7] focus-within:shadow-[0_0_0_2px_rgba(50,120,247,0.12)]", allowClear: true }) }), _jsx("div", { className: "max-h-72 overflow-y-auto", role: "listbox", children: isLoading ? (_jsx("div", { className: "flex items-center justify-center py-8", children: _jsx(Spin, {}) })) : supporters && supporters.length > 0 ? (_jsx("div", { className: clsx("flex flex-col transition-opacity duration-200", isFetching && "opacity-50 pointer-events-none"), children: supporters.map((item) => (_jsx(SupporterItem, { supporter: item, onClick: handleSelectAgent, isCurrentAssignee: item.memberId === (supporter === null || supporter === void 0 ? void 0 : supporter.id) }, item.memberId))) })) : (_jsx("div", { className: "flex items-center justify-center py-8", children: _jsx("span", { className: "text-sm text-gray-400", children: t("manual_assign_no_results") }) })) })] }));
|
|
79
|
+
return (_jsxs(_Fragment, { children: [_jsx(Popover, { content: popoverContent, trigger: "click", open: open, onOpenChange: handleOpenChange, placement: "topLeft", arrow: false, children: _jsxs("div", { role: "button", tabIndex: 0, "aria-label": t("manual_assign_button_reassign"), className: clsx("flex items-center border border-gray-200 rounded-lg p-1 gap-1 transition-opacity", isAssigning
|
|
80
|
+
? "opacity-50 pointer-events-none"
|
|
81
|
+
: "cursor-pointer hover:opacity-80"), children: [_jsx(Avatar, { src: supporter === null || supporter === void 0 ? void 0 : supporter.avatar, size: 28, children: ((_b = (_a = supporter === null || supporter === void 0 ? void 0 : supporter.fullName) === null || _a === void 0 ? void 0 : _a.charAt) === null || _b === void 0 ? void 0 : _b.call(_a, 0)) || "A" }), _jsx("span", { className: "text-purple-500", children: _jsx(Icon, { icon: "shuffle-b", size: 20 }) })] }) }), _jsx(AssignConfirmModal, { open: confirmModalOpen, agent: selectedAgent, loading: isAssigning, onCancel: handleCancelConfirm, onConfirm: handleConfirmAssign, afterClose: handleAfterClose })] }));
|
|
82
|
+
};
|
|
83
|
+
export default ManualAssignPopover;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionSection.d.ts","sourceRoot":"","sources":["../../../src/components/thread/SessionSection.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SessionSection.d.ts","sourceRoot":"","sources":["../../../src/components/thread/SessionSection.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAkB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAoBnE,eAAO,MAAM,iBAAiB,GAAI,wBAG/B;IACD,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;CACnB,4CA6MA,CAAC;AA+CF,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,cAAc,GAAI,yBAAyB,mBAAmB,4CAmDnE,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -2,12 +2,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useBoolean, useDebounce } from "ahooks";
|
|
3
3
|
import { Icon } from "../icon";
|
|
4
4
|
import { Button, Select, Spin, Tag, Input, message, Avatar } from "antd";
|
|
5
|
+
import ManualAssignPopover from "./ManualAssignPopover";
|
|
5
6
|
import { useGetLabelSession } from "../../hooks/session/useGetLabelSession";
|
|
6
7
|
import { useUpdateSessionInfo } from "../../hooks/session/useUpdateSessionInfo";
|
|
7
8
|
import { useCloseSession } from "../../hooks/session/useCloseSession";
|
|
8
9
|
import { useQueryClient } from "@tanstack/react-query";
|
|
9
10
|
import { QUERY_KEYS } from "../../services/query";
|
|
10
11
|
import { useEffect, useState } from "react";
|
|
12
|
+
import { useTranslation } from "react-i18next";
|
|
11
13
|
const { TextArea } = Input;
|
|
12
14
|
const formatSessionDate = (dateString) => {
|
|
13
15
|
if (!dateString)
|
|
@@ -22,6 +24,7 @@ const formatSessionDate = (dateString) => {
|
|
|
22
24
|
export const SessionDetailCard = ({ session, isActive, }) => {
|
|
23
25
|
var _a, _b, _c, _d, _e;
|
|
24
26
|
const queryClient = useQueryClient();
|
|
27
|
+
const { t } = useTranslation("common");
|
|
25
28
|
const { data: availableLabels, isLoading: isLoadingLabels } = useGetLabelSession();
|
|
26
29
|
const { mutate: updateSession } = useUpdateSessionInfo();
|
|
27
30
|
const { mutate: closeSession, isPending: isClosing } = useCloseSession();
|
|
@@ -95,13 +98,13 @@ export const SessionDetailCard = ({ session, isActive, }) => {
|
|
|
95
98
|
const handleCloseSession = () => {
|
|
96
99
|
closeSession(session.id, {
|
|
97
100
|
onSuccess: () => {
|
|
98
|
-
message.success("
|
|
101
|
+
message.success(t("close_session_success"));
|
|
99
102
|
queryClient.invalidateQueries({
|
|
100
103
|
queryKey: [QUERY_KEYS.GET_LIST_SESSION_BY_CONVERSATION],
|
|
101
104
|
});
|
|
102
105
|
},
|
|
103
106
|
onError: () => {
|
|
104
|
-
message.error("
|
|
107
|
+
message.error(t("close_session_failed"));
|
|
105
108
|
},
|
|
106
109
|
});
|
|
107
110
|
};
|
|
@@ -109,13 +112,14 @@ export const SessionDetailCard = ({ session, isActive, }) => {
|
|
|
109
112
|
value: label.id,
|
|
110
113
|
label: label.name,
|
|
111
114
|
}));
|
|
112
|
-
return (_jsxs("div", { className: `p-3 border rounded-lg shadow-md ${isActive ? "border-blue-500" : "border-gray-300"}`, children: [_jsxs("div", { className: "flex justify-between items-start mb-3", children: [_jsx("div", { className: "flex items-center gap-2", children: _jsxs("div", { className: "flex flex-col", children: [_jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Icon, { icon: "chat-square-b", size: 16, className: "text-gray-500" }),
|
|
115
|
+
return (_jsxs("div", { className: `p-3 border rounded-lg shadow-md ${isActive ? "border-blue-500" : "border-gray-300"}`, children: [_jsxs("div", { className: "flex justify-between items-start mb-3", children: [_jsx("div", { className: "flex items-center gap-2", children: _jsxs("div", { className: "flex flex-col", children: [_jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Icon, { icon: "chat-square-b", size: 16, className: "text-gray-500" }), _jsx("p", { className: "font-semibold text-sm", children: t("session_label", { order: session.order }) })] }), _jsx("p", { className: "text-xs text-gray-400", children: formatSessionDate(session.closedDate || session.createdDate) })] }) }), isActive ? (_jsx(Tag, { color: "processing", children: t("session_active") })) : (_jsx(Avatar, { src: (_a = session.supporter) === null || _a === void 0 ? void 0 : _a.avatar, size: 24, children: ((_d = (_c = (_b = session.supporter) === null || _b === void 0 ? void 0 : _b.fullName) === null || _c === void 0 ? void 0 : _c.charAt) === null || _d === void 0 ? void 0 : _d.call(_c, 0)) || "A" }))] }), _jsxs("div", { className: "flex flex-col gap-3 text-sm", children: [_jsxs("div", { className: "flex items-center gap-2 text-gray-500", children: [_jsx(Icon, { icon: "tag-o", size: 16, className: "mt-1" }), _jsx(Select, { mode: "multiple", loading: isLoadingLabels, className: "w-full", placeholder: t("session_add_tag_placeholder"), options: labelOptions, value: (_e = session.labels) === null || _e === void 0 ? void 0 : _e.map((label) => label.id), onChange: handleUpdateLabels, removeIcon: true })] }), _jsxs("div", { className: "flex items-start gap-2 text-gray-500", children: [_jsx(Icon, { icon: "info-circle-o", size: 16, className: "mt-1" }), _jsx(TextArea, { value: issueDetailInput.value, onChange: (e) => setIssueDetailInput({
|
|
113
116
|
value: e.target.value,
|
|
114
117
|
sessionId: session.id,
|
|
115
|
-
}), placeholder: "
|
|
118
|
+
}), placeholder: t("session_issue_detail_placeholder"), className: "border-none !shadow-none py-0 px-2", autoSize: { minRows: 1, maxRows: 3 } })] }), _jsxs("div", { className: "flex items-start gap-2 text-gray-500", children: [_jsx(Icon, { icon: "paper-o", size: 16, className: "mt-1" }), _jsx(TextArea, { value: noteInput.value, onChange: (e) => setNoteInput({ value: e.target.value, sessionId: session.id }), placeholder: t("session_note_placeholder"), className: "border-none !shadow-none py-0 px-2", autoSize: { minRows: 1, maxRows: 3 } })] })] }), isActive && (_jsxs("div", { className: "flex items-center gap-2 mt-4 border-t border-gray-200 pt-4", children: [_jsx(ManualAssignPopover, { sessionId: session.id, supporter: session.supporter, teamId: session.teamId }), _jsx(Button, { type: "primary", className: "flex-1", onClick: handleCloseSession, loading: isClosing, children: t("session_close_button") })] }))] }));
|
|
116
119
|
};
|
|
117
120
|
const ClosedSessionItem = ({ session, expandedSessionId, onToggleExpand, }) => {
|
|
118
121
|
var _a, _b, _c, _d;
|
|
122
|
+
const { t } = useTranslation("common");
|
|
119
123
|
const isExpanded = session.id === expandedSessionId;
|
|
120
124
|
const handleClick = () => {
|
|
121
125
|
onToggleExpand(session.id);
|
|
@@ -123,9 +127,10 @@ const ClosedSessionItem = ({ session, expandedSessionId, onToggleExpand, }) => {
|
|
|
123
127
|
if (isExpanded) {
|
|
124
128
|
return (_jsx("div", { children: _jsx(SessionDetailCard, { session: session, isActive: false }) }));
|
|
125
129
|
}
|
|
126
|
-
return (_jsxs("div", { className: "flex justify-between items-center p-2 rounded-md hover:bg-gray-100 cursor-pointer", onClick: handleClick, children: [_jsxs("div", { className: "flex items-center gap-2 text-sm", children: [_jsx(Icon, { icon: "chat-square-b", size: 16, className: "text-gray-500" }),
|
|
130
|
+
return (_jsxs("div", { className: "flex justify-between items-center p-2 rounded-md hover:bg-gray-100 cursor-pointer", onClick: handleClick, children: [_jsxs("div", { className: "flex items-center gap-2 text-sm", children: [_jsx(Icon, { icon: "chat-square-b", size: 16, className: "text-gray-500" }), _jsx("span", { className: "font-semibold", children: t("session_label", { order: session.order }) }), _jsx("span", { className: "text-gray-400 text-xs", children: formatSessionDate(session.closedDate || session.createdDate) })] }), _jsx(Avatar, { src: (_a = session.supporter) === null || _a === void 0 ? void 0 : _a.avatar, size: 24, children: ((_d = (_c = (_b = session.supporter) === null || _b === void 0 ? void 0 : _b.fullName) === null || _c === void 0 ? void 0 : _c.charAt) === null || _d === void 0 ? void 0 : _d.call(_c, 0)) || "A" })] }));
|
|
127
131
|
};
|
|
128
132
|
const SessionSection = ({ sessions, isLoading }) => {
|
|
133
|
+
const { t } = useTranslation("common");
|
|
129
134
|
const [isOpen, { toggle }] = useBoolean(true);
|
|
130
135
|
const [expandedSessionId, setExpandedSessionId] = useState(null);
|
|
131
136
|
const handleToggleExpand = (sessionId) => {
|
|
@@ -136,6 +141,6 @@ const SessionSection = ({ sessions, isLoading }) => {
|
|
|
136
141
|
setExpandedSessionId(null);
|
|
137
142
|
}
|
|
138
143
|
}, [isOpen]);
|
|
139
|
-
return (_jsxs("div", { className: "flex flex-col border-b", children: [_jsxs("div", { role: "button", onClick: toggle, className: "flex items-center justify-between px-4 py-2 rounded-md hover:bg-gray-100 sticky top-0 bg-white z-10", children: [_jsx("h3", { className: "font-bold text-gray-500 text-xs tracking-wider", children: "
|
|
144
|
+
return (_jsxs("div", { className: "flex flex-col border-b", children: [_jsxs("div", { role: "button", onClick: toggle, className: "flex items-center justify-between px-4 py-2 rounded-md hover:bg-gray-100 sticky top-0 bg-white z-10", children: [_jsx("h3", { className: "font-bold text-gray-500 text-xs tracking-wider", children: t("sessions_heading") }), _jsx(Icon, { icon: isOpen ? "angle-up-o" : "angle-down-o", size: 18 })] }), isOpen && (_jsx("div", { className: "px-4 pt-2 pb-4", children: isLoading ? (_jsx("div", { className: "text-center mt-4", children: _jsx(Spin, {}) })) : (_jsx("div", { className: "flex flex-col gap-1", children: sessions.map((session) => (_jsx(ClosedSessionItem, { session: session, expandedSessionId: expandedSessionId, onToggleExpand: handleToggleExpand }, session.id))) })) }))] }));
|
|
140
145
|
};
|
|
141
146
|
export default SessionSection;
|
|
@@ -70,7 +70,7 @@ const UserSection = () => {
|
|
|
70
70
|
navigator.clipboard.writeText((data === null || data === void 0 ? void 0 : data.id) || "");
|
|
71
71
|
message.success(t("copied_to_clipboard"));
|
|
72
72
|
} })] }), _jsxs("div", { className: "flex justify-between items-center gap-2", children: [_jsxs("p", { className: "text-sm truncate flex gap-3", children: [_jsx("span", { className: "font-light text-gray-400 w-16", children: "Username" }), (data === null || data === void 0 ? void 0 : data.username) || ""] }), _jsx(Icon, { icon: "copy-o", size: 16, onClick: () => {
|
|
73
|
-
navigator.clipboard.writeText((data === null || data === void 0 ? void 0 : data.
|
|
73
|
+
navigator.clipboard.writeText((data === null || data === void 0 ? void 0 : data.username) || "");
|
|
74
74
|
message.success(t("copied_to_clipboard"));
|
|
75
75
|
} })] }), _jsxs("div", { className: "flex justify-between", children: [_jsx("p", { className: "text-sm flex gap-3", children: _jsx("span", { className: "font-light text-gray-400 w-16", children: "Note" }) }), _jsx(TextArea, { value: noteValue, placeholder: t("add_note"), className: "border-none py-0", autoSize: { minRows: 1, maxRows: 6 }, onChange: (e) => {
|
|
76
76
|
const v = e.target.value;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ICannedCategoryResponse } from "../../types/dto";
|
|
2
|
+
export declare const useFetchCannedCategories: (teamId?: string, enabled?: boolean) => import("@tanstack/react-query").UseQueryResult<ICannedCategoryResponse[], Error>;
|
|
3
|
+
//# sourceMappingURL=useFetchCannedCategories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchCannedCategories.d.ts","sourceRoot":"","sources":["../../../src/hooks/cannedResponse/useFetchCannedCategories.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAExE,eAAO,MAAM,wBAAwB,GAAI,SAAS,MAAM,EAAE,UAAU,OAAO,qFAUvE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { QUERY_KEYS } from "../../services/query";
|
|
3
|
+
import { apiInstance } from "../../services/api";
|
|
4
|
+
import { ENDPOINTS } from "../../services/routes";
|
|
5
|
+
export const useFetchCannedCategories = (teamId, enabled) => useQuery({
|
|
6
|
+
queryKey: [QUERY_KEYS.GET_CANNED_CATEGORIES, teamId],
|
|
7
|
+
queryFn: async () => {
|
|
8
|
+
var _a;
|
|
9
|
+
const res = await apiInstance.get(ENDPOINTS.chatService.getCannedCategories, { params: { teamId } });
|
|
10
|
+
return ((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.data) || [];
|
|
11
|
+
},
|
|
12
|
+
enabled: !!enabled && !!teamId,
|
|
13
|
+
});
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { BaseResponse, ICannedResponseItem, IFetchCannedResponseRequest } from "../../types/dto";
|
|
2
|
+
export declare const useFetchCannedResponse: (payload: IFetchCannedResponseRequest) => {
|
|
3
|
+
error: Error;
|
|
4
|
+
isError: true;
|
|
5
|
+
isPending: false;
|
|
6
|
+
isLoadingError: false;
|
|
7
|
+
isRefetchError: true;
|
|
8
|
+
isSuccess: false;
|
|
9
|
+
isPlaceholderData: false;
|
|
10
|
+
status: "error";
|
|
11
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>, Error>>;
|
|
12
|
+
hasPreviousPage: boolean;
|
|
13
|
+
isFetchNextPageError: boolean;
|
|
14
|
+
isFetchPreviousPageError: boolean;
|
|
15
|
+
isFetchingPreviousPage: boolean;
|
|
16
|
+
dataUpdatedAt: number;
|
|
17
|
+
errorUpdatedAt: number;
|
|
18
|
+
failureCount: number;
|
|
19
|
+
failureReason: Error | null;
|
|
20
|
+
errorUpdateCount: number;
|
|
21
|
+
isFetched: boolean;
|
|
22
|
+
isFetchedAfterMount: boolean;
|
|
23
|
+
isFetching: boolean;
|
|
24
|
+
isInitialLoading: boolean;
|
|
25
|
+
isPaused: boolean;
|
|
26
|
+
isRefetching: boolean;
|
|
27
|
+
isStale: boolean;
|
|
28
|
+
isEnabled: boolean;
|
|
29
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>, Error>>;
|
|
30
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
31
|
+
promise: Promise<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>>;
|
|
32
|
+
data: import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown> | undefined;
|
|
33
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>, Error>>;
|
|
34
|
+
hasNextPage: boolean;
|
|
35
|
+
isFetchingNextPage: boolean;
|
|
36
|
+
isLoading: boolean;
|
|
37
|
+
dataFlatten: ICannedResponseItem[];
|
|
38
|
+
} | {
|
|
39
|
+
error: null;
|
|
40
|
+
isError: false;
|
|
41
|
+
isPending: false;
|
|
42
|
+
isLoadingError: false;
|
|
43
|
+
isRefetchError: false;
|
|
44
|
+
isFetchNextPageError: false;
|
|
45
|
+
isFetchPreviousPageError: false;
|
|
46
|
+
isSuccess: true;
|
|
47
|
+
isPlaceholderData: false;
|
|
48
|
+
status: "success";
|
|
49
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>, Error>>;
|
|
50
|
+
hasPreviousPage: boolean;
|
|
51
|
+
isFetchingPreviousPage: boolean;
|
|
52
|
+
dataUpdatedAt: number;
|
|
53
|
+
errorUpdatedAt: number;
|
|
54
|
+
failureCount: number;
|
|
55
|
+
failureReason: Error | null;
|
|
56
|
+
errorUpdateCount: number;
|
|
57
|
+
isFetched: boolean;
|
|
58
|
+
isFetchedAfterMount: boolean;
|
|
59
|
+
isFetching: boolean;
|
|
60
|
+
isInitialLoading: boolean;
|
|
61
|
+
isPaused: boolean;
|
|
62
|
+
isRefetching: boolean;
|
|
63
|
+
isStale: boolean;
|
|
64
|
+
isEnabled: boolean;
|
|
65
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>, Error>>;
|
|
66
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
67
|
+
promise: Promise<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>>;
|
|
68
|
+
data: import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown> | undefined;
|
|
69
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>, Error>>;
|
|
70
|
+
hasNextPage: boolean;
|
|
71
|
+
isFetchingNextPage: boolean;
|
|
72
|
+
isLoading: boolean;
|
|
73
|
+
dataFlatten: ICannedResponseItem[];
|
|
74
|
+
} | {
|
|
75
|
+
error: Error;
|
|
76
|
+
isError: true;
|
|
77
|
+
isPending: false;
|
|
78
|
+
isLoadingError: true;
|
|
79
|
+
isRefetchError: false;
|
|
80
|
+
isFetchNextPageError: false;
|
|
81
|
+
isFetchPreviousPageError: false;
|
|
82
|
+
isSuccess: false;
|
|
83
|
+
isPlaceholderData: false;
|
|
84
|
+
status: "error";
|
|
85
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>, Error>>;
|
|
86
|
+
hasPreviousPage: boolean;
|
|
87
|
+
isFetchingPreviousPage: boolean;
|
|
88
|
+
dataUpdatedAt: number;
|
|
89
|
+
errorUpdatedAt: number;
|
|
90
|
+
failureCount: number;
|
|
91
|
+
failureReason: Error | null;
|
|
92
|
+
errorUpdateCount: number;
|
|
93
|
+
isFetched: boolean;
|
|
94
|
+
isFetchedAfterMount: boolean;
|
|
95
|
+
isFetching: boolean;
|
|
96
|
+
isInitialLoading: boolean;
|
|
97
|
+
isPaused: boolean;
|
|
98
|
+
isRefetching: boolean;
|
|
99
|
+
isStale: boolean;
|
|
100
|
+
isEnabled: boolean;
|
|
101
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>, Error>>;
|
|
102
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
103
|
+
promise: Promise<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>>;
|
|
104
|
+
data: import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown> | undefined;
|
|
105
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>, Error>>;
|
|
106
|
+
hasNextPage: boolean;
|
|
107
|
+
isFetchingNextPage: boolean;
|
|
108
|
+
isLoading: boolean;
|
|
109
|
+
dataFlatten: ICannedResponseItem[];
|
|
110
|
+
} | {
|
|
111
|
+
error: null;
|
|
112
|
+
isError: false;
|
|
113
|
+
isPending: true;
|
|
114
|
+
isLoadingError: false;
|
|
115
|
+
isRefetchError: false;
|
|
116
|
+
isFetchNextPageError: false;
|
|
117
|
+
isFetchPreviousPageError: false;
|
|
118
|
+
isSuccess: false;
|
|
119
|
+
isPlaceholderData: false;
|
|
120
|
+
status: "pending";
|
|
121
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>, Error>>;
|
|
122
|
+
hasPreviousPage: boolean;
|
|
123
|
+
isFetchingPreviousPage: boolean;
|
|
124
|
+
dataUpdatedAt: number;
|
|
125
|
+
errorUpdatedAt: number;
|
|
126
|
+
failureCount: number;
|
|
127
|
+
failureReason: Error | null;
|
|
128
|
+
errorUpdateCount: number;
|
|
129
|
+
isFetched: boolean;
|
|
130
|
+
isFetchedAfterMount: boolean;
|
|
131
|
+
isFetching: boolean;
|
|
132
|
+
isInitialLoading: boolean;
|
|
133
|
+
isPaused: boolean;
|
|
134
|
+
isRefetching: boolean;
|
|
135
|
+
isStale: boolean;
|
|
136
|
+
isEnabled: boolean;
|
|
137
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>, Error>>;
|
|
138
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
139
|
+
promise: Promise<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>>;
|
|
140
|
+
data: import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown> | undefined;
|
|
141
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>, Error>>;
|
|
142
|
+
hasNextPage: boolean;
|
|
143
|
+
isFetchingNextPage: boolean;
|
|
144
|
+
isLoading: boolean;
|
|
145
|
+
dataFlatten: ICannedResponseItem[];
|
|
146
|
+
} | {
|
|
147
|
+
error: null;
|
|
148
|
+
isError: false;
|
|
149
|
+
isPending: true;
|
|
150
|
+
isLoadingError: false;
|
|
151
|
+
isRefetchError: false;
|
|
152
|
+
isFetchNextPageError: false;
|
|
153
|
+
isFetchPreviousPageError: false;
|
|
154
|
+
isSuccess: false;
|
|
155
|
+
isPlaceholderData: false;
|
|
156
|
+
status: "pending";
|
|
157
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>, Error>>;
|
|
158
|
+
hasPreviousPage: boolean;
|
|
159
|
+
isFetchingPreviousPage: boolean;
|
|
160
|
+
dataUpdatedAt: number;
|
|
161
|
+
errorUpdatedAt: number;
|
|
162
|
+
failureCount: number;
|
|
163
|
+
failureReason: Error | null;
|
|
164
|
+
errorUpdateCount: number;
|
|
165
|
+
isFetched: boolean;
|
|
166
|
+
isFetchedAfterMount: boolean;
|
|
167
|
+
isFetching: boolean;
|
|
168
|
+
isInitialLoading: boolean;
|
|
169
|
+
isPaused: boolean;
|
|
170
|
+
isRefetching: boolean;
|
|
171
|
+
isStale: boolean;
|
|
172
|
+
isEnabled: boolean;
|
|
173
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>, Error>>;
|
|
174
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
175
|
+
promise: Promise<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>>;
|
|
176
|
+
data: import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown> | undefined;
|
|
177
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>, Error>>;
|
|
178
|
+
hasNextPage: boolean;
|
|
179
|
+
isFetchingNextPage: boolean;
|
|
180
|
+
isLoading: boolean;
|
|
181
|
+
dataFlatten: ICannedResponseItem[];
|
|
182
|
+
} | {
|
|
183
|
+
isError: false;
|
|
184
|
+
error: null;
|
|
185
|
+
isPending: false;
|
|
186
|
+
isLoadingError: false;
|
|
187
|
+
isRefetchError: false;
|
|
188
|
+
isSuccess: true;
|
|
189
|
+
isPlaceholderData: true;
|
|
190
|
+
isFetchNextPageError: false;
|
|
191
|
+
isFetchPreviousPageError: false;
|
|
192
|
+
status: "success";
|
|
193
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>, Error>>;
|
|
194
|
+
hasPreviousPage: boolean;
|
|
195
|
+
isFetchingPreviousPage: boolean;
|
|
196
|
+
dataUpdatedAt: number;
|
|
197
|
+
errorUpdatedAt: number;
|
|
198
|
+
failureCount: number;
|
|
199
|
+
failureReason: Error | null;
|
|
200
|
+
errorUpdateCount: number;
|
|
201
|
+
isFetched: boolean;
|
|
202
|
+
isFetchedAfterMount: boolean;
|
|
203
|
+
isFetching: boolean;
|
|
204
|
+
isInitialLoading: boolean;
|
|
205
|
+
isPaused: boolean;
|
|
206
|
+
isRefetching: boolean;
|
|
207
|
+
isStale: boolean;
|
|
208
|
+
isEnabled: boolean;
|
|
209
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>, Error>>;
|
|
210
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
211
|
+
promise: Promise<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>>;
|
|
212
|
+
data: import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown> | undefined;
|
|
213
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<BaseResponse<ICannedResponseItem[]>, unknown>, Error>>;
|
|
214
|
+
hasNextPage: boolean;
|
|
215
|
+
isFetchingNextPage: boolean;
|
|
216
|
+
isLoading: boolean;
|
|
217
|
+
dataFlatten: ICannedResponseItem[];
|
|
218
|
+
};
|
|
219
|
+
//# sourceMappingURL=useFetchCannedResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchCannedResponse.d.ts","sourceRoot":"","sources":["../../../src/hooks/cannedResponse/useFetchCannedResponse.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,2BAA2B,EAC5B,MAAM,iBAAiB,CAAC;AAMzB,eAAO,MAAM,sBAAsB,GACjC,SAAS,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyDrC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
13
|
+
import { QUERY_KEYS } from "../../services/query";
|
|
14
|
+
import { apiInstance } from "../../services/api";
|
|
15
|
+
import { ENDPOINTS } from "../../services/routes";
|
|
16
|
+
import { PAGE_SIZE } from "../../constants";
|
|
17
|
+
import { useMemo } from "react";
|
|
18
|
+
export const useFetchCannedResponse = (payload) => {
|
|
19
|
+
const _a = useInfiniteQuery({
|
|
20
|
+
initialPageParam: 1,
|
|
21
|
+
queryKey: [QUERY_KEYS.GET_CANNED_RESPONSES, payload],
|
|
22
|
+
queryFn: async ({ pageParam = 1 }) => {
|
|
23
|
+
const params = Object.assign(Object.assign({ pageSize: (payload === null || payload === void 0 ? void 0 : payload.pageSize) || PAGE_SIZE }, payload), { page: pageParam });
|
|
24
|
+
const res = await apiInstance.get(ENDPOINTS.chatService.getCannedResponses, {
|
|
25
|
+
params,
|
|
26
|
+
});
|
|
27
|
+
return res.data;
|
|
28
|
+
},
|
|
29
|
+
getNextPageParam: (lastPage) => {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
const pageSize = (payload === null || payload === void 0 ? void 0 : payload.pageSize) || PAGE_SIZE;
|
|
32
|
+
const dataLength = ((_a = lastPage === null || lastPage === void 0 ? void 0 : lastPage.data) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
33
|
+
const currentPage = ((_b = lastPage === null || lastPage === void 0 ? void 0 : lastPage.pageable) === null || _b === void 0 ? void 0 : _b.pageNumber) || 1;
|
|
34
|
+
return dataLength < pageSize ? undefined : currentPage + 1;
|
|
35
|
+
},
|
|
36
|
+
enabled: (payload === null || payload === void 0 ? void 0 : payload.visibilityScope) === "PRIVATE" || !!(payload === null || payload === void 0 ? void 0 : payload.teamId),
|
|
37
|
+
}), { data, fetchNextPage, hasNextPage, isFetchingNextPage, isLoading } = _a, rest = __rest(_a, ["data", "fetchNextPage", "hasNextPage", "isFetchingNextPage", "isLoading"]);
|
|
38
|
+
const { dataFlatten } = useMemo(() => {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
if (!data)
|
|
41
|
+
return {
|
|
42
|
+
dataFlatten: [],
|
|
43
|
+
};
|
|
44
|
+
const allItems = ((_b = (_a = data === null || data === void 0 ? void 0 : data.pages) === null || _a === void 0 ? void 0 : _a.flatMap) === null || _b === void 0 ? void 0 : _b.call(_a, (page) => page.data)) || [];
|
|
45
|
+
return {
|
|
46
|
+
dataFlatten: allItems,
|
|
47
|
+
};
|
|
48
|
+
}, [data]);
|
|
49
|
+
return Object.assign({ data,
|
|
50
|
+
fetchNextPage,
|
|
51
|
+
hasNextPage,
|
|
52
|
+
isFetchingNextPage,
|
|
53
|
+
isLoading,
|
|
54
|
+
dataFlatten }, rest);
|
|
55
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useMessage.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"useMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,WAAW,EACX,WAAW,EAEZ,MAAM,yBAAyB,CAAC;AAQjC,eAAO,MAAM,kBAAkB,eAe9B,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,iBAAiB,MAAM,EACvB,oBAAoB,MAAM;;;;;qBAML,WAAW,EAAE;;;;;;qBAAb,WAAW,EAAE;;;;;;CAgPnC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,SAAS,WAAW,SACpB,CAAC;AAChC,eAAO,MAAM,gBAAgB,GAAI,SAAS,WAAW,SACpB,CAAC;AAClC,eAAO,MAAM,gBAAgB,GAAI,aAAa,MAAM,SACf,CAAC;AAEtC,eAAO,MAAM,kBAAkB,GAC7B,aAAa,WAAW,EAAE,EAC1B,SAAS,WAAW,EACpB,WAAW,MAAM,GAAG,MAAM,KACzB,WAAW,GAAG,SAkBhB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
|
-
import { ViewType, MessageType } from "@openim/wasm-client-sdk";
|
|
2
|
+
import { ViewType, MessageType, } from "@openim/wasm-client-sdk";
|
|
3
3
|
import { DChatSDK } from "../../constants/sdk";
|
|
4
4
|
import { useLatest, useRequest } from "ahooks";
|
|
5
5
|
import emitter, { emit } from "../../utils/events";
|
|
@@ -19,6 +19,7 @@ export const visibleTypeMessage = [
|
|
|
19
19
|
MessageType.QuoteMessage,
|
|
20
20
|
MessageType.FaceMessage,
|
|
21
21
|
MessageType.UrlTextMessage,
|
|
22
|
+
MessageType.RevokeMessage,
|
|
22
23
|
];
|
|
23
24
|
export const useMessage = (conversationId, searchClientMsgID) => {
|
|
24
25
|
const [loadState, setLoadState] = useState({
|
|
@@ -134,11 +135,27 @@ export const useMessage = (conversationId, searchClientMsgID) => {
|
|
|
134
135
|
};
|
|
135
136
|
const updateOneMessage = (message) => {
|
|
136
137
|
setLoadState((preState) => {
|
|
138
|
+
var _a, _b, _c, _d;
|
|
137
139
|
const tmpList = [...preState.messageList];
|
|
138
140
|
const idx = tmpList.findIndex((msg) => msg.clientMsgID === message.clientMsgID);
|
|
139
141
|
if (idx < 0) {
|
|
140
142
|
return preState;
|
|
141
143
|
}
|
|
144
|
+
const isRevoked = message.contentType === MessageType.RevokeMessage;
|
|
145
|
+
if (isRevoked) {
|
|
146
|
+
const relatedQuoteMessageIds = (_a = tmpList === null || tmpList === void 0 ? void 0 : tmpList.filter((msg) => {
|
|
147
|
+
var _a, _b;
|
|
148
|
+
return (msg === null || msg === void 0 ? void 0 : msg.contentType) === MessageType.QuoteMessage &&
|
|
149
|
+
((_b = (_a = msg === null || msg === void 0 ? void 0 : msg.quoteElem) === null || _a === void 0 ? void 0 : _a.quoteMessage) === null || _b === void 0 ? void 0 : _b.clientMsgID) ===
|
|
150
|
+
(message === null || message === void 0 ? void 0 : message.clientMsgID);
|
|
151
|
+
})) === null || _a === void 0 ? void 0 : _a.map((msg) => msg === null || msg === void 0 ? void 0 : msg.clientMsgID);
|
|
152
|
+
for (const relatedQuoteMessageId of relatedQuoteMessageIds || []) {
|
|
153
|
+
const relatedQuoteMessageIdx = tmpList.findIndex((msg) => msg.clientMsgID === relatedQuoteMessageId);
|
|
154
|
+
if (relatedQuoteMessageIdx >= 0) {
|
|
155
|
+
tmpList[relatedQuoteMessageIdx] = Object.assign(Object.assign({}, tmpList[relatedQuoteMessageIdx]), { quoteElem: Object.assign(Object.assign({}, (_b = tmpList[relatedQuoteMessageIdx]) === null || _b === void 0 ? void 0 : _b.quoteElem), { quoteMessage: Object.assign(Object.assign({}, (_d = (_c = tmpList[relatedQuoteMessageIdx]) === null || _c === void 0 ? void 0 : _c.quoteElem) === null || _d === void 0 ? void 0 : _d.quoteMessage), { contentType: MessageType.RevokeMessage }) }) });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
142
159
|
tmpList[idx] = Object.assign(Object.assign({}, tmpList[idx]), message);
|
|
143
160
|
return Object.assign(Object.assign({}, preState), { messageList: tmpList });
|
|
144
161
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRevokeMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useRevokeMessage.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB;;;CAiB5B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DChatSDK } from "../../constants/sdk";
|
|
2
|
+
import { useRequest } from "ahooks";
|
|
3
|
+
export const useRevokeMessage = () => {
|
|
4
|
+
const { loading, runAsync: revokeMessage } = useRequest(async (conversationID, clientMsgID) => {
|
|
5
|
+
await DChatSDK.revokeMessage({
|
|
6
|
+
conversationID,
|
|
7
|
+
clientMsgID,
|
|
8
|
+
});
|
|
9
|
+
}, {
|
|
10
|
+
manual: true,
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
revokeMessage,
|
|
14
|
+
loading,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -12,6 +12,7 @@ export declare const createMergerMessage: (mergerMsgParams: MergerMsgParams) =>
|
|
|
12
12
|
export declare const createVideoMessageByFile: (file: VideoMsgParamsByFile) => Promise<MessageItem | null>;
|
|
13
13
|
export declare const createFileMessageByFile: (file: FileMsgParamsByFile) => Promise<MessageItem | null>;
|
|
14
14
|
export declare const createUrlTextMessage: (text: string, urls: string[]) => Promise<MessageItem | null>;
|
|
15
|
+
export declare const createQuoteMessage: (text: string, quotedMessage: MessageItem) => Promise<MessageItem | null>;
|
|
15
16
|
export declare const useSendMessage: () => {
|
|
16
17
|
sendTextMessage: ({ plainText, richText, currentSession, }: {
|
|
17
18
|
plainText: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSendMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useSendMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,WAAW,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"useSendMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useSendMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,WAAW,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAW1B,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAQlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAepD,eAAO,MAAM,iBAAiB,GAAI,SAAS;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB,YAE0C,CAAC;AAE5C,eAAO,MAAM,iBAAiB,GAAU,MAAM,MAAM,gCAanD,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAU,MAAM,oBAAoB,gCAaxE,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAU,iBAAiB,eAAe,gCAazE,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAU,MAAM,oBAAoB,gCAaxE,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAU,MAAM,mBAAmB,gCAatE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAU,MAAM,MAAM,EAAE,MAAM,MAAM,EAAE,gCActE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,MAAM,MAAM,EACZ,eAAe,WAAW,gCAc3B,CAAC;AAEF,eAAO,MAAM,cAAc;gEAgKpB;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,cAAc,CAAC,EAAE,gBAAgB,CAAC;KACnC;wEAkCE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,UAAU,EAAE,CAAC;QACpB,cAAc,CAAC,EAAE,gBAAgB,CAAC;KACnC;mCAhJqB,WAAW;CAgRpC,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAI,+BAGvC;IACD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,gBAAgB,CAAC;CACnC,KAWM,iBACN,CAAC"}
|