@@ -12,6 +12,9 @@ import { HelpText } from "components/HelpText";
1212import copyToClipboard from "copy-to-clipboard" ;
1313import { trans } from "i18n" ;
1414import { messageInstance } from "lowcoder-design/src/components/GlobalInstances" ;
15+ import Divider from "antd/es/divider" ;
16+ import Flex from "antd/es/flex" ;
17+ import Select from "antd/es/select" ;
1518
1619const InviteButton = styled ( TacoButton ) `
1720 width: 76px;
@@ -23,14 +26,36 @@ const StyledLoading = styled(WhiteLoading)`
2326 height: 170px;
2427` ;
2528
26- function InviteContent ( props : { inviteInfo : InviteInfo } ) {
27- const { inviteInfo } = props ;
29+ function InviteContent ( props : { inviteInfo : InviteInfo , onClose ?: ( ) => void } ) {
30+ const { inviteInfo, onClose } = props ;
2831 const inviteLink = genInviteLink ( inviteInfo ?. inviteCode ) ;
2932 const inviteText = trans ( "memberSettings.inviteText" , {
3033 userName : inviteInfo . createUserName ,
3134 organization : inviteInfo . invitedOrganizationName ,
3235 inviteLink,
3336 } ) ;
37+ const [ emails , setEmails ] = useState < string [ ] > ( [ ] ) ;
38+
39+ const isValidEmail = ( email : string ) => / ^ [ ^ \s @ ] + @ [ ^ \s @ ] + \. [ ^ \s @ ] + $ / . test ( email ) ;
40+
41+ const sendInvitations = async ( ) => {
42+ const filteredEmails = emails . filter ( isValidEmail ) ;
43+ if ( ! filteredEmails . length ) {
44+ return messageInstance . error ( trans ( "memberSettings.noValidEmails" ) ) ;
45+ }
46+ try {
47+ const resp = await InviteApi . sendInvitations ( { emails : filteredEmails , orgId : inviteInfo . invitedOrganizationId } )
48+ if ( validateResponse ( resp ) && resp . data . success ) {
49+ messageInstance . success ( trans ( 'membersSettings.inviteByEmailSuccess' ) ) ;
50+ onClose ?.( ) ;
51+ return ;
52+ }
53+ throw new Error ( trans ( 'membersSettings.inviteByEmailError' ) ) ;
54+ } catch ( e : any ) {
55+ messageInstance . error ( e . message ) ;
56+ }
57+ }
58+
3459 return (
3560 < >
3661 < HelpText style = { { marginBottom : 16 } } > { trans ( "memberSettings.inviteUserHelp" ) } </ HelpText >
@@ -48,6 +73,34 @@ function InviteContent(props: { inviteInfo: InviteInfo }) {
4873 { trans ( "memberSettings.inviteCopyLink" ) }
4974 </ InviteButton >
5075 </ div >
76+ < Divider style = { { marginTop : '60px' } } />
77+ < HelpText style = { { marginBottom : 16 } } > { trans ( "memberSettings.inviteByEmailHelp" ) } </ HelpText >
78+ < CommonTextLabel > { trans ( "memberSettings.inviteByEmailLabel" ) } </ CommonTextLabel >
79+ < Select
80+ mode = "tags"
81+ allowClear
82+ open = { false }
83+ style = { { width : '100%' , marginTop : '8px' , marginBottom : '8px' } }
84+ placeholder = "Enter emails"
85+ defaultValue = { [ ] }
86+ onChange = { ( value ) => {
87+ setEmails ( value ) ;
88+ } }
89+ options = { [ ] }
90+ showSearch = { false }
91+ suffixIcon = { '' }
92+ />
93+ < Flex justify = "end" >
94+ < TacoButton
95+ buttonType = "primary"
96+ onClick = { ( ) => {
97+ sendInvitations ( ) ;
98+ } }
99+ disabled = { ! Boolean ( emails ?. length ) }
100+ >
101+ { trans ( "memberSettings.inviteByEmailButton" ) }
102+ </ TacoButton >
103+ </ Flex >
51104 </ >
52105 ) ;
53106}
@@ -101,7 +154,7 @@ function InviteDialog(props: {
101154 showCancelButton = { false }
102155 width = "440px"
103156 >
104- { ! inviteInfo ? < StyledLoading size = { 20 } /> : < InviteContent inviteInfo = { inviteInfo } /> }
157+ { ! inviteInfo ? < StyledLoading size = { 20 } /> : < InviteContent inviteInfo = { inviteInfo } onClose = { ( ) => setInviteDialogVisible ( false ) } /> }
105158 </ CustomModal >
106159 </ >
107160 ) ;
0 commit comments