mirror of
https://github.com/sergeyyarkov/educt-client.git
synced 2026-10-11 10:19:22 +03:00
refactor: fixed dirty values in edit user form
This commit is contained in:
parent
6d72fdb1c3
commit
479a6291eb
@ -79,8 +79,8 @@ const UpdateUserForm: React.FC<UpdateUserFormPropsType> = ({ onClose, isOpen, me
|
||||
last_name: editingUser && editingUser.last_name,
|
||||
email: editingUser && editingUser.email,
|
||||
role: editingUser && editingUser.roles[0].slug,
|
||||
login: null,
|
||||
password: null,
|
||||
login: '',
|
||||
password: '',
|
||||
},
|
||||
});
|
||||
const isMountedRef = useIsMountedRef();
|
||||
|
||||
@ -84,8 +84,6 @@ export default class UserStore {
|
||||
try {
|
||||
const result = await this.userService.create(data);
|
||||
|
||||
console.log(`[${this.constructor.name}]: ${result.message}`, result);
|
||||
|
||||
if (this.users !== null) {
|
||||
/**
|
||||
* Fetch updated users data with new pagination data
|
||||
@ -103,11 +101,10 @@ export default class UserStore {
|
||||
try {
|
||||
const result = await this.userService.update(id, params);
|
||||
|
||||
console.log(`[${this.constructor.name}]: ${result.message}`, result);
|
||||
|
||||
runInAction(() => {
|
||||
if (this.users !== null) {
|
||||
const userIndex = this.users.findIndex(user => user.id === id);
|
||||
|
||||
if (userIndex !== -1) {
|
||||
this.users[userIndex] = result.data;
|
||||
}
|
||||
@ -130,8 +127,6 @@ export default class UserStore {
|
||||
try {
|
||||
const result = await this.userService.delete(id);
|
||||
|
||||
console.log(`[${this.constructor.name}]: ${result.message}`, result);
|
||||
|
||||
if (this.users !== null) {
|
||||
/**
|
||||
* Fetch updated users data with new pagination data
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user