fix: mutation latency in sidebar projects when user leaves the project (#2083)

* fix: mutation latency in sidebar projects when user leaves the project

* chore: remove console
This commit is contained in:
guru_sainath 2023-09-04 17:24:52 +05:30 committed by GitHub
parent 2c9c8d5a89
commit faf5a274cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,6 @@
import React from "react";
// next imports
import { useRouter } from "next/router";
// swr
import { mutate } from "swr";
// react-hook-form
import { Controller, useForm } from "react-hook-form";
// headless ui
@ -21,6 +19,7 @@ import { RootStore } from "store/root";
// hooks
import useToast from "hooks/use-toast";
import useUser from "hooks/use-user";
import useProjects from "hooks/use-projects";
// types
import { IProject } from "types";
@ -42,6 +41,7 @@ export const ConfirmProjectLeaveModal: React.FC = observer(() => {
const { project } = store;
const { user } = useUser();
const { mutateProjects } = useProjects();
const { setToastAlert } = useToast();
@ -59,9 +59,6 @@ export const ConfirmProjectLeaveModal: React.FC = observer(() => {
reset({ ...defaultValues });
};
project?.projectLeaveDetails &&
console.log("project leave confirmation modal", project?.projectLeaveDetails);
const onSubmit = async (data: any) => {
if (data) {
if (data.projectName === project?.projectLeaveDetails?.name) {
@ -73,13 +70,7 @@ export const ConfirmProjectLeaveModal: React.FC = observer(() => {
user
)
.then((res) => {
mutate<IProject[]>(
PROJECTS_LIST(project.projectLeaveDetails.workspaceSlug.toString(), {
is_favorite: "all",
}),
(prevData) => prevData?.filter((project: IProject) => project.id !== data.id),
false
);
mutateProjects();
handleClose();
router.push(`/${workspaceSlug}/projects`);
})