[FED-1054] fix: join project mutation (#2892)

* fix: join project mutation

* chore: code refactor
This commit is contained in:
Anmol Singh Bhatia 2023-11-27 17:16:46 +05:30 committed by sriram veeraghanta
parent 0887d35596
commit 21e32ce863
2 changed files with 14 additions and 5 deletions

View File

@ -3,6 +3,7 @@ import Image from "next/image";
import { useRouter } from "next/router";
// mobx store
import { useMobxStore } from "lib/mobx/store-provider";
import { RootStore } from "store/root";
// ui
import { Button } from "@plane/ui";
// icons
@ -14,8 +15,9 @@ export const JoinProject: React.FC = () => {
const [isJoiningProject, setIsJoiningProject] = useState(false);
const {
project: projectStore,
user: { joinProject },
} = useMobxStore();
}: RootStore = useMobxStore();
const router = useRouter();
const { workspaceSlug, projectId } = router.query;
@ -25,7 +27,11 @@ export const JoinProject: React.FC = () => {
setIsJoiningProject(true);
joinProject(workspaceSlug.toString(), [projectId.toString()]).finally(() => {
joinProject(workspaceSlug.toString(), [projectId.toString()])
.then(() => {
projectStore.fetchProjects(workspaceSlug.toString());
})
.finally(() => {
setIsJoiningProject(false);
});
};

View File

@ -7,6 +7,7 @@ import { Button } from "@plane/ui";
import type { IProject } from "types";
// lib
import { useMobxStore } from "lib/mobx/store-provider";
import { RootStore } from "store/root";
// type
type TJoinProjectModalProps = {
@ -22,8 +23,9 @@ export const JoinProjectModal: React.FC<TJoinProjectModalProps> = (props) => {
const [isJoiningLoading, setIsJoiningLoading] = useState(false);
// store
const {
project: projectStore,
user: { joinProject },
} = useMobxStore();
}: RootStore = useMobxStore();
// router
const router = useRouter();
@ -33,6 +35,7 @@ export const JoinProjectModal: React.FC<TJoinProjectModalProps> = (props) => {
joinProject(workspaceSlug, [project.id])
.then(() => {
router.push(`/${workspaceSlug}/projects/${project.id}/issues`);
projectStore.fetchProjects(workspaceSlug);
handleClose();
})
.finally(() => {