From c5d4a2f7825d5b0b65a3f54c82d9c8d91f202952 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Thu, 26 Jun 2025 13:57:25 +0300 Subject: [PATCH] fix update order via strapi ui --- .../order/content-types/order/lifecycles.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/api/order/content-types/order/lifecycles.ts b/src/api/order/content-types/order/lifecycles.ts index fadcb53..9f38cb7 100644 --- a/src/api/order/content-types/order/lifecycles.ts +++ b/src/api/order/content-types/order/lifecycles.ts @@ -64,6 +64,19 @@ export default { return; } + const existingOrder = await strapi.db.query('api::order.order').findOne({ + where: { id: entityId }, + select: ['documentId'], + populate: ['slot'], + }); + + if ( + existingOrder.time_start === time_start && + existingOrder.time_end === time_end + ) { + return; + } + if (!time_start || !time_end) { throw new Error(ERR_INVALID_TIME); } @@ -72,12 +85,6 @@ export default { throw new Error(ERR_INVALID_TIME); } - const existingOrder = await strapi.db.query('api::order.order').findOne({ - where: { id: entityId }, - select: ['documentId'], - populate: ['slot'], - }); - if (!existingOrder || !existingOrder.slot) { throw new Error('Существующий заказ или слот не найден'); }