Skip to content

Commit 0b5cea9

Browse files
committed
hotfix: metadata editor causing crash in the dashboard shipment page
1 parent 18d5ddc commit 0b5cea9

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

packages/hooks/metadata.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@ const MetadataStateProvider = ({
5757
if (isNone(key) && isNone(value) && Object.keys(state).length == 1) {
5858
return acc;
5959
}
60-
// This means that we have more than one metadata items with the same key
61-
if (Object.keys(acc).includes(key as string)) {
62-
let error: any | Error = new Error("Metadata keys must be unique.");
63-
error.key = key;
64-
throw error;
65-
}
6660
// This means that the metadata item has undefined key and/or value
6761
if (isNoneOrEmpty(key) || isNoneOrEmpty(value)) {
6862
let error: any | Error = new Error(
@@ -71,7 +65,14 @@ const MetadataStateProvider = ({
7165
error.key = key;
7266
throw error;
7367
}
74-
return { ...acc, [key as string]: value };
68+
// Convert key to string and check for uniqueness
69+
const stringKey = String(key);
70+
if (Object.keys(acc).includes(stringKey)) {
71+
let error: any | Error = new Error("Metadata keys must be unique.");
72+
error.key = key;
73+
throw error;
74+
}
75+
return { ...acc, [stringKey]: value };
7576
}, {});
7677
let discarded_keys = Object.keys(value || {}).filter(
7778
(key) => !Object.keys(added_values).includes(key),

packages/ui/core/forms/metadata-editor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ export const MetadataEditor = ({
8080
<div className="column p-1">
8181
{!isEditing && (
8282
<>
83-
{value?.includes("http://") ||
84-
value?.includes("https://") ? (
83+
{typeof value === "string" &&
84+
(value.includes("http://") || value.includes("https://")) ? (
8585
<a
8686
href={value}
8787
target="_blank"

0 commit comments

Comments
 (0)