-
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
Feat/ contact-groups - api, router store [WTEL-4740] #130
Open
SviatoslavBar
wants to merge
1
commit into
feat/lookups-pr
Choose a base branch
from
feat/contact-groups-api-store
base: feat/lookups-pr
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
141 changes: 141 additions & 0 deletions
141
src/modules/lookups/modules/contact-groups/modules/cgroups/api/contact-groups.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,141 @@ | ||
import { | ||
getDefaultGetListResponse, | ||
getDefaultGetParams, | ||
} from '@webitel/ui-sdk/src/api/defaults/index.js'; | ||
import applyTransform, { | ||
camelToSnake, | ||
merge, | ||
mergeEach, | ||
log, | ||
notify, | ||
sanitize, | ||
snakeToCamel, | ||
starToSearch, | ||
generateUrl, | ||
} from '@webitel/ui-sdk/src/api/transformers/index.js'; | ||
|
||
import instance from '../../../../../../../app/api/instance'; | ||
|
||
const contactGroupsUrl = '/contacts/groups'; | ||
|
||
const getContactGroupsList = async (params) => { | ||
const fieldsToSend = ['page', 'size', 'fields', 'sort', 'id', 'q', 'name']; | ||
|
||
const defaultObject = { | ||
}; | ||
|
||
const url = applyTransform(params, [ | ||
starToSearch('search'), | ||
(params) => ({ ...params, q: params.search }), | ||
sanitize(fieldsToSend), | ||
camelToSnake(), | ||
generateUrl(contactGroupsUrl), | ||
]); | ||
|
||
try { | ||
const response = await instance.get(url); | ||
|
||
const { items, next } = applyTransform(response.data, [ | ||
snakeToCamel(), | ||
merge(getDefaultGetListResponse()), | ||
]); | ||
return { | ||
items: applyTransform(items, [mergeEach(defaultObject), log]), | ||
next, | ||
}; | ||
|
||
} catch (err) { | ||
throw applyTransform(err, [notify]); | ||
} | ||
}; | ||
|
||
const getAgent = async ({ itemId: id }) => { | ||
const url = `${contactGroupsUrl}/${id}`; | ||
const defaultObject = { | ||
}; | ||
|
||
try { | ||
const response = await instance.get(url); | ||
|
||
return applyTransform(response.data.group, [ | ||
snakeToCamel(), | ||
merge(defaultObject), | ||
]); | ||
} catch (err) { | ||
throw applyTransform(err, [notify]); | ||
} | ||
}; | ||
|
||
const fieldsToSend = [ | ||
'name', | ||
'description', | ||
]; | ||
|
||
const addAgent = async ({ itemInstance }) => { | ||
const item = applyTransform(itemInstance, [ | ||
sanitize(fieldsToSend), | ||
camelToSnake(), | ||
]); | ||
|
||
try { | ||
const response = await instance.post(contactGroupsUrl, item); | ||
return applyTransform(response.data, []); | ||
} catch (err) { | ||
throw applyTransform(err, [notify]); | ||
} | ||
}; | ||
|
||
const patchAgent = async ({ itemInstance, id }) => { | ||
const url = `${contactGroupsUrl}/${id}`; | ||
|
||
const item = applyTransform(itemInstance, [ | ||
sanitize(fieldsToSend), | ||
camelToSnake(), | ||
]); | ||
|
||
try { | ||
const response = await instance.patch(url, item); | ||
return applyTransform(response.data, []); | ||
} catch (err) { | ||
throw applyTransform(err, [notify]); | ||
} | ||
}; | ||
|
||
const updateAgent = async ({ itemInstance, itemId: id }) => { | ||
const url = `${contactGroupsUrl}/${id}`; | ||
|
||
const item = applyTransform(itemInstance, [ | ||
sanitize(fieldsToSend), | ||
camelToSnake(), | ||
]); | ||
|
||
try { | ||
const response = await instance.put(url, item); | ||
return applyTransform(response.data, []); | ||
} catch (err) { | ||
throw applyTransform(err, [notify]); | ||
} | ||
}; | ||
|
||
const deleteAgent = async ({ id }) => { | ||
const url = `${contactGroupsUrl}/${id}` | ||
|
||
try { | ||
const response = await instance.delete(url); | ||
return applyTransform(response.data, []); | ||
} catch (err) { | ||
throw applyTransform(err, [notify]); | ||
} | ||
}; | ||
|
||
const ContactGroupsAPI = { | ||
getList: getContactGroupsList, | ||
getListGroups: getContactGroupsList, | ||
get: getAgent, | ||
add: addAgent, | ||
patch: patchAgent, | ||
update: updateAgent, | ||
delete: deleteAgent, | ||
}; | ||
|
||
export default ContactGroupsAPI; |
15 changes: 15 additions & 0 deletions
15
...ookups/modules/contact-groups/modules/cgroups/assets/adm-agent-history-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions
15
...okups/modules/contact-groups/modules/cgroups/assets/adm-agent-history-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
.../modules/contact-groups/modules/cgroups/router/_internals/ContactGroupsRouteNames.enum.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,6 @@ | ||
import RouteNames from "../../../../../../../../app/router/_internals/RouteNames.enum.js"; | ||
|
||
export default Object.freeze({ | ||
GENERAL: `${RouteNames.CONTACT_GROUPS}-general`, | ||
PERMISSIONS: `${RouteNames.CONTACT_GROUPS}-permissions`, | ||
}); |
39 changes: 39 additions & 0 deletions
39
src/modules/lookups/modules/contact-groups/modules/cgroups/router/contact-groups.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,39 @@ | ||
import RouteNames from "../../../../../../../app/router/_internals/RouteNames.enum.js"; | ||
import ContactGroupsRouteNames from "./_internals/ContactGroupsRouteNames.enum.js"; | ||
|
||
const ContactGroups = () => import( '../components/the-contact-groups.vue'); | ||
const Agent = () => import('../components/opened-contact-groups.vue'); | ||
const General = () => import("../components/opened-contact-groups-general.vue"); | ||
const Permissions = () => import("../../../../../../_shared/permissions-tab/components/permissions-tab.vue"); | ||
|
||
import {checkRouteAccess} from "../../../../../../../app/router/_internals/guards.js"; | ||
|
||
|
||
const ContactGroupsRoutes = [ | ||
{ | ||
path: '/lookups/contact-groups', | ||
name: RouteNames.CONTACT_GROUPS, | ||
component: ContactGroups, | ||
beforeEnter: checkRouteAccess, | ||
}, | ||
{ | ||
path: '/lookups/contact-groups/:id', | ||
name: `${RouteNames.CONTACT_GROUPS}-card`, | ||
redirect: { name: ContactGroupsRouteNames.GENERAL }, | ||
component: Agent, | ||
beforeEnter: checkRouteAccess, | ||
children: [ | ||
{ | ||
path: 'general', | ||
name: ContactGroupsRouteNames.GENERAL, | ||
component: General, | ||
},{ | ||
path: 'permissions/:permissionId?', | ||
name: ContactGroupsRouteNames.PERMISSIONS, | ||
component: Permissions, | ||
} | ||
], | ||
}, | ||
] | ||
|
||
export default ContactGroupsRoutes; |
16 changes: 16 additions & 0 deletions
16
src/modules/lookups/modules/contact-groups/modules/cgroups/store/_internals/headers.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,16 @@ | ||
import { SortSymbols } from '@webitel/ui-sdk/src/scripts/sortQueryAdapters'; | ||
|
||
export default [ | ||
{ | ||
value: 'name', | ||
locale: 'objects.name', | ||
field: 'name', | ||
sort: SortSymbols.NONE, | ||
}, | ||
{ | ||
value: 'description', | ||
locale: 'objects.description', | ||
field: 'description', | ||
sort: SortSymbols.NONE, | ||
}, | ||
]; |
46 changes: 46 additions & 0 deletions
46
src/modules/lookups/modules/contact-groups/modules/cgroups/store/contact-groups.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,46 @@ | ||
import HistoryStoreModule from '../../../../../../../app/store/BaseStoreModules/StoreModules/HistoryStoreModule/HistoryStoreModule'; | ||
import ObjectStoreModule from '../../../../../../../app/store/BaseStoreModules/StoreModules/ObjectStoreModule'; | ||
import PermissionsStoreModule from '../../../../../../../app/store/BaseStoreModules/StoreModules/PermissionsStoreModule/PermissionsStoreModule'; | ||
import ContactGroupsAPI from '../api/contact-groups'; | ||
import headers from './_internals/headers'; | ||
|
||
const resettableState = { | ||
itemInstance: { | ||
user: {}, | ||
team: {}, | ||
supervisor: [], | ||
auditor: [], | ||
region: {}, | ||
progressiveCount: 1, | ||
chatCount: 1, | ||
taskCount: 1, | ||
isSupervisor: false, | ||
greetingMedia: {}, | ||
}, | ||
}; | ||
|
||
const actions = { | ||
RESET_ITEM_STATE: async (context) => { | ||
context.commit('RESET_ITEM_STATE'); | ||
}, | ||
}; | ||
|
||
const PERMISSIONS_API_URL = '/contacts/groups'; | ||
const permissions = new PermissionsStoreModule() | ||
.generateAPIActions(PERMISSIONS_API_URL) | ||
.getModule(); | ||
|
||
const history = new HistoryStoreModule() | ||
.generateGetListAction(ContactGroupsAPI.getAgentHistory) | ||
.getModule(); | ||
|
||
const contactGroups = new ObjectStoreModule({ resettableState, headers }) | ||
Comment on lines
+29
to
+37
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. пермішени модуль точно з адмінки то не комільфо, треба переробити з новими модулями |
||
.attachAPIModule(ContactGroupsAPI) | ||
.generateAPIActions() | ||
.setChildModules({ | ||
history, | ||
permissions, | ||
}) | ||
.getModule({ actions }); | ||
|
||
export default contactGroups; |
10 changes: 10 additions & 0 deletions
10
src/modules/lookups/modules/contact-groups/store/cgroups.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,10 @@ | ||
import contactGroups from '../modules/cgroups/store/contact-groups'; | ||
|
||
const modules = { | ||
groups: contactGroups, | ||
}; | ||
|
||
export default { | ||
namespaced: true, | ||
modules, | ||
}; |
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.
імпорти краще робити з розширенням файлу, по можливості, щоб потім не було проблем з білдами
імпорти без розширення -- це фішка commonjs модулів, що в esm модулях, більш нових, вже не канає