(event: any)
| 277 | }, []); |
| 278 | |
| 279 | const createInvite = async (event: any) => { |
| 280 | event.preventDefault(); |
| 281 | setLoading(true); |
| 282 | try { |
| 283 | const form = event.target; |
| 284 | const emails = form.email.value.split(','); |
| 285 | const role = form.role.value; |
| 286 | const existingEmails = users.map((user) => user.email); |
| 287 | const usedEmails = emails.filter((email: string) => |
| 288 | existingEmails.includes(email) |
| 289 | ); |
| 290 | |
| 291 | if (usedEmails.length > 0) { |
| 292 | return Toast.error( |
| 293 | `Provided ${ |
| 294 | usedEmails.length === 1 ? 'email is' : 'emails are' |
| 295 | } already used: ${usedEmails.join(', ')}` |
| 296 | ); |
| 297 | } |
| 298 | |
| 299 | if (!isEmailValid(emails.join(','))) { |
| 300 | return Toast.error('Please enter a valid email'); |
| 301 | } |
| 302 | |
| 303 | await api.createInvite({ |
| 304 | email: emails.join(','), |
| 305 | role, |
| 306 | communityId: currentCommunity.id, |
| 307 | }); |
| 308 | routerReload(); |
| 309 | } catch (exception) { |
| 310 | Toast.error('Something went wrong'); |
| 311 | } finally { |
| 312 | setLoading(false); |
| 313 | } |
| 314 | }; |
| 315 | |
| 316 | const onChangeMember = async (id: string, role: any, status: string) => { |
| 317 | try { |
nothing calls this directly
no test coverage detected