refactoring

This commit is contained in:
Elyor Djalilov 2024-07-04 15:40:53 +05:00
parent 2c2d4001e7
commit 3bac675e44
2 changed files with 6 additions and 7 deletions

View File

@ -33,8 +33,8 @@ const DisableUserDialog = ({
const onClickDisableUser = async () => { const onClickDisableUser = async () => {
try { try {
await updateUserStatus(EmployeeStatus.Disabled, userIds); await updateUserStatus(EmployeeStatus.Disabled, userIds);
toastr.success(t("PeopleTranslations:SuccessChangeUserStatus"));
await fetchData(); await fetchData();
toastr.success(t("PeopleTranslations:SuccessChangeUserStatus"));
} catch (error) { } catch (error) {
toastr.error(error); toastr.error(error);
} finally { } finally {

View File

@ -596,7 +596,7 @@ class SelectionStore {
updateDataFromSocket = (data) => { updateDataFromSocket = (data) => {
const newArr = [...this.dataFromSocket]; const newArr = [...this.dataFromSocket];
const indexTest = newArr.findIndex(({ id }) => id === data.id); const index = newArr.findIndex(({ id }) => id === data.id);
const currentSesstionIndex = this.sessionsData.findIndex( const currentSesstionIndex = this.sessionsData.findIndex(
({ id }) => id === data.id, ({ id }) => id === data.id,
); );
@ -609,13 +609,13 @@ class SelectionStore {
}; };
} }
if (indexTest === -1) { if (index === -1) {
this.dataFromSocket = [...this.dataFromSocket, data]; this.dataFromSocket = [...this.dataFromSocket, data];
return; return;
} }
newArr[indexTest] = { newArr[index] = {
...newArr[indexTest], ...newArr[index],
sessions, sessions,
status, status,
}; };
@ -628,8 +628,7 @@ class SelectionStore {
const isCurrentSesstion = session.id === data?.id; const isCurrentSesstion = session.id === data?.id;
const connectionsIsEmpty = session.connections.length === 0; const connectionsIsEmpty = session.connections.length === 0;
const lastIndex = -1; const sessionData = data.sessions?.at(-1);
const sessionData = data.sessions?.at(lastIndex);
if (isCurrentSesstion) return [{ ...first, ...sessionData }, ...other]; if (isCurrentSesstion) return [{ ...first, ...sessionData }, ...other];
if (connectionsIsEmpty) { if (connectionsIsEmpty) {