forked from github/plane
fix: mutation on transfer issues from cycle (#2979)
* fix cycle issues mutation on transfering issues * fix transfer issues from cycle
This commit is contained in:
parent
fa990ed444
commit
b527ec582f
@ -2,10 +2,12 @@ import React, { useState } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
import useSWR from "swr";
|
||||
import { Dialog, Transition } from "@headlessui/react";
|
||||
import { observer } from "mobx-react-lite";
|
||||
// services
|
||||
import { CycleService } from "services/cycle.service";
|
||||
// hooks
|
||||
import useToast from "hooks/use-toast";
|
||||
import { useMobxStore } from "lib/mobx/store-provider";
|
||||
//icons
|
||||
import { ContrastIcon, TransferIcon } from "@plane/ui";
|
||||
import { AlertCircle, Search, X } from "lucide-react";
|
||||
@ -23,17 +25,19 @@ type Props = {
|
||||
|
||||
const cycleService = new CycleService();
|
||||
|
||||
export const TransferIssuesModal: React.FC<Props> = ({ isOpen, handleClose }) => {
|
||||
export const TransferIssuesModal: React.FC<Props> = observer(({ isOpen, handleClose }) => {
|
||||
const [query, setQuery] = useState("");
|
||||
|
||||
const { cycleIssues: cycleIssueStore } = useMobxStore();
|
||||
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, projectId, cycleId } = router.query;
|
||||
|
||||
const { setToastAlert } = useToast();
|
||||
|
||||
const transferIssue = async (payload: any) => {
|
||||
await cycleService
|
||||
.transferIssues(workspaceSlug as string, projectId as string, cycleId as string, payload)
|
||||
await cycleIssueStore
|
||||
.transferIssuesFromCycle(workspaceSlug as string, projectId as string, cycleId as string, payload)
|
||||
.then(() => {
|
||||
setToastAlert({
|
||||
type: "success",
|
||||
@ -159,4 +163,4 @@ export const TransferIssuesModal: React.FC<Props> = ({ isOpen, handleClose }) =>
|
||||
</Dialog>
|
||||
</Transition.Root>
|
||||
);
|
||||
};
|
||||
});
|
||||
|
@ -62,7 +62,14 @@ export interface ICycleIssuesStore {
|
||||
issueId: string,
|
||||
issueBridgeId: string
|
||||
) => Promise<IIssue>;
|
||||
|
||||
transferIssuesFromCycle: (
|
||||
workspaceSlug: string,
|
||||
projectId: string,
|
||||
cycleId: string,
|
||||
payload: {
|
||||
new_cycle_id: string;
|
||||
}
|
||||
) => Promise<IIssue>;
|
||||
viewFlags: ViewFlags;
|
||||
}
|
||||
|
||||
@ -103,6 +110,7 @@ export class CycleIssuesStore extends IssueBaseStore implements ICycleIssuesStor
|
||||
quickAddIssue: action,
|
||||
addIssueToCycle: action,
|
||||
removeIssueFromCycle: action,
|
||||
transferIssuesFromCycle: action,
|
||||
});
|
||||
|
||||
this.rootStore = _rootStore;
|
||||
@ -348,4 +356,28 @@ export class CycleIssuesStore extends IssueBaseStore implements ICycleIssuesStor
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
transferIssuesFromCycle = async (
|
||||
workspaceSlug: string,
|
||||
projectId: string,
|
||||
cycleId: string,
|
||||
payload: {
|
||||
new_cycle_id: string;
|
||||
}
|
||||
) => {
|
||||
try {
|
||||
const response = await this.cycleService.transferIssues(
|
||||
workspaceSlug as string,
|
||||
projectId as string,
|
||||
cycleId as string,
|
||||
payload
|
||||
);
|
||||
await this.fetchIssues(workspaceSlug, projectId, "mutation", cycleId);
|
||||
|
||||
return response;
|
||||
} catch (error) {
|
||||
this.fetchIssues(workspaceSlug, projectId, "mutation", cycleId);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user