diff --git a/package.json b/package.json index f82f3dbf0..ed631960c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@webitel/ui-sdk", - "version": "24.10.81", + "version": "24.10.82", "private": false, "scripts": { "dev": "vite", diff --git "a/src/api/clients/\321\201ontacts/contactChatMessagesHistory.js" "b/src/api/clients/\321\201ontacts/contactChatMessagesHistory.js" index 512023f4e..4f9b2c1ec 100644 --- "a/src/api/clients/\321\201ontacts/contactChatMessagesHistory.js" +++ "b/src/api/clients/\321\201ontacts/contactChatMessagesHistory.js" @@ -29,7 +29,7 @@ const getChat = async ({ contactId, chatId }) => { const response = await contactChatService.getContactChatHistory(contactId, chatId); const { messages, peers } = applyTransform(response.data, [snakeToCamel()]); return { - items: applyTransform({ messages, peers }, [mergeChatMessagesData]).reverse(), + items: applyTransform({ messages, peers }, [mergeChatMessagesData]), peers, }; } catch (err) { @@ -70,7 +70,7 @@ const getAllMessages = async (params) => { merge(getDefaultGetListResponse()), ]); return { - items: applyTransform({ messages, peers, chats }, [mergeMessagesData]).reverse(), + items: applyTransform({ messages, peers, chats }, [mergeMessagesData]), next, }; } catch (err) { diff --git a/src/modules/QueryFilters/mixins/sortFilterMixin.js b/src/modules/QueryFilters/mixins/sortFilterMixin.js index dc7cdedf8..dd96079ab 100644 --- a/src/modules/QueryFilters/mixins/sortFilterMixin.js +++ b/src/modules/QueryFilters/mixins/sortFilterMixin.js @@ -28,6 +28,24 @@ const decodeSortQuery = ({ value }) => { }; }; +const changeHeadersSort = ({ headers, sortedHeader, order }) => { + return headers.map((header) => { + if (header.sort === undefined) return header; + + // reset all headers by default + let newSort = null; + + if (header.field === sortedHeader.field) { + newSort = order; + } + + return { + ...header, + sort: newSort, + }; + }); +}; + export default { mixins: [baseFilterMixin], data: () => ({ @@ -40,21 +58,12 @@ export default { }, setValue({ column, order }) { - const headers = this.headers.map((header) => { - if (header.sort === undefined) return header; - - // reset all headers by default - let newSort = null; - - if (header.value === column.value) { - newSort = order; - } - - return { - ...header, - sort: newSort, - }; + const headers = changeHeadersSort({ + headers: this.headers, + sortedHeader: column, + order, }); + const value = encodeSortQuery({ column, order }); this.setHeaders(headers); this.setValueToQuery({ @@ -65,6 +74,13 @@ export default { restoreValue(value) { const sortedColumns = decodeSortQuery({ value }); + + debugger; + + // const sortedHeader = + + // const headers = changeHeadersSort({ headers: this.headers, sortedHeader: { field: sortedColumns[0] }, order }); + const headers = this.headers.map((header) => ({ ...header, sort: sortedColumns[header.field] || null,