diff --git a/apps/app/components/issues/sidebar.tsx b/apps/app/components/issues/sidebar.tsx index d39b4158a..bda5cdd01 100644 --- a/apps/app/components/issues/sidebar.tsx +++ b/apps/app/components/issues/sidebar.tsx @@ -153,11 +153,20 @@ export const IssueDetailsSidebar: React.FC = ({ await issuesService .createIssueLink(workspaceSlug as string, projectId as string, issueDetail.id, payload) - .then((res) => { - mutate(ISSUE_DETAILS(issueDetail.id)); - }) + .then(() => mutate(ISSUE_DETAILS(issueDetail.id))) .catch((err) => { - console.log(err); + if (err.status === 400) + setToastAlert({ + type: "error", + title: "Error!", + message: "This URL already exists for this issue.", + }); + else + setToastAlert({ + type: "error", + title: "Error!", + message: "Something went wrong. Please try again.", + }); }); }; diff --git a/apps/app/components/modules/sidebar.tsx b/apps/app/components/modules/sidebar.tsx index f1a174692..4ecf8cdd2 100644 --- a/apps/app/components/modules/sidebar.tsx +++ b/apps/app/components/modules/sidebar.tsx @@ -107,15 +107,20 @@ export const ModuleDetailsSidebar: React.FC = ({ await modulesService .createModuleLink(workspaceSlug as string, projectId as string, moduleId as string, payload) - .then((res) => { - mutate(MODULE_DETAILS(moduleId as string)); - }) + .then(() => mutate(MODULE_DETAILS(moduleId as string))) .catch((err) => { - setToastAlert({ - type: "error", - title: "Error!", - message: "Couldn't create the link. Please try again.", - }); + if (err.status === 400) + setToastAlert({ + type: "error", + title: "Error!", + message: "This URL already exists for this module.", + }); + else + setToastAlert({ + type: "error", + title: "Error!", + message: "Something went wrong. Please try again.", + }); }); }; diff --git a/apps/app/services/issues.service.ts b/apps/app/services/issues.service.ts index e6848f7b5..d23ff33f2 100644 --- a/apps/app/services/issues.service.ts +++ b/apps/app/services/issues.service.ts @@ -343,7 +343,7 @@ class ProjectIssuesServices extends APIService { ) .then((response) => response?.data) .catch((error) => { - throw error?.response?.data; + throw error?.response; }); } diff --git a/apps/app/services/modules.service.ts b/apps/app/services/modules.service.ts index 419d6033c..1fe3aaac5 100644 --- a/apps/app/services/modules.service.ts +++ b/apps/app/services/modules.service.ts @@ -175,7 +175,7 @@ class ProjectIssuesServices extends APIService { ) .then((response) => response?.data) .catch((error) => { - throw error?.response?.data; + throw error?.response; }); }