From 48d84fb158ae1c533fdf6a44dafb8d94a4b5138d Mon Sep 17 00:00:00 2001 From: Joost Smit Date: Tue, 10 Dec 2024 13:15:49 +0100 Subject: [PATCH 1/3] fix: set empty array for associates when creating a business unit --- src/repositories/business-unit.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/repositories/business-unit.ts b/src/repositories/business-unit.ts index 2b5d267..2c8f528 100644 --- a/src/repositories/business-unit.ts +++ b/src/repositories/business-unit.ts @@ -93,7 +93,7 @@ export class BusinessUnitRepository extends AbstractResourceRepository<"business associates: draft.associates?.map((a) => createAssociate(a, context.projectKey, this._storage), - ), + ) ?? [], }; if (this._isDivisionDraft(draft)) { @@ -130,8 +130,7 @@ export class BusinessUnitRepository extends AbstractResourceRepository<"business class BusinessUnitUpdateHandler extends AbstractUpdateHandler implements - Partial> -{ + Partial> { addAddress( context: RepositoryContext, resource: Writable, From f817329f6859c097cf792fc298564c4db5b4831f Mon Sep 17 00:00:00 2001 From: Joost Smit Date: Tue, 10 Dec 2024 13:19:43 +0100 Subject: [PATCH 2/3] fix: formatting --- src/repositories/business-unit.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/repositories/business-unit.ts b/src/repositories/business-unit.ts index 2c8f528..873cb8e 100644 --- a/src/repositories/business-unit.ts +++ b/src/repositories/business-unit.ts @@ -91,9 +91,10 @@ export class BusinessUnitRepository extends AbstractResourceRepository<"business associateMode: draft.associateMode, approvalRuleMode: draft.approvalRuleMode, - associates: draft.associates?.map((a) => - createAssociate(a, context.projectKey, this._storage), - ) ?? [], + associates: + draft.associates?.map((a) => + createAssociate(a, context.projectKey, this._storage), + ) ?? [], }; if (this._isDivisionDraft(draft)) { @@ -130,7 +131,8 @@ export class BusinessUnitRepository extends AbstractResourceRepository<"business class BusinessUnitUpdateHandler extends AbstractUpdateHandler implements - Partial> { + Partial> +{ addAddress( context: RepositoryContext, resource: Writable, From 20b794ab217bbb695f4b392635984d6eff2bc7b6 Mon Sep 17 00:00:00 2001 From: Joost Smit Date: Tue, 10 Dec 2024 13:21:30 +0100 Subject: [PATCH 3/3] fix: add changeset --- .changeset/lovely-rabbits-hear.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/lovely-rabbits-hear.md diff --git a/.changeset/lovely-rabbits-hear.md b/.changeset/lovely-rabbits-hear.md new file mode 100644 index 0000000..0fb0195 --- /dev/null +++ b/.changeset/lovely-rabbits-hear.md @@ -0,0 +1,5 @@ +--- +"@labdigital/commercetools-mock": patch +--- + +Allow setting associates to business unit, if its created without associates