From 9061c6eda3dece59b7a74444636b674b015b8f85 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Sat, 2 Aug 2025 11:07:18 +0300 Subject: [PATCH] feat(slots): add time validation to prevent past slot selection --- packages/graphql/api/slots.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/graphql/api/slots.ts b/packages/graphql/api/slots.ts index e5473b7..e051c68 100644 --- a/packages/graphql/api/slots.ts +++ b/packages/graphql/api/slots.ts @@ -80,6 +80,9 @@ export class SlotsService extends BaseService { const slots = getSlotsResult.data.slots; const times: Array<{ slotId: string; time: string }> = []; + + const now = dayjs(); + for (const slot of slots) { if (!slot?.datetime_start || !slot?.datetime_end) continue; @@ -98,7 +101,7 @@ export class SlotsService extends BaseService { potentialDatetimeEnd.isAfter(dayjs(order.datetime_start)), ); - if (!hasConflict) { + if (!hasConflict && datetimeStart.isAfter(now, 'minute')) { times.push({ slotId: slot.documentId, time: datetimeStart.toISOString() }); }