[WEB-2043] fix: delete action validation and toast alert (#5254)
* dev: canPerformProjectAdminActions helper function added * chore: deleteInboxIssue action updated * dev: bulk delete modal validation updated * chore: issue, intake, cycle and module delete action toast updated * chore: code refactor
This commit is contained in:
parent
ba9d9fd5eb
commit
35e58e9ec7
8 changed files with 107 additions and 18 deletions
|
|
@ -3,7 +3,9 @@ import { observer } from "mobx-react";
|
|||
// types
|
||||
import type { TIssue } from "@plane/types";
|
||||
// ui
|
||||
import { AlertModalCore } from "@plane/ui";
|
||||
import { AlertModalCore, setToast, TOAST_TYPE } from "@plane/ui";
|
||||
// constants
|
||||
import { PROJECT_ERROR_MESSAGES } from "@/constants/project";
|
||||
// hooks
|
||||
import { useProject } from "@/hooks/store";
|
||||
|
||||
|
|
@ -29,7 +31,26 @@ export const DeleteInboxIssueModal: React.FC<Props> = observer(({ isOpen, onClos
|
|||
|
||||
const handleDelete = async () => {
|
||||
setIsDeleting(true);
|
||||
await onSubmit().finally(() => handleClose());
|
||||
await onSubmit()
|
||||
.then(() => {
|
||||
setToast({
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: "Success!",
|
||||
message: `Issue deleted successfully`,
|
||||
});
|
||||
})
|
||||
.catch((errors) => {
|
||||
const isPermissionError = errors?.error === "Only admin or creator can delete the issue";
|
||||
const currentError = isPermissionError
|
||||
? PROJECT_ERROR_MESSAGES.permissionError
|
||||
: PROJECT_ERROR_MESSAGES.issueDeleteError;
|
||||
setToast({
|
||||
title: currentError.title,
|
||||
type: TOAST_TYPE.ERROR,
|
||||
message: currentError.message,
|
||||
});
|
||||
})
|
||||
.finally(() => handleClose());
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue