()
| 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 |
no test coverage detected