fix: cycle & module mutation , feat: cycle & module toast alerts (#962)

* fix: cycle remove issue mutation

* fix: module remove issue mutation

* feat: issue removed toast alert added
This commit is contained in:
Anmol Singh Bhatia 2023-04-28 17:49:16 +05:30 committed by GitHub
parent f0f24b6fc4
commit 0b9b4bb289
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 10 deletions

View File

@ -17,7 +17,7 @@ type Props = {
openIssuesListModal?: (() => void) | null; openIssuesListModal?: (() => void) | null;
handleDeleteIssue: (issue: IIssue) => void; handleDeleteIssue: (issue: IIssue) => void;
handleTrashBox: (isDragging: boolean) => void; handleTrashBox: (isDragging: boolean) => void;
removeIssue: ((bridgeId: string) => void) | null; removeIssue: ((bridgeId: string, issueId: string) => void) | null;
isCompleted?: boolean; isCompleted?: boolean;
userAuth: UserAuth; userAuth: UserAuth;
}; };

View File

@ -29,7 +29,7 @@ type Props = {
handleDeleteIssue: (issue: IIssue) => void; handleDeleteIssue: (issue: IIssue) => void;
openIssuesListModal?: (() => void) | null; openIssuesListModal?: (() => void) | null;
handleTrashBox: (isDragging: boolean) => void; handleTrashBox: (isDragging: boolean) => void;
removeIssue: ((bridgeId: string) => void) | null; removeIssue: ((bridgeId: string, issueId: string) => void) | null;
isCompleted?: boolean; isCompleted?: boolean;
userAuth: UserAuth; userAuth: UserAuth;
}; };
@ -130,7 +130,8 @@ export const SingleBoard: React.FC<Props> = ({
handleDeleteIssue={handleDeleteIssue} handleDeleteIssue={handleDeleteIssue}
handleTrashBox={handleTrashBox} handleTrashBox={handleTrashBox}
removeIssue={() => { removeIssue={() => {
if (removeIssue && issue.bridge_id) removeIssue(issue.bridge_id); if (removeIssue && issue.bridge_id)
removeIssue(issue.bridge_id, issue.id);
}} }}
isCompleted={isCompleted} isCompleted={isCompleted}
userAuth={userAuth} userAuth={userAuth}

View File

@ -314,10 +314,26 @@ export const IssuesView: React.FC<Props> = ({
); );
const removeIssueFromCycle = useCallback( const removeIssueFromCycle = useCallback(
(bridgeId: string) => { (bridgeId: string, issueId: string) => {
if (!workspaceSlug || !projectId || !cycleId) return; if (!workspaceSlug || !projectId || !cycleId) return;
mutate(CYCLE_ISSUES_WITH_PARAMS(cycleId as string, params)); mutate(
CYCLE_ISSUES_WITH_PARAMS(cycleId as string, params),
(prevData: any) => {
if (!prevData) return prevData;
if (selectedGroup) {
const filteredData: any = {};
for (const key in prevData) {
filteredData[key] = prevData[key].filter((item: any) => item.id !== issueId);
}
return filteredData;
} else {
const filteredData = prevData.filter((i: any) => i.id !== issueId);
return filteredData;
}
},
false
);
issuesService issuesService
.removeIssueFromCycle( .removeIssueFromCycle(
@ -326,6 +342,13 @@ export const IssuesView: React.FC<Props> = ({
cycleId as string, cycleId as string,
bridgeId bridgeId
) )
.then(() => {
setToastAlert({
title: "Success",
message: "Issue removed successfully.",
type: "success",
});
})
.catch((e) => { .catch((e) => {
console.log(e); console.log(e);
}); });
@ -334,10 +357,26 @@ export const IssuesView: React.FC<Props> = ({
); );
const removeIssueFromModule = useCallback( const removeIssueFromModule = useCallback(
(bridgeId: string) => { (bridgeId: string, issueId: string) => {
if (!workspaceSlug || !projectId || !moduleId) return; if (!workspaceSlug || !projectId || !moduleId) return;
mutate(MODULE_ISSUES_WITH_PARAMS(moduleId as string, params)); mutate(
MODULE_ISSUES_WITH_PARAMS(moduleId as string, params),
(prevData: any) => {
if (!prevData) return prevData;
if (selectedGroup) {
const filteredData: any = {};
for (const key in prevData) {
filteredData[key] = prevData[key].filter((item: any) => item.id !== issueId);
}
return filteredData;
} else {
const filteredData = prevData.filter((item: any) => item.id !== issueId);
return filteredData;
}
},
false
);
modulesService modulesService
.removeIssueFromModule( .removeIssueFromModule(
@ -346,6 +385,13 @@ export const IssuesView: React.FC<Props> = ({
moduleId as string, moduleId as string,
bridgeId bridgeId
) )
.then(() => {
setToastAlert({
title: "Success",
message: "Issue removed successfully.",
type: "success",
});
})
.catch((e) => { .catch((e) => {
console.log(e); console.log(e);
}); });

View File

@ -14,7 +14,7 @@ type Props = {
handleEditIssue: (issue: IIssue) => void; handleEditIssue: (issue: IIssue) => void;
handleDeleteIssue: (issue: IIssue) => void; handleDeleteIssue: (issue: IIssue) => void;
openIssuesListModal?: (() => void) | null; openIssuesListModal?: (() => void) | null;
removeIssue: ((bridgeId: string) => void) | null; removeIssue: ((bridgeId: string, issueId: string) => void) | null;
isCompleted?: boolean; isCompleted?: boolean;
userAuth: UserAuth; userAuth: UserAuth;
}; };

View File

@ -37,7 +37,7 @@ type Props = {
handleEditIssue: (issue: IIssue) => void; handleEditIssue: (issue: IIssue) => void;
handleDeleteIssue: (issue: IIssue) => void; handleDeleteIssue: (issue: IIssue) => void;
openIssuesListModal?: (() => void) | null; openIssuesListModal?: (() => void) | null;
removeIssue: ((bridgeId: string) => void) | null; removeIssue: ((bridgeId: string, issueId: string) => void) | null;
isCompleted?: boolean; isCompleted?: boolean;
userAuth: UserAuth; userAuth: UserAuth;
}; };
@ -204,7 +204,7 @@ export const SingleList: React.FC<Props> = ({
makeIssueCopy={() => makeIssueCopy(issue)} makeIssueCopy={() => makeIssueCopy(issue)}
handleDeleteIssue={handleDeleteIssue} handleDeleteIssue={handleDeleteIssue}
removeIssue={() => { removeIssue={() => {
if (removeIssue !== null && issue.bridge_id) removeIssue(issue.bridge_id); if (removeIssue !== null && issue.bridge_id) removeIssue(issue.bridge_id, issue.id);
}} }}
isCompleted={isCompleted} isCompleted={isCompleted}
userAuth={userAuth} userAuth={userAuth}