Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: fixing time range conditions M2-8301 #908

Merged
merged 4 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/entities/conditional-logic/model/conditions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ describe('[isEqualToValue] function', () => {
{ a: 1, b: 2 },
{ a: 'Hello', b: 'Bye' },
{ a: 0, b: -1 },
{ a: {}, b: {} },
];

differentValueTestCases.forEach(({ a, b }) => {
Expand Down
25 changes: 19 additions & 6 deletions src/entities/conditional-logic/model/conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ export const isEqualToValue = (
if (input == null) {
return false;
}

return input === valueToCompareWith;
return input.toString() === valueToCompareWith.toString();
};

export const isGreaterThan = (
Expand Down Expand Up @@ -146,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;

Expand All @@ -163,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;

Expand All @@ -181,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;

Expand All @@ -199,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;

Expand Down
Loading