move_users #5

Merged
vbuglov merged 4 commits from move_users into master 2024-04-03 09:28:15 +00:00
Showing only changes of commit e2fe94c1de - Show all commits

View File

@ -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<Object>} * @returns {Promise<Object>}
*/ */
async setUserFields(key, value) { async setUserFields(key, value) {
@ -117,23 +118,6 @@ class UsersOfServices {
} }
} }
/**
*
* @param {Number} selectedUserId
* @param {Number} serviceId
* @returns {Promise<Object>}
*/
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 * @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<Object>}
*/
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() { async resetStore() {
this.store.dispatch('users/resetStore') this.store.dispatch('users/resetStore')
} }