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)); mutate(MODULE_DETAILS(moduleId as string));
} else mutate(PROJECT_ISSUES_LIST_WITH_PARAMS(projectId as string, params)); } else mutate(PROJECT_ISSUES_LIST_WITH_PARAMS(projectId as string, params));
setToastAlert({ setToastAlert({
type: "info", type: "success",
title: "Issue Updated Successfully", title: "Success",
message: "Issue updated successfully.",
}); });
}) })
.catch((error) => { .catch((error) => {

View File

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

View File

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

View File

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

View File

@ -156,7 +156,14 @@ export const IssueDetailsSidebar: React.FC<Props> = ({
await issuesService await issuesService
.createIssueLink(workspaceSlug as string, projectId as string, issueDetail.id, payload) .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) => { .catch((err) => {
if (err.status === 400) if (err.status === 400)
setToastAlert({ setToastAlert({
@ -188,9 +195,19 @@ export const IssueDetailsSidebar: React.FC<Props> = ({
.deleteIssueLink(workspaceSlug as string, projectId as string, issueDetail.id, linkId) .deleteIssueLink(workspaceSlug as string, projectId as string, issueDetail.id, linkId)
.then((res) => { .then((res) => {
mutate(ISSUE_DETAILS(issueDetail.id)); mutate(ISSUE_DETAILS(issueDetail.id));
setToastAlert({
title: "Success",
message: "Link removed successfully",
type: "success",
});
}) })
.catch((err) => { .catch((err) => {
console.log(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 // react-hook-form
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
// hooks
import useToast from "hooks/use-toast";
// services // services
import issuesService from "services/issues.service"; import issuesService from "services/issues.service";
// layouts // layouts
@ -50,6 +52,8 @@ const IssueDetailsPage: NextPage = () => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId, issueId } = router.query; const { workspaceSlug, projectId, issueId } = router.query;
const { setToastAlert } = useToast();
const { data: issueDetails, mutate: mutateIssueDetails } = useSWR<IIssue | undefined>( const { data: issueDetails, mutate: mutateIssueDetails } = useSWR<IIssue | undefined>(
workspaceSlug && projectId && issueId ? ISSUE_DETAILS(issueId as string) : null, workspaceSlug && projectId && issueId ? ISSUE_DETAILS(issueId as string) : null,
workspaceSlug && projectId && issueId workspaceSlug && projectId && issueId
@ -93,9 +97,19 @@ const IssueDetailsPage: NextPage = () => {
.then((res) => { .then((res) => {
mutateIssueDetails(); mutateIssueDetails();
mutate(PROJECT_ISSUES_ACTIVITY(issueId as string)); mutate(PROJECT_ISSUES_ACTIVITY(issueId as string));
setToastAlert({
type: "success",
title: "Success",
message: "Issue updated successfully.",
});
}) })
.catch((e) => { .catch((e) => {
console.error(e); console.error(e);
setToastAlert({
type: "error",
title: "Error!",
message: "Something went wrong. Please try again.",
});
}); });
}, },
[workspaceSlug, issueId, projectId, mutateIssueDetails] [workspaceSlug, issueId, projectId, mutateIssueDetails]