feat(slots): add time validation to prevent past slot selection

This commit is contained in:
vchikalkin 2025-08-02 11:07:18 +03:00
parent 10981e2afb
commit 9061c6eda3

View File

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