From 7f86fc164dfa56baeb18913b9f53101a24938d74 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Thu, 3 Jul 2025 12:00:50 +0300 Subject: [PATCH] fix(api/orders): update master validation logic to handle optional masters --- packages/graphql/api/orders.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/graphql/api/orders.ts b/packages/graphql/api/orders.ts index c9fae88..2b2f274 100644 --- a/packages/graphql/api/orders.ts +++ b/packages/graphql/api/orders.ts @@ -52,10 +52,11 @@ export class OrdersService extends BaseService { throw new Error(ERRORS.INVALID_CLIENT); } - const masters = await customersService.getMasters(this.customer); + const { customers } = await customersService.getMasters(this.customer); + const masters = customers.at(0)?.masters; const masterId = slot?.master?.documentId; - if (!masters.customers.some((master) => master?.documentId === masterId)) { + if (!masters?.some((master) => master?.documentId === masterId)) { throw new Error(ERRORS.INVALID_MASTER); } }