-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/teams hooks [WTEL-4246] #642
Merged
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
30a79fd
feature: new tab in teams in progress [WTEL-4246]
lizacoma 34dbe3e
feature: added tab hook in teams [WTEL-4246]
lizacoma b51dead
feature: fixes after review [WTEL-4246]
lizacoma f9206e0
feature: fixes after review [WTEL-4246]
lizacoma b10d1e8
feature: fixes after review [WTEL-4246]
lizacoma 9a5a1db
Delete webitel-ui-sdk/src/scripts/caseConverters.js
liza-pohranichna 59279be
feature: fixes after review [WTEL-4246]
lizacoma 5f9695b
Merge branch 'feature/teams-hooks' of https://github.com/webitel/clie…
lizacoma ea6dd12
feature: fixes after review [WTEL-4246]
lizacoma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
169 changes: 169 additions & 0 deletions
169
src/modules/contact-center/modules/teams/modules/hooks/api/teamHooks.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
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, | ||
); | ||
console.log('getTeamHooksList'); | ||
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 { | ||
console.log('addTeamHook item', item); | ||
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; |
105 changes: 105 additions & 0 deletions
105
...modules/contact-center/modules/teams/modules/hooks/components/opened-team-hooks-popup.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<template> | ||
<wt-popup | ||
min-width="480" | ||
overflow | ||
@close="close" | ||
> | ||
<template #title> | ||
{{ $tc('objects.ccenter.queues.hooks.hooks', 1) }} | ||
</template> | ||
<template #main> | ||
<form> | ||
<wt-select | ||
v-model="event" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. зроби будь ласка через велью) |
||
:clearable="false" | ||
:label="$t('objects.ccenter.queues.hooks.event')" | ||
:options="eventOptions" | ||
:v="v$.itemInstance.event" | ||
required | ||
track-by="value" | ||
/> | ||
<wt-select | ||
:clearable="false" | ||
:label="$tc('objects.routing.flow.flow', 1)" | ||
:search-method="loadFlowOptions" | ||
:v="v$.itemInstance.schema" | ||
:value="itemInstance.schema" | ||
required | ||
@input="setItemProp({ prop: 'schema', value: $event })" | ||
/> | ||
</form> | ||
</template> | ||
<template #actions> | ||
<wt-button | ||
:disabled="disabledSave" | ||
@click="save" | ||
> | ||
{{ $t('objects.save') }} | ||
</wt-button> | ||
<wt-button | ||
color="secondary" | ||
@click="close" | ||
> | ||
{{ $t('objects.close') }} | ||
</wt-button> | ||
</template> | ||
</wt-popup> | ||
</template> | ||
|
||
<script> | ||
import { EngineRoutingSchemaType } from 'webitel-sdk'; | ||
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'; | ||
|
||
export default { | ||
name: 'OpenedQueueHooksPopup', | ||
mixins: [nestedObjectMixin], | ||
|
||
setup: () => ({ | ||
v$: useVuelidate(), | ||
}), | ||
data: () => ({ | ||
namespace: 'ccenter/teams/hooks', | ||
}), | ||
validations: { | ||
itemInstance: { | ||
event: { required }, | ||
schema: { required }, | ||
}, | ||
}, | ||
|
||
computed: { | ||
eventOptions() { | ||
return Object.values(HookEvent).map((event) => ({ | ||
name: event, | ||
value: event, | ||
})); | ||
}, | ||
event: { | ||
get() { | ||
const { event } = this.itemInstance; | ||
return event ? { | ||
name: event, | ||
value: event, | ||
} : {}; | ||
}, | ||
set(value) { | ||
this.setItemProp({ prop: 'event', value: value.value }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Тут можна деструктурізацію зробити) |
||
}, | ||
}, | ||
}, | ||
|
||
methods: { | ||
loadFlowOptions(params) { | ||
return FlowsAPI.getLookup({ ...params, type: [EngineRoutingSchemaType.Service] }); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
|
||
</style> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А цей попап чимось відрізняється від того що в чергах?
Може винести один загальний компонент, ніж дублювати?