fix: join project mutation (#835)

* fix: join project mutation

* chore: remove imports
This commit is contained in:
Aaryan Khandelwal 2023-04-17 10:27:20 +05:30 committed by GitHub
parent 8638170a98
commit 363c5c8ec4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);