From 4c7f92f3a1ba65f43b1152d446698750444e916a Mon Sep 17 00:00:00 2001 From: felipeMetaLab Date: Mon, 2 Dec 2024 13:05:49 -0800 Subject: [PATCH] Fix: fixing time range conditions M2-8301 (#908) * fix/M2-8277_fixing_EqualToValue * fixing is greater than time range condition * fix: fixing time range condition * fixing unit test --------- Co-authored-by: Felipe Imperio --- .../conditional-logic/model/conditions.ts | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/entities/conditional-logic/model/conditions.ts b/src/entities/conditional-logic/model/conditions.ts index 300288a1e..6e6cf9948 100644 --- a/src/entities/conditional-logic/model/conditions.ts +++ b/src/entities/conditional-logic/model/conditions.ts @@ -145,8 +145,12 @@ export const isGreaterThanTimeRange = ( }>, { time, fieldName }: { time: HourMinute; fieldName: string }, ): boolean => { - if (!isValidTimeFormat(time) || !timeRange) return false; + if (!time || !timeRange) return false; + const selectedTime = getTimeBasedOnFieldName(fieldName, timeRange); + + if (!isValidTimeFormat(selectedTime)) return false; + const normalizedTime = typeof time === 'string' ? parseTimeString(time) : time; @@ -162,9 +166,12 @@ export const isLessThanTimeRange = ( }>, { time, fieldName }: { time: HourMinute; fieldName: string }, ): boolean => { - if (!isValidTimeFormat(time) || !timeRange) return false; + if (!time || !timeRange) return false; const selectedTime = getTimeBasedOnFieldName(fieldName, timeRange); + + if (!isValidTimeFormat(selectedTime)) return false; + const normalizedTime = typeof time === 'string' ? parseTimeString(time) : time; @@ -180,9 +187,12 @@ export const isEqualToTimeRange = ( }>, { time, fieldName }: { time: HourMinute; fieldName: string }, ): boolean => { - if (!isValidTimeFormat(time) || !timeRange) return false; + if (!time || !timeRange) return false; const selectedTime = getTimeBasedOnFieldName(fieldName, timeRange); + + if (!isValidTimeFormat(selectedTime)) return false; + const normalizedTime = typeof time === 'string' ? parseTimeString(time) : time; @@ -198,8 +208,12 @@ export const isNotEqualToTimeRange = ( }>, { time, fieldName }: { time: HourMinute; fieldName: string }, ): boolean => { - if (!isValidTimeFormat(time) || !timeRange) return false; + if (!time || !timeRange) return false; + const selectedTime = getTimeBasedOnFieldName(fieldName, timeRange); + + if (!isValidTimeFormat(selectedTime)) return false; + const normalizedTime = typeof time === 'string' ? parseTimeString(time) : time;