Multi user org invites

This commit is contained in:
Daniel Hougaard
2024-08-23 02:25:15 +04:00
parent c2c9edf156
commit c5c949e034
3 changed files with 11 additions and 7 deletions
@@ -2,7 +2,7 @@ import React, { useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { useAddUserToOrg } from "@app/hooks/api"; import { useAddUsersToOrg } from "@app/hooks/api";
import { useFetchServerStatus } from "@app/hooks/api/serverDetails"; import { useFetchServerStatus } from "@app/hooks/api/serverDetails";
import { usePopUp } from "@app/hooks/usePopUp"; import { usePopUp } from "@app/hooks/usePopUp";
@@ -17,7 +17,7 @@ export default function TeamInviteStep(): JSX.Element {
const [emails, setEmails] = useState(""); const [emails, setEmails] = useState("");
const { data: serverDetails } = useFetchServerStatus(); const { data: serverDetails } = useFetchServerStatus();
const { mutateAsync } = useAddUserToOrg(); const { mutateAsync } = useAddUsersToOrg();
const { handlePopUpToggle, popUp, handlePopUpOpen } = usePopUp(["setUpEmail"] as const); const { handlePopUpToggle, popUp, handlePopUpOpen } = usePopUp(["setUpEmail"] as const);
// Redirect user to the getting started page // Redirect user to the getting started page
@@ -31,7 +31,7 @@ export default function TeamInviteStep(): JSX.Element {
.map((email) => email.trim()) .map((email) => email.trim())
.map(async (email) => { .map(async (email) => {
mutateAsync({ mutateAsync({
inviteeEmail: email, inviteeEmails: [email],
organizationId: String(localStorage.getItem("orgData.id")) organizationId: String(localStorage.getItem("orgData.id"))
}); });
}); });
+3 -2
View File
@@ -6,7 +6,7 @@ export {
} from "./mutation"; } from "./mutation";
export { export {
fetchOrgUsers, fetchOrgUsers,
useAddUserToOrg, useAddUsersToOrg,
useCreateAPIKey, useCreateAPIKey,
useDeleteAPIKey, useDeleteAPIKey,
useDeleteMe, useDeleteMe,
@@ -26,4 +26,5 @@ export {
useRevokeMySessions, useRevokeMySessions,
useUpdateMfaEnabled, useUpdateMfaEnabled,
useUpdateOrgMembership, useUpdateOrgMembership,
useUpdateUserAuthMethods} from "./queries"; useUpdateUserAuthMethods
} from "./queries";
+5 -2
View File
@@ -157,12 +157,15 @@ export const useGetOrgUsers = (orgId: string) =>
// mutation // mutation
// TODO(akhilmhdh): move all mutation to mutation file // TODO(akhilmhdh): move all mutation to mutation file
export const useAddUserToOrg = () => { export const useAddUsersToOrg = () => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
type Response = { type Response = {
data: { data: {
message: string; message: string;
completeInviteLink: string | undefined; completeInviteLinks: {
email: string;
link: string;
}[];
}; };
}; };