@@ -91,10 +91,14 @@ const InviteUsers: React.FC<InviteUsersProps> = ({
9191 titleText = { titleText }
9292 submitText = { submitText }
9393 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 }
9597 onCancel = { onCancel }
9698 onSubmit = { ( ) => {
97- const selectedUserList = Object . keys ( selectedUsers ) ;
99+ const selectedUserList = Object . keys ( selectedUsers ) . length > 0
100+ ? Object . keys ( selectedUsers )
101+ : [ userId ] ;
98102 if ( typeof overrideInviteUser === 'function' ) {
99103 overrideInviteUser ( {
100104 users : selectedUserList ,
@@ -103,28 +107,27 @@ const InviteUsers: React.FC<InviteUsersProps> = ({
103107 } ) ;
104108 return ;
105109 }
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 ] ;
125123 }
126- onCancel ( ) ;
124+ setChannelType ( params , type ) ;
125+ // do not have custom params
126+ createChannel ( params ) . then ( ( channel ) => {
127+ onCreateChannel ( channel ) ;
128+ } ) ;
127129 }
130+ onCancel ( ) ;
128131 } }
129132 >
130133 < div >
0 commit comments