@@ -91,10 +91,14 @@ const InviteUsers: React.FC<InviteUsersProps> = ({
91
91
titleText = { titleText }
92
92
submitText = { submitText }
93
93
type = { ButtonTypes . PRIMARY }
94
- disabled = { Object . keys ( selectedUsers ) . length === 0 }
94
+ // Disable the create button if no users are selected,
95
+ // but if there's no users to display, then the create button should be enabled
96
+ disabled = { users . length > 0 && Object . keys ( selectedUsers ) . length === 0 }
95
97
onCancel = { onCancel }
96
98
onSubmit = { ( ) => {
97
- const selectedUserList = Object . keys ( selectedUsers ) ;
99
+ const selectedUserList = Object . keys ( selectedUsers ) . length > 0
100
+ ? Object . keys ( selectedUsers )
101
+ : [ userId ] ;
98
102
if ( typeof overrideInviteUser === 'function' ) {
99
103
overrideInviteUser ( {
100
104
users : selectedUserList ,
@@ -103,28 +107,27 @@ const InviteUsers: React.FC<InviteUsersProps> = ({
103
107
} ) ;
104
108
return ;
105
109
}
106
- if ( selectedUserList . length > 0 ) {
107
- if ( onBeforeCreateChannel ) {
108
- const params = onBeforeCreateChannel ( selectedUserList ) ;
109
- setChannelType ( params , type ) ;
110
- createChannel ( params ) . then ( ( channel ) => {
111
- onCreateChannel ( channel ) ;
112
- } ) ;
113
- } else {
114
- const params : GroupChannelCreateParams = { } ;
115
- params . invitedUserIds = selectedUserList ;
116
- params . isDistinct = false ;
117
- if ( userId ) {
118
- params . operatorUserIds = [ userId ] ;
119
- }
120
- setChannelType ( params , type ) ;
121
- // do not have custom params
122
- createChannel ( params ) . then ( ( channel ) => {
123
- onCreateChannel ( channel ) ;
124
- } ) ;
110
+
111
+ if ( onBeforeCreateChannel ) {
112
+ const params = onBeforeCreateChannel ( selectedUserList ) ;
113
+ setChannelType ( params , type ) ;
114
+ createChannel ( params ) . then ( ( channel ) => {
115
+ onCreateChannel ( channel ) ;
116
+ } ) ;
117
+ } else {
118
+ const params : GroupChannelCreateParams = { } ;
119
+ params . invitedUserIds = selectedUserList ;
120
+ params . isDistinct = false ;
121
+ if ( userId ) {
122
+ params . operatorUserIds = [ userId ] ;
125
123
}
126
- onCancel ( ) ;
124
+ setChannelType ( params , type ) ;
125
+ // do not have custom params
126
+ createChannel ( params ) . then ( ( channel ) => {
127
+ onCreateChannel ( channel ) ;
128
+ } ) ;
127
129
}
130
+ onCancel ( ) ;
128
131
} }
129
132
>
130
133
< div >
0 commit comments