fix: add validation to ensure order times fall within the specified slot boundaries

This commit is contained in:
vchikalkin 2025-07-18 14:55:09 +03:00
parent d42e240a2a
commit d91cabaed0

View File

@ -39,6 +39,14 @@ export default {
});
if (!slot) throw new Error(ERR_MISSING_SLOT);
// Проверка, что заказ укладывается в рамки слота
if (
new Date(datetime_start) < new Date(slot.datetime_start) ||
new Date(datetime_end) > new Date(slot.datetime_end)
) {
throw new Error('Время заказа выходит за пределы слота');
}
// 1. Слот не должен быть закрыт
if (slot.state === 'closed') {
throw new Error(ERR_SLOT_CLOSED);