fix(api/orders): update master validation logic to handle optional masters

This commit is contained in:
vchikalkin 2025-07-03 12:00:50 +03:00
parent b7a217787d
commit 7f86fc164d

View File

@ -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);
}
}