mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
[FED-1054] fix: join project mutation (#2892)
* fix: join project mutation * chore: code refactor
This commit is contained in:
parent
0887d35596
commit
21e32ce863
@ -3,6 +3,7 @@ import Image from "next/image";
|
|||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
// mobx store
|
// mobx store
|
||||||
import { useMobxStore } from "lib/mobx/store-provider";
|
import { useMobxStore } from "lib/mobx/store-provider";
|
||||||
|
import { RootStore } from "store/root";
|
||||||
// ui
|
// ui
|
||||||
import { Button } from "@plane/ui";
|
import { Button } from "@plane/ui";
|
||||||
// icons
|
// icons
|
||||||
@ -14,8 +15,9 @@ export const JoinProject: React.FC = () => {
|
|||||||
const [isJoiningProject, setIsJoiningProject] = useState(false);
|
const [isJoiningProject, setIsJoiningProject] = useState(false);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
project: projectStore,
|
||||||
user: { joinProject },
|
user: { joinProject },
|
||||||
} = useMobxStore();
|
}: RootStore = useMobxStore();
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspaceSlug, projectId } = router.query;
|
const { workspaceSlug, projectId } = router.query;
|
||||||
@ -25,7 +27,11 @@ export const JoinProject: React.FC = () => {
|
|||||||
|
|
||||||
setIsJoiningProject(true);
|
setIsJoiningProject(true);
|
||||||
|
|
||||||
joinProject(workspaceSlug.toString(), [projectId.toString()]).finally(() => {
|
joinProject(workspaceSlug.toString(), [projectId.toString()])
|
||||||
|
.then(() => {
|
||||||
|
projectStore.fetchProjects(workspaceSlug.toString());
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
setIsJoiningProject(false);
|
setIsJoiningProject(false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -7,6 +7,7 @@ import { Button } from "@plane/ui";
|
|||||||
import type { IProject } from "types";
|
import type { IProject } from "types";
|
||||||
// lib
|
// lib
|
||||||
import { useMobxStore } from "lib/mobx/store-provider";
|
import { useMobxStore } from "lib/mobx/store-provider";
|
||||||
|
import { RootStore } from "store/root";
|
||||||
|
|
||||||
// type
|
// type
|
||||||
type TJoinProjectModalProps = {
|
type TJoinProjectModalProps = {
|
||||||
@ -22,8 +23,9 @@ export const JoinProjectModal: React.FC<TJoinProjectModalProps> = (props) => {
|
|||||||
const [isJoiningLoading, setIsJoiningLoading] = useState(false);
|
const [isJoiningLoading, setIsJoiningLoading] = useState(false);
|
||||||
// store
|
// store
|
||||||
const {
|
const {
|
||||||
|
project: projectStore,
|
||||||
user: { joinProject },
|
user: { joinProject },
|
||||||
} = useMobxStore();
|
}: RootStore = useMobxStore();
|
||||||
// router
|
// router
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
@ -33,6 +35,7 @@ export const JoinProjectModal: React.FC<TJoinProjectModalProps> = (props) => {
|
|||||||
joinProject(workspaceSlug, [project.id])
|
joinProject(workspaceSlug, [project.id])
|
||||||
.then(() => {
|
.then(() => {
|
||||||
router.push(`/${workspaceSlug}/projects/${project.id}/issues`);
|
router.push(`/${workspaceSlug}/projects/${project.id}/issues`);
|
||||||
|
projectStore.fetchProjects(workspaceSlug);
|
||||||
handleClose();
|
handleClose();
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user