MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / createInvite

Function createInvite

apps/web/ui/MembersView/index.tsx:279–314  ·  view source on GitHub ↗
(event: any)

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 3

isEmailValidFunction · 0.90
mapMethod · 0.80
errorMethod · 0.65

Tested by

no test coverage detected