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 await issuesService
.createIssueLink(workspaceSlug as string, projectId as string, issueDetail.id, payload) .createIssueLink(workspaceSlug as string, projectId as string, issueDetail.id, payload)
.then((res) => { .then(() => mutate(ISSUE_DETAILS(issueDetail.id)))
mutate(ISSUE_DETAILS(issueDetail.id));
})
.catch((err) => { .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,14 +107,19 @@ export const ModuleDetailsSidebar: React.FC<Props> = ({
await modulesService await modulesService
.createModuleLink(workspaceSlug as string, projectId as string, moduleId as string, payload) .createModuleLink(workspaceSlug as string, projectId as string, moduleId as string, payload)
.then((res) => { .then(() => mutate(MODULE_DETAILS(moduleId as string)))
mutate(MODULE_DETAILS(moduleId as string));
})
.catch((err) => { .catch((err) => {
if (err.status === 400)
setToastAlert({ setToastAlert({
type: "error", type: "error",
title: "Error!", title: "Error!",
message: "Couldn't create the link. Please try again.", 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) .then((response) => response?.data)
.catch((error) => { .catch((error) => {
throw error?.response?.data; throw error?.response;
}); });
} }

View File

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