From c0c9a6f27d4140838ac8077506f064663244b5a3 Mon Sep 17 00:00:00 2001
From: dlohvinov
Date: Tue, 3 Oct 2023 17:52:13 +0300
Subject: [PATCH] feat: contact timezone [WTEL-3707]
---
package-lock.json | 18 +++++++++---------
package.json | 2 +-
src/modules/contacts/api/ContactsAPI.js | 13 +++++++++++--
src/modules/contacts/api/TimezonesAPI.js | 10 ++++++++++
.../contacts/components/contact-popup.vue | 6 +++---
.../components/opened-contact-general.vue | 2 +-
6 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 33f99a38..2023f84f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "crm",
- "version": "0.1.0",
+ "version": "23.09.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "crm",
- "version": "0.1.0",
+ "version": "23.09.0",
"dependencies": {
"@vuelidate/core": "^2.0.0",
"@vuelidate/validators": "^2.0.2",
@@ -19,7 +19,7 @@
"vue-i18n": "^9.2.2",
"vue-router": "^4.0.3",
"vuex": "^4.0.0",
- "webitel-sdk": "^23.7.13"
+ "webitel-sdk": "^23.9.5"
},
"devDependencies": {
"@babel/core": "^7.12.16",
@@ -19990,9 +19990,9 @@
}
},
"node_modules/webitel-sdk": {
- "version": "23.7.13",
- "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-23.7.13.tgz",
- "integrity": "sha512-dhFC0g4pXbM5Gy3fD1tiCz3rhIlQzLFXzMIlPUtFgwKTMwsiX4vEz1wuRJy7P2x1CvIOOiylkzYas0A/bY6yAg==",
+ "version": "23.9.5",
+ "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-23.9.5.tgz",
+ "integrity": "sha512-2kexMAFaWD5dBw3ssW973NL01LMh0YEk72KICjDuPuVBGEqcBffhhUAg1r59ndI6+K3ACrxmNUo9YqxmmLyWBQ==",
"dependencies": {
"@types/webrtc": "0.0.26",
"deep-copy": "1.4.2",
@@ -35881,9 +35881,9 @@
"dev": true
},
"webitel-sdk": {
- "version": "23.7.13",
- "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-23.7.13.tgz",
- "integrity": "sha512-dhFC0g4pXbM5Gy3fD1tiCz3rhIlQzLFXzMIlPUtFgwKTMwsiX4vEz1wuRJy7P2x1CvIOOiylkzYas0A/bY6yAg==",
+ "version": "23.9.5",
+ "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-23.9.5.tgz",
+ "integrity": "sha512-2kexMAFaWD5dBw3ssW973NL01LMh0YEk72KICjDuPuVBGEqcBffhhUAg1r59ndI6+K3ACrxmNUo9YqxmmLyWBQ==",
"requires": {
"@types/webrtc": "0.0.26",
"deep-copy": "1.4.2",
diff --git a/package.json b/package.json
index f7457c3b..964cde4f 100644
--- a/package.json
+++ b/package.json
@@ -20,7 +20,7 @@
"vue-i18n": "^9.2.2",
"vue-router": "^4.0.3",
"vuex": "^4.0.0",
- "webitel-sdk": "^23.7.13"
+ "webitel-sdk": "^23.9.5"
},
"devDependencies": {
"@babel/core": "^7.12.16",
diff --git a/src/modules/contacts/api/ContactsAPI.js b/src/modules/contacts/api/ContactsAPI.js
index c802a612..acd02685 100644
--- a/src/modules/contacts/api/ContactsAPI.js
+++ b/src/modules/contacts/api/ContactsAPI.js
@@ -92,7 +92,7 @@ const getList = async (params) => {
};
const get = async ({ itemId: id }) => {
- const fields = ['name', 'about', 'labels', 'etag', 'mode', 'managers'];
+ const fields = ['name', 'about', 'labels', 'etag', 'mode', 'managers', 'timezones'];
const defaultObject = {};
const itemResponseHandler = (item) => {
@@ -118,7 +118,7 @@ const get = async ({ itemId: id }) => {
}
};
-const fieldsToSend = ['name', 'labels', 'about', 'managers'];
+const fieldsToSend = ['name', 'labels', 'about', 'managers', 'timezones'];
const sanitizeManagers = (itemInstance) => {
// handle many managers and even no managers field cases
@@ -127,9 +127,17 @@ const sanitizeManagers = (itemInstance) => {
return { ...itemInstance, managers };
};
+const sanitizeTimezones = (itemInstance) => {
+ // handle many timezones and even no timezones field cases
+ const timezones = (itemInstance.timezones ||
+ []).filter(({ timezone } = {}) => timezone.id);
+ return { ...itemInstance, timezones };
+};
+
const add = async ({ itemInstance }) => {
const item = applyTransform(itemInstance, [
sanitizeManagers,
+ sanitizeTimezones,
sanitize(fieldsToSend),
camelToSnake(),
@@ -150,6 +158,7 @@ const update = async ({ itemInstance }) => {
const { etag } = itemInstance;
const item = applyTransform(itemInstance, [
sanitizeManagers,
+ sanitizeTimezones,
sanitize(fieldsToSend),
camelToSnake(),
]);
diff --git a/src/modules/contacts/api/TimezonesAPI.js b/src/modules/contacts/api/TimezonesAPI.js
index ebb64bf4..78dcb751 100644
--- a/src/modules/contacts/api/TimezonesAPI.js
+++ b/src/modules/contacts/api/TimezonesAPI.js
@@ -18,6 +18,8 @@ const getList = async (params) => {
page,
size,
search,
+ sort,
+ fields,
} = applyTransform(params, [
merge(getDefaultGetParams()),
starToSearch('search'),
@@ -28,6 +30,8 @@ const getList = async (params) => {
page,
size,
search,
+ sort,
+ fields,
);
const { items, next } = applyTransform(response.data, [
snakeToCamel(),
@@ -44,8 +48,14 @@ const getList = async (params) => {
}
};
+const getLookup = (params) => getList({
+ ...params,
+ fields: params.fields || ['id', 'name'],
+});
+
const TimezonesAPI = {
getList,
+ getLookup,
};
export default TimezonesAPI;
diff --git a/src/modules/contacts/components/contact-popup.vue b/src/modules/contacts/components/contact-popup.vue
index 0e419d18..ceca990e 100644
--- a/src/modules/contacts/components/contact-popup.vue
+++ b/src/modules/contacts/components/contact-popup.vue
@@ -19,10 +19,10 @@
@input="draft.name.commonName = $event"
>
{{ t('date.timezone', 1) }}
- {{ timezones[0] }}
+ {{ timezones[0].timezone.name }}