diff --git a/packages/graphql/api/slots.ts b/packages/graphql/api/slots.ts index 3ba9837..405b4c0 100644 --- a/packages/graphql/api/slots.ts +++ b/packages/graphql/api/slots.ts @@ -7,6 +7,7 @@ import { getMinutes } from '@repo/utils/datetime-format'; import dayjs from 'dayjs'; const ERRORS = { + HAS_ORDERS: 'Slot has orders', MISSING_DATE: 'Missing date', MISSING_SERVICE: 'Missing service', MISSING_SERVICE_ID: 'Missing service id', @@ -39,6 +40,12 @@ export class SlotsService extends BaseService { async deleteSlot(variables: VariablesOf) { await this.checkPermission(variables); + const { slot } = await this.getSlot({ documentId: variables.documentId }); + + if (slot?.orders?.length) { + throw new Error(ERRORS.HAS_ORDERS); + } + const { mutate } = await getClientWithToken(); const mutationResult = await mutate({