fix: user cannot create duplicate links (#680)

This commit is contained in:
Aaryan Khandelwal 2023-04-03 16:22:37 +05:30 committed by GitHub
parent a63c551e75
commit 1b30e4b57f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 14 deletions

View File

@ -153,11 +153,20 @@ export const IssueDetailsSidebar: React.FC<Props> = ({
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.",
});
});
};

View File

@ -107,15 +107,20 @@ export const ModuleDetailsSidebar: React.FC<Props> = ({
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.",
});
});
};

View File

@ -343,7 +343,7 @@ class ProjectIssuesServices extends APIService {
)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
throw error?.response;
});
}

View File

@ -175,7 +175,7 @@ class ProjectIssuesServices extends APIService {
)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
throw error?.response;
});
}