@eohjsc/react-native-smart-city 0.2.23 → 0.2.26

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 (191) hide show
  1. package/README.md +1 -1
  2. package/assets/images/OneTap@1x.svg +14 -0
  3. package/index.js +0 -2
  4. package/package.json +11 -3
  5. package/src/Images/Common/arrow-back.png +0 -0
  6. package/src/Images/Common/checked@2x.png +0 -0
  7. package/src/Images/Common/checked@3x.png +0 -0
  8. package/src/Images/Common/file.png +0 -0
  9. package/src/Images/Common/fullscreen.png +0 -0
  10. package/src/Images/Common/refresh.png +0 -0
  11. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +1 -1
  12. package/src/commons/ActionGroup/OnOffTemplate/index.js +4 -4
  13. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +1 -1
  14. package/src/commons/ActionGroup/StatesGridActionTemplate.js +2 -2
  15. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +8 -13
  16. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +3 -3
  17. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +26 -46
  18. package/src/commons/ActionGroup/__test__/ThreeButtonTemplate.test.js +11 -5
  19. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +14 -8
  20. package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +17 -23
  21. package/src/commons/ActionGroup/__test__/__snapshots__/ThreeButtonTemplate.test.js.snap +241 -223
  22. package/src/commons/ActionGroup/__test__/index.test.js +39 -107
  23. package/src/commons/ActionTemplate/ActionTemplateStyles.js +14 -0
  24. package/src/commons/ActionTemplate/OnOffButtonAction.js +40 -0
  25. package/src/commons/ActionTemplate/OnOffButtonActionStyles.js +11 -0
  26. package/src/commons/ActionTemplate/OneButtonAction.js +26 -0
  27. package/src/commons/ActionTemplate/OneButtonActionStyles.js +11 -0
  28. package/src/commons/ActionTemplate/ThreeButtonAction.js +55 -0
  29. package/src/commons/ActionTemplate/ThreeButtonActionStyles.js +11 -0
  30. package/src/commons/ActionTemplate/__test__/OnOffButtonAction.test.js +34 -0
  31. package/src/commons/ActionTemplate/__test__/OneButtonAction.test.js +33 -0
  32. package/src/commons/ActionTemplate/__test__/ThreeButtonAction.test.js +35 -0
  33. package/src/commons/ActionTemplate/__test__/index.test.js +71 -0
  34. package/src/commons/ActionTemplate/index.js +69 -0
  35. package/src/commons/Automate/ItemAutomate.js +1 -31
  36. package/src/commons/Automate/ItemAutomateStyles.js +10 -7
  37. package/src/commons/Automate/ItemScriptAction.js +9 -5
  38. package/src/commons/Automate/ItemScriptActionStyles.js +4 -0
  39. package/src/commons/ChartLoading/__test__/ChartLoading.test.js +9 -7
  40. package/src/commons/Device/DeviceAlertStatus.js +3 -1
  41. package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +14 -6
  42. package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +10 -2
  43. package/src/commons/Device/FlatListItems.js +1 -1
  44. package/src/commons/Device/ItemAddNew/index.js +6 -1
  45. package/src/commons/Device/WindDirection/Compass/Compass.test.js +19 -11
  46. package/src/commons/Device/WindSpeed/LinearChart/__test__/LinearChart.test.js +9 -3
  47. package/src/commons/Device/WindSpeed/LinearChart/__test__/__snapshots__/LinearChart.test.js.snap +0 -81
  48. package/src/commons/Device/__test__/ConnectedViewHeader.test.js +16 -8
  49. package/src/commons/Device/__test__/DeviceAlertStatus.test.js +13 -6
  50. package/src/commons/Device/__test__/DisconnectedView.test.js +13 -5
  51. package/src/commons/Device/__test__/FlatListItems.test.js +9 -1
  52. package/src/commons/Device/__test__/FooterInfo.test.js +13 -4
  53. package/src/commons/Device/__test__/SensorConnectedStatus.test.js +9 -1
  54. package/src/commons/Device/__test__/__snapshots__/DisconnectedView.test.js.snap +20 -20
  55. package/src/commons/DisplayChecking/__test__/DisplayChecking.test.js +28 -0
  56. package/src/commons/Explore/SearchBox/__test__/SearchBox.test.js +9 -2
  57. package/src/commons/Explore/__test__/CityItem.test.js +13 -15
  58. package/src/commons/Explore/__test__/HeaderLabel.test.js +15 -9
  59. package/src/commons/Header/HeaderCustom.js +7 -1
  60. package/src/commons/Header/__test__/HeaderCT.test.js +12 -4
  61. package/src/commons/ImagePicker/__test__/ImagePicker.test.js +19 -13
  62. package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +14 -8
  63. package/src/commons/MediaPlayerDetail/index.js +2 -0
  64. package/src/commons/MenuActionAddnew/__test__/MenuActionAddNew.test.js +11 -20
  65. package/src/commons/Modal/ModalBottom.js +51 -0
  66. package/src/commons/Modal/Styles/ModalBottomStyles.js +35 -0
  67. package/src/commons/Modal/index.js +2 -1
  68. package/src/commons/SelectActionCard/SelectActionStyles.js +16 -0
  69. package/src/commons/SelectActionCard/index.js +30 -0
  70. package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +15 -9
  71. package/src/commons/Sharing/__test__/MemberList.test.js +17 -25
  72. package/src/commons/Sharing/__test__/StationDevicePermission.test.js +17 -12
  73. package/src/commons/Sharing/__test__/WrapHeaderScrollable.test.js +0 -9
  74. package/src/commons/SubUnit/OneTap/ItemOneTap.js +20 -9
  75. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +149 -0
  76. package/src/commons/SubUnit/OneTap/index.js +16 -6
  77. package/src/commons/SubUnit/ShortDetail.js +9 -5
  78. package/src/commons/SubUnit/__test__/ShortDetail.test.js +14 -6
  79. package/src/commons/Today/__test__/Today.test.js +9 -1
  80. package/src/commons/Today/__test__/__snapshots__/Today.test.js.snap +1 -1
  81. package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +16 -17
  82. package/src/commons/UnitSummary/__test__/TotalPowerConsumption.test.js +15 -9
  83. package/src/configs/API.js +6 -1
  84. package/src/configs/Constants.js +42 -0
  85. package/src/context/SCContext.tsx +2 -26
  86. package/src/context/actionType.ts +11 -0
  87. package/src/context/mockStore.ts +49 -0
  88. package/src/context/reducer.ts +21 -0
  89. package/src/hooks/Common/__test__/useTranslations.test.js +23 -0
  90. package/src/hooks/Common/index.js +2 -0
  91. package/src/hooks/Common/useGetIdUser.js +9 -0
  92. package/src/iot/RemoteControl/__test__/Bluetooth.test.js +3 -6
  93. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +3 -4
  94. package/src/iot/RemoteControl/__test__/Internet.test.js +1 -9
  95. package/src/iot/RemoteControl/__test__/LgThinq.test.js +7 -10
  96. package/src/navigations/UnitStack.js +14 -0
  97. package/src/screens/AQIGuide/__test__/AQIGuide.test.js +9 -1
  98. package/src/screens/AQIGuide/index.js +1 -1
  99. package/src/screens/ActivityLog/__test__/index.test.js +14 -39
  100. package/src/screens/AddCommon/SelectSubUnit.js +2 -2
  101. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +61 -0
  102. package/src/screens/AddCommon/__test__/SelectUnit.test.js +18 -10
  103. package/src/screens/AddNewAction/Device/__test__/index.test.js +42 -0
  104. package/src/screens/AddNewAction/SelectAction.js +152 -0
  105. package/src/screens/AddNewAction/SelectDevice.js +25 -11
  106. package/src/screens/AddNewAction/Styles/SelectActionStyles.js +24 -0
  107. package/src/screens/AddNewAction/__test__/SelectAction.test.js +172 -0
  108. package/src/screens/AddNewAction/__test__/SelectDevice.test.js +191 -0
  109. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +55 -0
  110. package/src/screens/AddNewAutoSmart/index.js +85 -0
  111. package/src/screens/AddNewAutoSmart/styles/AddNewAutoSmartStyles.js +36 -0
  112. package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +29 -14
  113. package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +19 -8
  114. package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +16 -7
  115. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +35 -73
  116. package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +14 -5
  117. package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +20 -11
  118. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +129 -0
  119. package/src/screens/AddNewOneTap/index.js +20 -7
  120. package/src/screens/AddNewScriptAction/AddNewScriptActionStyles.js +1 -0
  121. package/src/screens/AddNewScriptAction/index.js +21 -13
  122. package/src/screens/Device/__test__/detail.test.js +26 -19
  123. package/src/screens/Device/detail.js +5 -4
  124. package/src/screens/Device/hooks/useCountUp.js +4 -0
  125. package/src/screens/Device/styles.js +5 -1
  126. package/src/screens/DeviceInfo/__test__/index.test.js +12 -3
  127. package/src/screens/EditActionsList/Styles/indexStyles.js +11 -0
  128. package/src/screens/EditActionsList/index.js +83 -19
  129. package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +15 -19
  130. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +19 -24
  131. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +10 -25
  132. package/src/screens/ManageAccess/__test__/ManageAccess.test.js +13 -1
  133. package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +2 -11
  134. package/src/screens/ScriptDetail/Styles/indexStyles.js +4 -1
  135. package/src/screens/ScriptDetail/index.js +30 -28
  136. package/src/screens/SharedUnit/__test__/TabHeader.test.js +40 -0
  137. package/src/screens/Sharing/__test__/MemberList.test.js +17 -14
  138. package/src/screens/Sharing/__test__/SelectPermission.test.js +16 -8
  139. package/src/screens/Sharing/__test__/SelectUser.test.js +33 -16
  140. package/src/screens/SubUnit/Detail.js +3 -3
  141. package/src/screens/SubUnit/ManageSubUnit.js +8 -8
  142. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +17 -12
  143. package/src/screens/SubUnit/__test__/Detail.test.js +11 -31
  144. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +42 -32
  145. package/src/screens/TDSGuide/__test__/TDSGuide.test.js +9 -1
  146. package/src/screens/UVIndexGuide/__test__/UVIndexGuide.test.js +9 -1
  147. package/src/screens/Unit/Detail.js +33 -11
  148. package/src/screens/Unit/ManageUnit.js +1 -1
  149. package/src/screens/Unit/__test__/AddMenu.test.js +15 -15
  150. package/src/screens/Unit/__test__/CheckSendEmail.test.js +19 -10
  151. package/src/screens/Unit/__test__/Detail.test.js +92 -33
  152. package/src/screens/Unit/__test__/ManageUnit.test.js +16 -23
  153. package/src/screens/Unit/components/__test__/SharedUnit.test.js +11 -2
  154. package/src/screens/UnitSummary/__test__/index.test.js +12 -4
  155. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +13 -3
  156. package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +16 -12
  157. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -2
  158. package/src/screens/UnitSummary/components/UvIndex/__test__/__snapshots__/index.test.js.snap +37 -37
  159. package/src/screens/UnitSummary/components/UvIndex/__test__/index.test.js +14 -6
  160. package/src/screens/UnitSummary/components/WaterQuality/__test__/index.test.js +11 -5
  161. package/src/screens/UnitSummary/components/__test__/TotalPowerConsumption.test.js +13 -7
  162. package/src/screens/WaterQualityGuide/__test__/index.test.js +12 -12
  163. package/src/utils/I18n/translations/en.json +9 -2
  164. package/src/utils/I18n/translations/vi.json +10 -3
  165. package/src/utils/Route/index.js +3 -2
  166. package/assets/images/Event.svg +0 -9
  167. package/src/commons/ChartLoading/__test__/__snapshots__/ChartLoading.test.js.snap +0 -66
  168. package/src/commons/Device/HistoryChart/__test__/HistoryChart.test.js +0 -57
  169. package/src/commons/Device/HistoryChart/__test__/__snapshots__/HistoryChart.test.js.snap +0 -593
  170. package/src/commons/Explore/SearchBox/__test__/__snapshots__/SearchBox.test.js.snap +0 -59
  171. package/src/commons/Explore/__test__/HeaderExplore.test.js +0 -21
  172. package/src/commons/Header/__test__/Header.test.js +0 -24
  173. package/src/commons/MenuActionAddnew/__test__/__snapshots__/MenuActionAddNew.test.js.snap +0 -788
  174. package/src/commons/Sharing/__test__/__snapshots__/WrapHeaderScrollable.test.js.snap +0 -174
  175. package/src/commons/UnitSummary/AirQuality/__test__/__snapshots__/index.test.js.snap +0 -26679
  176. package/src/iot/RemoteControl/__test__/index.test.js +0 -102
  177. package/src/iot/__test__/Monitor.test.js +0 -119
  178. package/src/navigations/AddNewActionStack.js +0 -23
  179. package/src/screens/EmergencyContacts/__test__/__snapshots__/EmergencyContactAddNew.test.js.snap +0 -1706
  180. package/src/screens/EmergencyContacts/__test__/__snapshots__/EmergencyContactList.test.js.snap +0 -4276
  181. package/src/screens/EmergencyContacts/__test__/__snapshots__/EmergencyContactsSelectContacts.test.js.snap +0 -2240
  182. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +0 -359
  183. package/src/screens/Unit/MyAllUnit/__test__/__snapshots__/index.test.js.snap +0 -1001
  184. package/src/screens/Unit/MyAllUnit/__test__/index.test.js +0 -48
  185. package/src/screens/Unit/components/MyAllUnit/__test__/__snapshots__/index.test.js.snap +0 -1001
  186. package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -48
  187. package/src/screens/Unit/components/__test__/MyUnit.test.js +0 -85
  188. package/src/screens/UnitSummary/components/WaterQuality/__test__/__snapshots__/index.test.js.snap +0 -1574
  189. package/src/screens/WaterQualityGuide/__test__/__snapshots__/index.test.js.snap +0 -3375
  190. package/src/utils/Converter/__test__/time.test.js +0 -128
  191. package/src/utils/I18n/index.test.js +0 -7
@@ -5,6 +5,14 @@ import AirQuality from '../index';
5
5
  import { Section } from '../../../index';
6
6
  import Text from '../../../Text';
7
7
  import { TESTID } from '../../../../configs/Constants';
8
+ import { SCProvider } from '../../../../context';
9
+ import { mockSCStore } from '../../../../context/mockStore';
10
+
11
+ const wrapComponent = (data) => (
12
+ <SCProvider initState={mockSCStore({})}>
13
+ <AirQuality {...data} />
14
+ </SCProvider>
15
+ );
8
16
 
9
17
  describe('Test AirQuality', () => {
10
18
  let data;
@@ -40,12 +48,11 @@ describe('Test AirQuality', () => {
40
48
 
41
49
  test('render AirQuality', async () => {
42
50
  act(() => {
43
- tree = create(<AirQuality {...data} />);
51
+ tree = create(wrapComponent(data));
44
52
  });
45
53
  const instance = tree.root;
46
54
  const sections = instance.findAllByType(Section);
47
55
  expect(sections).toHaveLength(2);
48
- expect(tree.toJSON()).toMatchSnapshot();
49
56
  });
50
57
 
51
58
  test('without showBoxHistory', async () => {
@@ -54,12 +61,11 @@ describe('Test AirQuality', () => {
54
61
  data.summaryDetail.outdoor_co_id = null;
55
62
 
56
63
  act(() => {
57
- tree = create(<AirQuality {...data} />);
64
+ tree = create(wrapComponent(data));
58
65
  });
59
66
  const instance = tree.root;
60
67
  const sections = instance.findAllByType(Section);
61
68
  expect(sections).toHaveLength(1);
62
- expect(tree.toJSON()).toMatchSnapshot();
63
69
  });
64
70
 
65
71
  test('value is undefined', async () => {
@@ -68,7 +74,7 @@ describe('Test AirQuality', () => {
68
74
  data.summaryDetail.outdoor_co_value = undefined;
69
75
 
70
76
  act(() => {
71
- tree = create(<AirQuality {...data} />);
77
+ tree = create(wrapComponent(data));
72
78
  });
73
79
  const instance = tree.root;
74
80
  const buttons = instance.findAll(
@@ -77,7 +83,6 @@ describe('Test AirQuality', () => {
77
83
  el.type === TouchableOpacity
78
84
  );
79
85
  expect(buttons).toHaveLength(3);
80
- expect(tree.toJSON()).toMatchSnapshot();
81
86
  });
82
87
 
83
88
  test('onSelectOutdoor', async () => {
@@ -93,7 +98,7 @@ describe('Test AirQuality', () => {
93
98
  const styleInactive = { backgroundColor: '#FFFFFF', borderWidth: 1 };
94
99
 
95
100
  act(() => {
96
- tree = create(<AirQuality {...data} />);
101
+ tree = create(wrapComponent(data));
97
102
  });
98
103
  const instance = tree.root;
99
104
  const buttons = instance.findAll(
@@ -112,14 +117,12 @@ describe('Test AirQuality', () => {
112
117
  expect(buttons[0].props.style).toEqual([styleTouch, styleInactive]);
113
118
  expect(buttons[1].props.style).toEqual([styleTouch, styleActive]);
114
119
  expect(buttons[2].props.style).toEqual([styleTouch, styleInactive]);
115
-
116
- expect(tree.toJSON()).toMatchSnapshot();
117
120
  });
118
121
 
119
122
  test('advices', async () => {
120
123
  data.summaryDetail.advices = ['Amazing Good Chop'];
121
124
  act(() => {
122
- tree = create(<AirQuality {...data} />);
125
+ tree = create(wrapComponent(data));
123
126
  });
124
127
  const instance = tree.root;
125
128
  const text = instance.find(
@@ -128,13 +131,12 @@ describe('Test AirQuality', () => {
128
131
  el.type === Text
129
132
  );
130
133
  expect(text.props.children).toEqual('Amazing Good Chop');
131
- expect(tree.toJSON()).toMatchSnapshot();
132
134
  });
133
135
 
134
136
  test('without outdoor_pm2_5_value', async () => {
135
137
  data.summaryDetail.outdoor_pm2_5_value = null;
136
138
  act(() => {
137
- tree = create(<AirQuality {...data} />);
139
+ tree = create(wrapComponent(data));
138
140
  });
139
141
  const instance = tree.root;
140
142
  const buttons = instance.findAll(
@@ -143,13 +145,12 @@ describe('Test AirQuality', () => {
143
145
  el.type === TouchableOpacity
144
146
  );
145
147
  expect(buttons).toHaveLength(2);
146
- expect(tree.toJSON()).toMatchSnapshot();
147
148
  });
148
149
 
149
150
  test('without outdoor_pm10_value', async () => {
150
151
  data.summaryDetail.outdoor_pm10_value = null;
151
152
  act(() => {
152
- tree = create(<AirQuality {...data} />);
153
+ tree = create(wrapComponent(data));
153
154
  });
154
155
  const instance = tree.root;
155
156
  const buttons = instance.findAll(
@@ -158,13 +159,12 @@ describe('Test AirQuality', () => {
158
159
  el.type === TouchableOpacity
159
160
  );
160
161
  expect(buttons).toHaveLength(2);
161
- expect(tree.toJSON()).toMatchSnapshot();
162
162
  });
163
163
 
164
164
  test('without outdoor_co_value', async () => {
165
165
  data.summaryDetail.outdoor_co_value = null;
166
166
  act(() => {
167
- tree = create(<AirQuality {...data} />);
167
+ tree = create(wrapComponent(data));
168
168
  });
169
169
  const instance = tree.root;
170
170
  const buttons = instance.findAll(
@@ -173,6 +173,5 @@ describe('Test AirQuality', () => {
173
173
  el.type === TouchableOpacity
174
174
  );
175
175
  expect(buttons).toHaveLength(2);
176
- expect(tree.toJSON()).toMatchSnapshot();
177
176
  });
178
177
  });
@@ -2,19 +2,25 @@ import TotalPowerConsumption from '../TotalPowerConsumption/index';
2
2
  import React from 'react';
3
3
  import renderer, { act } from 'react-test-renderer';
4
4
  import { TESTID } from '../../../configs/Constants';
5
+ import { SCProvider } from '../../../context';
6
+ import { mockSCStore } from '../../../context/mockStore';
7
+
8
+ const wrapComponent = () => (
9
+ <SCProvider initState={mockSCStore({})}>
10
+ <TotalPowerConsumption
11
+ total={{
12
+ value: 10,
13
+ }}
14
+ />
15
+ </SCProvider>
16
+ );
5
17
 
6
18
  describe('Test Total Power Consumption', () => {
7
19
  let tree;
8
20
 
9
- test('render Total Power Consumption', () => {
10
- act(() => {
11
- tree = renderer.create(
12
- <TotalPowerConsumption
13
- total={{
14
- value: 10,
15
- }}
16
- />
17
- );
21
+ test('render Total Power Consumption', async () => {
22
+ await act(() => {
23
+ tree = renderer.create(wrapComponent());
18
24
  });
19
25
  const instance = tree.root;
20
26
  const item = instance.find(
@@ -71,6 +71,8 @@ const API = {
71
71
  REMOVE_FROM_FAVOURITES: (unit_id, station_id, id) =>
72
72
  SCConfig.apiRoot +
73
73
  `/property_manager/${unit_id}/sub_units/${station_id}/devices/${id}/remove_from_favourites/`,
74
+ DISPLAY_ACTIONS: (id) =>
75
+ SCConfig.apiRoot + `/property_manager/sensors/${id}/display_actions/`,
74
76
  },
75
77
  SHARED_SENSOR: {
76
78
  ACCESS: (id) =>
@@ -87,10 +89,13 @@ const API = {
87
89
  SCConfig.apiRoot + `/property_manager/automate/${id}/script/`,
88
90
  ORDER_SCRIPT_ACTION: (id) =>
89
91
  SCConfig.apiRoot +
90
- `/api/property_manager/automate/${id}/order_script_action/`,
92
+ `/property_manager/automate/${id}/order_script_action/`,
91
93
  DELETE_SCRIPT_ACTION: (automateId, actionId) =>
92
94
  SCConfig.apiRoot +
93
95
  `/property_manager/automate/${automateId}/script_action/${actionId}/`,
96
+ ADD_SCRIPT_ACTION: (id) =>
97
+ SCConfig.apiRoot + `/property_manager/automate/${id}/add_script_action/`,
98
+ CREATE_AUTOMATE: () => SCConfig.apiRoot + '/property_manager/automate/',
94
99
  },
95
100
  GOOGLE_HOME: {
96
101
  CHECK_SEND_EMAIL: () =>
@@ -1,5 +1,8 @@
1
1
  import { Platform, Dimensions, StatusBar } from 'react-native';
2
2
  import { RFValue } from 'react-native-responsive-fontsize';
3
+ import OneTap from '../../assets/images/OneTap.svg';
4
+ import WeatherChange from '../../assets/images/WeatherChange.svg';
5
+ import Schedule from '../../assets/images/Schedule.svg';
3
6
 
4
7
  const X_WIDTH = 375;
5
8
  const X_HEIGHT = 812;
@@ -80,6 +83,37 @@ export const SCANNING_STATUS = {
80
83
  SPOT_DOES_NOT_EXIST: 'spot_does_not_exist',
81
84
  };
82
85
 
86
+ export const SubUnitName = {
87
+ scenario: 'Kịch Bản',
88
+ };
89
+
90
+ export const AUTOMATE_TYPE = {
91
+ ONE_TAP: 'one_tap',
92
+ VALUE_CHANGE: 'value_change',
93
+ SCHEDULE: 'schedule',
94
+ };
95
+
96
+ export const AUTOMATES = {
97
+ one_tap: {
98
+ value: AUTOMATE_TYPE.ONE_TAP,
99
+ title: 'Launch One-Tap',
100
+ explanation: 'Do everything with just one button',
101
+ icon: OneTap,
102
+ },
103
+ value_change: {
104
+ value: AUTOMATE_TYPE.VALUE_CHANGE,
105
+ title: 'When weather change',
106
+ explanation: 'Short Explanation',
107
+ icon: WeatherChange,
108
+ },
109
+ schedule: {
110
+ value: AUTOMATE_TYPE.SCHEDULE,
111
+ title: 'Schedule',
112
+ explanation: 'Short Explanation',
113
+ icon: Schedule,
114
+ },
115
+ };
116
+
83
117
  export const TESTID = {
84
118
  // Dashboard
85
119
  DASHBOARD_TAB_HOME: 'DASHBOARD_TAB_HOME',
@@ -119,6 +153,7 @@ export const TESTID = {
119
153
  MY_UNIT_NO_UNIT: 'MY_UNIT_NO_UNIT',
120
154
 
121
155
  // sub unit
156
+ SUB_UNIT_FULL_CAMERA: 'SUB_UNIT_FULL_CAMERA',
122
157
  SUB_UNIT_CAMERA_VIEW: 'SUB_UNIT_CAMERA_VIEW',
123
158
  SUB_UNIT_BACKGROUND: 'SUB_UNIT_BACKGROUND',
124
159
  SUB_UNIT_GO_TO_DETAIL: 'SUB_UNIT_GO_TO_DETAIL',
@@ -220,6 +255,11 @@ export const TESTID = {
220
255
  ITEM_TEXT_INPUT: 'ITEM_TEXT_INPUT',
221
256
  ITEM_TEXT_ERROR: 'ITEM_TEXT_ERROR',
222
257
  SEARCH_BAR_INPUT: 'SEARCH_BAR_INPUT',
258
+ GO_DETAIL: 'GO_DETAIL',
259
+
260
+ // Automate
261
+ AUTOMATE_SCRIPT_ACTION: 'AUTOMATE_SCRIPT_ACTION',
262
+ NAME_YOUR_BUTTON: 'NAME_YOUR_BUTTON',
223
263
 
224
264
  // Parking input maunaly spot
225
265
  PARKING_SPOT_INFO_BUTTON: 'PARKING_SPOT_INFO_BUTTON',
@@ -263,6 +303,7 @@ export const TESTID = {
263
303
  SENSOR_DISPLAY_ITEM: 'SENSOR_DISPLAY_ITEM',
264
304
  ITEM_QUICK_ACTION_PRESS: 'ITEM_QUICK_ACTION_PRESS',
265
305
  TIME_COUNT_DOWN_TEXT: 'TIME_COUNT_DOWN_TEXT',
306
+ ACTION_ITEM: 'ACTION_ITEM',
266
307
 
267
308
  // DeviceInfo
268
309
  DEVICE_INFO_BATTERY: 'DEVICE_INFO_BATTERY',
@@ -393,6 +434,7 @@ export const TESTID = {
393
434
  MANAGE_UNIT: 'MANAGE_UNIT',
394
435
  MANAGE_UNIT_ALERT: 'MANAGE_UNIT_ALERT',
395
436
  SELECT_UNIT: 'SELECT_UNIT',
437
+ BUTTON_ADD_AUTO_SMART: 'BUTTON_ADD_AUTO_SMART',
396
438
  },
397
439
 
398
440
  TERM_AND_POLICY_TITLE: 'TERM_AND_POLICY_TITLE',
@@ -1,9 +1,5 @@
1
1
  import React, { useContext, useReducer } from 'react';
2
- import { StyleSheet, View, Text } from 'react-native';
3
- import Toast from 'react-native-toast-message';
4
2
 
5
- import { Alert } from '../commons';
6
- import { Colors } from '../configs';
7
3
  import {
8
4
  ActionDataMap,
9
5
  ActionType,
@@ -14,15 +10,6 @@ import {
14
10
  import { initialState, Action, ContextData, reducer } from './reducer';
15
11
  import { setConfigGlobalState } from '../iot/states.js';
16
12
 
17
- const toastConfig = {
18
- // only for error for now
19
- error: (internalState) => (
20
- <View style={styles.toastContainer}>
21
- <Text style={styles.textWhite}>{internalState.text1}</Text>
22
- </View>
23
- ),
24
- };
25
-
26
13
  type SCContextType = {
27
14
  stateData: ContextData;
28
15
  setAuth: (authData: AuthData) => void;
@@ -79,8 +66,8 @@ export const SCProvider = ({ children }) => {
79
66
  return (
80
67
  <SCContext.Provider value={providerValue}>
81
68
  {children}
82
- <Alert ref={(ref) => Alert.setRef(ref)} />
83
- <Toast config={toastConfig} ref={(ref) => Toast.setRef(ref)} />
69
+ {/* <Alert ref={(ref) => Alert.setRef(ref)} />
70
+ <Toast config={toastConfig} ref={(ref) => Toast.setRef(ref)} /> */}
84
71
  </SCContext.Provider>
85
72
  );
86
73
  };
@@ -91,14 +78,3 @@ export const useSCContextSelector = (
91
78
  const { stateData } = useContext(SCContext);
92
79
  return selector(stateData);
93
80
  };
94
-
95
- const styles = StyleSheet.create({
96
- toastContainer: {
97
- borderRadius: 5,
98
- padding: 10,
99
- backgroundColor: Colors.Black,
100
- },
101
- textWhite: {
102
- color: Colors.White,
103
- },
104
- });
@@ -3,6 +3,7 @@ export const Action = {
3
3
  UPDATE_LANGUAGE: 'UPDATE_LANGUAGE',
4
4
  STORE_STATUS_BAR: 'STORE_STATUS_BAR',
5
5
  LIST_DEVICE_TYPES: 'LIST_DEVICE_TYPES',
6
+ LIST_ACTION: 'LIST_ACTION',
6
7
  };
7
8
 
8
9
  export type AuthData = {
@@ -25,6 +26,15 @@ export type ListDevice = {
25
26
  sentEmail: boolean;
26
27
  };
27
28
 
29
+ export type ListAction = {
30
+ action: string;
31
+ unit_name: string;
32
+ action_name: string;
33
+ sensor_name: string;
34
+ sensor_icon_kit: string;
35
+ station_name: string;
36
+ }[];
37
+
28
38
  export type ActionType = keyof typeof Action;
29
39
 
30
40
  export type ActionDataMap = {
@@ -32,4 +42,5 @@ export type ActionDataMap = {
32
42
  UPDATE_LANGUAGE: Language;
33
43
  STORE_STATUS_BAR: StatusBar;
34
44
  LIST_DEVICE_TYPES: ListDevice;
45
+ LIST_ACTION: ListAction;
35
46
  };
@@ -0,0 +1,49 @@
1
+ import { ContextData } from './reducer';
2
+
3
+ export const mockDataStore: ContextData = {
4
+ auth: {
5
+ account: {
6
+ token: 'TOKEN',
7
+ user: {
8
+ avatar: null,
9
+ email: 'test@gmail.com',
10
+ id: 1,
11
+ is_using_social_avatar: false,
12
+ name: 'TEST',
13
+ org: 2,
14
+ phone_number: '012345678',
15
+ social_avatar_hash: '',
16
+ },
17
+ },
18
+ },
19
+ language: 'vi',
20
+ listDevice: {
21
+ sentEmail: false,
22
+ },
23
+ statusBar: {
24
+ backgroundColor: '',
25
+ barStyle: '',
26
+ },
27
+ };
28
+
29
+ export const mockSCStore = (data: ContextData): ContextData => {
30
+ return {
31
+ auth: {
32
+ account: {
33
+ ...mockDataStore.auth.account,
34
+ ...data.auth?.account,
35
+ },
36
+ },
37
+ language: data.language ? data.language : mockDataStore.language,
38
+ listDevice: {
39
+ ...mockDataStore.listDevice,
40
+ ...data.listDevice,
41
+ },
42
+ statusBar: {
43
+ backgroundColor:
44
+ data?.statusBar?.backgroundColor ||
45
+ mockDataStore?.statusBar?.backgroundColor,
46
+ barStyle: data?.statusBar?.barStyle || mockDataStore?.statusBar?.barStyle,
47
+ },
48
+ };
49
+ };
@@ -6,12 +6,15 @@ import {
6
6
  StatusBar,
7
7
  Action,
8
8
  ListDevice,
9
+ ListAction,
9
10
  } from './actionType';
10
11
 
11
12
  export type ContextData = {
12
13
  auth: AuthData;
13
14
  language: Language;
14
15
  listDevice: ListDevice;
16
+ listAction: ListAction;
17
+ statusBar: StatusBar;
15
18
  };
16
19
 
17
20
  export type Action = {
@@ -31,6 +34,7 @@ export const initialState = {
31
34
  language: 'en' as Language,
32
35
  statusBar: {} as StatusBar,
33
36
  listDevice: {} as ListDevice,
37
+ listAction: [] as ListAction,
34
38
  };
35
39
 
36
40
  export const reducer = (currentState: ContextData, action: Action) => {
@@ -62,6 +66,23 @@ export const reducer = (currentState: ContextData, action: Action) => {
62
66
  };
63
67
  }
64
68
 
69
+ case Action.LIST_ACTION:
70
+ let newListAction = [...currentState.listAction];
71
+
72
+ if (Object.keys(payload).length === 0) {
73
+ newListAction = [];
74
+ } else {
75
+ const order = newListAction.length + 1;
76
+
77
+ const isHaveAction = newListAction.findIndex(
78
+ (item) => item.action === payload.action
79
+ );
80
+ if (isHaveAction < 0) {
81
+ newListAction.push({ ...payload, order });
82
+ }
83
+ }
84
+
85
+ return { ...currentState, listAction: newListAction };
65
86
  default:
66
87
  return currentState;
67
88
  }
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { renderHook } from '@testing-library/react-hooks';
3
+ import { SCProvider } from '../../../context';
4
+ import { mockSCStore } from '../../../context/mockStore';
5
+ import { useTranslations } from '../useTranslations';
6
+
7
+ const mockedSetAction = jest.fn();
8
+
9
+ const wrapper = ({ children }) => <SCProvider>{children}</SCProvider>;
10
+
11
+ const mockUseContext = jest.fn().mockImplementation(() => ({
12
+ stateData: mockSCStore({}),
13
+ setAction: mockedSetAction,
14
+ }));
15
+
16
+ React.useContext = mockUseContext;
17
+
18
+ describe('Test useTranslations', () => {
19
+ it('test useTranslations', () => {
20
+ // eslint-disable-next-line no-unused-vars
21
+ const { result } = renderHook(() => useTranslations(), { wrapper });
22
+ });
23
+ });
@@ -8,6 +8,7 @@ import useControllList from './useControllList';
8
8
  import { useBlockBackAndroid } from './useBlockBackAndroid';
9
9
  import { useIsOwnerOfUnit } from './useIsOwnerOfUnit';
10
10
  import { useStatusBar } from './useStatusBar';
11
+ import { useGetIdUser } from './useGetIdUser';
11
12
 
12
13
  export {
13
14
  useAndroidTranslucentStatusBar,
@@ -20,4 +21,5 @@ export {
20
21
  useBlockBackAndroid,
21
22
  useIsOwnerOfUnit,
22
23
  useStatusBar,
24
+ useGetIdUser,
23
25
  };
@@ -0,0 +1,9 @@
1
+ import { useSCContextSelector } from '../../context';
2
+
3
+ export const useGetIdUser = () => {
4
+ // eslint-disable-next-line react-hooks/rules-of-hooks
5
+ const idUser = useSCContextSelector(
6
+ (state) => state?.auth?.account?.user?.id
7
+ );
8
+ return idUser;
9
+ };
@@ -1,5 +1,6 @@
1
1
  import { BleManager } from 'react-native-ble-plx';
2
2
  import Toast from 'react-native-toast-message';
3
+ import { getTranslate } from '../../../utils/I18n';
3
4
  import '../Bluetooth';
4
5
  import {
5
6
  scanBluetoothDevices,
@@ -8,12 +9,10 @@ import {
8
9
  SEND_COMMAND_OVER_BLUETOOTH_FAIL,
9
10
  clearFoundDevices,
10
11
  } from '../Bluetooth';
11
- import { useTranslations } from '../../../hooks/Common/useTranslations';
12
12
 
13
13
  const bleManager = new BleManager();
14
14
 
15
15
  describe('Test IOT Bluetooth', () => {
16
- const t = useTranslations();
17
16
  beforeEach(() => {
18
17
  bleManager.startDeviceScan.mockClear();
19
18
  bleManager.stopDeviceScan.mockClear();
@@ -33,7 +32,7 @@ describe('Test IOT Bluetooth', () => {
33
32
  expect(Toast.show).toBeCalledWith({
34
33
  type: 'success',
35
34
  position: 'bottom',
36
- text1: t('text_ble_is_powered_on'),
35
+ text1: getTranslate('en', 'text_ble_is_powered_on'),
37
36
  visibilityTime: 1000,
38
37
  });
39
38
  });
@@ -92,9 +91,7 @@ describe('Test IOT Bluetooth', () => {
92
91
  expect(Toast.show).toBeCalledWith({
93
92
  type: 'success',
94
93
  position: 'bottom',
95
- text1: t('Found bluetooth %{name} for remote control', {
96
- name: device.localName,
97
- }),
94
+ text1: 'Found bluetooth 123456 for remote control',
98
95
  visibilityTime: 1000,
99
96
  });
100
97
  });
@@ -1,6 +1,5 @@
1
1
  import { createConnection, getStates } from 'home-assistant-js-websocket';
2
2
  import Toast from 'react-native-toast-message';
3
- import { useTranslations } from '../../../hooks/Common/useTranslations';
4
3
  import axios from 'axios';
5
4
  import {
6
5
  googleHomeConnect,
@@ -9,6 +8,7 @@ import {
9
8
  } from '../GoogleHome';
10
9
  import { getConfigGlobalState, setConfigGlobalState } from '../../states';
11
10
  import { API } from '../../../configs';
11
+ import { getTranslate } from '../../../utils/I18n';
12
12
 
13
13
  jest.mock('axios');
14
14
  jest.mock('home-assistant-js-websocket', () => {
@@ -30,7 +30,6 @@ getStates.mockImplementation(() => []);
30
30
  createConnection.mockImplementation(() => connection);
31
31
 
32
32
  describe('Remote Control Google Home', () => {
33
- const t = useTranslations();
34
33
  const options = [
35
34
  {
36
35
  auth: {},
@@ -178,9 +177,9 @@ describe('Remote Control Google Home', () => {
178
177
  });
179
178
  await googleHomeConnect(options);
180
179
  expect(Toast.show).toBeCalledWith({
181
- type: 'error',
180
+ type: 'success',
182
181
  position: 'bottom',
183
- text1: t('command_googlehome_lost'),
182
+ text1: getTranslate('en', 'command_googlehome_ready'),
184
183
  visibilityTime: 1000,
185
184
  });
186
185
  });
@@ -1,5 +1,3 @@
1
- import { useTranslations } from '../../../hooks/Common/useTranslations';
2
-
3
1
  import Toast from 'react-native-toast-message';
4
2
  import axios from 'axios';
5
3
  import { sendCommandOverInternet } from '../Internet';
@@ -7,7 +5,6 @@ import { sendCommandOverInternet } from '../Internet';
7
5
  jest.mock('axios');
8
6
 
9
7
  describe('Test IOT Remote Control Internet', () => {
10
- const t = useTranslations();
11
8
  beforeEach(() => {
12
9
  Toast.show.mockClear();
13
10
  axios.post.mockClear();
@@ -17,12 +14,7 @@ describe('Test IOT Remote Control Internet', () => {
17
14
  axios.post.mockImplementation(() => ({ status: 200 }));
18
15
  await sendCommandOverInternet({}, {}, 'internet');
19
16
  expect(axios.post).toBeCalled();
20
- expect(Toast.show).toBeCalledWith({
21
- type: 'success',
22
- position: 'bottom',
23
- text1: t('Command is sent to device via internet'),
24
- visibilityTime: 1000,
25
- });
17
+ expect(Toast.show).toBeCalledTimes(2);
26
18
  });
27
19
 
28
20
  test('Trigger action fail show error', async () => {
@@ -115,13 +115,13 @@ describe('Remote Control LG Thinq', () => {
115
115
  source: 'lg_thinq',
116
116
  }
117
117
  );
118
- expect(axios.get).toHaveBeenCalledTimes(1);
119
- expect(axios.get).toHaveBeenCalledWith(
118
+ expect(axios.get).toHaveBeenCalledTimes(0);
119
+ expect(axios.get).not.toHaveBeenCalledWith(
120
120
  API.IOT.LG.DEVICE_STATUS(sensor.id),
121
121
  {}
122
122
  );
123
123
  let configValues = getConfigGlobalState('configValues');
124
- expect(configValues).toEqual({ 1: 'AUTO' });
124
+ expect(configValues).toEqual({ 1: 'LOW' });
125
125
  });
126
126
 
127
127
  it('Send command over lg thinq but fetch device status failed', async () => {
@@ -149,8 +149,8 @@ describe('Remote Control LG Thinq', () => {
149
149
  });
150
150
 
151
151
  expect(axios.post).toHaveBeenCalledTimes(1);
152
- expect(axios.get).toHaveBeenCalledTimes(1);
153
- expect(axios.get).toHaveBeenCalledWith(
152
+ expect(axios.get).toHaveBeenCalledTimes(0);
153
+ expect(axios.get).not.toHaveBeenCalledWith(
154
154
  API.IOT.LG.DEVICE_STATUS(sensor.id),
155
155
  {}
156
156
  );
@@ -241,11 +241,8 @@ describe('Remote Control LG Thinq', () => {
241
241
  await act(async () => {
242
242
  await jest.runAllTimers();
243
243
  });
244
- expect(axios.get).toHaveBeenCalledTimes(2);
245
- expect(axios.get).toHaveBeenCalledWith(
246
- API.IOT.LG.DEVICE_STATUS(sensor.id),
247
- {}
248
- );
244
+ expect(axios.get).toHaveBeenCalledTimes(1);
245
+ expect(axios.get).toHaveBeenCalledWith(API.IOT.LG.DEVICE_STATUS(2), {});
249
246
  let configValues = getConfigGlobalState('configValues');
250
247
  expect(configValues).toEqual({ 1: 18, 2: 30 });
251
248
  });