From 56e475d61f196f879fe0836aeaa782390d41f140 Mon Sep 17 00:00:00 2001 From: shancheas Date: Wed, 11 Jun 2025 19:03:09 +0700 Subject: [PATCH] fix: ensure time_group data is only accessed if it exists in BookingOrderController --- .../order/infrastructure/order.controller.ts | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/modules/booking-online/order/infrastructure/order.controller.ts b/src/modules/booking-online/order/infrastructure/order.controller.ts index e5d24cb..01edcae 100644 --- a/src/modules/booking-online/order/infrastructure/order.controller.ts +++ b/src/modules/booking-online/order/infrastructure/order.controller.ts @@ -156,21 +156,23 @@ export class BookingOrderController { const usageItems = items.map((item) => { const itemData = item.item; - const timeGroupData = itemData.time_group; - const { - id: groupId, - name, - start_time, - end_time, - max_usage_time, - } = timeGroupData; - timeGroup = { - id: groupId, - name, - start_time, - end_time, - max_usage_time, - }; + if (itemData.time_group) { + const timeGroupData = itemData.time_group; + const { + id: groupId, + name, + start_time, + end_time, + max_usage_time, + } = timeGroupData; + timeGroup = { + id: groupId, + name, + start_time, + end_time, + max_usage_time, + }; + } const { id, item_id,