@eohjsc/react-native-smart-city 0.7.20 → 0.7.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import React, {
2
2
  useCallback,
3
+ useContext,
3
4
  useEffect,
4
5
  useMemo,
5
6
  useRef,
@@ -49,6 +50,11 @@ import styles from './Styles/indexStyles';
49
50
  import ItemConditionScriptDetail from '../../../commons/Automate/ItemConditionScriptDetail';
50
51
  import { ModalCustom } from '../../../commons/Modal';
51
52
  import { Card } from '../../../commons/CardShadow';
53
+ import ButtonAddCondition from '../../../commons/Automate/ButtonAddCondition';
54
+ import ModalAddCondition from './Components/ModalAddCondition';
55
+ import DeleteCondition from './Components/DeleteCondition';
56
+ import { SCContext } from '../../../context';
57
+ import { Action } from '../../../context/actionType';
52
58
 
53
59
  const PreventDoubleTouch = withPreventDoubleClick(TouchableOpacity);
54
60
 
@@ -56,6 +62,7 @@ const ScriptDetail = ({ route }) => {
56
62
  const { dispatch, navigate, goBack, getState } = useNavigation();
57
63
  const { params = {} } = route;
58
64
  const refMenuAction = useRef();
65
+ const { setAction } = useContext(SCContext);
59
66
  const { childRef, showingPopover, showPopoverWithRef, hidePopover } =
60
67
  usePopover();
61
68
  const {
@@ -77,9 +84,12 @@ const ScriptDetail = ({ route }) => {
77
84
  const [data, setData] = useState([]);
78
85
  const [isShowRename, setIsShowRename] = useState(false);
79
86
  const [isShowDelete, setIsShowDelete] = useState(false);
87
+ const [itemDeleteCondition, setItemDeleteCondition] = useState({});
80
88
  const [isShowAddAction, setIsShowAddAction] = useState(false);
81
89
  const [isShowLocalControl, setIsShowLocalControl] = useState(false);
82
90
  const [listChipShared, setListChipShared] = useState([]);
91
+ const [isShowSelectCondition, setIsShowSelectCondition] = useState(false);
92
+ const [numberConditionsUsed, setNumberConditionsUsed] = useState(0);
83
93
  const {
84
94
  script,
85
95
  type,
@@ -87,9 +97,12 @@ const ScriptDetail = ({ route }) => {
87
97
  unit,
88
98
  can_edit,
89
99
  id: automateId,
90
- value_change,
100
+ is_need_all_conditions,
101
+ conditions = [{}],
91
102
  } = automate;
92
- const { end_device_id, unit_id } = value_change || {};
103
+ const [needAllCondition, setNeedAllCondition] = useState(
104
+ is_need_all_conditions
105
+ );
93
106
  const {
94
107
  enable,
95
108
  chip_local_control,
@@ -103,7 +116,12 @@ const ScriptDetail = ({ route }) => {
103
116
  chip_id_local_control,
104
117
  });
105
118
  const [enableScript, setEnableScript] = useState(enable);
106
- const refMenuAction1 = useRef();
119
+ const [listMenuItemCondition, setListMenuItemCondition] = useState([]);
120
+ const [isShowAddCondition, setIsShowAddCondition] = useState(false);
121
+ const permissions = useBackendPermission();
122
+ const { max_actions_per_automation, max_conditions_per_automation } =
123
+ permissions;
124
+
107
125
  const onShowActivityLog = useCallback(() => {
108
126
  navigate(Routes.ActivityLog, {
109
127
  id: automateId,
@@ -158,24 +176,77 @@ const ScriptDetail = ({ route }) => {
158
176
  [closeScreen, dispatch, getState, route.params]
159
177
  );
160
178
 
161
- const handleUpdateAutomate = useCallback(async () => {
162
- if (!can_edit) {
163
- ToastBottomHelper.error(
164
- t('only_owner_has_permission_to_edit_this_script')
165
- );
166
- return;
167
- }
168
- if (!enableScript) {
169
- ToastBottomHelper.error(t('this_script_has_been_disabled'));
170
- return;
171
- }
179
+ const canUpdateCondition = useMemo(() => {
180
+ return can_edit && enableScript;
181
+ }, [can_edit, enableScript]);
182
+
183
+ const handleEditCondition = useCallback(
184
+ async (item) => {
185
+ if (!canUpdateCondition) {
186
+ if (!can_edit) {
187
+ ToastBottomHelper.error(
188
+ t('only_owner_has_permission_to_edit_this_script')
189
+ );
190
+ } else if (!enableScript) {
191
+ ToastBottomHelper.error(t('this_script_has_been_disabled'));
192
+ }
193
+ return;
194
+ }
172
195
 
173
- // Reset stack and navigate to AddUnknownTypeSmart
174
- handleNavigate(Routes.AddUnknownTypeSmart, {
196
+ if (item.type === AUTOMATE_TYPE.SCHEDULE) {
197
+ navigate(Routes.AddEditConditionSchedule, {
198
+ automate: automate,
199
+ condition: item,
200
+ isUpdateCondition: true,
201
+ closeScreen: Routes.ScriptDetail,
202
+ });
203
+ } else {
204
+ setAction(Action.IS_CREATE_CONDITION, false);
205
+ setAction(Action.IS_UPDATE_CONDITION, item.id);
206
+ const navParams = {
207
+ automate: automate,
208
+ closeScreen: Routes.ScriptDetail,
209
+ routeName: unit ? null : Routes.SelectControlDevices,
210
+ };
211
+
212
+ if (unit) {
213
+ navigate(Routes.SelectMonitorDevices, navParams);
214
+ } else {
215
+ navigate(Routes.SelectUnit, {
216
+ automate,
217
+ routeName: Routes.SelectMonitorDevices,
218
+ });
219
+ }
220
+ }
221
+ },
222
+ [
175
223
  automate,
176
- closeScreen: route.name,
177
- });
178
- }, [automate, can_edit, enableScript, route.name, t, handleNavigate]);
224
+ canUpdateCondition,
225
+ can_edit,
226
+ enableScript,
227
+ navigate,
228
+ setAction,
229
+ t,
230
+ unit,
231
+ ]
232
+ );
233
+
234
+ const handleDeleteCondition = useCallback(
235
+ async (item) => {
236
+ if (!canUpdateCondition) {
237
+ if (!can_edit) {
238
+ ToastBottomHelper.error(
239
+ t('only_owner_has_permission_to_edit_this_script')
240
+ );
241
+ } else if (!enableScript) {
242
+ ToastBottomHelper.error(t('this_script_has_been_disabled'));
243
+ }
244
+ return;
245
+ }
246
+ setItemDeleteCondition(item);
247
+ },
248
+ [canUpdateCondition, can_edit, enableScript, t]
249
+ );
179
250
 
180
251
  const listMenuItem = useMemo(
181
252
  () => [
@@ -192,32 +263,6 @@ const ScriptDetail = ({ route }) => {
192
263
  [t, onShowActivityLog]
193
264
  );
194
265
 
195
- const listMenuItemCondition = useMemo(() => {
196
- const items = [
197
- { text: t('edit_condition'), doAction: () => handleUpdateAutomate() },
198
- ];
199
- if (unit_id) {
200
- items.unshift({
201
- text: t('text_unit'),
202
- doAction: () =>
203
- navigate(Routes.UnitDetail, {
204
- unitId: unit_id,
205
- }),
206
- });
207
- }
208
- if (end_device_id) {
209
- items.unshift({
210
- text: t('device_display'),
211
- doAction: () =>
212
- navigate(Routes.DeviceDetail, {
213
- unitId: unit_id,
214
- sensorId: end_device_id,
215
- }),
216
- });
217
- }
218
- return items;
219
- }, [t, handleUpdateAutomate, navigate, unit_id, end_device_id]);
220
-
221
266
  const handleShowMenuAction = useCallback(() => {
222
267
  if (!can_edit) {
223
268
  ToastBottomHelper.error(
@@ -248,6 +293,7 @@ const ScriptDetail = ({ route }) => {
248
293
  if (success) {
249
294
  setAutomate(automateData);
250
295
  setEnableScript(automateData.script.enable);
296
+ setNeedAllCondition(automateData.is_need_all_conditions);
251
297
  }
252
298
  }, [automateId]);
253
299
 
@@ -295,13 +341,39 @@ const ScriptDetail = ({ route }) => {
295
341
  enable: checked,
296
342
  }
297
343
  );
298
- success && setEnableScript(checked);
344
+ if (success) {
345
+ ToastBottomHelper.success(t('update_successfully'));
346
+ setEnableScript(checked);
347
+ }
299
348
  },
300
- [automateId]
349
+ [automateId, t]
301
350
  );
302
351
 
303
352
  useBlockBack(handleGoBack);
304
353
 
354
+ const getConditionUsed = useCallback(async () => {
355
+ if (max_conditions_per_automation > 0) {
356
+ setNumberConditionsUsed(
357
+ max_conditions_per_automation - conditions.length
358
+ );
359
+ } else {
360
+ const { success, data: perms } = await axiosGet(API.AUTH.PERMISSIONS());
361
+ if (success) {
362
+ setNumberConditionsUsed(
363
+ perms.max_conditions_per_automation - conditions.length
364
+ );
365
+ setAction(Action.UPDATE_PERMISSIONS, perms);
366
+ return;
367
+ }
368
+ }
369
+
370
+ // eslint-disable-next-line react-hooks/exhaustive-deps
371
+ }, [conditions.length, max_conditions_per_automation]); // Add dependency setAction will cause loop
372
+
373
+ useEffect(() => {
374
+ getConditionUsed();
375
+ }, [getConditionUsed]);
376
+
305
377
  useEffect(() => {
306
378
  if (isFocused) {
307
379
  fetchAutomate();
@@ -340,18 +412,60 @@ const ScriptDetail = ({ route }) => {
340
412
  saveAt && fetchAutomateActions();
341
413
  }, [saveAt, fetchAutomateActions]);
342
414
 
343
- const handleShowMenuAction1 = useCallback(() => {
344
- showPopoverWithRef1(refMenuAction1);
345
- }, [showPopoverWithRef1, refMenuAction1]);
415
+ const handleShowMenuAction1 = useCallback(
416
+ (item, refMenuAction1) => {
417
+ const { unit_id: unitCondition, end_device_id } = item;
418
+ const menu = [
419
+ {
420
+ text: t('edit_condition'),
421
+ doAction: () => handleEditCondition(item),
422
+ },
423
+ {
424
+ text: t('delete_condition'),
425
+ doAction: () => handleDeleteCondition(item),
426
+ },
427
+ ];
428
+ if (unitCondition) {
429
+ menu.unshift({
430
+ text: t('go_to_unit'),
431
+ doAction: () =>
432
+ navigate(Routes.UnitDetail, {
433
+ unitId: unitCondition,
434
+ }),
435
+ });
436
+ }
437
+ if (end_device_id) {
438
+ menu.unshift({
439
+ text: t('device_display'),
440
+ doAction: () =>
441
+ navigate(Routes.DeviceDetail, {
442
+ unitId: unitCondition,
443
+ sensorId: end_device_id,
444
+ }),
445
+ });
446
+ }
447
+ setListMenuItemCondition(menu);
448
+ showPopoverWithRef1(refMenuAction1);
449
+ },
450
+ [
451
+ t,
452
+ showPopoverWithRef1,
453
+ handleEditCondition,
454
+ handleDeleteCondition,
455
+ navigate,
456
+ ]
457
+ );
346
458
 
347
459
  const onCloseLocalControl = () => setIsShowLocalControl(false);
348
460
 
461
+ const onCloseSelectCondition = () => setIsShowSelectCondition(false);
462
+
349
463
  const fetchChipShared = useCallback(async () => {
350
464
  const { success, data: listChip } = await axiosGet(
351
465
  API.DEV_MODE.GATEWAY.SHARED(),
352
466
  {
353
467
  params: {
354
- unit: unit_id,
468
+ unit: unit,
355
469
  },
356
470
  },
357
471
  true
@@ -359,12 +473,16 @@ const ScriptDetail = ({ route }) => {
359
473
  if (success) {
360
474
  setListChipShared(listChip);
361
475
  }
362
- }, [unit_id]);
476
+ }, [unit]);
363
477
 
364
478
  const onShowLocalControl = useCallback(async () => {
365
479
  setIsShowLocalControl(true);
366
480
  }, []);
367
481
 
482
+ const onShowSelectCondition = useCallback(async () => {
483
+ setIsShowSelectCondition(true);
484
+ }, []);
485
+
368
486
  useEffect(() => {
369
487
  fetchChipShared();
370
488
  }, [fetchChipShared]);
@@ -384,6 +502,7 @@ const ScriptDetail = ({ route }) => {
384
502
  );
385
503
  setIsShowLocalControl(false);
386
504
  if (success) {
505
+ ToastBottomHelper.success(t('local_control_update_success'));
387
506
  setLocalControl({
388
507
  is_local_control: enable_local_control,
389
508
  chip_local_control: item.name,
@@ -391,7 +510,7 @@ const ScriptDetail = ({ route }) => {
391
510
  });
392
511
  }
393
512
  },
394
- [automateId, local_control.chip_id_local_control]
513
+ [automateId, local_control.chip_id_local_control, t]
395
514
  );
396
515
 
397
516
  const renderLocalControl = useMemo(() => {
@@ -430,6 +549,119 @@ const ScriptDetail = ({ route }) => {
430
549
  type,
431
550
  ]);
432
551
 
552
+ const onPressSelectCondition = useCallback(
553
+ async (value) => {
554
+ setIsShowSelectCondition(false);
555
+ setNeedAllCondition(value);
556
+ const { success } = await axiosPost(
557
+ API.AUTOMATE.NEED_ALL_CONDITIONS(automateId),
558
+ {
559
+ is_need_all_conditions: value,
560
+ }
561
+ );
562
+ if (success) {
563
+ ToastBottomHelper.success(t('update_condition_success'));
564
+ } else {
565
+ ToastBottomHelper.error(t('error_please_try_later'));
566
+ }
567
+ },
568
+ [automateId, t]
569
+ );
570
+
571
+ const selectCondition = useMemo(() => {
572
+ if (type === AUTOMATE_TYPE.ONE_TAP || !max_conditions_per_automation) {
573
+ return (
574
+ <View style={styles.row}>
575
+ <Text type="H3" semibold style={styles.width40}>
576
+ {t('how_to_start')}
577
+ </Text>
578
+ </View>
579
+ );
580
+ }
581
+ return (
582
+ <>
583
+ <View style={styles.row}>
584
+ <Text type="H3" semibold style={styles.width30}>
585
+ {t('condition')}
586
+ </Text>
587
+ <Card style={styles.card}>
588
+ <TouchableOpacity
589
+ style={styles.boxCondition}
590
+ onPress={onShowSelectCondition}
591
+ accessibilityLabel={AccessibilityLabel.AUTOMATE_CONDITION}
592
+ >
593
+ <Text numberOfLines={1}>
594
+ {t(needAllCondition ? 'are_met' : 'is_met')}
595
+ </Text>
596
+
597
+ <IconOutline name="down" size={15} style={styles.marginLeft5} />
598
+ </TouchableOpacity>
599
+ </Card>
600
+ </View>
601
+ <View>
602
+ <Text
603
+ type="H5"
604
+ accessibilityLabel={AccessibilityLabel.AUTOMATE_NUMBER_CONDITION}
605
+ >
606
+ {t('available_condition', {
607
+ number: numberConditionsUsed,
608
+ })}
609
+ </Text>
610
+ </View>
611
+ </>
612
+ );
613
+ }, [
614
+ max_conditions_per_automation,
615
+ needAllCondition,
616
+ numberConditionsUsed,
617
+ onShowSelectCondition,
618
+ t,
619
+ type,
620
+ ]);
621
+
622
+ const renderCondition = useMemo(() => {
623
+ if (max_conditions_per_automation) {
624
+ return conditions.map((item, index) => (
625
+ <ItemConditionScriptDetail
626
+ key={`condition${index}`}
627
+ automate={automate}
628
+ condition={item}
629
+ enableScript={enableScript}
630
+ handleShowMenuAction1={handleShowMenuAction1}
631
+ />
632
+ ));
633
+ } else {
634
+ return (
635
+ <ItemConditionScriptDetail
636
+ automate={automate}
637
+ condition={conditions[0] || {}}
638
+ enableScript={enableScript}
639
+ handleShowMenuAction1={handleShowMenuAction1}
640
+ />
641
+ );
642
+ }
643
+ }, [
644
+ automate,
645
+ conditions,
646
+ enableScript,
647
+ handleShowMenuAction1,
648
+ max_conditions_per_automation,
649
+ ]);
650
+
651
+ const renderButtonAddCondition = useMemo(() => {
652
+ if (type === AUTOMATE_TYPE.ONE_TAP || !max_conditions_per_automation) {
653
+ return;
654
+ } else {
655
+ return (
656
+ <ButtonAddCondition
657
+ setIsShowAddCondition={setIsShowAddCondition}
658
+ numberConditionsUsed={numberConditionsUsed}
659
+ max_conditions_per_automation={max_conditions_per_automation}
660
+ />
661
+ );
662
+ }
663
+ }, [max_conditions_per_automation, numberConditionsUsed, type]);
664
+
433
665
  return (
434
666
  <View style={styles.wrap}>
435
667
  <WrapHeaderScrollable
@@ -448,15 +680,9 @@ const ScriptDetail = ({ route }) => {
448
680
  </View>
449
681
  )}
450
682
  {renderLocalControl}
451
- <Text type="H3" semibold>
452
- {t('how_to_start')}
453
- </Text>
454
- <ItemConditionScriptDetail
455
- automate={automate}
456
- enableScript={enableScript}
457
- handleShowMenuAction1={handleShowMenuAction1}
458
- refMenuAction1={refMenuAction1}
459
- />
683
+ {selectCondition}
684
+ {renderCondition}
685
+ {renderButtonAddCondition}
460
686
  {type === AUTOMATE_TYPE.ONE_TAP && enableScript && (
461
687
  <TouchableOpacity
462
688
  onPress={handleScriptAction}
@@ -467,7 +693,7 @@ const ScriptDetail = ({ route }) => {
467
693
  </TouchableOpacity>
468
694
  )}
469
695
 
470
- <View style={styles.row}>
696
+ <View style={styles.rowActionList}>
471
697
  <Text type="H3" color={Colors.Gray9} semibold>
472
698
  {t('actions_list')}
473
699
  </Text>
@@ -479,15 +705,20 @@ const ScriptDetail = ({ route }) => {
479
705
  AccessibilityLabel.BUTTON_EDIT_SCRIPT_ACTION
480
706
  }
481
707
  >
482
- <Text type="Label" highlight>
483
- {t('edit')}
484
- </Text>
708
+ <Text highlight>{t('edit')}</Text>
485
709
  </TouchableOpacity>
486
710
  )}
487
711
  </View>
712
+ <View style={styles.row}>
713
+ <Text>
714
+ {t('available_action', {
715
+ number: max_actions_per_automation - data.length,
716
+ })}
717
+ </Text>
718
+ </View>
488
719
  {data.map((item, index) => (
489
720
  <Item
490
- key={item?.id}
721
+ key={`Item${index}`}
491
722
  item={item}
492
723
  index={index}
493
724
  enableScript={enableScript}
@@ -497,7 +728,8 @@ const ScriptDetail = ({ route }) => {
497
728
  ))}
498
729
  {!!can_edit && !!enableScript && (
499
730
  <ItemAdd
500
- automate={automate}
731
+ t={t}
732
+ max_actions_per_automation={max_actions_per_automation}
501
733
  numberActionAdded={data.length}
502
734
  setIsShowAddAction={setIsShowAddAction}
503
735
  />
@@ -540,6 +772,14 @@ const ScriptDetail = ({ route }) => {
540
772
  type={type}
541
773
  navigate={handleNavigate}
542
774
  />
775
+ <ModalAddCondition
776
+ automate={automate}
777
+ numberActionAdded={data.length}
778
+ isVisible={isShowAddCondition}
779
+ setIsVisible={setIsShowAddCondition}
780
+ type={type}
781
+ navigate={navigate}
782
+ />
543
783
  <RenameScript
544
784
  automate={automate}
545
785
  setAutomate={setAutomate}
@@ -551,7 +791,15 @@ const ScriptDetail = ({ route }) => {
551
791
  setIsVisible={setIsShowDelete}
552
792
  isVisible={isShowDelete}
553
793
  />
794
+ <DeleteCondition
795
+ automate={automate}
796
+ setAutomate={setAutomate}
797
+ condition={itemDeleteCondition}
798
+ setIsVisible={setItemDeleteCondition}
799
+ isVisible={Boolean(itemDeleteCondition.id)}
800
+ />
554
801
  <ModalCustom
802
+ key={'ModalLocalControl'}
555
803
  isVisible={isShowLocalControl}
556
804
  onBackButtonPress={onCloseLocalControl}
557
805
  onBackdropPress={onCloseLocalControl}
@@ -601,6 +849,43 @@ const ScriptDetail = ({ route }) => {
601
849
  </ScrollView>
602
850
  </View>
603
851
  </ModalCustom>
852
+ <ModalCustom
853
+ key={'ModalSelectCondition'}
854
+ isVisible={isShowSelectCondition}
855
+ onBackButtonPress={onCloseSelectCondition}
856
+ onBackdropPress={onCloseSelectCondition}
857
+ >
858
+ <View key={'selectCondition'} style={styles.popoverStyle}>
859
+ <ScrollView>
860
+ <TouchableOpacity
861
+ style={styles.textDisable}
862
+ key={'are_met'}
863
+ onPress={() => {
864
+ onPressSelectCondition(true);
865
+ }}
866
+ accessibilityLabel={AccessibilityLabel.AUTOMATE_SELECT_CONDITION}
867
+ >
868
+ <Text>{t('are_met')}</Text>
869
+ {needAllCondition && (
870
+ <IconOutline style={styles.checked} name={'check'} size={20} />
871
+ )}
872
+ </TouchableOpacity>
873
+ <TouchableOpacity
874
+ style={styles.textDisable}
875
+ key={'is_met'}
876
+ onPress={() => {
877
+ onPressSelectCondition(false);
878
+ }}
879
+ accessibilityLabel={AccessibilityLabel.AUTOMATE_SELECT_CONDITION}
880
+ >
881
+ <Text>{t('is_met')}</Text>
882
+ {!needAllCondition && (
883
+ <IconOutline style={styles.checked} name={'check'} size={20} />
884
+ )}
885
+ </TouchableOpacity>
886
+ </ScrollView>
887
+ </View>
888
+ </ModalCustom>
604
889
  </View>
605
890
  );
606
891
  };
@@ -780,10 +1065,12 @@ const Item = ({ item, index, enableScript, t, local_control }) => {
780
1065
  }
781
1066
  };
782
1067
 
783
- const ItemAdd = ({ automate, numberActionAdded, setIsShowAddAction }) => {
784
- const t = useTranslations();
785
- const permissions = useBackendPermission();
786
- const { max_actions_per_automation } = permissions || {};
1068
+ const ItemAdd = ({
1069
+ t,
1070
+ max_actions_per_automation,
1071
+ numberActionAdded,
1072
+ setIsShowAddAction,
1073
+ }) => {
787
1074
  const paddedIndex = (numberActionAdded + 1).toString().padStart(2, '0');
788
1075
 
789
1076
  const onPressAddAction = useCallback(() => {
@@ -35,11 +35,11 @@ export const getAutomationData = (automate) => {
35
35
  };
36
36
 
37
37
  const generateAutomationConditionValueEvaluation = (
38
- automateData,
38
+ conditionItem,
39
39
  valueEvaluations,
40
40
  t
41
41
  ) => {
42
- const { action, end_device_name, config_name, value } = automateData;
42
+ const { end_device_name, config_name, value } = conditionItem;
43
43
 
44
44
  const index = value[1];
45
45
  const valueEvaluation = valueEvaluations?.find((v) => v.id === value[0]);
@@ -62,26 +62,22 @@ const generateAutomationConditionValueEvaluation = (
62
62
  if (config_name) {
63
63
  textEvent = config_name;
64
64
  } else {
65
- textEvent = `${end_device_name} - ${action}`;
65
+ textEvent = end_device_name;
66
66
  }
67
67
  return textEvent;
68
68
  };
69
69
 
70
70
  export const generateAutomationConditionText = (
71
71
  automate,
72
+ conditionItem,
72
73
  valueEvaluations,
73
74
  t
74
75
  ) => {
75
- const automateData = getAutomationData(automate);
76
- if (!automateData) {
77
- return;
78
- }
79
- const { type } = automate;
76
+ const { condition, config_name, value, type } = conditionItem;
80
77
  if ([AUTOMATE_TYPE.VALUE_CHANGE].includes(type)) {
81
- const { condition, config_name, value } = automateData;
82
78
  if (condition === 'value_evaluation') {
83
79
  return generateAutomationConditionValueEvaluation(
84
- automateData,
80
+ conditionItem,
85
81
  valueEvaluations,
86
82
  t
87
83
  );
@@ -97,7 +93,7 @@ export const generateAutomationConditionText = (
97
93
  }
98
94
  return `${config_name} ${t(text)} ${value}`;
99
95
  } else if (type === AUTOMATE_TYPE.SCHEDULE) {
100
- const { repeat, time_repeat, date_repeat, weekday_repeat } = automateData;
96
+ const { repeat, time_repeat, date_repeat, weekday_repeat } = conditionItem;
101
97
  const time =
102
98
  time_repeat?.length >= 8
103
99
  ? time_repeat.substring(0, time_repeat?.length - 3)