diff --git a/src/api/order/content-types/order/lifecycles.ts b/src/api/order/content-types/order/lifecycles.ts index 8c7a42c..370062c 100644 --- a/src/api/order/content-types/order/lifecycles.ts +++ b/src/api/order/content-types/order/lifecycles.ts @@ -174,6 +174,10 @@ export default { async beforeCreate(event) { const { data } = event.params; const { datetime_start, datetime_end, client, services } = data; + + const isUpdate = !!data?.publishedAt; + if (isUpdate) return; + const clientId = extractId(client); const slotId = extractId(data.slot); @@ -193,7 +197,7 @@ export default { // Проверка, что заказ не создается на время в прошлом const now = dayjs().tz(DEFAULT_TZ); const orderStart = dayjs(datetime_start).tz(DEFAULT_TZ); - + if (orderStart.isBefore(now, 'minute')) { throw new Error(ERR_ORDER_IN_PAST); } diff --git a/src/api/slot/content-types/slot/lifecycles.ts b/src/api/slot/content-types/slot/lifecycles.ts index aae12dd..3a5c18a 100644 --- a/src/api/slot/content-types/slot/lifecycles.ts +++ b/src/api/slot/content-types/slot/lifecycles.ts @@ -24,6 +24,9 @@ export default { const { data } = event.params; const { master, datetime_start, datetime_end } = data; + const isUpdate = !!data?.publishedAt; + if (isUpdate) return; + // Проверка, что мастер существует и активен const masterId = extractId(master); const masterEntity = await strapi.db