MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / InviteDialog

Function InviteDialog

packages/react/src/pages/org.tsx:531–663  ·  view source on GitHub ↗
(props: {
  open: boolean;
  onOpenChange: (v: boolean) => void;
  roles: readonly RoleData[];
})

Source from the content-addressed store, hash-verified

529}
530
531function InviteDialog(props: {
532 open: boolean;
533 onOpenChange: (v: boolean) => void;
534 roles: readonly RoleData[];
535}) {
536 const [state, dispatch] = useReducer(inviteReducer, initialInviteState);
537 const doInvite = useAtomSet(inviteMember, { mode: "promiseExit" });
538
539 const handleInvite = async () => {
540 if (!state.email.trim()) return;
541 dispatch({ type: "send" });
542 const exit = await doInvite({
543 payload: {
544 email: state.email.trim(),
545 ...(state.roleSlug ? { roleSlug: state.roleSlug } : {}),
546 },
547 reactivityKeys: orgMemberWriteKeys,
548 });
549 trackEvent("org_member_invited", {
550 role: state.roleSlug,
551 success: Exit.isSuccess(exit),
552 });
553 if (Exit.isSuccess(exit)) {
554 toast.success(`Invitation sent to ${state.email.trim()}`);
555 dispatch({ type: "reset" });
556 props.onOpenChange(false);
557 return;
558 }
559 // Surface a server-provided reason (e.g. the plan's member-seat limit, a
560 // 403 AccountForbidden carrying a message) so the admin knows WHY and that
561 // retrying will not help. Transient/untyped failures fall back to the
562 // generic retry copy.
563 dispatch({
564 type: "error",
565 message: messageFromExit(exit, GENERIC_INVITE_ERROR),
566 });
567 };
568
569 return (
570 <Dialog
571 open={props.open}
572 onOpenChange={(v) => {
573 if (!v) dispatch({ type: "reset" });
574 props.onOpenChange(v);
575 }}
576 >
577 <DialogContent className="sm:max-w-[400px]">
578 <DialogHeader>
579 <DialogTitle className="font-display text-xl">Invite member</DialogTitle>
580 <DialogDescription className="text-sm leading-relaxed">
581 Send an email invitation to join your organization.
582 </DialogDescription>
583 </DialogHeader>
584
585 <div className="grid gap-4 py-3">
586 <div className="grid gap-1.5">
587 <Label
588 htmlFor="invite-email"

Callers

nothing calls this directly

Calls 1

handleInviteFunction · 0.85

Tested by

no test coverage detected