From dbd1c89266ccc7714dcc626eb5b04aa166b940b9 Mon Sep 17 00:00:00 2001 From: liza-pohranichna Date: Wed, 28 Aug 2024 16:02:38 +0300 Subject: [PATCH 1/2] feature: refactored chats api and remove unused import in timelineTaskPointModule [WTEL-4962] --- package-lock.json | 16 ++++++++-------- package.json | 2 +- .../timeline/modules/chats/store/chats.js | 2 +- .../timeline/store/TimelineTaskPointsModule.js | 1 - 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index c0e03dfb..55fbb0a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@vuelidate/core": "^2.0.3", "@vuelidate/validators": "^2.0.4", "@vueuse/core": "^10.10.0", - "@webitel/ui-sdk": "^24.8.22", + "@webitel/ui-sdk": "^24.8.31", "axios": "^1.7.2", "deep-equal": "^2.2.1", "dompurify": "^3.1.2", @@ -2064,9 +2064,9 @@ } }, "node_modules/@webitel/ui-sdk": { - "version": "24.8.22", - "resolved": "https://registry.npmjs.org/@webitel/ui-sdk/-/ui-sdk-24.8.22.tgz", - "integrity": "sha512-SD6YoIJu8uWRR8a0nUYxbN8v7Iepq94unzM8tzku3h/tW4Kfhxle+l1VPjBCcQie5skJZyuN+0eqUmh555YD9A==", + "version": "24.8.31", + "resolved": "https://registry.npmjs.org/@webitel/ui-sdk/-/ui-sdk-24.8.31.tgz", + "integrity": "sha512-8g/EALIm0+Pp4LlJBaGSL6bAh51Oba4bpRD4tCpmWeoPMaXvD/nk+ZkTffC9SGGOmWs7scykjWScQ2kDHP/oqQ==", "dependencies": { "@floating-ui/vue": "^1.0.1", "@morev/vue-transitions": "^3.0.2", @@ -2094,7 +2094,7 @@ "vue-multiselect": "^3.0.0-beta.3", "vue-observe-visibility": "^2.0.0-alpha.1", "vue-router": "^4.1.6", - "webitel-sdk": "^24.2.16", + "webitel-sdk": "^24.8.1", "xlsx": "^0.18.5" } }, @@ -9822,9 +9822,9 @@ } }, "node_modules/webitel-sdk": { - "version": "24.4.16", - "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-24.4.16.tgz", - "integrity": "sha512-evkakLCmVaRa+AwJ5OvXq27En19vRh5t7ibahtyXDUDGQk2IfHzZ4El/4AVm/RFTow5Una6aGhyhL7Ln4CgDZw==", + "version": "24.8.1", + "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-24.8.1.tgz", + "integrity": "sha512-abdjKyIX7OgykvRJwAAJiIZAyvCExGa9aA9obtXbSfQtMvrF9mTXVQFYv5STYWLQGgpU04Q8BSLp2nj+GSFOZQ==", "dependencies": { "@types/webrtc": "~0.0.41", "deep-copy": "1.4.2", diff --git a/package.json b/package.json index 8bf6bf3a..2bc6ab1b 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "@vuelidate/core": "^2.0.3", "@vuelidate/validators": "^2.0.4", "@vueuse/core": "^10.10.0", - "@webitel/ui-sdk": "^24.8.22", + "@webitel/ui-sdk": "^24.8.31", "axios": "^1.7.2", "deep-equal": "^2.2.1", "dompurify": "^3.1.2", diff --git a/src/modules/contacts/modules/timeline/modules/chats/store/chats.js b/src/modules/contacts/modules/timeline/modules/chats/store/chats.js index f387cc23..4e9e8287 100644 --- a/src/modules/contacts/modules/timeline/modules/chats/store/chats.js +++ b/src/modules/contacts/modules/timeline/modules/chats/store/chats.js @@ -1,6 +1,6 @@ import TimelineTaskPointsModule from '../../../store/TimelineTaskPointsModule.js'; -import MessageHistoryAPI from '../api/MessageHistoryAPI.js'; +import MessageHistoryAPI from '@webitel/ui-sdk/src/api/crm/contactChatMessagesHistory.js'; const chats = new TimelineTaskPointsModule({ apiModule: { diff --git a/src/modules/contacts/modules/timeline/store/TimelineTaskPointsModule.js b/src/modules/contacts/modules/timeline/store/TimelineTaskPointsModule.js index 9e6adba3..61fd9314 100644 --- a/src/modules/contacts/modules/timeline/store/TimelineTaskPointsModule.js +++ b/src/modules/contacts/modules/timeline/store/TimelineTaskPointsModule.js @@ -1,6 +1,5 @@ import BaseStoreModule from '@webitel/ui-sdk/src/store/BaseStoreModules/BaseStoreModule'; -import MessageHistoryAPI from '../modules/chats/api/MessageHistoryAPI.js'; export default class TimelineTaskPointsModule extends BaseStoreModule { apiModule = null; From c728a7c024f87acde9234f74510c8f91d056bfd2 Mon Sep 17 00:00:00 2001 From: liza-pohranichna Date: Wed, 28 Aug 2024 18:53:32 +0300 Subject: [PATCH 2/2] feature: fixed bug with MessageHistoryAPI using [WTEL-4962] --- .../modules/chats/api/MessageHistoryAPI.js | 43 ------------------- .../timeline/modules/chats/store/chats.js | 4 +- 2 files changed, 2 insertions(+), 45 deletions(-) delete mode 100644 src/modules/contacts/modules/timeline/modules/chats/api/MessageHistoryAPI.js diff --git a/src/modules/contacts/modules/timeline/modules/chats/api/MessageHistoryAPI.js b/src/modules/contacts/modules/timeline/modules/chats/api/MessageHistoryAPI.js deleted file mode 100644 index 7be20af9..00000000 --- a/src/modules/contacts/modules/timeline/modules/chats/api/MessageHistoryAPI.js +++ /dev/null @@ -1,43 +0,0 @@ -import applyTransform, { - notify, - snakeToCamel, - camelToSnake, - generateUrl, -} from '@webitel/ui-sdk/src/api/transformers/index.js'; - -import instance from '../../../../../../../app/api/instance'; - -const getList = async (params) => { - const mergeMessageData = ({ peers, messages }) => { - return messages.map(({ from, ...message }) => { - return { - ...message, - peer: peers[from.id - 1], - }; - }); - }; - const url = applyTransform(params, [ - camelToSnake(), - generateUrl(`contacts/${params.parentId}/chat/${params.taskId}/messages`), - ]); - - try { - const response = await instance.get(url); - const { peers, messages } = applyTransform(response.data, [ - snakeToCamel(), - ]); - return { - items: applyTransform({ peers, messages }, [ - mergeMessageData, - ]).reverse(), - }; - } catch (err) { - throw applyTransform(err, [ - notify, - ]); - } -}; - -export default { - getList, -}; diff --git a/src/modules/contacts/modules/timeline/modules/chats/store/chats.js b/src/modules/contacts/modules/timeline/modules/chats/store/chats.js index 4e9e8287..fbe9160a 100644 --- a/src/modules/contacts/modules/timeline/modules/chats/store/chats.js +++ b/src/modules/contacts/modules/timeline/modules/chats/store/chats.js @@ -5,8 +5,8 @@ import MessageHistoryAPI from '@webitel/ui-sdk/src/api/crm/contactChatMessagesHi const chats = new TimelineTaskPointsModule({ apiModule: { getList: ({ taskId, parentId }) => MessageHistoryAPI.getList({ - taskId, - parentId, + contactId: parentId, + chatId: taskId, }), }, })