From 81dfdec7a5aa316f6c08c2f2ad0f5f9b4cca435b Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Tue, 5 Aug 2025 13:48:21 +0300 Subject: [PATCH] refactor(slots): rename validation methods for clarity and consistency in slot service --- packages/graphql/api/slots.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/graphql/api/slots.ts b/packages/graphql/api/slots.ts index df601dd..ceb3b18 100644 --- a/packages/graphql/api/slots.ts +++ b/packages/graphql/api/slots.ts @@ -24,7 +24,7 @@ export const ERRORS = { export class SlotsService extends BaseService { async createSlot(variables: VariablesOf) { - await this.checkCreate(variables); + await this.checkBeforeCreate(variables); const { customer } = await this._getUser(); @@ -48,7 +48,7 @@ export class SlotsService extends BaseService { } async deleteSlot(variables: VariablesOf) { - await this.checkUpdatePermission(variables); + await this.checkPermission(variables); const { slot } = await this.getSlot({ documentId: variables.documentId }); @@ -158,8 +158,8 @@ export class SlotsService extends BaseService { } async updateSlot(variables: VariablesOf) { - await this.checkUpdatePermission(variables); - await this.checkUpdateDatetime(variables); + await this.checkPermission(variables); + await this.checkBeforeUpdateDatetime(variables); const { mutate } = await getClientWithToken(); @@ -174,7 +174,7 @@ export class SlotsService extends BaseService { return mutationResult.data; } - private async checkCreate(variables: VariablesOf) { + private async checkBeforeCreate(variables: VariablesOf) { const { datetime_end, datetime_start } = variables.input; if (!datetime_start) throw new Error(ERRORS.MISSING_DATETIME_START); @@ -216,7 +216,7 @@ export class SlotsService extends BaseService { } } - private async checkUpdateDatetime(variables: VariablesOf) { + private async checkBeforeUpdateDatetime(variables: VariablesOf) { const { slot } = await this.getSlot({ documentId: variables.documentId }); if (!slot) throw new Error(ERRORS.NOT_FOUND_SLOT); @@ -269,7 +269,7 @@ export class SlotsService extends BaseService { } } - private async checkUpdatePermission( + private async checkPermission( variables: Pick, 'documentId'>, ) { const { customer } = await this._getUser();