@@ -14,7 +14,6 @@ import compact from 'lodash/compact';
14
14
import CustomPopover from '@/features/entities/neuron-simulation/experiment/elements/popover' ;
15
15
import AddMembersModal from '@/components/VirtualLab/create-entity-flows/project/add-members' ;
16
16
import useUserPermissions from '@/hooks/useUserPermission' ;
17
- import useNotification from '@/hooks/notifications' ;
18
17
import { MemberAvatarCasual } from '@/components/VirtualLab/create-entity-flows/common/member-avatar' ;
19
18
import {
20
19
cancelProjectInvite ,
@@ -25,6 +24,8 @@ import { classNames } from '@/util/utils';
25
24
import { extractInitials } from '@/util/slugify' ;
26
25
import { tryCatch } from '@/api/utils' ;
27
26
import { projectStatsAtomFamily } from '@/state/virtual-lab/projects' ;
27
+ import { useAppNotification } from '@/components/notification' ;
28
+
28
29
import type { Member , Role } from '@/api/virtual-lab-svc/queries/types' ;
29
30
30
31
type Props = {
@@ -52,7 +53,8 @@ function RoleModifier({ user, ownerId, virtualLabId, projectId, onRemove }: Role
52
53
const [ loading , setLoading ] = useState ( false ) ;
53
54
const [ removeLoading , seRemoveLoading ] = useState ( false ) ;
54
55
const refreshProjectStats = useSetAtom ( projectStatsAtomFamily ( { virtualLabId, projectId } ) ) ;
55
- const { error : notifyError , success : notifySuccess } = useNotification ( ) ;
56
+
57
+ const { error : notifyError , success : notifySuccess } = useAppNotification ( ) ;
56
58
57
59
const onChange = async ( _role : Role ) => {
58
60
setLoading ( true ) ;
@@ -68,24 +70,21 @@ function RoleModifier({ user, ownerId, virtualLabId, projectId, onRemove }: Role
68
70
}
69
71
) ;
70
72
if ( error ) {
71
- notifyError (
72
- 'Failed to update user role. Please try again or contact support if the issue persists.' ,
73
- undefined ,
74
- 'topRight' ,
75
- true ,
76
- 'user-role-update'
77
- ) ;
73
+ notifyError ( {
74
+ message :
75
+ 'Failed to update user role. Please try again or contact support if the issue persists.' ,
76
+ placement : 'topRight' ,
77
+ key : 'user-role-update' ,
78
+ } ) ;
78
79
return ;
79
80
}
80
81
if ( result . data ) {
81
82
updateRole ( _role ) ;
82
- notifySuccess (
83
- `User "${ user . name } " role updated to ${ get ( find ( roleOptions , { value : _role } ) , 'label' ) } successfully` ,
84
- undefined ,
85
- 'topRight' ,
86
- true ,
87
- 'user-role-update'
88
- ) ;
83
+ notifySuccess ( {
84
+ message : `User "${ user . name } " role updated to ${ get ( find ( roleOptions , { value : _role } ) , 'label' ) } successfully` ,
85
+ placement : 'topRight' ,
86
+ key : 'user-role-update' ,
87
+ } ) ;
89
88
}
90
89
} ;
91
90
@@ -103,23 +102,20 @@ function RoleModifier({ user, ownerId, virtualLabId, projectId, onRemove }: Role
103
102
}
104
103
) ;
105
104
if ( error ) {
106
- notifyError (
107
- 'Failed to cancel invite. Please try again or contact support if the issue persists.' ,
108
- undefined ,
109
- 'topRight' ,
110
- true ,
111
- 'user-cancel-invite'
112
- ) ;
105
+ notifyError ( {
106
+ message :
107
+ 'Failed to cancel invite. Please try again or contact support if the issue persists.' ,
108
+ placement : 'topRight' ,
109
+ key : 'user-cancel-invite' ,
110
+ } ) ;
113
111
return ;
114
112
}
115
113
if ( result . message ) {
116
- notifySuccess (
117
- `Invite for ${ user . email } cancelled successfully` ,
118
- undefined ,
119
- 'topRight' ,
120
- true ,
121
- 'user-cancel-invite'
122
- ) ;
114
+ notifySuccess ( {
115
+ message : `Invite for ${ user . email } cancelled successfully` ,
116
+ placement : 'topRight' ,
117
+ key : 'user-cancel-invite' ,
118
+ } ) ;
123
119
refreshProjectStats ( ) ;
124
120
onRemove ( user . email ) ;
125
121
}
@@ -139,32 +135,27 @@ function RoleModifier({ user, ownerId, virtualLabId, projectId, onRemove }: Role
139
135
) ;
140
136
if ( error ) {
141
137
if ( get ( error , 'cause.error_code' ) === 'FORBIDDEN_OPERATION' ) {
142
- notifyError (
143
- 'You are not authorized to remove this user from the virtual lab.' ,
144
- undefined ,
145
- 'topRight' ,
146
- true ,
147
- 'user-remove-from-vlab'
148
- ) ;
138
+ notifyError ( {
139
+ message : 'You are not authorized to remove this user from the virtual lab.' ,
140
+ placement : 'topRight' ,
141
+ key : 'user-remove-from-vlab' ,
142
+ } ) ;
149
143
return ;
150
144
}
151
- notifyError (
152
- 'Failed to remove user from virtual lab. Please try again or contact support if the issue persists.' ,
153
- undefined ,
154
- 'topRight' ,
155
- true ,
156
- 'user-remove-from-vlab'
157
- ) ;
145
+ notifyError ( {
146
+ message :
147
+ 'Failed to remove user from virtual lab. Please try again or contact support if the issue persists.' ,
148
+ placement : 'topRight' ,
149
+ key : 'user-remove-from-vlab' ,
150
+ } ) ;
158
151
return ;
159
152
}
160
153
if ( result . message ) {
161
- notifySuccess (
162
- `User "${ user . name } " removed from virtual lab successfully` ,
163
- undefined ,
164
- 'topRight' ,
165
- true ,
166
- 'user-remove-from-vlab'
167
- ) ;
154
+ notifySuccess ( {
155
+ message : `User "${ user . name } " removed from virtual lab successfully` ,
156
+ placement : 'topRight' ,
157
+ key : 'user-remove-from-vlab' ,
158
+ } ) ;
168
159
refreshProjectStats ( ) ;
169
160
onRemove ( user . id ) ;
170
161
}
0 commit comments