feat: issues alerts

This commit is contained in:
anmolsinghbhatia 2023-04-28 14:26:29 +05:30
parent 1b06b21087
commit 2836161107
6 changed files with 42 additions and 8 deletions

View File

@ -174,8 +174,9 @@ export const SingleBoardIssue: React.FC<Props> = ({
mutate(MODULE_DETAILS(moduleId as string));
} else mutate(PROJECT_ISSUES_LIST_WITH_PARAMS(projectId as string, params));
setToastAlert({
type: "info",
title: "Issue Updated Successfully",
type: "success",
title: "Success",
message: "Issue updated successfully.",
});
})
.catch((error) => {

View File

@ -150,8 +150,9 @@ export const SingleListIssue: React.FC<Props> = ({
mutate(MODULE_DETAILS(moduleId as string));
} else mutate(PROJECT_ISSUES_LIST_WITH_PARAMS(projectId as string, params));
setToastAlert({
type: "info",
title: "Issue Updated Successfully",
type: "success",
title: "Success",
message: "Issue updated successfully.",
});
})
.catch((error) => {

View File

@ -179,7 +179,7 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = ({
setToastAlert({
type: "success",
title: "Success!",
title: "Success",
message: "Issue updated successfully.",
});
})

View File

@ -58,8 +58,9 @@ export const MyIssuesListItem: React.FC<Props> = ({ issue, properties, projectId
.then((res) => {
mutate(USER_ISSUE(workspaceSlug as string));
setToastAlert({
type: "info",
title: "Issue Updated Successfully",
type: "success",
title: "Success",
message: "Issue updated successfully.",
});
})
.catch((error) => {

View File

@ -156,7 +156,14 @@ export const IssueDetailsSidebar: React.FC<Props> = ({
await issuesService
.createIssueLink(workspaceSlug as string, projectId as string, issueDetail.id, payload)
.then(() => mutate(ISSUE_DETAILS(issueDetail.id)))
.then(() => {
mutate(ISSUE_DETAILS(issueDetail.id));
setToastAlert({
type: "success",
title: "Success",
message: "Link added successfully",
});
})
.catch((err) => {
if (err.status === 400)
setToastAlert({
@ -188,9 +195,19 @@ export const IssueDetailsSidebar: React.FC<Props> = ({
.deleteIssueLink(workspaceSlug as string, projectId as string, issueDetail.id, linkId)
.then((res) => {
mutate(ISSUE_DETAILS(issueDetail.id));
setToastAlert({
title: "Success",
message: "Link removed successfully",
type: "success",
});
})
.catch((err) => {
console.log(err);
setToastAlert({
type: "error",
title: "Error!",
message: "Something went wrong. Please try again.",
});
});
};

View File

@ -7,6 +7,8 @@ import useSWR, { mutate } from "swr";
// react-hook-form
import { useForm } from "react-hook-form";
// hooks
import useToast from "hooks/use-toast";
// services
import issuesService from "services/issues.service";
// layouts
@ -50,6 +52,8 @@ const IssueDetailsPage: NextPage = () => {
const router = useRouter();
const { workspaceSlug, projectId, issueId } = router.query;
const { setToastAlert } = useToast();
const { data: issueDetails, mutate: mutateIssueDetails } = useSWR<IIssue | undefined>(
workspaceSlug && projectId && issueId ? ISSUE_DETAILS(issueId as string) : null,
workspaceSlug && projectId && issueId
@ -93,9 +97,19 @@ const IssueDetailsPage: NextPage = () => {
.then((res) => {
mutateIssueDetails();
mutate(PROJECT_ISSUES_ACTIVITY(issueId as string));
setToastAlert({
type: "success",
title: "Success",
message: "Issue updated successfully.",
});
})
.catch((e) => {
console.error(e);
setToastAlert({
type: "error",
title: "Error!",
message: "Something went wrong. Please try again.",
});
});
},
[workspaceSlug, issueId, projectId, mutateIssueDetails]