forked from github/plane
fix: project member mutate issue (#1967)
This commit is contained in:
parent
489ef6a3cc
commit
802e6b3e8e
@ -2,7 +2,7 @@ import React, { useEffect } from "react";
|
|||||||
|
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
|
|
||||||
import useSWR, { mutate } from "swr";
|
import useSWR from "swr";
|
||||||
|
|
||||||
import { useForm, Controller, useFieldArray } from "react-hook-form";
|
import { useForm, Controller, useFieldArray } from "react-hook-form";
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ import useToast from "hooks/use-toast";
|
|||||||
// types
|
// types
|
||||||
import { ICurrentUserResponse } from "types";
|
import { ICurrentUserResponse } from "types";
|
||||||
// fetch-keys
|
// fetch-keys
|
||||||
import { PROJECT_MEMBERS, WORKSPACE_MEMBERS } from "constants/fetch-keys";
|
import { WORKSPACE_MEMBERS } from "constants/fetch-keys";
|
||||||
// constants
|
// constants
|
||||||
import { ROLE } from "constants/workspace";
|
import { ROLE } from "constants/workspace";
|
||||||
|
|
||||||
@ -37,6 +37,7 @@ type Props = {
|
|||||||
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
members: any[];
|
members: any[];
|
||||||
user: ICurrentUserResponse | undefined;
|
user: ICurrentUserResponse | undefined;
|
||||||
|
onSuccess: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
type member = {
|
type member = {
|
||||||
@ -57,7 +58,9 @@ const defaultValues: FormValues = {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const SendProjectInvitationModal: React.FC<Props> = ({ isOpen, setIsOpen, members, user }) => {
|
const SendProjectInvitationModal: React.FC<Props> = (props) => {
|
||||||
|
const { isOpen, setIsOpen, members, user, onSuccess } = props;
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspaceSlug, projectId } = router.query;
|
const { workspaceSlug, projectId } = router.query;
|
||||||
|
|
||||||
@ -98,13 +101,13 @@ const SendProjectInvitationModal: React.FC<Props> = ({ isOpen, setIsOpen, member
|
|||||||
type: "success",
|
type: "success",
|
||||||
message: "Member added successfully",
|
message: "Member added successfully",
|
||||||
});
|
});
|
||||||
|
onSuccess();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
reset(defaultValues);
|
reset(defaultValues);
|
||||||
mutate(PROJECT_MEMBERS(projectId.toString()));
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -108,6 +108,8 @@ const MembersSettings: NextPage = () => {
|
|||||||
|
|
||||||
const currentUser = projectMembers?.find((item) => item.member.id === user?.id);
|
const currentUser = projectMembers?.find((item) => item.member.id === user?.id);
|
||||||
|
|
||||||
|
const handleProjectInvitationSuccess = () => {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ProjectAuthorizationWrapper
|
<ProjectAuthorizationWrapper
|
||||||
breadcrumbs={
|
breadcrumbs={
|
||||||
@ -167,6 +169,7 @@ const MembersSettings: NextPage = () => {
|
|||||||
setIsOpen={setInviteModal}
|
setIsOpen={setInviteModal}
|
||||||
members={members}
|
members={members}
|
||||||
user={user}
|
user={user}
|
||||||
|
onSuccess={() => mutateMembers()}
|
||||||
/>
|
/>
|
||||||
<div className="p-8">
|
<div className="p-8">
|
||||||
<SettingsHeader />
|
<SettingsHeader />
|
||||||
|
Loading…
Reference in New Issue
Block a user