fix: issue delete redirection, chore: code refactor (#1521)

This commit is contained in:
Anmol Singh Bhatia 2023-07-13 19:00:43 +05:30 committed by GitHub
parent 60e96bcb72
commit 7361657660
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 24 deletions

View File

@ -39,13 +39,11 @@ export const AutoArchiveAutomation: React.FC<Props> = ({ projectDetails, handleC
</div>
<ToggleSwitch
value={projectDetails?.archive_in !== 0}
onChange={() => {
if (projectDetails?.archive_in === 0) {
handleChange({ archive_in: 1 });
} else {
handleChange({ archive_in: 0 });
}
}}
onChange={() =>
projectDetails?.archive_in === 0
? handleChange({ archive_in: 1 })
: handleChange({ archive_in: 0 })
}
size="sm"
/>
</div>

View File

@ -88,13 +88,11 @@ export const AutoCloseAutomation: React.FC<Props> = ({ projectDetails, handleCha
</div>
<ToggleSwitch
value={projectDetails?.close_in !== 0}
onChange={() => {
if (projectDetails?.close_in === 0) {
handleChange({ close_in: 1, default_state: defaultState });
} else {
handleChange({ close_in: 0, default_state: null });
}
}}
onChange={() =>
projectDetails?.close_in === 0
? handleChange({ close_in: 1, default_state: defaultState })
: handleChange({ close_in: 0, default_state: null })
}
size="sm"
/>
</div>

View File

@ -121,6 +121,7 @@ export const DeleteIssueModal: React.FC<Props> = ({ isOpen, handleClose, data, u
type: "success",
message: "Issue deleted successfully",
});
router.back();
})
.catch((error) => {
console.log(error);
@ -142,7 +143,7 @@ export const DeleteIssueModal: React.FC<Props> = ({ isOpen, handleClose, data, u
type: "success",
message: "Issue deleted successfully",
});
router.push(`/${workspaceSlug}/projects/${projectId}/archived-issues/`);
router.back();
})
.catch((error) => {
console.log(error);
@ -150,6 +151,9 @@ export const DeleteIssueModal: React.FC<Props> = ({ isOpen, handleClose, data, u
});
};
const handleIssueDelete = () =>
isArchivedIssues ? handleArchivedIssueDeletion() : handleDeletion();
return (
<Transition.Root show={isOpen} as={React.Fragment}>
<Dialog as="div" className="relative z-20" onClose={onClose}>
@ -201,13 +205,7 @@ export const DeleteIssueModal: React.FC<Props> = ({ isOpen, handleClose, data, u
</span>
<div className="flex justify-end gap-2">
<SecondaryButton onClick={onClose}>Cancel</SecondaryButton>
<DangerButton
onClick={() => {
if (isArchivedIssues) handleArchivedIssueDeletion();
else handleDeletion();
}}
loading={isDeleteLoading}
>
<DangerButton onClick={handleIssueDelete} loading={isDeleteLoading}>
{isDeleteLoading ? "Deleting..." : "Delete Issue"}
</DangerButton>
</div>

View File

@ -21,7 +21,7 @@ import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
import type { NextPage } from "next";
import { IProject } from "types";
// constant
import { PROJECT_DETAILS } from "constants/fetch-keys";
import { PROJECTS_LIST, PROJECT_DETAILS } from "constants/fetch-keys";
const AutomationsSettings: NextPage = () => {
const router = useRouter();
@ -40,10 +40,15 @@ const AutomationsSettings: NextPage = () => {
(prevData) => ({ ...(prevData as IProject), ...formData }),
false
);
await projectService
.updateProject(workspaceSlug as string, projectId as string, formData, user)
.then(() => {
mutate<IProject[]>(
PROJECTS_LIST(workspaceSlug as string),
(prevData) =>
(prevData ?? []).map((p) => (p.id === projectDetails?.id ? { ...p, ...formData } : p)),
false
);
mutate(PROJECT_DETAILS(projectId as string));
})
.catch(() => {