diff --git a/packages/graphql/api/orders.ts b/packages/graphql/api/orders.ts index f64eded..f9b55fa 100644 --- a/packages/graphql/api/orders.ts +++ b/packages/graphql/api/orders.ts @@ -67,6 +67,15 @@ export class OrdersService extends BaseService { } } + if (isMaster) { + const { customers: myMasters } = await customersService.getMasters(this.customer); + + const clientId = variables.input.client; + const isTryingToRecordMaster = myMasters.some((master) => master?.documentId === clientId); + + if (isTryingToRecordMaster) throw new Error(ERRORS.INVALID_CLIENT); + } + if (isMaster && slot?.master?.documentId !== customer.documentId) { throw new Error(ERRORS.INVALID_MASTER); }