mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
fix: join project mutation (#835)
* fix: join project mutation * chore: remove imports
This commit is contained in:
parent
8638170a98
commit
363c5c8ec4
@ -5,15 +5,16 @@ import { useRouter } from "next/router";
|
|||||||
|
|
||||||
import { mutate } from "swr";
|
import { mutate } from "swr";
|
||||||
|
|
||||||
|
// services
|
||||||
|
import projectService from "services/project.service";
|
||||||
// ui
|
// ui
|
||||||
import { PrimaryButton } from "components/ui";
|
import { PrimaryButton } from "components/ui";
|
||||||
// icon
|
// icons
|
||||||
import { AssignmentClipboardIcon } from "components/icons";
|
import { AssignmentClipboardIcon } from "components/icons";
|
||||||
// img
|
// images
|
||||||
import JoinProjectImg from "public/auth/project-not-authorized.svg";
|
import JoinProjectImg from "public/auth/project-not-authorized.svg";
|
||||||
import projectService from "services/project.service";
|
|
||||||
// fetch-keys
|
// fetch-keys
|
||||||
import { PROJECT_MEMBERS } from "constants/fetch-keys";
|
import { USER_PROJECT_VIEW } from "constants/fetch-keys";
|
||||||
|
|
||||||
export const JoinProject: React.FC = () => {
|
export const JoinProject: React.FC = () => {
|
||||||
const [isJoiningProject, setIsJoiningProject] = useState(false);
|
const [isJoiningProject, setIsJoiningProject] = useState(false);
|
||||||
@ -22,13 +23,16 @@ export const JoinProject: React.FC = () => {
|
|||||||
const { workspaceSlug, projectId } = router.query;
|
const { workspaceSlug, projectId } = router.query;
|
||||||
|
|
||||||
const handleJoin = () => {
|
const handleJoin = () => {
|
||||||
|
if (!workspaceSlug || !projectId) return;
|
||||||
|
|
||||||
setIsJoiningProject(true);
|
setIsJoiningProject(true);
|
||||||
projectService
|
projectService
|
||||||
.joinProject(workspaceSlug as string, {
|
.joinProject(workspaceSlug as string, {
|
||||||
project_ids: [projectId as string],
|
project_ids: [projectId as string],
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(async () => {
|
||||||
mutate(PROJECT_MEMBERS(projectId as string));
|
await mutate(USER_PROJECT_VIEW(workspaceSlug.toString()));
|
||||||
|
setIsJoiningProject(false);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
Loading…
Reference in New Issue
Block a user