From ebe8ee543745d9e506b221b5ae82aac4196161b7 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Wed, 21 May 2025 17:47:53 +0300 Subject: [PATCH] fix build --- apps/web/components/schedule/components/time-range.tsx | 9 ++++----- apps/web/components/schedule/types/index.tsx | 1 + packages/graphql/api/orders.ts | 4 ++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/web/components/schedule/components/time-range.tsx b/apps/web/components/schedule/components/time-range.tsx index 129357d..18cbf0a 100644 --- a/apps/web/components/schedule/components/time-range.tsx +++ b/apps/web/components/schedule/components/time-range.tsx @@ -1,6 +1,7 @@ 'use client'; import { ScheduleTimeContext } from '../context'; +import { type OrderTimeRange } from '../types'; import { formatTime } from '@repo/graphql/utils/datetime-format'; import { Input } from '@repo/ui/components/ui/input'; import { cn } from '@repo/ui/lib/utils'; @@ -11,11 +12,9 @@ type EditableTimeRangeProps = { readonly onSubmit: (event: FormEvent) => void; }; -type TimeRangeProps = { +type TimeRangeProps = OrderTimeRange & { readonly className?: string; readonly delimiter?: boolean; - readonly time_end: string; - readonly time_start: string; }; export function EditableTimeRangeForm({ @@ -62,9 +61,9 @@ export function ReadonlyTimeRange({ }: Readonly) { return (
- {formatTime(time_start).user()} + {time_start ? formatTime(time_start).user() : 'xx:xx'} {delimiter && ' - '} - {formatTime(time_end).user()} + {time_end ? formatTime(time_end).user() : 'xx:xx'}
); } diff --git a/apps/web/components/schedule/types/index.tsx b/apps/web/components/schedule/types/index.tsx index f82eab7..e177b89 100644 --- a/apps/web/components/schedule/types/index.tsx +++ b/apps/web/components/schedule/types/index.tsx @@ -2,5 +2,6 @@ import type * as GQL from '@repo/graphql/types'; export type OrderClient = NonNullable['client']; export type OrderComponentProps = Pick; +export type OrderTimeRange = Pick; export type Slot = NonNullable; export type SlotComponentProps = Pick; diff --git a/packages/graphql/api/orders.ts b/packages/graphql/api/orders.ts index dfe002b..714ab62 100644 --- a/packages/graphql/api/orders.ts +++ b/packages/graphql/api/orders.ts @@ -12,6 +12,7 @@ import { type VariablesOf } from '@graphql-typed-document-node/core'; const ERRORS = { INVALID_CLIENT: 'Invalid client', INVALID_MASTER: 'Invalid master', + INVALID_SERVICE_DURATION: 'Invalid service duration', MISSING_CLIENT: 'Missing client id', MISSING_SERVICE_ID: 'Missing service id', MISSING_SERVICES: 'Missing services', @@ -63,6 +64,9 @@ export class OrdersService extends BaseService { const { service } = await servicesService.getService({ documentId: variables.input.services[0], }); + + if (!service?.duration) throw new Error(ERRORS.INVALID_SERVICE_DURATION); + const endTime = sumTime(variables.input.time_start, service?.duration); const { mutate } = await getClientWithToken(); const mutationResult = await mutate({