@@ -136,9 +136,13 @@ const AddUser = ({
136136
137137 const { mutate : updateMutate , isLoading : updateUserLoading } = useMutation (
138138 ( input : { input : AssignOrganizationRoleInput } ) =>
139- GraphQL ( updateUser , {
140- [ params . entityType ] : params . entitySlug ,
141- } , input ) ,
139+ GraphQL (
140+ updateUser ,
141+ {
142+ [ params . entityType ] : params . entitySlug ,
143+ } ,
144+ input
145+ ) ,
142146 {
143147 onSuccess : ( res : any ) => {
144148 toast ( 'User updated successfully' ) ;
@@ -172,6 +176,12 @@ const AddUser = ({
172176 const filteredOptions = Users . data ?. searchUsers ;
173177 const handleInputChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
174178 const value = e . target . value ;
179+ if ( value === '' ) {
180+ setFormData ( {
181+ userId : '' ,
182+ roleId : formData . roleId ,
183+ } ) ;
184+ }
175185 setSearchValue ( value ) ;
176186 setIsDropdownOpen ( true ) ; // Keep dropdown open while typing
177187 Users . refetch ( ) ; // Refetch when search term changes
@@ -193,13 +203,13 @@ const AddUser = ({
193203 >
194204 < div className = "m-auto mb-6 flex flex-col gap-6" >
195205 < div className = "relative w-full" >
196- < Label > Select User</ Label >
206+ < Label > Select User * </ Label >
197207 < input
198208 type = "text"
199209 id = "combobox"
200210 disabled = { isEdit }
201211 value = { searchValue }
202- autoComplete = ' off'
212+ autoComplete = " off"
203213 onChange = { handleInputChange }
204214 className = "border border-gray-100 placeholder:text-sm mt-1 block w-full px-3 py-1"
205215 placeholder = { 'Select user' }
@@ -229,7 +239,7 @@ const AddUser = ({
229239 label : toTitleCase ( role . name ) ,
230240 value : role . id ,
231241 } ) ) }
232- label = "Select a role"
242+ label = "Select a role * "
233243 helpText = { RolesList . data ?. roles
234244 . filter ( ( role : any ) => role . id === formData . roleId )
235245 . map ( ( role : any ) => role . description ) }
@@ -239,9 +249,12 @@ const AddUser = ({
239249 < Button
240250 kind = "primary"
241251 className = "m-auto"
252+ disabled = { ! formData . userId || ! formData . roleId }
242253 onClick = { ( ) => {
243254 setIsOpen ( false ) ;
244- isEdit ? updateMutate ( { input : formData } ) : mutate ( { input : formData } ) ;
255+ isEdit
256+ ? updateMutate ( { input : formData } )
257+ : mutate ( { input : formData } ) ;
245258 } }
246259 >
247260 { isEdit ? 'Update' : 'Add' }
0 commit comments