Skip to content

Commit

Permalink
Merge pull request #188 from samply/fix/remove-nodeType-from-catalog
Browse files Browse the repository at this point in the history
fix: remove nodeType from catalogue types
  • Loading branch information
patrickskowronekdkfz authored Feb 3, 2025
2 parents 9e5d7e4 + 3f721e9 commit 1e0bb7f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<InfoButtonComponent message={element.infoButtonText} />
{/if}

{#if element.nodeType === "branch" && element.infoLink !== undefined}
{#if "infoLink" in element && element.infoLink !== undefined}
<a href={element.infoLink.link} target="_blank"
>{element.infoLink.display}</a
>
Expand Down
6 changes: 3 additions & 3 deletions packages/lib/src/stores/catalogue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const resolveElementInCatalogueRec = (
): string[] => {
let newCri: string[] = [];

if (node.nodeType === "leaf") {
if ("criteria" in node) {
if (node.key === key) {
for (const cri of node.criteria) {
if (cri.key == value) {
Expand All @@ -51,7 +51,7 @@ const resolveElementInCatalogueRec = (
}
}
}
} else if (node.nodeType === "branch") {
} else {
node.childCategories?.forEach((y) => {
newCri = newCri.concat(resolveElementInCatalogueRec(key, value, y));
});
Expand All @@ -64,7 +64,7 @@ const resolveElementInCatalogue = (key: string, value: string): string[] => {
let subcatagories: string[] = [];
catalogue.subscribe((x) => {
x.forEach((element) => {
if (element.nodeType === "branch") {
if ("childCategories" in element) {
element.childCategories.forEach((y: Category) => {
subcatagories = subcatagories.concat(
resolveElementInCatalogueRec(key, value, y),
Expand Down
2 changes: 0 additions & 2 deletions packages/lib/src/types/treeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export type TreeNode =
export type Category = CategoryBranch | CategoryLeaf;

export type CategoryBranch = {
nodeType: "branch";
key: string;
name: string;
childCategories: Category[];
Expand All @@ -23,7 +22,6 @@ export type InfoLink = {
};

export type CategoryLeaf = {
nodeType: "leaf";
key: string;
name: string;
system?: string;
Expand Down

0 comments on commit 1e0bb7f

Please sign in to comment.