updated Service of users

This commit is contained in:
SergeyVS 2024-04-03 12:11:27 +03:00
parent 327f716fe9
commit e2fe94c1de

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>}
*/
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
@ -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() {
this.store.dispatch('users/resetStore')
}