@eohjsc/react-native-smart-city 0.7.3-rc9 → 0.7.4

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.
Files changed (166) hide show
  1. package/assets/images/Map/LocationPin.svg +10 -0
  2. package/package.json +4 -2
  3. package/src/commons/Action/__test__/ItemQuickAction.test.js +2 -2
  4. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +3 -3
  5. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapper.js +3 -3
  6. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +3 -3
  7. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/ButtonWrapper.js +2 -2
  8. package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +2 -2
  9. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +2 -2
  10. package/src/commons/ActionGroup/SliderRangeTemplate.js +7 -7
  11. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +2 -2
  12. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/CircleButton.js +5 -5
  13. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/ControlPlay.js +5 -5
  14. package/src/commons/ActionGroup/TerminalBoxTemplate.js +2 -2
  15. package/src/commons/ActionGroup/TextBoxTemplate.js +2 -2
  16. package/src/commons/ActionGroup/TimerActionTemplate.js +6 -3
  17. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +2 -2
  18. package/src/commons/ActionGroup/__test__/index.test.js +2 -2
  19. package/src/commons/ActionGroup/index.js +2 -2
  20. package/src/commons/Automate/ItemAutomate.js +9 -41
  21. package/src/commons/Automate/ItemConditionScriptDetail.js +109 -0
  22. package/src/commons/Automate/ItemConditionScriptDetailStyles.js +46 -0
  23. package/src/commons/Automate/__test__/ItemAutomate.test.js +0 -21
  24. package/src/commons/BackDefault/index.js +2 -2
  25. package/src/commons/BottomButtonView/index.js +1 -0
  26. package/src/commons/ButtonPopup/index.js +3 -2
  27. package/src/commons/DateTimeRangeChange/DateTimeButton.js +3 -3
  28. package/src/commons/Device/ConnectedViewHeader.js +2 -2
  29. package/src/commons/Device/Emergency/EmergencyDetail.js +3 -3
  30. package/src/commons/Device/FlatListItems.js +3 -3
  31. package/src/commons/Device/Hanet/ItemHanetDevice.js +3 -3
  32. package/src/commons/Device/HorizontalBarChart.js +54 -34
  33. package/src/commons/Device/ItemAddNew/index.js +2 -2
  34. package/src/commons/Device/ItemDevice.js +2 -2
  35. package/src/commons/Device/SonosSpeaker/index.js +3 -3
  36. package/src/commons/Device/WaterPurifierStatus/AlertStatusMachine.js +2 -2
  37. package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +6 -2
  38. package/src/commons/DisplayChecking/index.js +2 -2
  39. package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -2
  40. package/src/commons/FieldTemplate/ChooseUserField/index.js +2 -2
  41. package/src/commons/FlatListDnD/index.js +12 -9
  42. package/src/commons/Grid/GridItem.js +10 -2
  43. package/src/commons/Header/HeaderCustom.js +2 -2
  44. package/src/commons/HeaderAni/index.js +2 -2
  45. package/src/commons/IconComponent/index.js +4 -4
  46. package/src/commons/NavBar/index.js +2 -2
  47. package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +3 -3
  48. package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +4 -4
  49. package/src/commons/SearchLocation/index.js +3 -3
  50. package/src/commons/SelectActionCard/index.js +2 -2
  51. package/src/commons/SelectSubUnit/index.js +6 -2
  52. package/src/commons/Sharing/BtnRemoveMember.js +2 -2
  53. package/src/commons/Sharing/StationDevicePermissions.js +2 -2
  54. package/src/commons/SubUnit/DeviceTemplate/ConfigAndEvaluation/ConfigAndEvaluation.js +2 -2
  55. package/src/commons/SubUnit/DeviceTemplate/ConfigValue/ConfigValue.js +2 -2
  56. package/src/commons/SubUnit/DeviceTemplate/EvaluationOverConfig/EvaluationOverConfig.js +2 -2
  57. package/src/commons/SubUnit/OneTap/ItemOneTap.js +3 -4
  58. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +0 -2
  59. package/src/commons/SubUnit/OneTap/index.js +9 -8
  60. package/src/commons/Unit/HeaderUnit/index.js +3 -3
  61. package/src/commons/Unit/SharedUnit.js +7 -7
  62. package/src/commons/Widgets/IFrameWithConfig/IFrameWithConfig.js +4 -15
  63. package/src/commons/Widgets/IFrameWithConfig/__tests__/IFrameWithConfig.test.js +29 -18
  64. package/src/configs/API.js +1 -1
  65. package/src/configs/AccessibilityLabel.js +1 -0
  66. package/src/configs/Theme.js +1 -1
  67. package/src/hooks/IoT/__test__/useRemoteControl.test.js +14 -7
  68. package/src/hooks/IoT/useRemoteControl.js +18 -7
  69. package/src/hooks/useMqtt.js +2 -2
  70. package/src/iot/RemoteControl/Bluetooth.js +19 -22
  71. package/src/iot/RemoteControl/Internet.js +11 -3
  72. package/src/navigations/EmergencyContactsStack.js +4 -3
  73. package/src/navigations/SharedStack.js +2 -0
  74. package/src/navigations/UnitStack.js +56 -57
  75. package/src/screens/AQIGuide/index.js +0 -2
  76. package/src/screens/ActivityLog/index.js +2 -2
  77. package/src/screens/AddLocationMaps/index.js +16 -19
  78. package/src/screens/AddLocationMaps/indexStyle.js +1 -0
  79. package/src/screens/AddNewGateway/RenameNewDevices.js +2 -2
  80. package/src/screens/AddNewGateway/SelectDeviceType.js +1 -1
  81. package/src/screens/AllGateway/GatewayInfo/__test__/index.test.js +25 -9
  82. package/src/screens/Automate/AddNewAction/ChooseAction.js +17 -3
  83. package/src/screens/Automate/AddNewAction/ChooseConfig.js +7 -6
  84. package/src/screens/Automate/AddNewAction/NewActionWrapper.js +8 -8
  85. package/src/screens/Automate/AddNewAction/SelectControlDevices.js +30 -20
  86. package/src/screens/Automate/AddNewAction/SelectMonitorDevices.js +17 -10
  87. package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +58 -44
  88. package/src/screens/Automate/AddNewAction/SetupScriptDelay.js +1 -1
  89. package/src/screens/Automate/AddNewAction/SetupScriptNotify.js +3 -3
  90. package/src/screens/Automate/AddNewAction/Styles/SetupSensorStyles.js +20 -4
  91. package/src/screens/Automate/AddNewAction/__test__/ChooseAction.test.js +1 -1
  92. package/src/screens/Automate/AddNewAction/__test__/SelectControlDevices.test.js +14 -8
  93. package/src/screens/Automate/AddNewAction/__test__/SelectMonitorDevices.test.js +13 -7
  94. package/src/screens/Automate/AddNewAction/__test__/SetupConfigCondition.test.js +54 -15
  95. package/src/screens/Automate/AddNewAction/__test__/SetupScriptNotify.test.js +29 -0
  96. package/src/screens/Automate/AddNewAutoSmart/AddTypeSmart.js +10 -10
  97. package/src/screens/Automate/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +2 -0
  98. package/src/screens/Automate/Components/InputName.js +10 -7
  99. package/src/screens/Automate/EditActionsList/index.js +19 -17
  100. package/src/screens/Automate/MultiUnits.js +19 -22
  101. package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +12 -2
  102. package/src/screens/Automate/Scenario/__test__/AddNewOneTap.test.js +9 -1
  103. package/src/screens/Automate/ScriptDetail/Components/AddActionScript.js +14 -6
  104. package/src/screens/Automate/ScriptDetail/Components/RenameScript.js +4 -7
  105. package/src/screens/Automate/ScriptDetail/__test__/index.test.js +42 -17
  106. package/src/screens/Automate/ScriptDetail/index.js +33 -22
  107. package/src/screens/Automate/SetSchedule/__test__/index.test.js +21 -10
  108. package/src/screens/Automate/SetSchedule/components/RowItem.js +5 -5
  109. package/src/screens/Automate/SetSchedule/index.js +8 -7
  110. package/src/screens/Automate/Styles/indexStyles.js +1 -1
  111. package/src/screens/Automate/__test__/MultiUnits.test.js +1 -4
  112. package/src/screens/Automate/__test__/index.test.js +0 -1
  113. package/src/screens/Automate/index.js +36 -34
  114. package/src/screens/ChangePosition/index.js +2 -1
  115. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +4 -4
  116. package/src/screens/Device/EditDevice/index.js +4 -4
  117. package/src/screens/Device/__test__/BluetoothDevice.test.js +300 -0
  118. package/src/screens/Device/__test__/detail.test.js +3 -3
  119. package/src/screens/Device/components/BluetoothDevice.js +135 -0
  120. package/src/screens/Device/components/SensorDisplayItem.js +4 -3
  121. package/src/screens/Device/detail.js +70 -62
  122. package/src/screens/Device/hooks/useEvaluateValue.js +1 -1
  123. package/src/screens/Drawer/index.js +3 -3
  124. package/src/screens/EmergencyContacts/EmergencyContactsList.js +8 -4
  125. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +3 -3
  126. package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
  127. package/src/screens/GuestInfo/components/RowGuestInfo.js +2 -2
  128. package/src/screens/GuestInfo/index.js +2 -2
  129. package/src/screens/HanetCamera/ManageAccess.js +3 -3
  130. package/src/screens/HanetCamera/MemberInfo.js +2 -2
  131. package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -2
  132. package/src/screens/ManageAccess/index.js +3 -3
  133. package/src/screens/Notification/components/NotificationItem.js +3 -3
  134. package/src/screens/Notification/index.js +3 -3
  135. package/src/screens/ScanChipQR/components/QRScan/index.js +3 -3
  136. package/src/screens/SelectUnit/__test__/index.test.js +1 -1
  137. package/src/screens/SelectUnit/index.js +4 -4
  138. package/src/screens/SharedUnit/TabHeader.js +2 -2
  139. package/src/screens/Sharing/Components/EndDevice.js +3 -3
  140. package/src/screens/Sharing/UnitMemberList.js +2 -2
  141. package/src/screens/SmartAccount/SuccessfullyConnected/index.js +2 -2
  142. package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +3 -2
  143. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +2 -2
  144. package/src/screens/SmartIr/components/SelectBrand.js +2 -2
  145. package/src/screens/SubUnit/AddSubUnit.js +28 -24
  146. package/src/screens/SubUnit/AddSubUnitStyles.js +10 -4
  147. package/src/screens/SubUnit/EditSubUnit.js +12 -11
  148. package/src/screens/SubUnit/ManageSubUnit.js +3 -3
  149. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +13 -13
  150. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +3 -3
  151. package/src/screens/Template/EditTemplate.js +6 -4
  152. package/src/screens/UVIndexGuide/index.js +2 -4
  153. package/src/screens/Unit/SelectAddToFavorites.js +2 -2
  154. package/src/screens/Unit/SelectAddress.js +16 -12
  155. package/src/screens/Unit/components/AutomateScript/index.js +2 -2
  156. package/src/screens/Unit/components/ButtonWrapper/index.js +3 -3
  157. package/src/screens/Unit/components/Header/index.js +2 -2
  158. package/src/screens/Unit/components/SharedUnit/index.js +5 -5
  159. package/src/screens/UnitSummary/components/AirQuality/index.js +6 -11
  160. package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +6 -6
  161. package/src/screens/UnitSummary/index.js +3 -3
  162. package/src/utils/Apis/axios.js +5 -5
  163. package/src/utils/Functions/ShortEmail.js +1 -0
  164. package/src/utils/I18n/translations/en.js +6 -3
  165. package/src/utils/I18n/translations/vi.js +8 -4
  166. package/src/utils/bluetooth.js +3 -0
@@ -8,7 +8,6 @@ import MockAdapter from 'axios-mock-adapter';
8
8
  import { SCProvider } from '../../../../context';
9
9
  import { mockSCStore } from '../../../../context/mockStore';
10
10
  import ScriptDetail from '../index';
11
- import MenuActionMore from '../../../../commons/MenuActionMore';
12
11
  import AlertAction from '../../../../commons/AlertAction';
13
12
  import _TextInput from '../../../../commons/Form/TextInput';
14
13
  import {
@@ -18,12 +17,12 @@ import {
18
17
  import { API } from '../../../../configs';
19
18
  import Routes from '../../../../utils/Route';
20
19
  import WrapHeaderScrollable from '../../../../commons/Sharing/WrapHeaderScrollable';
21
- import ItemAutomate from '../../../../commons/Automate/ItemAutomate';
22
20
  import api from '../../../../utils/Apis/axios';
23
21
  import Text from '../../../../commons/Text';
24
22
  import { ToastBottomHelper } from '../../../../utils/Utils';
25
23
  import { getTranslate } from '../../../../utils/I18n';
26
24
  import AddActionScript from '../Components/AddActionScript';
25
+ import ItemConditionScriptDetail from '../../../../commons/Automate/ItemConditionScriptDetail';
27
26
 
28
27
  const wrapComponent = (route, storeData = {}) => (
29
28
  <SCProvider initState={mockSCStore(storeData)}>
@@ -101,7 +100,10 @@ describe('Test ScriptDetail', () => {
101
100
  tree = await create(wrapComponent(route));
102
101
  });
103
102
  const instance = tree.root;
104
- const menu = instance.findByType(MenuActionMore);
103
+ const menu = instance.find(
104
+ (el) =>
105
+ el.props.accessibilityLabel === AccessibilityLabel.MENU_POPPER_MORE
106
+ );
105
107
  const alertAction = instance.findAllByType(AlertAction)[0];
106
108
  const rename = menu.props.listMenuItem[0];
107
109
 
@@ -127,7 +129,10 @@ describe('Test ScriptDetail', () => {
127
129
  tree = await create(wrapComponent(route));
128
130
  });
129
131
  const instance = tree.root;
130
- const menu = instance.findByType(MenuActionMore);
132
+ const menu = instance.find(
133
+ (el) =>
134
+ el.props.accessibilityLabel === AccessibilityLabel.MENU_POPPER_MORE
135
+ );
131
136
  const alertAction = instance.findAllByType(AlertAction)[0];
132
137
  const rename = menu.props.listMenuItem[0];
133
138
 
@@ -153,9 +158,9 @@ describe('Test ScriptDetail', () => {
153
158
  tree = await create(wrapComponent(route));
154
159
  });
155
160
  const instance = tree.root;
156
- const menu = instance.findByProps({
157
- accessibilityLabel: AccessibilityLabel.ICON_MORE,
158
- });
161
+ const menu = instance.find(
162
+ (el) => el.props.accessibilityLabel === AccessibilityLabel.ICON_MORE
163
+ );
159
164
 
160
165
  await act(async () => {
161
166
  await menu.props.onPress();
@@ -173,7 +178,7 @@ describe('Test ScriptDetail', () => {
173
178
  tree = await create(wrapComponent(route));
174
179
  });
175
180
  const instance = tree.root;
176
- const itemAutomate = instance.findByType(ItemAutomate);
181
+ const itemAutomate = instance.findByType(ItemConditionScriptDetail);
177
182
 
178
183
  await act(async () => {
179
184
  await itemAutomate.props.onPress();
@@ -188,7 +193,10 @@ describe('Test ScriptDetail', () => {
188
193
  tree = await create(wrapComponent(route));
189
194
  });
190
195
  const instance = tree.root;
191
- const menu = instance.findByType(MenuActionMore);
196
+ const menu = instance.find(
197
+ (el) =>
198
+ el.props.accessibilityLabel === AccessibilityLabel.MENU_POPPER_MORE
199
+ );
192
200
  const alertAction = instance.findAllByType(AlertAction)[1];
193
201
  const deleteItem = menu.props.listMenuItem[2];
194
202
 
@@ -222,7 +230,10 @@ describe('Test ScriptDetail', () => {
222
230
  await act(async () => {
223
231
  await buttonStar.props.onPress();
224
232
  });
225
- const menu = instance.findByType(MenuActionMore);
233
+ const menu = instance.find(
234
+ (el) =>
235
+ el.props.accessibilityLabel === AccessibilityLabel.MENU_POPPER_MORE
236
+ );
226
237
  const addFavorite = menu.props.listMenuItem[1];
227
238
  mock.onPost(API.AUTOMATE.STAR_SCRIPT(1)).reply(200);
228
239
  await act(async () => {
@@ -308,6 +319,8 @@ describe('Test ScriptDetail', () => {
308
319
  unitId: route.params.preAutomate.unit,
309
320
  automateId: route.params.preAutomate.id,
310
321
  numberActionCanAdd: 2,
322
+ closeScreen: undefined,
323
+ routeName: null,
311
324
  }
312
325
  );
313
326
  mockedNavigate.mockClear();
@@ -344,7 +357,7 @@ describe('Test ScriptDetail', () => {
344
357
  const instance = tree.root;
345
358
  const switchButton = instance.findByType(Switch);
346
359
  await act(async () => {
347
- await switchButton.props.onChange(false);
360
+ await switchButton.props.onValueChange(false);
348
361
  });
349
362
  const buttonAddScript = instance.findAll(
350
363
  (el) =>
@@ -442,7 +455,10 @@ describe('Test ScriptDetail', () => {
442
455
  tree = await create(wrapComponent(route));
443
456
  });
444
457
  const instance = tree.root;
445
- const menu = instance.findByType(MenuActionMore);
458
+ const menu = instance.find(
459
+ (el) =>
460
+ el.props.accessibilityLabel === AccessibilityLabel.MENU_POPPER_MORE
461
+ );
446
462
  const gotoActivityLog = menu.props.listMenuItem[1];
447
463
 
448
464
  await act(async () => {
@@ -490,7 +506,7 @@ describe('Test ScriptDetail', () => {
490
506
  tree = await create(wrapComponent(route));
491
507
  });
492
508
  const instance = tree.root;
493
- const itemAutomate = instance.findByType(ItemAutomate);
509
+ const itemAutomate = instance.findByType(ItemConditionScriptDetail);
494
510
  expect(itemAutomate.findAllByType(Text)[1].props.children).toEqual(
495
511
  'Light Value higher than 3'
496
512
  );
@@ -498,6 +514,15 @@ describe('Test ScriptDetail', () => {
498
514
  await act(async () => {
499
515
  itemAutomate.findByType(TouchableOpacity).props.onPress();
500
516
  });
517
+ const menuActionMore = instance.find(
518
+ (el) =>
519
+ el.props.accessibilityLabel ===
520
+ AccessibilityLabel.MENU_ACTION_LIST_TOUCHABLE
521
+ );
522
+ await act(async () => {
523
+ menuActionMore.props.onItemClick({ doAction: jest.fn() });
524
+ menuActionMore.props.listMenuItem[0].doAction();
525
+ });
501
526
  expect(global.mockedNavigate).toBeCalled();
502
527
  });
503
528
 
@@ -513,7 +538,7 @@ describe('Test ScriptDetail', () => {
513
538
  tree = await create(wrapComponent(route));
514
539
  });
515
540
  const instance = tree.root;
516
- const itemAutomate = instance.findByType(ItemAutomate);
541
+ const itemAutomate = instance.findByType(ItemConditionScriptDetail);
517
542
  expect(itemAutomate.findAllByType(Text)[1].props.children).toEqual(
518
543
  'Light Value equal 3'
519
544
  );
@@ -535,7 +560,7 @@ describe('Test ScriptDetail', () => {
535
560
  tree = await create(wrapComponent(route));
536
561
  });
537
562
  const instance = tree.root;
538
- const itemAutomate = instance.findByType(ItemAutomate);
563
+ const itemAutomate = instance.findByType(ItemConditionScriptDetail);
539
564
  expect(itemAutomate.findAllByType(Text)[1].props.children).toEqual(
540
565
  'Light Value lower than 3'
541
566
  );
@@ -557,7 +582,7 @@ describe('Test ScriptDetail', () => {
557
582
  tree = await create(wrapComponent(route));
558
583
  });
559
584
  const instance = tree.root;
560
- const itemAutomate = instance.findByType(ItemAutomate);
585
+ const itemAutomate = instance.findByType(ItemConditionScriptDetail);
561
586
  expect(itemAutomate.findAllByType(Text)[1].props.children).toEqual(
562
587
  'Every day at 19:00'
563
588
  );
@@ -580,7 +605,7 @@ describe('Test ScriptDetail', () => {
580
605
  tree = await create(wrapComponent(route));
581
606
  });
582
607
  const instance = tree.root;
583
- const itemAutomate = instance.findByType(ItemAutomate);
608
+ const itemAutomate = instance.findByType(ItemConditionScriptDetail);
584
609
  expect(itemAutomate.findAllByType(Text)[1].props.children).toEqual(
585
610
  'Mon, Tue, Thu, Sat at 19:00'
586
611
  );
@@ -7,14 +7,13 @@ import React, {
7
7
  } from 'react';
8
8
  import { Image, Platform, Switch, TouchableOpacity, View } from 'react-native';
9
9
  import { PopoverMode } from 'react-native-popover-view';
10
- import AntDesign from 'react-native-vector-icons/AntDesign';
10
+ import { IconFill, IconOutline } from '@ant-design/icons-react-native';
11
11
  import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
12
12
 
13
13
  import { useIsFocused, useNavigation } from '@react-navigation/native';
14
14
  import Add from '../../../../assets/images/Add.svg';
15
15
  import Delay from '../../../../assets/images/Delay.svg';
16
16
  import Notify from '../../../../assets/images/Notify.svg';
17
- import ItemAutomate from '../../../commons/Automate/ItemAutomate';
18
17
  import IconComponent from '../../../commons/IconComponent';
19
18
  import MenuActionMore from '../../../commons/MenuActionMore';
20
19
  import WrapHeaderScrollable from '../../../commons/Sharing/WrapHeaderScrollable';
@@ -34,6 +33,7 @@ import DeleteScript from './Components/DeleteScript';
34
33
  import RenameScript from './Components/RenameScript';
35
34
  import { useStarredScript } from './hooks/useStarredScript';
36
35
  import styles from './Styles/indexStyles';
36
+ import ItemConditionScriptDetail from '../../../commons/Automate/ItemConditionScriptDetail';
37
37
 
38
38
  const PreventDoubleTouch = withPreventDoubleClick(TouchableOpacity);
39
39
 
@@ -45,11 +45,10 @@ const ScriptDetail = ({ route }) => {
45
45
  usePopover();
46
46
  const t = useTranslations();
47
47
  const {
48
- id,
49
48
  saveAt,
50
49
  preAutomate = {}, // pre-loaded automate data
51
- newAutomate, // updated automate data
52
50
  newActionsList, // updated actions list
51
+ closeScreen,
53
52
  } = params;
54
53
  const [automate, setAutomate] = useState(preAutomate);
55
54
  const isFocused = useIsFocused();
@@ -63,7 +62,7 @@ const ScriptDetail = ({ route }) => {
63
62
  const [enableScript, setEnableScript] = useState(enable);
64
63
  const onShowActivityLog = useCallback(() => {
65
64
  navigate(Routes.ActivityLog, {
66
- id: id,
65
+ id: automateId,
67
66
  type:
68
67
  type === AUTOMATE_TYPE.ONE_TAP
69
68
  ? `automate.${AUTOMATE_TYPE.ONE_TAP}`
@@ -74,7 +73,7 @@ const ScriptDetail = ({ route }) => {
74
73
  user: Boolean(unit),
75
74
  },
76
75
  });
77
- }, [navigate, id, type, unit]);
76
+ }, [navigate, automateId, type, unit]);
78
77
 
79
78
  const listMenuItem = useMemo(
80
79
  () => [
@@ -107,39 +106,41 @@ const ScriptDetail = ({ route }) => {
107
106
 
108
107
  const fetchAutomateActions = useCallback(async () => {
109
108
  const { success, data: automateData } = await axiosGet(
110
- API.AUTOMATE.SCRIPT_ITEMS(id)
109
+ API.AUTOMATE.SCRIPT_ITEMS(automateId)
111
110
  );
112
111
  if (success) {
113
112
  setData(automateData.script_items || []);
114
113
  }
115
- }, [id]);
114
+ }, [automateId]);
116
115
 
117
116
  const fetchAutomate = useCallback(async () => {
118
117
  const { success, data: automateData } = await axiosGet(
119
- API.AUTOMATE.FETCH_AUTOMATE(id)
118
+ API.AUTOMATE.FETCH_AUTOMATE(automateId)
120
119
  );
121
120
  if (success) {
122
121
  setAutomate(automateData);
123
122
  setEnableScript(automateData.script.enable);
124
123
  }
125
- }, [id]);
124
+ }, [automateId]);
126
125
 
127
126
  const onPressEdit = useCallback(() => {
128
127
  navigate(Routes.EditActionsList, {
129
128
  data,
130
- id,
129
+ id: automateId,
131
130
  unitId: automate.unit,
132
131
  });
133
- }, [navigate, data, id, automate.unit]);
132
+ }, [navigate, data, automateId, automate.unit]);
134
133
 
135
134
  const handleScriptAction = useCallback(async () => {
136
- const { success } = await axiosPost(API.AUTOMATE.ACTION_ONE_TAP(id));
135
+ const { success } = await axiosPost(
136
+ API.AUTOMATE.ACTION_ONE_TAP(automateId)
137
+ );
137
138
  if (success) {
138
139
  ToastBottomHelper.success(t('activated_successfully'));
139
140
  } else {
140
141
  ToastBottomHelper.error(t('activation_failed'));
141
142
  }
142
- }, [id, t]);
143
+ }, [automateId, t]);
143
144
 
144
145
  const handleUpdateAutomate = useCallback(async () => {
145
146
  if (!can_edit) {
@@ -158,6 +159,19 @@ const ScriptDetail = ({ route }) => {
158
159
  });
159
160
  }, [automate, can_edit, enableScript, navigate, route.name, t]);
160
161
 
162
+ const handleGoBack = useCallback(async () => {
163
+ if (closeScreen === Routes.UnitDetail) {
164
+ navigate(closeScreen, { unitId: unit });
165
+ } else if (
166
+ closeScreen === Routes.MultiUnits ||
167
+ closeScreen === Routes.Automate
168
+ ) {
169
+ navigate(closeScreen, {});
170
+ } else {
171
+ goBack();
172
+ }
173
+ }, [closeScreen, goBack, navigate, unit]);
174
+
161
175
  const onChangeSwitch = useCallback(
162
176
  async (checked) => {
163
177
  setEnableScript(checked);
@@ -210,17 +224,13 @@ const ScriptDetail = ({ route }) => {
210
224
  saveAt && fetchAutomateActions();
211
225
  }, [saveAt, fetchAutomateActions]);
212
226
 
213
- useEffect(() => {
214
- newAutomate && setAutomate(newAutomate);
215
- }, [newAutomate]);
216
-
217
227
  return (
218
228
  <View style={styles.wrap}>
219
229
  <WrapHeaderScrollable
220
230
  title={name}
221
231
  headerAniStyle={styles.headerAniStyle}
222
232
  rightComponent={rightComponent}
223
- onGoBack={goBack}
233
+ onGoBack={handleGoBack}
224
234
  >
225
235
  <View style={styles.wrapContent}>
226
236
  {!!can_edit && (
@@ -234,7 +244,7 @@ const ScriptDetail = ({ route }) => {
234
244
  <Text type="H3" semibold>
235
245
  {t('how_to_start')}
236
246
  </Text>
237
- <ItemAutomate
247
+ <ItemConditionScriptDetail
238
248
  automate={automate}
239
249
  enableScript={enableScript}
240
250
  onPress={handleUpdateAutomate}
@@ -296,6 +306,7 @@ const ScriptDetail = ({ route }) => {
296
306
  mode={
297
307
  Platform.OS === 'ios' ? PopoverMode.JS_MODAL : PopoverMode.RN_MODAL
298
308
  }
309
+ accessibilityLabel={AccessibilityLabel.MENU_POPPER_MORE}
299
310
  />
300
311
  <AddActionScript
301
312
  automate={automate}
@@ -479,9 +490,9 @@ const ButtonStar = ({ automate }) => {
479
490
  accessibilityLabel={AccessibilityLabel.HEADER_SCRIPT_DETAIL_BUTTON_STAR}
480
491
  >
481
492
  {isStarred ? (
482
- <AntDesign name="star" size={25} color={Colors.Yellow6} />
493
+ <IconFill name="star" size={25} color={Colors.Yellow6} />
483
494
  ) : (
484
- <AntDesign name="staro" size={25} />
495
+ <IconOutline name="star" size={25} />
485
496
  )}
486
497
  </PreventDoubleTouch>
487
498
  );
@@ -1,4 +1,4 @@
1
- import { useNavigation } from '@react-navigation/native';
1
+ import { useNavigation, useRoute } from '@react-navigation/native';
2
2
  import moment from 'moment';
3
3
  import React from 'react';
4
4
  import { act, create } from 'react-test-renderer';
@@ -16,19 +16,22 @@ import RowItem from '../components/RowItem';
16
16
  import SelectWeekday from '../components/SelectWeekday';
17
17
  import SetSchedule from '../index';
18
18
 
19
- const wrapComponent = (route) => (
20
- <SCProvider initState={mockSCStore({})}>
21
- <SetSchedule route={route} />
22
- </SCProvider>
23
- );
19
+ const wrapComponent = (route) => {
20
+ useRoute.mockReturnValue(route);
21
+ return (
22
+ <SCProvider initState={mockSCStore({})}>
23
+ <SetSchedule route={route} />
24
+ </SCProvider>
25
+ );
26
+ };
24
27
 
25
28
  describe('Test SetSchedule', () => {
26
29
  let tree;
27
30
  let route = {
28
31
  params: {
29
- type: 'schedule',
30
- unit: { id: 1 },
31
- isAutomateTab: true,
32
+ automate: { type: 'schedule', unit: 1 },
33
+ unitId: 1,
34
+ closeScreen: 'UnitDetail',
32
35
  },
33
36
  };
34
37
 
@@ -70,7 +73,11 @@ describe('Test SetSchedule', () => {
70
73
  await act(async () => {
71
74
  await header.props.onPress();
72
75
  });
73
- expect(global.mockedNavigate).toHaveBeenCalledWith(undefined);
76
+ expect(global.mockedNavigate).toHaveBeenCalledWith('UnitDetail', {
77
+ automate: { type: 'schedule', unit: 1 },
78
+ closeScreen: 'UnitDetail',
79
+ unitId: 1,
80
+ });
74
81
  });
75
82
 
76
83
  it('test repeat options popup', async () => {
@@ -137,7 +144,11 @@ describe('Test SetSchedule', () => {
137
144
  repeat: 'once',
138
145
  time_repeat: '12:00:00',
139
146
  weekday_repeat: [],
147
+ type: 'schedule',
148
+ unit: 1,
140
149
  },
150
+ closeScreen: 'UnitDetail',
151
+ unitId: 1,
141
152
  });
142
153
  });
143
154
  });
@@ -1,9 +1,9 @@
1
+ import { IconOutline } from '@ant-design/icons-react-native';
1
2
  import React from 'react';
2
- import { View, TouchableOpacity } from 'react-native';
3
- import AntDesign from 'react-native-vector-icons/AntDesign';
3
+ import { TouchableOpacity, View } from 'react-native';
4
4
  import Text from '../../../../commons/Text';
5
- import styles from '../styles/RowItemStyles';
6
5
  import { Colors } from '../../../../configs';
6
+ import styles from '../styles/RowItemStyles';
7
7
 
8
8
  const RowItem = ({ title, value, icon = null, arrow = false, onPress }) => {
9
9
  return (
@@ -17,8 +17,8 @@ const RowItem = ({ title, value, icon = null, arrow = false, onPress }) => {
17
17
  </Text>
18
18
  </View>
19
19
  <View style={[styles.itemRight, arrow && styles.center]}>
20
- {arrow && <AntDesign name="right" color={Colors.Gray7} />}
21
- {icon && <AntDesign name={icon} size={17} color={Colors.Black} />}
20
+ {arrow && <IconOutline name="right" color={Colors.Gray7} />}
21
+ {icon && <IconOutline name={icon} size={17} color={Colors.Black} />}
22
22
  </View>
23
23
  </TouchableOpacity>
24
24
  );
@@ -1,19 +1,19 @@
1
- import React, { memo, useCallback, useState } from 'react';
2
- import { ScrollView } from 'react-native';
3
1
  import { useNavigation } from '@react-navigation/native';
4
2
  import moment from 'moment';
5
- import WheelDateTimePicker from '../../../commons/WheelDateTimePicker';
3
+ import React, { memo, useCallback, useState } from 'react';
4
+ import { ScrollView } from 'react-native';
6
5
  import Calendar from '../../../commons/Calendar';
6
+ import WheelDateTimePicker from '../../../commons/WheelDateTimePicker';
7
+ import { useBoolean } from '../../../hooks/Common';
8
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
9
+ import Routes from '../../../utils/Route';
10
+ import NewActionWrapper from '../AddNewAction/NewActionWrapper';
7
11
  import RepeatOptionsPopup, {
8
12
  REPEAT_OPTIONS,
9
13
  } from './components/RepeatOptionsPopup';
10
14
  import RowItem from './components/RowItem';
11
15
  import SelectWeekday from './components/SelectWeekday';
12
- import { useBoolean } from '../../../hooks/Common';
13
- import { useTranslations } from '../../../hooks/Common/useTranslations';
14
16
  import styles from './styles/indexStyles';
15
- import Routes from '../../../utils/Route';
16
- import NewActionWrapper from '../AddNewAction/NewActionWrapper';
17
17
 
18
18
  const SetSchedule = ({ route }) => {
19
19
  const t = useTranslations();
@@ -54,6 +54,7 @@ const SetSchedule = ({ route }) => {
54
54
  date_repeat: date.format('YYYY-MM-DD'),
55
55
  weekday_repeat: weekday,
56
56
  },
57
+ unitId: automate.unit,
57
58
  });
58
59
  }, [navigate, closeScreen, automate, repeat, time, date, weekday]);
59
60
 
@@ -65,9 +65,9 @@ export default StyleSheet.create({
65
65
  width: (Constants.width - 40) / 2,
66
66
  },
67
67
  automatesRow: {
68
+ display: 'flex',
68
69
  flexDirection: 'row',
69
70
  marginTop: 8,
70
71
  overflow: 'hidden',
71
- alignSelf: 'center',
72
72
  },
73
73
  });
@@ -76,7 +76,6 @@ describe('Test MultiUnits', () => {
76
76
  params: {
77
77
  isMultiUnits: true,
78
78
  unitName: null,
79
- unit: null,
80
79
  },
81
80
  });
82
81
  await act(async () => {
@@ -111,7 +110,6 @@ describe('Test MultiUnits', () => {
111
110
  expect(global.mockedNavigate).toBeCalledWith(Routes.UnitStack, {
112
111
  screen: Routes.ScriptDetail,
113
112
  params: {
114
- id: response[1].id,
115
113
  preAutomate: response[1],
116
114
  },
117
115
  });
@@ -120,7 +118,7 @@ describe('Test MultiUnits', () => {
120
118
  ItemAddNews[0].props.onAddNew();
121
119
  });
122
120
  expect(global.mockedNavigate).toBeCalledWith(Routes.UnitStack, {
123
- screen: Routes.AddUnknownTypeSmart,
121
+ screen: Routes.AddAutomationTypeSmart,
124
122
  params: {
125
123
  automate: { unit: undefined },
126
124
  closeScreen: undefined,
@@ -264,7 +262,6 @@ describe('Test MultiUnits', () => {
264
262
  params: {
265
263
  isMultiUnits: true,
266
264
  unitName: null,
267
- unit: null,
268
265
  },
269
266
  });
270
267
  await act(async () => {
@@ -173,7 +173,6 @@ describe('Test Automate', () => {
173
173
  params: {
174
174
  preAutomate: response.data[0].automates[0],
175
175
  closeScreen: undefined,
176
- id: 1,
177
176
  },
178
177
  });
179
178
  });
@@ -1,3 +1,9 @@
1
+ import { IconFill } from '@ant-design/icons-react-native';
2
+ import {
3
+ useIsFocused,
4
+ useNavigation,
5
+ useRoute,
6
+ } from '@react-navigation/native';
1
7
  import React, {
2
8
  useCallback,
3
9
  useEffect,
@@ -6,27 +12,21 @@ import React, {
6
12
  useState,
7
13
  } from 'react';
8
14
  import { FlatList, Image, TouchableOpacity, View } from 'react-native';
9
- import AntDesign from 'react-native-vector-icons/AntDesign';
10
- import {
11
- useIsFocused,
12
- useNavigation,
13
- useRoute,
14
- } from '@react-navigation/native';
15
15
  import { useSCContextSelector } from '../../context';
16
16
 
17
- import styles from './Styles/indexStyles';
17
+ import ItemAddNew from '../../commons/Device/ItemAddNew';
18
+ import ItemOneTap from '../../commons/SubUnit/OneTap/ItemOneTap';
19
+ import Text from '../../commons/Text';
18
20
  import { API, Colors, Images } from '../../configs';
21
+ import { AccessibilityLabel, UNIT_TYPES } from '../../configs/Constants';
22
+ import { useGetIdUser } from '../../hooks/Common';
23
+ import { useTranslations } from '../../hooks/Common/useTranslations';
19
24
  import { axiosGet } from '../../utils/Apis/axios';
20
- import Text from '../../commons/Text';
21
- import ItemOneTap from '../../commons/SubUnit/OneTap/ItemOneTap';
25
+ import { useBackendPermission } from '../../utils/Permission/backend';
22
26
  import Routes from '../../utils/Route';
23
- import Loading from './Components/Loading';
24
- import ItemAddNew from '../../commons/Device/ItemAddNew';
25
- import { useTranslations } from '../../hooks/Common/useTranslations';
26
- import { useGetIdUser } from '../../hooks/Common';
27
- import { AccessibilityLabel, UNIT_TYPES } from '../../configs/Constants';
28
27
  import { keyExtractor, ToastBottomHelper } from '../../utils/Utils';
29
- import { useBackendPermission } from '../../utils/Permission/backend';
28
+ import Loading from './Components/Loading';
29
+ import styles from './Styles/indexStyles';
30
30
 
31
31
  const Automate = () => {
32
32
  const t = useTranslations();
@@ -75,7 +75,6 @@ const Automate = () => {
75
75
  navigate(Routes.UnitStack, {
76
76
  screen: Routes.ScriptDetail,
77
77
  params: {
78
- id: item?.id,
79
78
  closeScreen: currentRouteName,
80
79
  preAutomate: item, // pre-loaded automate data
81
80
  },
@@ -164,29 +163,32 @@ const Automate = () => {
164
163
  <Image source={Images.arrowBack} style={styles.arrowRight} />
165
164
  </TouchableOpacity>
166
165
  </View>
167
- {!!automates?.length && (
168
- <View style={styles.automatesRow}>
169
- <ItemOneTap
170
- isOwner={isOwner}
171
- automate={automates[0]}
172
- wrapSyles={styles.wrapAutomateItem}
173
- onPressItem={() =>
174
- onPressItem(automates[0], unit_id, type, isOwner)
175
- }
176
- />
177
- {!!automates[1] && (
166
+ <View style={styles.automatesRow}>
167
+ {!!automates?.length && (
168
+ <>
178
169
  <ItemOneTap
179
170
  isOwner={isOwner}
180
- automate={automates[1]}
171
+ automate={automates[0]}
181
172
  wrapSyles={styles.wrapAutomateItem}
182
173
  onPressItem={() =>
183
- onPressItem(automates[1], unit_id, type, isOwner)
174
+ onPressItem(automates[0], unit_id, type, isOwner)
184
175
  }
185
176
  />
186
- )}
187
- </View>
188
- )}
189
- {!automates?.length && renderListFooterComponent(unit_id, automates)}
177
+ {!!automates[1] && (
178
+ <ItemOneTap
179
+ isOwner={isOwner}
180
+ automate={automates[1]}
181
+ wrapSyles={styles.wrapAutomateItem}
182
+ onPressItem={() =>
183
+ onPressItem(automates[1], unit_id, type, isOwner)
184
+ }
185
+ />
186
+ )}
187
+ </>
188
+ )}
189
+ {(!automates?.length || automates.length === 1) &&
190
+ renderListFooterComponent(unit_id, automates)}
191
+ </View>
190
192
  </View>
191
193
  );
192
194
  },
@@ -210,7 +212,7 @@ const Automate = () => {
210
212
  /* istanbul ignore next */
211
213
  headerRight: () => (
212
214
  <TouchableOpacity style={styles.buttonAdd}>
213
- <AntDesign name={'pluscircle'} size={28} color={Colors.Orange} />
215
+ <IconFill name={'plus-circle'} size={28} color={Colors.Orange} />
214
216
  </TouchableOpacity>
215
217
  ),
216
218
  });
@@ -49,7 +49,8 @@ const ChangePosition = () => {
49
49
  }
50
50
  };
51
51
 
52
- const renderItem = ({ item, index, drag, isActive }) => {
52
+ const renderItem = ({ item, getIndex, drag, isActive }) => {
53
+ const index = getIndex();
53
54
  return (
54
55
  <View style={styles.widgetItem}>
55
56
  <View style={[styles.itemOrder, isActive ? styles.isDragging : {}]}>