mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 19:28:09 +00:00
Refactor add users to org handlers
This commit is contained in:
+8
-8
@@ -33,7 +33,7 @@ import {
|
|||||||
useUser
|
useUser
|
||||||
} from "@app/context";
|
} from "@app/context";
|
||||||
import {
|
import {
|
||||||
useAddUserToOrg,
|
useAddUsersToOrg,
|
||||||
useFetchServerStatus,
|
useFetchServerStatus,
|
||||||
useGetOrgRoles,
|
useGetOrgRoles,
|
||||||
useGetOrgUsers,
|
useGetOrgUsers,
|
||||||
@@ -50,10 +50,10 @@ type Props = {
|
|||||||
description?: string;
|
description?: string;
|
||||||
}
|
}
|
||||||
) => void;
|
) => void;
|
||||||
setCompleteInviteLink: (link: string) => void;
|
setCompleteInviteLinks: (links: Array<{ email: string; link: string }> | null) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const OrgMembersTable = ({ handlePopUpOpen, setCompleteInviteLink }: Props) => {
|
export const OrgMembersTable = ({ handlePopUpOpen, setCompleteInviteLinks }: Props) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { subscription } = useSubscription();
|
const { subscription } = useSubscription();
|
||||||
const { currentOrg } = useOrganization();
|
const { currentOrg } = useOrganization();
|
||||||
@@ -68,7 +68,7 @@ export const OrgMembersTable = ({ handlePopUpOpen, setCompleteInviteLink }: Prop
|
|||||||
const { data: serverDetails } = useFetchServerStatus();
|
const { data: serverDetails } = useFetchServerStatus();
|
||||||
const { data: members, isLoading: isMembersLoading } = useGetOrgUsers(orgId);
|
const { data: members, isLoading: isMembersLoading } = useGetOrgUsers(orgId);
|
||||||
|
|
||||||
const { mutateAsync: addUserMutateAsync } = useAddUserToOrg();
|
const { mutateAsync: addUsersMutateAsync } = useAddUsersToOrg();
|
||||||
const { mutateAsync: updateOrgMembership } = useUpdateOrgMembership();
|
const { mutateAsync: updateOrgMembership } = useUpdateOrgMembership();
|
||||||
|
|
||||||
const onRoleChange = async (membershipId: string, role: string) => {
|
const onRoleChange = async (membershipId: string, role: string) => {
|
||||||
@@ -106,14 +106,14 @@ export const OrgMembersTable = ({ handlePopUpOpen, setCompleteInviteLink }: Prop
|
|||||||
|
|
||||||
const onResendInvite = async (email: string) => {
|
const onResendInvite = async (email: string) => {
|
||||||
try {
|
try {
|
||||||
const { data } = await addUserMutateAsync({
|
const { data } = await addUsersMutateAsync({
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
inviteeEmail: email
|
inviteeEmails: [email]
|
||||||
});
|
});
|
||||||
|
|
||||||
setCompleteInviteLink(data?.completeInviteLink || "");
|
setCompleteInviteLinks(data?.completeInviteLinks || null);
|
||||||
|
|
||||||
if (!data.completeInviteLink) {
|
if (!data.completeInviteLinks) {
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully resent invite to ${email}`,
|
text: `Successfully resent invite to ${email}`,
|
||||||
type: "success"
|
type: "success"
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
} from "@app/context";
|
} from "@app/context";
|
||||||
import { useTimedReset } from "@app/hooks";
|
import { useTimedReset } from "@app/hooks";
|
||||||
import {
|
import {
|
||||||
useAddUserToOrg,
|
useAddUsersToOrg,
|
||||||
useFetchServerStatus,
|
useFetchServerStatus,
|
||||||
useGetOrgMembership,
|
useGetOrgMembership,
|
||||||
useGetOrgRoles
|
useGetOrgRoles
|
||||||
@@ -44,18 +44,18 @@ export const UserDetailsSection = ({ membershipId, handlePopUpOpen }: Props) =>
|
|||||||
const { data: roles } = useGetOrgRoles(orgId);
|
const { data: roles } = useGetOrgRoles(orgId);
|
||||||
const { data: serverDetails } = useFetchServerStatus();
|
const { data: serverDetails } = useFetchServerStatus();
|
||||||
const { data: membership } = useGetOrgMembership(orgId, membershipId);
|
const { data: membership } = useGetOrgMembership(orgId, membershipId);
|
||||||
const { mutateAsync: inviteUser, isLoading } = useAddUserToOrg();
|
const { mutateAsync: inviteUsers, isLoading } = useAddUsersToOrg();
|
||||||
|
|
||||||
const onResendInvite = async (email: string) => {
|
const onResendInvite = async (email: string) => {
|
||||||
try {
|
try {
|
||||||
const { data } = await inviteUser({
|
const { data } = await inviteUsers({
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
inviteeEmail: email
|
inviteeEmails: [email]
|
||||||
});
|
});
|
||||||
|
|
||||||
// setCompleteInviteLink(data?.completeInviteLink || "");
|
// setCompleteInviteLink(data?.completeInviteLink || "");
|
||||||
|
|
||||||
if (!data.completeInviteLink) {
|
if (!data.completeInviteLinks) {
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully resent invite to ${email}`,
|
text: `Successfully resent invite to ${email}`,
|
||||||
type: "success"
|
type: "success"
|
||||||
|
|||||||
Reference in New Issue
Block a user