Skip to content

Commit

Permalink
[ReviewEntries] Prevent duplicate semantic domain on a sense (#2573)
Browse files Browse the repository at this point in the history
  • Loading branch information
imnasnainaec authored Sep 14, 2023
1 parent db14c8c commit 51243a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@
"noDefinition": "No definitions input",
"noGloss": "No glosses input",
"noDomain": "No domain selected",
"duplicateDomain": "This sense already has domain {{ val }}.",
"noNote": "No note",
"deleteWordWarning": "This word will be permanently deleted!",
"deleteDisabled": "This was imported with data that The Combine doesn't handle, so it may not be deleted.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Chip, Dialog, Grid, IconButton } from "@mui/material";
import React, { ReactElement, useState } from "react";
import { useTranslation } from "react-i18next";
import { useSelector } from "react-redux";
import { toast } from "react-toastify";

import { SemanticDomain } from "api/models";
import { getCurrentUser } from "backend/localStorage";
Expand Down Expand Up @@ -47,7 +48,13 @@ export default function DomainCell(props: DomainCellProps): ReactElement {
);
}
if (selectedDomain.mongoId == "") {
throw new Error("SelectedSemanticDomainTreeNode have no mongoId");
throw new Error("SelectedSemanticDomainTreeNode have no mongoId.");
}
if (senseToChange.domains.find((d) => d.id === selectedDomain.id)) {
toast.error(
t("reviewEntries.duplicateDomain", { val: selectedDomain.id })
);
return;
}
props.editDomains(senseToChange.guid, [
...senseToChange.domains,
Expand Down

0 comments on commit 51243a5

Please sign in to comment.