Skip to content

Commit 18bf0cb

Browse files
authored
fix: properly get key from BU reference (#363)
1 parent ac3a7c0 commit 18bf0cb

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

.changeset/fine-lemons-care.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@labdigital/commercetools-mock": patch
3+
---
4+
5+
properly fetch the business unit key in getBusinessUnitKeyReference

src/repositories/helpers.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import type {
1010
AssociateRoleResourceIdentifier,
1111
BaseAddress,
1212
BusinessUnitKeyReference,
13-
BusinessUnitReference,
1413
BusinessUnitResourceIdentifier,
1514
CentPrecisionMoney,
1615
CustomFields,
@@ -323,18 +322,17 @@ export const getBusinessUnitKeyReference = (
323322
};
324323
}
325324

326-
const value = getReferenceFromResourceIdentifier<BusinessUnitReference>(
327-
id,
325+
const resource = storage.getByResourceIdentifier<"business-unit">(
328326
projectKey,
329-
storage,
327+
id,
330328
);
331329

332-
if (!value.obj?.key) {
330+
if (!resource?.key) {
333331
throw new Error("No business-unit found for reference");
334332
}
335333

336334
return {
337335
typeId: "business-unit",
338-
key: value.obj?.key,
336+
key: resource.key,
339337
};
340338
};

0 commit comments

Comments
 (0)