[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"; 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,9 +27,13 @@ export const JoinProject: React.FC = () => {
setIsJoiningProject(true); setIsJoiningProject(true);
joinProject(workspaceSlug.toString(), [projectId.toString()]).finally(() => { joinProject(workspaceSlug.toString(), [projectId.toString()])
setIsJoiningProject(false); .then(() => {
}); projectStore.fetchProjects(workspaceSlug.toString());
})
.finally(() => {
setIsJoiningProject(false);
});
}; };
return ( return (

View File

@ -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(() => {