fix: mutation while adding issue to cycle or module (#589)
This commit is contained in:
parent
4e9715a5b2
commit
1509c8611d
5 changed files with 48 additions and 36 deletions
|
|
@ -20,6 +20,8 @@ import { CycleDetailsSidebar } from "components/cycles";
|
|||
import issuesService from "services/issues.service";
|
||||
import cycleServices from "services/cycles.service";
|
||||
import projectService from "services/project.service";
|
||||
// hooks
|
||||
import useToast from "hooks/use-toast";
|
||||
// ui
|
||||
import { CustomMenu } from "components/ui";
|
||||
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
||||
|
|
@ -44,6 +46,8 @@ const SingleCycle: React.FC<UserAuth> = (props) => {
|
|||
const router = useRouter();
|
||||
const { workspaceSlug, projectId, cycleId } = router.query;
|
||||
|
||||
const { setToastAlert } = useToast();
|
||||
|
||||
const { data: activeProject } = useSWR(
|
||||
workspaceSlug && projectId ? PROJECT_DETAILS(projectId as string) : null,
|
||||
workspaceSlug && projectId
|
||||
|
|
@ -93,12 +97,15 @@ const SingleCycle: React.FC<UserAuth> = (props) => {
|
|||
|
||||
await issuesService
|
||||
.addIssueToCycle(workspaceSlug as string, projectId as string, cycleId as string, data)
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
.then(() => {
|
||||
mutate(CYCLE_ISSUES(cycleId as string));
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
.catch(() => {
|
||||
setToastAlert({
|
||||
type: "error",
|
||||
title: "Error!",
|
||||
message: "Selected issues could not be added to the cycle. Please try again.",
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -107,7 +114,7 @@ const SingleCycle: React.FC<UserAuth> = (props) => {
|
|||
<ExistingIssuesListModal
|
||||
isOpen={cycleIssuesListModal}
|
||||
handleClose={() => setCycleIssuesListModal(false)}
|
||||
issues={issues?.filter((i) => !i.issue_cycle) ?? []}
|
||||
issues={issues?.filter((i) => !i.cycle_id) ?? []}
|
||||
handleOnSubmit={handleAddIssuesToCycle}
|
||||
/>
|
||||
<AppLayout
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ import { requiredAdmin, requiredAuth } from "lib/auth";
|
|||
// services
|
||||
import modulesService from "services/modules.service";
|
||||
import issuesService from "services/issues.service";
|
||||
// hooks
|
||||
import useToast from "hooks/use-toast";
|
||||
// layouts
|
||||
import AppLayout from "layouts/app-layout";
|
||||
// contexts
|
||||
|
|
@ -47,6 +49,8 @@ const SingleModule: React.FC<UserAuth> = (props) => {
|
|||
const router = useRouter();
|
||||
const { workspaceSlug, projectId, moduleId } = router.query;
|
||||
|
||||
const { setToastAlert } = useToast();
|
||||
|
||||
const { data: issues } = useSWR(
|
||||
workspaceSlug && projectId
|
||||
? PROJECT_ISSUES_LIST(workspaceSlug as string, projectId as string)
|
||||
|
|
@ -96,7 +100,13 @@ const SingleModule: React.FC<UserAuth> = (props) => {
|
|||
console.log(res);
|
||||
mutate(MODULE_ISSUES(moduleId as string));
|
||||
})
|
||||
.catch((e) => console.log(e));
|
||||
.catch((e) =>
|
||||
setToastAlert({
|
||||
type: "error",
|
||||
title: "Error!",
|
||||
message: "Selected issues could not be added to the module. Please try again.",
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const openIssuesListModal = () => {
|
||||
|
|
@ -108,7 +118,7 @@ const SingleModule: React.FC<UserAuth> = (props) => {
|
|||
<ExistingIssuesListModal
|
||||
isOpen={moduleIssuesListModal}
|
||||
handleClose={() => setModuleIssuesListModal(false)}
|
||||
issues={issues?.filter((i) => !i.issue_module) ?? []}
|
||||
issues={issues?.filter((i) => !i.module_id) ?? []}
|
||||
handleOnSubmit={handleAddIssuesToModule}
|
||||
/>
|
||||
<AppLayout
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue