From c8dddce27697940259a444e1526e392d057b68a5 Mon Sep 17 00:00:00 2001 From: Lera24 Date: Mon, 22 Apr 2024 18:29:32 +0300 Subject: [PATCH] fix: refactor day components, API and some styles[WTEL-4418] --- package-lock.json | 1 + package.json | 1 + .../modules/timeline/api/TimelineAPI.js | 75 +++++++++++-------- .../day-row/day-timeline-row-counters.vue | 1 + .../day-row/day-timeline-row-section.vue | 7 +- .../components/day-row/day-timeline-row.vue | 13 +--- .../task-row/call-task-timeline-row.vue | 7 +- .../components/task-row/task-timeline-row.vue | 7 +- .../timeline/components/the-timeline.vue | 3 +- .../timeline/components/timeline-header.vue | 12 +-- .../components/utils/timeline-pin.vue | 11 +-- .../components/utils/timeline-row-info.vue | 12 ++- .../components/utils/timeline-separator.vue | 39 ++++++++++ .../timeline-task-status.vue} | 22 +----- 14 files changed, 117 insertions(+), 94 deletions(-) create mode 100644 src/modules/contacts/modules/timeline/components/utils/timeline-separator.vue rename src/modules/contacts/modules/timeline/components/{event-status-detail.vue => utils/timeline-task-status.vue} (61%) diff --git a/package-lock.json b/package-lock.json index 60eca7bb..27e0a4ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "@vitejs/plugin-vue": "5.0.3", "@vitest/coverage-v8": "^1.1.3", "@vue/test-utils": "^2.0.0-0", + "deep-copy": "^1.4.2", "eslint": "^8.56.0", "eslint-plugin-import": "^2.25.3", "eslint-plugin-vue": "^9.20.0", diff --git a/package.json b/package.json index cff65bb3..6f28829d 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "@vitejs/plugin-vue": "5.0.3", "@vitest/coverage-v8": "^1.1.3", "@vue/test-utils": "^2.0.0-0", + "deep-copy": "^1.4.2", "eslint": "^8.56.0", "eslint-plugin-import": "^2.25.3", "eslint-plugin-vue": "^9.20.0", diff --git a/src/modules/contacts/modules/timeline/api/TimelineAPI.js b/src/modules/contacts/modules/timeline/api/TimelineAPI.js index 6d08f080..041acdb1 100644 --- a/src/modules/contacts/modules/timeline/api/TimelineAPI.js +++ b/src/modules/contacts/modules/timeline/api/TimelineAPI.js @@ -4,6 +4,7 @@ import applyTransform, { merge, notify, sanitize, snakeToCamel, starToSearch, mergeEach, } from '@webitel/ui-sdk/src/api/transformers'; +import deepCopy from 'deep-copy'; import { TimelineApiFactory } from 'webitel-sdk'; import getDefaultGetListResponse from '../../../../../app/api/defaults/getDefaultGetListResponse'; @@ -12,40 +13,52 @@ import instance from '../../../../../app/api/instance'; const timeline = new TimelineApiFactory(configuration, '', instance); -const getList = async (params) => { - const fieldsToSend = ['parentId', 'dateFrom', 'dateTo', 'type']; - const { - parentId, - dateFrom, - dateTo, - type, - } = applyTransform(params, [ - sanitize(fieldsToSend), - merge(getDefaultGetParams()), - ]); - try { - const response = await timeline.getTimeline( +const listHandler = (items) => { + let copy = deepCopy(items); + if(copy) { + return copy.map(day => ({ + ...day, + items: day.items.map(item => ({ + ...item, + type:!item.type ? 'chat' : item.type, + })) + })); + } return copy; +} + + const getList = async (params) => { + const fieldsToSend = ['parentId', 'dateFrom', 'dateTo', 'type']; + const { parentId, dateFrom, dateTo, type, - ); - const { days, next } = applyTransform(response.data, [ - snakeToCamel(), - merge(getDefaultGetListResponse()), - ]); - return { - items: applyTransform(days, [ - ]), - next, - }; - } catch (err) { - throw applyTransform(err, [ - notify, + } = applyTransform(params, [ + sanitize(fieldsToSend), + merge(getDefaultGetParams()), ]); - } -}; + try { + const response = await timeline.getTimeline( + parentId, + dateFrom, + dateTo, + type, + ); + const { days, next } = applyTransform(response.data, [ + snakeToCamel(), + merge(getDefaultGetListResponse()), + ]); + return { + items: applyTransform(days, [ + listHandler, + ]), + next, + }; + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } + }; -export default { - getList, -}; + export default { getList };; diff --git a/src/modules/contacts/modules/timeline/components/day-row/day-timeline-row-counters.vue b/src/modules/contacts/modules/timeline/components/day-row/day-timeline-row-counters.vue index 3e1eb246..e4993058 100644 --- a/src/modules/contacts/modules/timeline/components/day-row/day-timeline-row-counters.vue +++ b/src/modules/contacts/modules/timeline/components/day-row/day-timeline-row-counters.vue @@ -31,6 +31,7 @@ const { t } = useI18n(); justify-content: flex-end; &__wrapper { + @extend %typo-body-2; display: flex; gap: var(--spacing-xs); } diff --git a/src/modules/contacts/modules/timeline/components/day-row/day-timeline-row-section.vue b/src/modules/contacts/modules/timeline/components/day-row/day-timeline-row-section.vue index d8816d0b..f0a72cf1 100644 --- a/src/modules/contacts/modules/timeline/components/day-row/day-timeline-row-section.vue +++ b/src/modules/contacts/modules/timeline/components/day-row/day-timeline-row-section.vue @@ -4,13 +4,12 @@ :timestamp="day.dayTimestamp" :calls-count="day.callsCount" :chats-count="day.chatsCount" - :last-day="lastDay" @toggle="opened = !opened" />
@@ -27,10 +26,6 @@ const props = defineProps({ day: { type: Object, }, - lastDay: { - type: Boolean, - default: false, - }, }); const opened = ref(false); diff --git a/src/modules/contacts/modules/timeline/components/day-row/day-timeline-row.vue b/src/modules/contacts/modules/timeline/components/day-row/day-timeline-row.vue index 155fa386..76be6130 100644 --- a/src/modules/contacts/modules/timeline/components/day-row/day-timeline-row.vue +++ b/src/modules/contacts/modules/timeline/components/day-row/day-timeline-row.vue @@ -4,10 +4,9 @@ - - + + - {{ props.timestamp }} - - - - - - - diff --git a/src/modules/contacts/modules/timeline/components/task-row/call-task-timeline-row.vue b/src/modules/contacts/modules/timeline/components/task-row/call-task-timeline-row.vue index 2d55d8ab..f36a5fde 100644 --- a/src/modules/contacts/modules/timeline/components/task-row/call-task-timeline-row.vue +++ b/src/modules/contacts/modules/timeline/components/task-row/call-task-timeline-row.vue @@ -1,7 +1,7 @@