diff --git a/users-manage/src/services/serviceOfUsers/Users.js b/users-manage/src/services/serviceOfUsers/Users.js index 4d8fc2d..9e1effb 100644 --- a/users-manage/src/services/serviceOfUsers/Users.js +++ b/users-manage/src/services/serviceOfUsers/Users.js @@ -105,7 +105,8 @@ class UsersOfServices { /** * - * @param {Object} params + * @param {String} key - field name + * @param {Any} value - updated data for selected user, send to server * @returns {Promise} */ async setUserFields(key, value) { @@ -117,23 +118,6 @@ class UsersOfServices { } } - /** - * - * @param {Number} selectedUserId - * @param {Number} serviceId - * @returns {Promise} - */ - async deleteUserFromService(selectedUserId, serviceId) { - // const deletedUser = await this.adapter.addUser(selectedUserId, serviceId) // Запрос на обновление пользователя с новым service_id??? - const users = this.store.getters['users/users'] - const updatedUsers = deleteServiceIdFromUser(selectedUserId, serviceId, users) - const usersWithService = usersWithThisService(serviceId, updatedUsers) - const usersWithoutService = usersWithoutThisService(serviceId, updatedUsers) - this.store.dispatch('users/updateUsers', updatedUsers) - this.store.dispatch('users/updateUsersWithService', usersWithService) - this.store.dispatch('users/updateUsersWithoutService', usersWithoutService) - } - /** * * @param {Number} serviceId - updated data for selected user, send to server @@ -172,6 +156,23 @@ class UsersOfServices { } } + /** + * + * @param {Number} selectedUserId + * @param {Number} serviceId + * @returns {Promise} + */ + async deleteUserFromService(selectedUserId, serviceId) { + // const deletedUser = await this.adapter.addUser(selectedUserId, serviceId) // Запрос на обновление пользователя с новым service_id??? + const users = this.store.getters['users/users'] + const updatedUsers = deleteServiceIdFromUser(selectedUserId, serviceId, users) + const usersWithService = usersWithThisService(serviceId, updatedUsers) + const usersWithoutService = usersWithoutThisService(serviceId, updatedUsers) + this.store.dispatch('users/updateUsers', updatedUsers) + this.store.dispatch('users/updateUsersWithService', usersWithService) + this.store.dispatch('users/updateUsersWithoutService', usersWithoutService) + } + async resetStore() { this.store.dispatch('users/resetStore') }