Skip to content

Commit

Permalink
Feat / merge conflicts (package-lock.json,package.json, /ContactsAPI.…
Browse files Browse the repository at this point in the history
…js) [WTEL-4740]
  • Loading branch information
SviatoslavBar committed Sep 13, 2024
2 parents 0b70705 + 0c6173a commit c868534
Show file tree
Hide file tree
Showing 45 changed files with 2,298 additions and 1,562 deletions.
2,468 changes: 1,257 additions & 1,211 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "crm",
"version": "24.04-1.0",
"version": "24.08.0",
"private": true,
"scripts": {
"dev": "vite",
Expand All @@ -14,33 +14,34 @@
"@vue/compat": "^3.4.27",
"@vuelidate/core": "^2.0.3",
"@vuelidate/validators": "^2.0.4",
"@vueuse/core": "^10.10.0",
"@vueuse/core": "^11.0.3",
"@webitel/ui-sdk": "^24.10.7",
"axios": "^1.7.2",
"axios": "^1.7.7",
"deep-equal": "^2.2.1",
"dompurify": "^3.1.2",
"linkify-html": "^4.1.3",
"linkifyjs": "^4.1.3",
"lodash": "^4.17.21",
"vue": "^3.4.27",
"markdown-it": "^14.1.0",
"vue": "^3.5.1",
"vue-i18n": "^9.13.1",
"vue-router": "^4.3.2",
"vuex": "^4.1.0",
"webitel-sdk": "^24.8.1"
},
"devDependencies": {
"@vitejs/plugin-vue": "5.0.4",
"@vitest/coverage-v8": "^2.0.0-beta.3",
"@vitejs/plugin-vue": "5.1.3",
"@vitest/coverage-v8": "^2.0.5",
"@vue/test-utils": "^2.4.6",
"deep-copy": "^1.4.2",
"eslint": "^9.3.0",
"eslint-plugin-vue": "^9.26.0",
"happy-dom": "^14.11.1",
"happy-dom": "^15.7.3",
"sass": "^1.77.2",
"tslib": "^2.6.2",
"vite": "^5.2.11",
"tslib": "^2.7.0",
"vite": "^5.4.3",
"vite-plugin-node-polyfills": "^0.22.0",
"vite-plugin-svg-sprite": "^0.5.2",
"vitest": "^2.0.0-beta.3"
"vitest": "^2.0.5"
}
}
10 changes: 9 additions & 1 deletion src/app/locale/en/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,27 @@ export default {
timeline: 'Timeline',
actions: {
openInHistory: 'Open in history',
playRecording: 'Play Recording',
playRecording: 'Play recording',
transcription: 'Transcription',
},
status: {
[TimelineTaskStatusEnum.STARTED]: 'Started',
[TimelineTaskStatusEnum.MISSED]: 'Missed',
[TimelineTaskStatusEnum.TRANSFERRED]: 'Transferred',
[TimelineTaskStatusEnum.ENDED]: 'Ended',
[TimelineTaskStatusEnum.SENT]: 'Sent',
[TimelineTaskStatusEnum.RECEIVED]: 'Received',
},
eventType: {
[WebitelContactsTimelineEventType.Call]: 'Call | Calls',
[WebitelContactsTimelineEventType.Chat]: 'Chat | Chats',
[WebitelContactsTimelineEventType.Email]: 'Email | Emails',
},
emails: {
to: 'To',
cc: 'CC',
subject: 'Subject',
},
},
communications: {
communications: 'Communication option | Communication options',
Expand All @@ -53,6 +60,7 @@ export default {
messaging: {
gateway: 'Gateway',
provider: 'Provider ',
username: 'Username',
dummy: 'There are no messaging options yet',
messengers: {
[ChatGatewayProvider.TELEGRAM_BOT]: 'Telegram Bot',
Expand Down
8 changes: 8 additions & 0 deletions src/app/locale/ru/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@ export default {
[TimelineTaskStatusEnum.MISSED]: 'Пропущен',
[TimelineTaskStatusEnum.TRANSFERRED]: 'Переведено',
[TimelineTaskStatusEnum.ENDED]: 'Конец',
[TimelineTaskStatusEnum.SENT]: 'Отправлено',
[TimelineTaskStatusEnum.RECEIVED]: 'Получено',
},
eventType: {
[WebitelContactsTimelineEventType.Call]: 'Звонок | Звонки',
[WebitelContactsTimelineEventType.Chat]: 'Чат | Чаты',
[WebitelContactsTimelineEventType.Email]: 'Письмо | Письма',
},
emails: {
to: 'Кому',
cc: 'CC',
subject: 'Тема',
},
},
communications: {
communications: 'Средство связи | Средства связи',
Expand All @@ -53,6 +60,7 @@ export default {
messaging: {
gateway: 'Шлюз',
provider: 'Провайдер',
username: 'Имя пользователя',
dummy: 'Пока еще не было текстовых диалогов',
messengers: {
[ChatGatewayProvider.TELEGRAM_BOT]: 'Telegram Бот',
Expand Down
8 changes: 8 additions & 0 deletions src/app/locale/ua/ua.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@ export default {
[TimelineTaskStatusEnum.MISSED]: 'Пропущений',
[TimelineTaskStatusEnum.TRANSFERRED]: 'Переведено',
[TimelineTaskStatusEnum.ENDED]: 'Кінець',
[TimelineTaskStatusEnum.SENT]: 'Надіслано',
[TimelineTaskStatusEnum.RECEIVED]: 'Отримано',
},
eventType: {
[WebitelContactsTimelineEventType.Call]: 'Дзвінок | Дзвінки',
[WebitelContactsTimelineEventType.Chat]: 'Чат | Чати',
[WebitelContactsTimelineEventType.Email]: 'Лист | Листи',
},
emails: {
to: 'Кому',
cc: 'CC',
subject: 'Тема',
},
},
communications: {
communications: 'Засіб зв\'язку | Засоби зв\'язку',
Expand All @@ -53,6 +60,7 @@ export default {
messaging: {
gateway: 'Шлюз',
provider: 'Провайдер',
username: 'Ім\'я користувача',
dummy: 'Поки ще не було текстових діалогів',
messengers: {
[ChatGatewayProvider.TELEGRAM_BOT]: 'Telegram Бот',
Expand Down
7 changes: 7 additions & 0 deletions src/app/scripts/generateMediaURL.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const generateMediaURL = (id, download) => {
const token = localStorage.getItem('access-token');
const BASE_URL = import.meta.env.VITE_API_URL;
return `${BASE_URL}/storage/recordings/${id}/${download ? 'download' : 'stream'}?access_token=${token}`;
};

export default generateMediaURL;
203 changes: 2 additions & 201 deletions src/modules/contacts/api/ContactsAPI.js
Original file line number Diff line number Diff line change
@@ -1,202 +1,3 @@
import { getDefaultGetParams } from '@webitel/ui-sdk/src/api/defaults/index.js';
import applyTransform, {
camelToSnake,
merge,
notify,
sanitize,
snakeToCamel,
} from '@webitel/ui-sdk/src/api/transformers/index.js';
import { ContactsApiFactory } from 'webitel-sdk';
import getDefaultGetListResponse
from '../../../app/api/defaults/getDefaultGetListResponse';
import instance from '../../../app/api/instance';
import configuration from '../../../app/api/openAPIConfig';
import SearchMode from '../modules/filters/enums/SearchMode.enum';
import { contacts } from '@webitel/ui-sdk/src/api/crm/index.js';

const service = new ContactsApiFactory(configuration, '', instance);

const formatAccessMode = (item) => ({
...item,
access: {
edit: item.mode.includes('w'),
delete: item.mode.includes('d'),
},
});

const getList = async (params) => {
const fieldsToSend = ['page', 'size', 'q', 'sort', 'fields', 'id', 'qin'];
let searchValue = '';
let searchKey = '';

if (params[SearchMode.NAME]) {
searchValue = params[SearchMode.NAME];
searchKey = SearchMode.NAME;
} else if (params[SearchMode.LABELS]) {
searchValue = params[SearchMode.LABELS];
searchKey = SearchMode.LABELS;
} else if (params[SearchMode.ABOUT]) {
searchValue = params[SearchMode.ABOUT];
searchKey = SearchMode.ABOUT;
} else if (params[SearchMode.VARIABLES]) {
searchValue = params[SearchMode.VARIABLES];
searchKey = SearchMode.VARIABLES;
} else if (params[SearchMode.DESTINATION]) {
searchValue = params[SearchMode.DESTINATION];
searchKey = 'emails,phones';
}

const changedParams = {
...params,
q: searchValue,
qin: searchKey,
};

const transformations = [
sanitize(fieldsToSend),
merge(getDefaultGetParams()),
camelToSnake(),
];

// This code needed for adding starToSearch method to applyTransform while searchKey !== SearchMode.VARIABLES because '*' in variables search mode brokes backend logic.
if (searchKey !== SearchMode.VARIABLES) {
// transformations.push(starToSearch('q')); WTEL-4265
}

const {
page,
size,
q,
sort,
fields,
id,
qin,
} = applyTransform(changedParams, transformations);

try {
const response = await service.searchContacts(
page,
size,
q,
sort || '+name',
['mode', ...fields],
id,
qin,
);
const { data, next } = applyTransform(response.data, [
snakeToCamel(),
merge(getDefaultGetListResponse()),
]);
return {
items: applyTransform(data, [
(items) => items.map((item) => formatAccessMode(item)),
]),
next,
};
} catch (err) {
throw applyTransform(err, [
notify,
]);
}
};

const get = async ({ itemId: id }) => {
const fields = ['name', 'about', 'labels', 'etag', 'mode', 'managers', 'timezones'];

const defaultObject = {};
const itemResponseHandler = (item) => {
return {
...item,
labels: item.labels?.data || [],
managers: item.managers?.data || [],
timezones: item.timezones?.data || [],
};
};
try {
const response = await service.locateContact(id, fields);
return applyTransform(response.data, [
snakeToCamel(),
merge(defaultObject),
itemResponseHandler,
formatAccessMode,
]);
} catch (err) {
throw applyTransform(err, [
notify,
]);
}
};

const fieldsToSend = ['name', 'labels', 'about', 'managers', 'timezones'];

const sanitizeManagers = (itemInstance) => {
// handle many managers and even no managers field cases
const managers = (itemInstance.managers ||
[]).filter(({ user } = {}) => user.id);
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(),

]);
try {
const response = await service.createContact(item);
return applyTransform(response.data, [
snakeToCamel(),
]);
} catch (err) {
throw applyTransform(err, [
notify,
]);
}
};

const update = async ({ itemInstance }) => {
const { etag } = itemInstance;
const item = applyTransform(itemInstance, [
sanitizeManagers,
sanitizeTimezones,
sanitize(fieldsToSend),
camelToSnake(),
]);
try {
const response = await service.updateContact(etag, item);
return applyTransform(response.data, [
snakeToCamel(),
]);
} catch (err) {
throw applyTransform(err, [
notify,
]);
}
};

const deleteContact = async ({ id }) => {
try {
const response = await service.deleteContact(id);
return applyTransform(response.data, []);
} catch (err) {
throw applyTransform(err, [
notify,
]);
}
};

export default {
getList,
get,
add,
update,
delete: deleteContact,
};
export default contacts;
14 changes: 8 additions & 6 deletions src/modules/contacts/components/contact-popup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,15 @@ async function loadItem(id = props.id) {
draft.value = await ContactsAPI.get({ itemId: id });
}
watch(() => props.shown, () => {
if (props.id) loadItem(props.id);
else {
draft.value = generateNewDraft();
setDefaultManager();
watch(() => props.shown, (value) => {
if(value) {
if (props.id) loadItem(props.id);
else {
draft.value = generateNewDraft();
setDefaultManager();
}
}
}, { immediate: true });
});
</script>

<style lang="scss" scoped>
Expand Down
Loading

0 comments on commit c868534

Please sign in to comment.