()
| 26 | type IForm = z.infer<typeof zInviteUser>; |
| 27 | |
| 28 | export default function CreateInvite() { |
| 29 | const { organizationId } = useAppParams(); |
| 30 | const trpc = useTRPC(); |
| 31 | const projectsQuery = useQuery( |
| 32 | trpc.project.list.queryOptions({ |
| 33 | organizationId, |
| 34 | }), |
| 35 | ); |
| 36 | const projects = projectsQuery.data ?? []; |
| 37 | |
| 38 | const queryClient = useQueryClient(); |
| 39 | |
| 40 | const { register, handleSubmit, formState, reset, control } = useForm<IForm>({ |
| 41 | resolver: zodResolver(zInviteUser), |
| 42 | defaultValues: { |
| 43 | organizationId, |
| 44 | access: [], |
| 45 | role: 'org:member', |
| 46 | }, |
| 47 | }); |
| 48 | |
| 49 | const mutation = useMutation( |
| 50 | trpc.organization.inviteUser.mutationOptions({ |
| 51 | onSuccess() { |
| 52 | toast.success('User has been invited'); |
| 53 | reset(); |
| 54 | queryClient.invalidateQueries( |
| 55 | trpc.organization.invitations.queryFilter({ organizationId }), |
| 56 | ); |
| 57 | }, |
| 58 | onError(error) { |
| 59 | toast.error('Failed to invite user', { |
| 60 | description: error.message, |
| 61 | }); |
| 62 | }, |
| 63 | }), |
| 64 | ); |
| 65 | |
| 66 | return ( |
| 67 | <> |
| 68 | {mutation.isSuccess ? ( |
| 69 | <SheetContent> |
| 70 | <SheetHeader> |
| 71 | <SheetTitle>User has been invited</SheetTitle> |
| 72 | </SheetHeader> |
| 73 | <div className="prose dark:prose-invert"> |
| 74 | {mutation.data.type === 'is_member' ? ( |
| 75 | <> |
| 76 | <p> |
| 77 | Since the user already has an account we have added him/her to |
| 78 | your organization. This means you will not see this user in |
| 79 | the list of invites. |
| 80 | </p> |
| 81 | <p>We have also notified the user by email about this.</p> |
| 82 | </> |
| 83 | ) : ( |
| 84 | <p> |
| 85 | We have sent an email with instructions to join the |
nothing calls this directly
no test coverage detected