diff --git a/src/app/locale/en/en.js b/src/app/locale/en/en.js index 42d2c27f2..6df642a6c 100644 --- a/src/app/locale/en/en.js +++ b/src/app/locale/en/en.js @@ -703,6 +703,11 @@ export default { longestIdleAgent: 'Agent with longest idle time', skillCapacity: 'By skill level', }, + hooks: { + eventTypes: { + agentStatus: 'Agent status changed', + } + }, }, members: { diff --git a/src/app/locale/ru/ru.js b/src/app/locale/ru/ru.js index 6695dcb35..a018bdeb0 100644 --- a/src/app/locale/ru/ru.js +++ b/src/app/locale/ru/ru.js @@ -701,6 +701,11 @@ export default { longestIdleAgent: 'Агент с наибольшим временем простоя', skillCapacity: 'По уровню навыка', }, + hooks: { + eventTypes: { + agentStatus: 'Изменение статуса оператора', + } + }, }, members: { diff --git a/src/app/locale/ua/ua.js b/src/app/locale/ua/ua.js index a34801a87..13f39255e 100644 --- a/src/app/locale/ua/ua.js +++ b/src/app/locale/ua/ua.js @@ -703,6 +703,11 @@ export default { longestIdleAgent: 'Оператор з найбільшим часом простою', skillCapacity: 'По рівню навички', }, + hooks: { + eventTypes: { + agentStatus: 'Зміна статуту оператора', + } + }, }, members: { diff --git a/src/modules/contact-center/modules/queues/modules/hooks/components/opened-queue-hooks-popup.vue b/src/modules/contact-center/modules/queues/modules/hooks/components/opened-queue-hooks-popup.vue index 6f263e9cf..1ead94daf 100644 --- a/src/modules/contact-center/modules/queues/modules/hooks/components/opened-queue-hooks-popup.vue +++ b/src/modules/contact-center/modules/queues/modules/hooks/components/opened-queue-hooks-popup.vue @@ -52,7 +52,7 @@ import { useVuelidate } from '@vuelidate/core'; import { required } from '@vuelidate/validators'; import nestedObjectMixin from '../../../../../../../app/mixins/objectPagesMixins/openedObjectMixin/nestedObjectMixin'; import FlowsAPI from '../../../../../../routing/modules/flow/api/flow'; -import HookEvent from '../enum/HookEvent.enum'; +import HookEvent from '../enum/HookQueueEvent.enum'; export default { name: 'OpenedQueueHooksPopup', diff --git a/src/modules/contact-center/modules/queues/modules/hooks/components/opened-queue-hooks.vue b/src/modules/contact-center/modules/queues/modules/hooks/components/opened-queue-hooks.vue index 2620162b7..d419d6690 100644 --- a/src/modules/contact-center/modules/queues/modules/hooks/components/opened-queue-hooks.vue +++ b/src/modules/contact-center/modules/queues/modules/hooks/components/opened-queue-hooks.vue @@ -93,8 +93,6 @@ export default { data: () => ({ subNamespace: 'hooks', isHookPopup: false, - - isDeleteConfirmation: false, }), methods: { diff --git a/src/modules/contact-center/modules/queues/modules/hooks/enum/HookEvent.enum.js b/src/modules/contact-center/modules/queues/modules/hooks/enum/HookQueueEvent.enum.js similarity index 100% rename from src/modules/contact-center/modules/queues/modules/hooks/enum/HookEvent.enum.js rename to src/modules/contact-center/modules/queues/modules/hooks/enum/HookQueueEvent.enum.js diff --git a/src/modules/contact-center/modules/queues/modules/hooks/store/_internals/headers.js b/src/modules/contact-center/modules/queues/modules/hooks/store/_internals/headers.js index 72ce3f8aa..41988077b 100644 --- a/src/modules/contact-center/modules/queues/modules/hooks/store/_internals/headers.js +++ b/src/modules/contact-center/modules/queues/modules/hooks/store/_internals/headers.js @@ -17,7 +17,6 @@ export default [ value: 'state', locale: 'reusable.state', field: 'enabled', - width: '100px', sort: SortSymbols.NONE, }, ]; diff --git a/src/modules/contact-center/modules/teams/components/opened-team.vue b/src/modules/contact-center/modules/teams/components/opened-team.vue index b6d438017..961f7b596 100644 --- a/src/modules/contact-center/modules/teams/components/opened-team.vue +++ b/src/modules/contact-center/modules/teams/components/opened-team.vue @@ -42,6 +42,7 @@ import Agents from '../modules/agents/components/opened-team-agents.vue'; import Supervisors from '../modules/supervisors/components/opened-team-supervisors.vue'; import General from './opened-team-general.vue'; import Parameters from './opened-team-parameters.vue'; +import Hooks from '../modules/hooks/components/opened-team-hooks.vue'; export default { name: 'OpenedTeam', @@ -50,6 +51,7 @@ export default { Supervisors, Agents, Parameters, + Hooks, }, mixins: [openedObjectMixin], @@ -87,7 +89,10 @@ export default { }, { text: this.$tc('objects.ccenter.agents.agents', 2), value: 'agents', - }, + }, { + text: this.$tc('objects.ccenter.queues.hooks.hooks', 2), + value: 'hooks', + } ]; if (this.id) tabs.push(this.permissionsTab); diff --git a/src/modules/contact-center/modules/teams/modules/hooks/api/teamHooks.js b/src/modules/contact-center/modules/teams/modules/hooks/api/teamHooks.js new file mode 100644 index 000000000..79eba7875 --- /dev/null +++ b/src/modules/contact-center/modules/teams/modules/hooks/api/teamHooks.js @@ -0,0 +1,167 @@ +import { + getDefaultGetListResponse, + getDefaultGetParams, +} from '@webitel/ui-sdk/src/api/defaults'; +import applyTransform, { + camelToSnake, + merge, + mergeEach, + notify, + sanitize, + snakeToCamel, + starToSearch, +} from '@webitel/ui-sdk/src/api/transformers'; +import { TeamHookServiceApiFactory } from 'webitel-sdk'; +import instance from '../../../../../../../app/api/instance'; +import configuration from '../../../../../../../app/api/openAPIConfig'; + +const teamHookService = new TeamHookServiceApiFactory(configuration, '', instance); + +const fieldsToSend = ['event', 'properties', 'schema', 'enabled']; + +const preRequestHandler = (parentId) => (item) => ({ + ...item, + teamId: parentId, +}); + +const getTeamHooksList = async (params) => { + const defaultObject = { + enabled: false, + }; + + const { + page, + size, + search, + sort, + fields, + id, + parentId, + } = applyTransform(params, [ + merge(getDefaultGetParams()), + starToSearch('search'), + ]); + + try { + const response = await teamHookService.searchTeamHook( + parentId, + page, + size, + search, + sort, + fields, + id, + ); + const { items, next } = applyTransform(response.data, [ + snakeToCamel(), + merge(getDefaultGetListResponse()), + ]); + return { + items: applyTransform(items, [ + mergeEach(defaultObject), + ]), + next, + }; + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const getTeamHook = async ({ parentId, itemId: id }) => { + const defaultObject = { + event: '', + properties: [], + schema: {}, + enabled: false, + }; + + try { + const response = await teamHookService.readTeamHook(parentId, id); + return applyTransform(response.data, [ + snakeToCamel(), + merge(defaultObject), + ]); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const addTeamHook = async ({ parentId, itemInstance }) => { + const item = applyTransform(itemInstance, [ + preRequestHandler(parentId), + sanitize(fieldsToSend), + camelToSnake(), + ]); + try { + const response = await teamHookService.createTeamHook(parentId, item); + return applyTransform(response.data, [ + snakeToCamel(), + ]); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const patchTeamHook = async ({ changes, id, parentId }) => { + const body = applyTransform(changes, [ + sanitize(fieldsToSend), + camelToSnake(), + ]); + + try { + const response = await teamHookService.patchTeamHook(parentId, id, body); + return applyTransform(response.data, [ + snakeToCamel(), + ]); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const updateTeamHook = async ({ itemInstance, itemId: id, parentId }) => { + const item = applyTransform(itemInstance, [ + preRequestHandler(parentId), + sanitize(fieldsToSend), + camelToSnake(), + ]); + try { + const response = await teamHookService.updateTeamHook(parentId, id, item); + return applyTransform(response.data, [ + snakeToCamel(), + ]); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const deleteTeamHook = async ({ parentId, id }) => { + try { + const response = await teamHookService.deleteTeamHook(parentId, id); + return applyTransform(response.data, []); + } catch (err) { + throw applyTransform(err, [ + notify, + ]); + } +}; + +const TeamHooksAPI = { + getList: getTeamHooksList, + get: getTeamHook, + add: addTeamHook, + patch: patchTeamHook, + update: updateTeamHook, + delete: deleteTeamHook, +}; + +export default TeamHooksAPI; diff --git a/src/modules/contact-center/modules/teams/modules/hooks/components/opened-team-hooks-popup.vue b/src/modules/contact-center/modules/teams/modules/hooks/components/opened-team-hooks-popup.vue new file mode 100644 index 000000000..5957fbb06 --- /dev/null +++ b/src/modules/contact-center/modules/teams/modules/hooks/components/opened-team-hooks-popup.vue @@ -0,0 +1,103 @@ + + + + + diff --git a/src/modules/contact-center/modules/teams/modules/hooks/components/opened-team-hooks.vue b/src/modules/contact-center/modules/teams/modules/hooks/components/opened-team-hooks.vue new file mode 100644 index 000000000..f7dd739b2 --- /dev/null +++ b/src/modules/contact-center/modules/teams/modules/hooks/components/opened-team-hooks.vue @@ -0,0 +1,110 @@ + + + + + diff --git a/src/modules/contact-center/modules/teams/modules/hooks/enum/HookTeamEvent.enum.js b/src/modules/contact-center/modules/teams/modules/hooks/enum/HookTeamEvent.enum.js new file mode 100644 index 000000000..3eb9a7101 --- /dev/null +++ b/src/modules/contact-center/modules/teams/modules/hooks/enum/HookTeamEvent.enum.js @@ -0,0 +1,3 @@ +export default Object.freeze({ + AGENT_STATUS: 'agent_status', +}); diff --git a/src/modules/contact-center/modules/teams/modules/hooks/store/_internals/headers.js b/src/modules/contact-center/modules/teams/modules/hooks/store/_internals/headers.js new file mode 100644 index 000000000..41988077b --- /dev/null +++ b/src/modules/contact-center/modules/teams/modules/hooks/store/_internals/headers.js @@ -0,0 +1,22 @@ +import { SortSymbols } from '@webitel/ui-sdk/src/scripts/sortQueryAdapters'; + +export default [ + { + value: 'event', + locale: 'objects.ccenter.queues.hooks.event', + field: 'event', + sort: SortSymbols.NONE, + }, + { + value: 'schema', + locale: ['objects.routing.flow.flow', 1], + field: 'schema', + sort: SortSymbols.NONE, + }, + { + value: 'state', + locale: 'reusable.state', + field: 'enabled', + sort: SortSymbols.NONE, + }, +]; diff --git a/src/modules/contact-center/modules/teams/modules/hooks/store/team-hooks.js b/src/modules/contact-center/modules/teams/modules/hooks/store/team-hooks.js new file mode 100644 index 000000000..d0f455a59 --- /dev/null +++ b/src/modules/contact-center/modules/teams/modules/hooks/store/team-hooks.js @@ -0,0 +1,20 @@ +import NestedObjectStoreModule + from '../../../../../../../app/store/BaseStoreModules/StoreModules/NestedObjectStoreModule'; +import TeamHooksAPI from '../api/teamHooks'; +import headers from './_internals/headers'; + +const resettableItemState = { + itemInstance: { + event: '', + properties: [], + schema: {}, + enabled: true, + }, +}; + +const teamHooks = new NestedObjectStoreModule({ resettableItemState, headers }) + .attachAPIModule(TeamHooksAPI) + .generateAPIActions() + .getModule(); + +export default teamHooks; diff --git a/src/modules/contact-center/modules/teams/modules/supervisors/api/teamSupervisors.js b/src/modules/contact-center/modules/teams/modules/supervisors/api/teamSupervisors.js index 122df7312..d3b5b662e 100644 --- a/src/modules/contact-center/modules/teams/modules/supervisors/api/teamSupervisors.js +++ b/src/modules/contact-center/modules/teams/modules/supervisors/api/teamSupervisors.js @@ -1,4 +1,5 @@ -import { AgentServiceApiFactory } from 'webitel-sdk';import { +import { AgentServiceApiFactory } from 'webitel-sdk'; +import { getDefaultGetListResponse, getDefaultGetParams, } from '@webitel/ui-sdk/src/api/defaults'; diff --git a/src/modules/contact-center/modules/teams/store/teams.js b/src/modules/contact-center/modules/teams/store/teams.js index 4135da601..01a9c4916 100644 --- a/src/modules/contact-center/modules/teams/store/teams.js +++ b/src/modules/contact-center/modules/teams/store/teams.js @@ -5,6 +5,7 @@ import PermissionsStoreModule import TeamsAPI from '../api/teams'; import agents from '../modules/agents/store/team-agents'; import supervisors from '../modules/supervisors/store/team-supervisors'; +import hooks from '../modules/hooks/store/team-hooks'; import headers from './_internals/headers'; const resettableState = { @@ -27,6 +28,7 @@ const actions = { context.commit('RESET_ITEM_STATE'); context.dispatch('ccenter/teams/supervisors/RESET_STATE', {}, { root: true }); context.dispatch('ccenter/teams/agents/RESET_STATE', {}, { root: true }); + context.dispatch('ccenter/teams/hooks/RESET_STATE', {}, { root: true }); }, }; @@ -38,7 +40,7 @@ const permissions = new PermissionsStoreModule() const teams = new ObjectStoreModule({ resettableState, headers }) .attachAPIModule(TeamsAPI) .generateAPIActions() -.setChildModules({ supervisors, agents, permissions }) +.setChildModules({ supervisors, agents, permissions, hooks }) .getModule({ actions }); export default teams;