@eohjsc/react-native-smart-city 0.3.86 → 0.3.87

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 (42) hide show
  1. package/package.json +1 -1
  2. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +30 -0
  3. package/src/commons/{FourButtonFilterHistory → ChartAggregationOption}/__test__/FourButtonFilterHistory.test.js +2 -2
  4. package/src/commons/ChartAggregationOption/index.js +72 -0
  5. package/src/commons/{FourButtonFilterHistory → ChartAggregationOption}/styles.js +0 -0
  6. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +19 -0
  7. package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +30 -9
  8. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +13 -1
  9. package/src/commons/Dashboard/MyUnit/index.js +20 -10
  10. package/src/commons/DateTimeRangeChange/DateTimeButton.js +3 -12
  11. package/src/commons/DateTimeRangeChange/index.js +113 -19
  12. package/src/commons/Device/HistoryChart.js +2 -2
  13. package/src/commons/Device/LinearChart.js +2 -2
  14. package/src/commons/Device/WindSpeed/Anemometer/index.js +23 -18
  15. package/src/commons/Device/WindSpeed/__test__/Anemometer.test.js +1 -1
  16. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +7 -7
  17. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +40 -13
  18. package/src/configs/API.js +1 -1
  19. package/src/configs/AccessibilityLabel.js +4 -0
  20. package/src/context/actionType.ts +2 -0
  21. package/src/context/reducer.ts +10 -0
  22. package/src/hooks/Common/useTranslations.ts +1 -1
  23. package/src/hooks/IoT/useRemoteControl.js +0 -1
  24. package/src/screens/ActivityLog/__test__/FilterPopup.test.js +1 -1
  25. package/src/screens/ActivityLog/__test__/index.test.js +1 -1
  26. package/src/screens/AddNewGateway/__test__/ScanModbusQR.test.js +15 -0
  27. package/src/screens/Device/__test__/DetailHistoryChart.test.js +1 -0
  28. package/src/screens/Device/__test__/sensorDisplayItem.test.js +150 -2
  29. package/src/screens/Device/components/ChartWrapper.js +39 -0
  30. package/src/screens/Device/components/ChartWrapperStyles.js +42 -0
  31. package/src/screens/Device/components/SensorDisplayItem.js +6 -2
  32. package/src/screens/Device/components/VisualChart.js +255 -0
  33. package/src/screens/Device/components/__test__/VisualChart.test.js +440 -0
  34. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +7 -6
  35. package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +3 -0
  36. package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +47 -0
  37. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +15 -2
  38. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +52 -0
  39. package/src/screens/Unit/components/__test__/Header.test.js +9 -0
  40. package/src/utils/I18n/translations/en.json +1 -1
  41. package/src/utils/I18n/translations/vi.json +1 -1
  42. package/src/commons/FourButtonFilterHistory/index.js +0 -72
@@ -91,6 +91,9 @@ describe('Test SuccessfullyConnected', () => {
91
91
  await flushPromises();
92
92
  const instance = tree.root;
93
93
  const inputs = instance.findAllByType(_TextInput);
94
+ await act(async () => {
95
+ inputs[0].props.onChange();
96
+ });
94
97
  expect(inputs).toHaveLength(3); // sensor + 2 end device
95
98
  expect(mock.history.get).toHaveLength(1);
96
99
  expect(mock.history.get[0].url).toBe(API.CHIP.RENAME_DEVICES(1));
@@ -8,6 +8,8 @@ import { ButtonsBottom } from '../components/GroupButtonByType/ButtonsBottom';
8
8
  import { AccessibilityLabel } from '../../../configs/Constants';
9
9
  import TextInput from '../../../commons/Form/TextInput';
10
10
  import { ModalCustom } from '../../../commons/Modal';
11
+ import { TouchableOpacity } from 'react-native';
12
+ import { IconOutline } from '@ant-design/icons-react-native';
11
13
 
12
14
  const wrapComponent = (route) => (
13
15
  <SCProvider initState={mockSCStore({})}>
@@ -118,4 +120,49 @@ describe('Test GroupButtonByType', () => {
118
120
  });
119
121
  expect(textInput).toHaveLength(1);
120
122
  });
123
+
124
+ it('onPress rightComponent', async () => {
125
+ const route = {
126
+ params: {
127
+ device_type: { id: 1, name: '', icon: '' },
128
+ brand: { id: 1, name: '' },
129
+ },
130
+ };
131
+ await act(async () => {
132
+ tree = renderer.create(wrapComponent(route));
133
+ });
134
+
135
+ const instance = tree.root;
136
+ const touch = instance.find(
137
+ (el) =>
138
+ el.props.accessibilityLabel ===
139
+ AccessibilityLabel.HEADER_BUTTON_TYPE_RELOAD &&
140
+ el.type === TouchableOpacity
141
+ );
142
+ const iconOutline = instance.find(
143
+ (el) =>
144
+ el.props.accessibilityLabel ===
145
+ AccessibilityLabel.ICON_OUTLINE_TYPE_RELOAD && el.type === IconOutline
146
+ );
147
+ await act(async () => {
148
+ await touch.props.onPress();
149
+ });
150
+ expect(iconOutline.props.name).toEqual('reload');
151
+
152
+ const touch2 = instance.find(
153
+ (el) =>
154
+ el.props.accessibilityLabel ===
155
+ AccessibilityLabel.HEADER_BUTTON_TYPE_MORE &&
156
+ el.type === TouchableOpacity
157
+ );
158
+ const iconOutline2 = instance.find(
159
+ (el) =>
160
+ el.props.accessibilityLabel ===
161
+ AccessibilityLabel.ICON_OUTLINE_TYPE_MORE && el.type === IconOutline
162
+ );
163
+ await act(async () => {
164
+ await touch2.props.onPress();
165
+ });
166
+ expect(iconOutline2.props.name).toEqual('more');
167
+ });
121
168
  });
@@ -46,6 +46,7 @@ const GroupButtonByType = memo(({ route }) => {
46
46
  },
47
47
  [t]
48
48
  );
49
+
49
50
  const rightComponent = useMemo(
50
51
  () => (
51
52
  <View style={styles.rightComponent}>
@@ -54,14 +55,26 @@ const GroupButtonByType = memo(({ route }) => {
54
55
  <TouchableOpacity
55
56
  onPress={rightButtonHeader('reload')}
56
57
  style={[styles.headerButton]}
58
+ accessibilityLabel={AccessibilityLabel.HEADER_BUTTON_TYPE_RELOAD}
57
59
  >
58
- <IconOutline name={'reload'} size={27} color={Colors.Black} />
60
+ <IconOutline
61
+ name={'reload'}
62
+ size={27}
63
+ color={Colors.Black}
64
+ accessibilityLabel={AccessibilityLabel.ICON_OUTLINE_TYPE_RELOAD}
65
+ />
59
66
  </TouchableOpacity>
60
67
  <TouchableOpacity
61
68
  onPress={rightButtonHeader('more')}
62
69
  style={[styles.headerButton]}
70
+ accessibilityLabel={AccessibilityLabel.HEADER_BUTTON_TYPE_MORE}
63
71
  >
64
- <IconOutline name={'more'} size={27} color={Colors.Black} />
72
+ <IconOutline
73
+ name={'more'}
74
+ size={27}
75
+ color={Colors.Black}
76
+ accessibilityLabel={AccessibilityLabel.ICON_OUTLINE_TYPE_MORE}
77
+ />
65
78
  </TouchableOpacity>
66
79
  </>
67
80
  ) : (
@@ -204,6 +204,58 @@ describe('Test Add LG Device', () => {
204
204
  expect(mockedNavigate).toHaveBeenCalledWith(Routes.Dashboard);
205
205
  });
206
206
 
207
+ it('ViewButtonBottom onRightClick with case sync device fail', async () => {
208
+ const response = {
209
+ status: 200,
210
+ data: {
211
+ id: 1,
212
+ name: 'Unit name',
213
+ stations: [{ id: 2, name: 'Station name' }],
214
+ },
215
+ };
216
+ mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, response.data);
217
+
218
+ const responseToken = {
219
+ status: 200,
220
+ data: {
221
+ access_token: 'ACCESS_TOKEN',
222
+ },
223
+ };
224
+ mock
225
+ .onPost(
226
+ API.IOT.LG.GET_TOKEN(
227
+ SCConfig.LG_CLIENT_ID,
228
+ 'CODE',
229
+ SCConfig.LG_REDIRECT_URI_APP,
230
+ 'https://doamin.com'
231
+ )
232
+ )
233
+ .reply(200, responseToken.data);
234
+ mock.onPost(API.IOT.LG.SYNC_DEVICE()).reply(500, {});
235
+ // const spyToastSuccess = jest.spyOn(ToastBottomHelper, 'success');
236
+ await act(async () => {
237
+ tree = await create(wrapComponent(route));
238
+ });
239
+ const instance = tree.root;
240
+ const groupCheckBox = instance.findByType(GroupCheckBox);
241
+ await act(async () => {
242
+ groupCheckBox.props.onSelect({ id: 2 }); // select stationId
243
+ });
244
+
245
+ const viewButtonBottom = instance.findByType(ViewButtonBottom);
246
+ await act(async () => {
247
+ viewButtonBottom.props.onRightClick();
248
+ });
249
+
250
+ expect(Toast.show).toBeCalledWith({
251
+ type: 'error',
252
+ position: 'bottom',
253
+ text1: getTranslate('en', 'lg_sync_failed'),
254
+ visibilityTime: 1000,
255
+ });
256
+ expect(mockedNavigate).toHaveBeenCalledWith(Routes.Dashboard);
257
+ });
258
+
207
259
  it('ViewButtonBottom onRightClick with stationId but sync failed', async () => {
208
260
  const response = {
209
261
  status: 200,
@@ -53,11 +53,20 @@ describe('Test Header', () => {
53
53
 
54
54
  const headerCustom = instance.findByType(HeaderCustom);
55
55
  const touchableOpacity = headerCustom.findAllByType(TouchableOpacity);
56
+
57
+ expect(modal[0].props.isVisible).toBeFalsy();
56
58
  await act(async () => {
57
59
  touchableOpacity[1].props.onPress();
58
60
  });
59
61
  expect(modal[0].props.isVisible).toBeTruthy();
60
62
 
63
+ const popOver = instance.findByType(Popover);
64
+ expect(popOver.props.isVisible).toBeFalsy();
65
+ await act(async () => {
66
+ touchableOpacity[2].props.onPress();
67
+ });
68
+ expect(popOver.props.isVisible).toBeTruthy();
69
+
61
70
  const imageButton = instance.findByType(ImageButton);
62
71
  await act(async () => {
63
72
  imageButton.props.onPress(Routes.Sharing);
@@ -675,7 +675,7 @@
675
675
  "text_notification_content_turbility_high": "The Turbility at **unit_name** is **status**. Water is not safe to drink.",
676
676
  "text_notification_content_smoke": "Smoke appears in **unit_name**. Please check your home and call the rescue team if there is a fire.",
677
677
  "text_notification_content_fire": "There is a fire at **unit_name**, Please move out of the house immediately and call the rescue team.",
678
- "text_notification_content_active_sos": "SOS button is activating at **unit_name**, Please check it NOW.",
678
+ "text_notification_content_active_sos": "**device_name** is activating at **unit_name** - **station_name**, Please check it NOW.",
679
679
  "text_notification_content_replace_water_filter": "Filter **config_name** of **device_name** in **station_name** has less than 10h remaining. Check and replace now.",
680
680
  "text_notification_content_low_battery": "Battery of **device_name** in **unit_name**: **station_name** has less than 20%. Check and replace now.",
681
681
  "text_notification_content_remove_unit_to_owner": "Unit **unit_name** has been removed successfully.",
@@ -688,7 +688,7 @@
688
688
  "text_notification_content_turbility_high": "Độ đục của nước tại **unit_name** đang ở mức **status**. Nước không đảm bảo an toàn để uống.",
689
689
  "text_notification_content_smoke": "Xuất hiện khói tại **unit_name**. Vui lòng kiểm tra nhà của bạn và gọi cho đội cứu hộ nếu xảy ra hỏa hoạn.",
690
690
  "text_notification_content_fire": "Có đám cháy tại **unit_name**, Vui lòng di chuyển ra khỏi nhà ngay lập tức và gọi cho đội cứu hộ.",
691
- "text_notification_content_active_sos": "Nút SOS đang kích hoạt tại **unit_name**. Vui lòng kiểm tra nó NGAY BÂY GIỜ.",
691
+ "text_notification_content_active_sos": "**device_name** đang kích hoạt tại **unit_name** - **station_name**. Vui lòng kiểm tra nó NGAY BÂY GIỜ.",
692
692
  "text_notification_content_replace_water_filter": "Lõi lọc **config_name** của **device_name** thuộc **unit_name**: **station_name** còn ít hơn 10 giờ lọc. Vui lòng kiểm tra và thay lõi lọc mới.",
693
693
  "text_notification_content_low_battery": "Thời lượng pin của **device_name** thuộc **unit_name**: **station_name** còn ít hơn 20%. Vui lòng kiểm tra và thay đổi.",
694
694
  "text_notification_content_remove_unit_to_owner": "Địa điểm **unit_name** vừa được xoá thành công.",
@@ -1,72 +0,0 @@
1
- import React, { memo, useCallback, useMemo } from 'react';
2
- import { View, TouchableOpacity } from 'react-native';
3
- import Text from '../Text';
4
- import { Colors } from '../../configs';
5
- import styles from './styles';
6
-
7
- const FourButtonFilterHistory = memo(({ groupBy, setGroupBy }) => {
8
- const listItem = useMemo(
9
- () => [
10
- {
11
- title: 'D',
12
- data: 'date',
13
- },
14
-
15
- {
16
- title: 'W',
17
- data: 'week',
18
- },
19
-
20
- {
21
- title: 'M',
22
- data: 'month',
23
- },
24
-
25
- {
26
- title: 'Y',
27
- data: 'year',
28
- },
29
- ],
30
- []
31
- );
32
-
33
- const ItemButton = memo(({ title, onPress, isSelected }) => {
34
- return (
35
- <TouchableOpacity
36
- onPress={onPress}
37
- style={[styles.button, isSelected && styles.selectedButton]}
38
- >
39
- <View>
40
- <Text bold color={isSelected && Colors.Primary}>
41
- {title}
42
- </Text>
43
- </View>
44
- </TouchableOpacity>
45
- );
46
- }, []);
47
-
48
- const onPressButton = useCallback(
49
- (data) => () => {
50
- setGroupBy && setGroupBy(data);
51
- },
52
- [setGroupBy]
53
- );
54
-
55
- return (
56
- <View style={styles.row}>
57
- {listItem &&
58
- listItem.map((item, index) => {
59
- return (
60
- <ItemButton
61
- key={index}
62
- title={item.title}
63
- onPress={onPressButton(item.data)}
64
- isSelected={item.data === groupBy}
65
- />
66
- );
67
- })}
68
- </View>
69
- );
70
- });
71
-
72
- export default FourButtonFilterHistory;