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

M2-7011: feat conditional logic extend item type #883

Merged
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
6 changes: 6 additions & 0 deletions src/entities/activity/lib/services/timeToMinutes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const timeToMinutes = (time: {
hours: number;
minutes: number;
}): number => {
return time.hours * 60 + time.minutes;
};
328 changes: 326 additions & 2 deletions src/entities/activity/lib/types/conditionalLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type ConditionalLogic = {
conditions: Array<Condition>;
};

type Condition =
export type Condition =
| IncludesOptionCondition
| NotIncludesOptionCondition
| EqualToOptionCondition
Expand All @@ -15,10 +15,130 @@ type Condition =
| EqualCondition
| NotEqualCondition
| BetweenCondition
| OutsideOfCondition;
| OutsideOfCondition
felipeMetaLab marked this conversation as resolved.
Show resolved Hide resolved
| GreaterThanDateCondition
| LessThanDateCondition
| EqualToDateCondition
| NotEqualToDateCondition
| BetweenDatesCondition
| OutsideOfDatesCondition
| GreaterThanTimeCondition
| LessThanTimeCondition
| EqualToTimeCondition
| NotEqualToTimeCondition
| BetweenTimesCondition
| OutsideOfTimesCondition
| GreaterThanTimeRangeCondition
| LessThanTimeRangeCondition
| EqualToTimeRangeCondition
| NotEqualToTimeRangeCondition
| BetweenTimesRangeCondition
| OutsideOfTimesRangeCondition
| EqualToRowOptionCondition
| NotEqualToRowOptionCondition
| IncludesRowOptionCondition
| NotIncludesRowOptionCondition
| EqualToSliderRowCondition
| NotEqualToSliderRowCondition
| GreaterThanSliderRowCondition
| LessThanSliderRowCondition
| BetweenSliderRowCondition
| OutsideOfSliderRowCondition;

export type ConditionType = Condition['type'];

type EqualToRowOptionCondition = {
activityItemName: string;
type: 'EQUAL_TO_ROW_OPTION';
payload: {
optionValue: string;
rowIndex: number;
};
};

type NotEqualToRowOptionCondition = {
activityItemName: string;
type: 'NOT_EQUAL_TO_ROW_OPTION';
payload: {
optionValue: string;
rowIndex: number;
};
};

type IncludesRowOptionCondition = {
activityItemName: string;
type: 'INCLUDES_ROW_OPTION';
payload: {
optionValue: string;
rowIndex: number;
};
};

type NotIncludesRowOptionCondition = {
activityItemName: string;
type: 'NOT_INCLUDES_ROW_OPTION';
payload: {
optionValue: string;
rowIndex: number;
};
};

type EqualToSliderRowCondition = {
activityItemName: string;
type: 'EQUAL_TO_SLIDER_ROWS';
payload: {
value: number;
rowIndex: number;
};
};

type NotEqualToSliderRowCondition = {
activityItemName: string;
type: 'NOT_EQUAL_TO_SLIDER_ROWS';
payload: {
value: number;
rowIndex: number;
};
};

type GreaterThanSliderRowCondition = {
activityItemName: string;
type: 'GREATER_THAN_SLIDER_ROWS';
payload: {
value: number;
rowIndex: number;
};
};

type LessThanSliderRowCondition = {
activityItemName: string;
type: 'LESS_THAN_SLIDER_ROWS';
payload: {
value: number;
rowIndex: number;
};
};

type BetweenSliderRowCondition = {
activityItemName: string;
type: 'BETWEEN_SLIDER_ROWS';
payload: {
minValue: number;
maxValue: number;
rowIndex: number;
};
};

type OutsideOfSliderRowCondition = {
activityItemName: string;
type: 'OUTSIDE_OF_SLIDER_ROWS';
payload: {
minValue: number;
maxValue: number;
rowIndex: number;
};
};

type IncludesOptionCondition = {
activityItemName: string;
type: 'INCLUDES_OPTION';
Expand Down Expand Up @@ -100,3 +220,207 @@ type OutsideOfCondition = {
maxValue: number;
};
};

type GreaterThanDateCondition = {
activityItemName: string;
type: 'GREATER_THAN_DATE';
payload: {
date: string;
};
};

type LessThanDateCondition = {
activityItemName: string;
type: 'LESS_THAN_DATE';
payload: {
date: string;
};
};

type EqualToDateCondition = {
activityItemName: string;
type: 'EQUAL_TO_DATE';
payload: {
date: string;
};
};

type NotEqualToDateCondition = {
activityItemName: string;
type: 'NOT_EQUAL_TO_DATE';
payload: {
date: string;
};
};

type BetweenDatesCondition = {
activityItemName: string;
type: 'BETWEEN_DATES';
payload: {
minDate: string;
maxDate: string;
};
};

type OutsideOfDatesCondition = {
activityItemName: string;
type: 'OUTSIDE_OF_DATES';
payload: {
minDate: string;
maxDate: string;
};
};

type GreaterThanTimeCondition = {
activityItemName: string;
type: 'GREATER_THAN_TIME';
payload: {
time: {
hours: number;
minutes: number;
};
};
};

type LessThanTimeCondition = {
activityItemName: string;
type: 'LESS_THAN_TIME';
payload: {
time: {
hours: number;
minutes: number;
};
};
};

type EqualToTimeCondition = {
activityItemName: string;
type: 'EQUAL_TO_TIME';
payload: {
time: {
hours: number;
minutes: number;
};
};
};

type NotEqualToTimeCondition = {
activityItemName: string;
type: 'NOT_EQUAL_TO_TIME';
payload: {
time: {
hours: number;
minutes: number;
};
};
};

type BetweenTimesCondition = {
activityItemName: string;
type: 'BETWEEN_TIMES';
payload: {
minTime: {
hours: number;
minutes: number;
};
maxTime: {
hours: number;
minutes: number;
};
};
};

type OutsideOfTimesCondition = {
activityItemName: string;
type: 'OUTSIDE_OF_TIMES';
payload: {
minTime: {
hours: number;
minutes: number;
};
maxTime: {
hours: number;
minutes: number;
};
};
};

type GreaterThanTimeRangeCondition = {
activityItemName: string;
type: 'GREATER_THAN_TIME_RANGE';
payload: {
time: {
hours: number;
minutes: number;
};
fieldName: string;
};
};

type LessThanTimeRangeCondition = {
activityItemName: string;
type: 'LESS_THAN_TIME_RANGE';
payload: {
time: {
hours: number;
minutes: number;
};
fieldName: string;
};
};

type EqualToTimeRangeCondition = {
activityItemName: string;
type: 'EQUAL_TO_TIME_RANGE';
payload: {
time: {
hours: number;
minutes: number;
};
fieldName: string;
};
};

type NotEqualToTimeRangeCondition = {
activityItemName: string;
type: 'NOT_EQUAL_TO_TIME_RANGE';
payload: {
time: {
hours: number;
minutes: number;
};
fieldName: string;
};
};

type BetweenTimesRangeCondition = {
activityItemName: string;
type: 'BETWEEN_TIMES_RANGE';
payload: {
minTime: {
hours: number;
minutes: number;
};
maxTime: {
hours: number;
minutes: number;
};
fieldName: string;
};
};

type OutsideOfTimesRangeCondition = {
activityItemName: string;
type: 'OUTSIDE_OF_TIMES_RANGE';
payload: {
minTime: {
hours: number;
minutes: number;
};
maxTime: {
hours: number;
minutes: number;
};
fieldName: string;
};
};
Loading
Loading