@eohjsc/react-native-smart-city 0.2.57 → 0.2.61

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 (118) hide show
  1. package/assets/images/Map/MarkerGeolocation.svg +4 -0
  2. package/package.json +4 -23
  3. package/src/Images/Common/buttonLeftCurtain.png +0 -0
  4. package/src/Images/Common/buttonPause-center-curtain.png +0 -0
  5. package/src/Images/Common/buttonRightCurtain.png +0 -0
  6. package/src/commons/ActionGroup/CurtainButtonTemplate.js +139 -0
  7. package/src/commons/ActionGroup/CurtainButtonTemplateStyle.js +58 -0
  8. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +72 -0
  9. package/src/commons/ActionGroup/index.js +3 -0
  10. package/src/commons/Auth/__test__/AccountList.test.js +33 -0
  11. package/src/commons/CameraDevice/index.js +2 -0
  12. package/src/commons/CardShadow/index.js +1 -1
  13. package/src/commons/CardShadow/styles.js +1 -3
  14. package/src/commons/DateTimeRangeChange/DateTimeButton.js +1 -1
  15. package/src/commons/Device/HistoryChart.js +78 -80
  16. package/src/commons/Device/HorizontalBarChart.js +46 -30
  17. package/src/commons/Device/LinearChart.js +0 -34
  18. package/src/commons/Form/CurrencyInput.js +7 -1
  19. package/src/commons/FourButtonFilterHistory/__test__/FourButtonFilterHistory.test.js +48 -0
  20. package/src/commons/FourButtonFilterHistory/index.js +72 -0
  21. package/src/commons/FourButtonFilterHistory/styles.js +22 -0
  22. package/src/commons/ImagePicker/index.js +27 -33
  23. package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +14 -0
  24. package/src/commons/MediaPlayerDetail/index.js +204 -161
  25. package/src/commons/SearchLocation/index.js +0 -1
  26. package/src/commons/Sharing/RowMember.js +4 -2
  27. package/src/commons/Sharing/__test__/RowMember.test.js +42 -0
  28. package/src/commons/SubUnit/ShortDetail.js +12 -6
  29. package/src/commons/UnitSummary/AirQuality/SegmentedRoundDisplay/index.js +1 -1
  30. package/src/commons/UnitSummary/AirQuality/index.js +9 -7
  31. package/src/commons/UnitSummary/ConfigHistoryChart.js +2 -1
  32. package/src/configs/API.js +13 -3
  33. package/src/configs/Constants.js +12 -2
  34. package/src/configs/Images.js +3 -0
  35. package/src/configs/SCConfig.js +8 -0
  36. package/src/context/actionType.ts +5 -0
  37. package/src/context/mockStore.ts +3 -0
  38. package/src/context/reducer.ts +14 -0
  39. package/src/iot/RemoteControl/Bluetooth.js +14 -0
  40. package/src/iot/RemoteControl/GoogleHome.js +1 -1
  41. package/src/iot/RemoteControl/index.js +0 -1
  42. package/src/navigations/UnitStack.js +42 -4
  43. package/src/screens/ActivityLog/FilterPopup.js +1 -1
  44. package/src/screens/ActivityLog/ItemLog.js +3 -3
  45. package/src/screens/ActivityLog/__test__/ItemLog.test.js +5 -2
  46. package/src/screens/ActivityLog/hooks/index.js +1 -0
  47. package/src/screens/ActivityLog/index.js +0 -1
  48. package/src/screens/AddCommon/SelectSubUnit.js +23 -1
  49. package/src/screens/AddCommon/SelectUnit.js +12 -0
  50. package/src/screens/AddLocationMaps/index.js +139 -44
  51. package/src/screens/AddLocationMaps/indexStyle.js +14 -12
  52. package/src/screens/AddNewAction/SelectAction.js +1 -0
  53. package/src/screens/Automate/MultiUnits.js +8 -8
  54. package/src/screens/Automate/__test__/MultiUnits.test.js +2 -2
  55. package/src/screens/Automate/__test__/index.test.js +2 -0
  56. package/src/screens/Automate/index.js +4 -2
  57. package/src/screens/Device/__test__/detail.test.js +3 -7
  58. package/src/screens/Device/components/SensorDisplayItem.js +10 -10
  59. package/src/screens/Device/detail.js +65 -15
  60. package/src/screens/Device/hooks/useDisconnectedDevice.js +32 -26
  61. package/src/screens/Device/styles.js +3 -3
  62. package/src/screens/EmergencySetting/__test__/DropDownItem.test.js +59 -0
  63. package/src/screens/EmergencySetting/__test__/index.test.js +27 -0
  64. package/src/screens/EmergencySetting/components/DropDownItem.js +54 -0
  65. package/src/screens/EmergencySetting/index.js +90 -0
  66. package/src/screens/EmergencySetting/styles/DropDownItem.js +38 -0
  67. package/src/screens/EmergencySetting/styles.js +19 -0
  68. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +126 -0
  69. package/src/screens/MoveToAnotherSubUnit/index.js +88 -0
  70. package/src/screens/MoveToAnotherSubUnit/styles/MoveToAnotherSubUnitStyles.js +50 -0
  71. package/src/screens/Notification/__test__/Notification.test.js +3 -3
  72. package/src/screens/Notification/components/NotificationItem.js +3 -6
  73. package/src/screens/Notification/index.js +2 -2
  74. package/src/screens/ScriptDetail/Styles/indexStyles.js +0 -1
  75. package/src/screens/ScriptDetail/__test__/index.test.js +13 -0
  76. package/src/screens/ScriptDetail/index.js +20 -17
  77. package/src/screens/SelectUnit/index.js +2 -0
  78. package/src/screens/Sharing/MemberList.js +2 -9
  79. package/src/screens/SubUnit/AddSubUnit.js +7 -6
  80. package/src/screens/SubUnit/AddSubUnitStyles.js +0 -2
  81. package/src/screens/SubUnit/EditSubUnit.js +8 -6
  82. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +4 -3
  83. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +2 -2
  84. package/src/screens/TDSGuide/index.js +6 -4
  85. package/src/screens/Unit/ChooseLocation.js +96 -0
  86. package/src/screens/Unit/ChooseLocationStyles.js +26 -0
  87. package/src/screens/Unit/Detail.js +8 -2
  88. package/src/screens/Unit/ManageUnit.js +12 -15
  89. package/src/screens/Unit/SelectAddress.js +240 -0
  90. package/src/screens/Unit/SelectAddressStyles.js +48 -0
  91. package/src/screens/Unit/__test__/ChooseLocation.test.js +112 -0
  92. package/src/screens/Unit/__test__/SelectAddress.test.js +216 -0
  93. package/src/screens/Unit/components/MyUnitDevice/index.js +21 -5
  94. package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +56 -58
  95. package/src/screens/UnitSummary/components/PowerConsumption/index.js +25 -21
  96. package/src/screens/UnitSummary/components/Temperature/index.js +15 -14
  97. package/src/screens/UnitSummary/components/UvIndex/index.js +6 -5
  98. package/src/screens/UnitSummary/components/WaterQuality/index.js +9 -7
  99. package/src/screens/UnitSummary/index.js +11 -7
  100. package/src/screens/WaterQualityGuide/index.js +1 -0
  101. package/src/utils/Apis/axios.js +21 -9
  102. package/src/utils/I18n/translations/en.json +15 -4
  103. package/src/utils/I18n/translations/vi.json +18 -6
  104. package/src/utils/Route/index.js +4 -1
  105. package/src/utils/Utils.js +22 -2
  106. package/assets/images/AddLocationMaps/PinLocation.svg +0 -3
  107. package/assets/images/AddLocationMaps/Point.svg +0 -3
  108. package/src/commons/ThreeButtonHistory/CalendarHeader.js +0 -35
  109. package/src/commons/ThreeButtonHistory/CalendarHeaderStyles.js +0 -17
  110. package/src/commons/ThreeButtonHistory/SelectMonth.js +0 -53
  111. package/src/commons/ThreeButtonHistory/SelectMonthStyles.js +0 -29
  112. package/src/commons/ThreeButtonHistory/__test__/SelectMonth.test.js +0 -37
  113. package/src/commons/ThreeButtonHistory/__test__/ThreeButtonHistory.test.js +0 -240
  114. package/src/commons/ThreeButtonHistory/index.js +0 -310
  115. package/src/commons/ThreeButtonHistory/styles.js +0 -65
  116. package/src/screens/Unit/ManageUnit/index.js +0 -286
  117. package/src/screens/Unit/SelectLocation.js +0 -161
  118. package/src/screens/Unit/SelectLocationStyles.js +0 -114
@@ -0,0 +1,112 @@
1
+ import React from 'react';
2
+ import { act, create } from 'react-test-renderer';
3
+ import { SCProvider } from '../../../context';
4
+ import { mockSCStore } from '../../../context/mockStore';
5
+ import ChooseLocation from '../ChooseLocation';
6
+ import axios from 'axios';
7
+ import { API, SCConfig } from '../../../configs';
8
+ import BottomButtonView from '../../../commons/BottomButtonView';
9
+
10
+ const wrapComponent = (route) => (
11
+ <SCProvider initState={mockSCStore({})}>
12
+ <ChooseLocation route={route} />
13
+ </SCProvider>
14
+ );
15
+
16
+ const mockGoBack = jest.fn();
17
+ jest.mock('@react-navigation/native', () => {
18
+ return {
19
+ ...jest.requireActual('@react-navigation/native'),
20
+ useNavigation: () => ({
21
+ goBack: mockGoBack,
22
+ }),
23
+ };
24
+ });
25
+
26
+ jest.mock('react', () => {
27
+ return {
28
+ ...jest.requireActual('react'),
29
+ memo: (x) => x,
30
+ };
31
+ });
32
+
33
+ jest.mock('react-native-maps', () => {
34
+ const { forwardRef } = require('react');
35
+ const { View } = require('react-native');
36
+ const MockMapView = forwardRef((props, ref) => (
37
+ <View refs={ref}>{props.children}</View>
38
+ ));
39
+ return {
40
+ __esModule: true,
41
+ default: MockMapView,
42
+ PROVIDER_GOOGLE: 'google',
43
+ };
44
+ });
45
+
46
+ jest.mock('axios');
47
+
48
+ describe('Test ChooseLocation', () => {
49
+ let tree;
50
+ let route;
51
+ const mockSetAddress = jest.fn();
52
+ const mockSetLocation = jest.fn();
53
+
54
+ beforeAll(() => {
55
+ axios.get.mockClear();
56
+ route = {
57
+ params: {
58
+ location: {
59
+ latitude: 10,
60
+ longitude: 10,
61
+ },
62
+ setAddress: mockSetAddress,
63
+ setLocation: mockSetLocation,
64
+ },
65
+ };
66
+ });
67
+
68
+ test('test done choose location', async () => {
69
+ await act(async () => {
70
+ tree = await create(wrapComponent(route));
71
+ });
72
+ const instance = tree.root;
73
+ const buttonBottom = instance.findByType(BottomButtonView);
74
+
75
+ const response = {
76
+ status: 200,
77
+ data: {
78
+ results: [
79
+ {
80
+ formatted_address: 'address',
81
+ geometry: {
82
+ location: {
83
+ lat: 20,
84
+ lng: 20,
85
+ },
86
+ },
87
+ },
88
+ ],
89
+ },
90
+ };
91
+ axios.get.mockImplementation(async () => response);
92
+ await act(async () => {
93
+ await buttonBottom.props.onPressMain();
94
+ });
95
+ expect(axios.get).toBeCalledWith(
96
+ API.EXTERNAL.GOOGLE_MAP.GET_LOCATION_FROM_LAT_LNG,
97
+ {
98
+ params: {
99
+ latlng: '10,10',
100
+ key: SCConfig.GOOGLE_MAP_API_KEY,
101
+ },
102
+ }
103
+ );
104
+ expect(mockSetAddress).toBeCalledWith('address');
105
+ expect(mockSetLocation).toBeCalledWith({
106
+ description: 'address',
107
+ latitude: 20,
108
+ longitude: 20,
109
+ });
110
+ expect(mockGoBack).toBeCalled();
111
+ });
112
+ });
@@ -0,0 +1,216 @@
1
+ import React from 'react';
2
+ import { act, create } from 'react-test-renderer';
3
+ import { SCProvider } from '../../../context';
4
+ import { mockSCStore } from '../../../context/mockStore';
5
+ import SelectAddress from '../SelectAddress';
6
+ import SearchBarLocation from '../../../commons/SearchLocation';
7
+ import RowLocation from '../../../commons/SearchLocation/RowLocation';
8
+ import BottomButtonView from '../../../commons/BottomButtonView';
9
+ import axios from 'axios';
10
+ import { API, SCConfig } from '../../../configs';
11
+ import { TESTID } from '../../../configs/Constants';
12
+
13
+ const wrapComponent = (route) => (
14
+ <SCProvider initState={mockSCStore({})}>
15
+ <SelectAddress route={route} />
16
+ </SCProvider>
17
+ );
18
+
19
+ const mockNavigate = jest.fn();
20
+ const mockGoBack = jest.fn();
21
+ jest.mock('@react-navigation/native', () => {
22
+ return {
23
+ ...jest.requireActual('@react-navigation/native'),
24
+ useNavigation: () => ({
25
+ navigate: mockNavigate,
26
+ goBack: mockGoBack,
27
+ }),
28
+ };
29
+ });
30
+
31
+ jest.mock('react', () => {
32
+ return {
33
+ ...jest.requireActual('react'),
34
+ memo: (x) => x,
35
+ };
36
+ });
37
+
38
+ jest.mock('react-native-maps', () => {
39
+ const { forwardRef } = require('react');
40
+ const { View } = require('react-native');
41
+ const MockMapView = forwardRef((props, ref) => (
42
+ <View refs={ref}>{props.children}</View>
43
+ ));
44
+ const MockMarker = (props) => <View>{props.children}</View>;
45
+ const MockCircle = (props) => <View>{props.children}</View>;
46
+ return {
47
+ __esModule: true,
48
+ default: MockMapView,
49
+ Marker: MockMarker,
50
+ Circle: MockCircle,
51
+ PROVIDER_GOOGLE: 'google',
52
+ };
53
+ });
54
+
55
+ jest.mock('@react-native-community/geolocation', () => {
56
+ const position = {
57
+ coords: {
58
+ latitude: 100,
59
+ longitude: 100,
60
+ },
61
+ };
62
+ return {
63
+ getCurrentPosition: (onSuccess, onError, options) => {
64
+ onSuccess(position);
65
+ },
66
+ };
67
+ });
68
+
69
+ jest.mock('axios');
70
+
71
+ describe('Test SelectAddress', () => {
72
+ let tree;
73
+ let route;
74
+ const mockUpdateLocation = jest.fn();
75
+
76
+ beforeAll(() => {
77
+ axios.get.mockClear();
78
+ route = {
79
+ params: {
80
+ updateLocation: mockUpdateLocation,
81
+ },
82
+ };
83
+ });
84
+
85
+ test('test search location', async () => {
86
+ await act(async () => {
87
+ tree = await create(wrapComponent(route));
88
+ });
89
+ const instance = tree.root;
90
+ const searchBars = instance.findAllByType(SearchBarLocation);
91
+ expect(searchBars).toHaveLength(1);
92
+
93
+ let response = {
94
+ status: 200,
95
+ data: {
96
+ predictions: [
97
+ { place_id: 1, description: '1' },
98
+ { place_id: 2, description: '2' },
99
+ { place_id: 3, description: '3' },
100
+ ],
101
+ },
102
+ };
103
+ axios.get.mockImplementation(async () => response);
104
+
105
+ await act(async () => {
106
+ await searchBars[0].props.onTextInput('');
107
+ });
108
+ let rowLocations = instance.findAllByType(RowLocation);
109
+ expect(rowLocations).toHaveLength(0);
110
+
111
+ await act(async () => {
112
+ await searchBars[0].props.onTextInput('input');
113
+ });
114
+ expect(axios.get).toBeCalledWith(API.EXTERNAL.GOOGLE_MAP.AUTO_COMPLETE, {
115
+ params: {
116
+ input: 'input',
117
+ key: SCConfig.GOOGLE_MAP_API_KEY,
118
+ sessiontoken: 123456324,
119
+ strictBounds: false,
120
+ types: ['establishment'],
121
+ },
122
+ });
123
+ rowLocations = instance.findAllByType(RowLocation);
124
+ expect(rowLocations).toHaveLength(3);
125
+
126
+ axios.get.mockClear();
127
+ response = {
128
+ status: 200,
129
+ data: {
130
+ result: {
131
+ geometry: {
132
+ location: {
133
+ lat: 10,
134
+ lng: 10,
135
+ },
136
+ },
137
+ },
138
+ },
139
+ };
140
+ axios.get.mockImplementation(async () => response);
141
+
142
+ await act(async () => {
143
+ await rowLocations[0].props.onPress({ place_id: 1, description: '1' });
144
+ });
145
+ expect(axios.get).toBeCalledWith(
146
+ API.EXTERNAL.GOOGLE_MAP.GET_LAT_LNG_BY_PLACE_ID,
147
+ {
148
+ params: {
149
+ place_id: 1,
150
+ key: SCConfig.GOOGLE_MAP_API_KEY,
151
+ },
152
+ }
153
+ );
154
+
155
+ const bottomButton = instance.findByType(BottomButtonView);
156
+ await act(async () => {
157
+ await bottomButton.props.onPressMain();
158
+ });
159
+ expect(mockUpdateLocation).toBeCalledWith('1');
160
+ expect(mockGoBack).toBeCalled();
161
+ });
162
+
163
+ test('test get current location', async () => {
164
+ await act(async () => {
165
+ tree = await create(wrapComponent(route));
166
+ });
167
+ const instance = tree.root;
168
+ const button = instance.find(
169
+ (el) => el.props.testID === TESTID.BUTTON_YOUR_LOCATION
170
+ );
171
+
172
+ const response = {
173
+ status: 200,
174
+ data: {
175
+ results: [
176
+ {
177
+ formatted_address: 'address',
178
+ geometry: {
179
+ location: {
180
+ lat: 10,
181
+ lng: 10,
182
+ },
183
+ },
184
+ },
185
+ ],
186
+ },
187
+ };
188
+ axios.get.mockImplementation(async () => response);
189
+ await act(async () => {
190
+ await button.props.onPress();
191
+ });
192
+ expect(axios.get).toBeCalledWith(
193
+ API.EXTERNAL.GOOGLE_MAP.GET_LOCATION_FROM_LAT_LNG,
194
+ {
195
+ params: {
196
+ latlng: '100,100',
197
+ key: SCConfig.GOOGLE_MAP_API_KEY,
198
+ },
199
+ }
200
+ );
201
+ });
202
+
203
+ test('test choose on map', async () => {
204
+ await act(async () => {
205
+ tree = await create(wrapComponent(route));
206
+ });
207
+ const instance = tree.root;
208
+ const button = instance.find(
209
+ (el) => el.props.testID === TESTID.BUTTON_CHOOSE_ON_MAP
210
+ );
211
+ await act(async () => {
212
+ await button.props.onPress();
213
+ });
214
+ expect(mockNavigate).toBeCalled();
215
+ });
216
+ });
@@ -1,16 +1,32 @@
1
- import React, { useState } from 'react';
2
- import { Image, StyleSheet, View } from 'react-native';
1
+ import React, { useState, useCallback } from 'react';
2
+ import { Image, StyleSheet, View, TouchableOpacity } from 'react-native';
3
+ import { useNavigation } from '@react-navigation/native';
4
+
3
5
  import ItemQuickAction from '../../../../commons/Action/ItemQuickAction';
4
6
  import Text from '../../../../commons/Text';
7
+ import Routes from '../../../../utils/Route';
5
8
 
6
9
  import { Colors, Images } from '../../../../configs';
7
10
 
8
- const MyUnitDevice = ({ sensor }) => {
11
+ const MyUnitDevice = ({ sensor, unit }) => {
9
12
  const [status, setStatus] = useState(sensor.status);
13
+ const { navigate } = useNavigation();
14
+
15
+ const goToSensorDisplay = useCallback(() => {
16
+ navigate(Routes.UnitStack, {
17
+ screen: Routes.DeviceDetail,
18
+ params: {
19
+ unit,
20
+ sensor,
21
+ title: sensor?.name,
22
+ station: sensor?.station,
23
+ },
24
+ });
25
+ }, [navigate, sensor, unit]);
10
26
 
11
27
  return (
12
28
  <View style={styles.item}>
13
- <View style={styles.rowCenter}>
29
+ <TouchableOpacity style={styles.rowCenter} onPress={goToSensorDisplay}>
14
30
  <Image style={styles.image} source={Images.mainDoor} />
15
31
  <View style={styles.marginTop3}>
16
32
  <Text semibold style={styles.nameDevice}>
@@ -23,7 +39,7 @@ const MyUnitDevice = ({ sensor }) => {
23
39
  </Text>
24
40
  </View>
25
41
  </View>
26
- </View>
42
+ </TouchableOpacity>
27
43
  <ItemQuickAction
28
44
  sensor={sensor}
29
45
  wrapperStyle={styles.iconCircle}
@@ -12,7 +12,7 @@ import HistoryChart from '../../../../commons/Device/HistoryChart';
12
12
  import { axiosGet } from '../../../../utils/Apis/axios';
13
13
  import { TESTID } from '../../../../configs/Constants';
14
14
 
15
- const ThreePhasePowerConsumption = memo(({ unit, summary, summaryDetail }) => {
15
+ const ThreePhasePowerConsumption = memo(({ summaryDetail }) => {
16
16
  const t = useTranslations();
17
17
  const {
18
18
  volt1Value,
@@ -133,8 +133,59 @@ const ThreePhasePowerConsumption = memo(({ unit, summary, summaryDetail }) => {
133
133
  return !!listConfigs;
134
134
  }, [listConfigs]);
135
135
 
136
- const listIdsConfig = useMemo(() => {
137
- return listConfigs;
136
+ const configs = useMemo(() => {
137
+ return [
138
+ {
139
+ id: listConfigs?.volt_1,
140
+ title: 'Volt 1',
141
+ color: Colors.Red6,
142
+ },
143
+ {
144
+ id: listConfigs?.volt_2,
145
+ title: 'Volt 2',
146
+ color: Colors.Red8,
147
+ },
148
+ {
149
+ id: listConfigs?.volt_3,
150
+ title: 'Volt 3',
151
+ color: Colors.Red9,
152
+ },
153
+ {
154
+ id: listConfigs?.current_1,
155
+ title: 'Current 1',
156
+ color: Colors.Blue10,
157
+ },
158
+ {
159
+ id: listConfigs?.current_2,
160
+ title: 'Current 2',
161
+ color: Colors.Blue11,
162
+ },
163
+ {
164
+ id: listConfigs?.current_3,
165
+ title: 'Current 3',
166
+ color: Colors.Blue12,
167
+ },
168
+ {
169
+ id: listConfigs?.active_power,
170
+ title: 'Active Power',
171
+ color: Colors.Orange6,
172
+ },
173
+ {
174
+ id: listConfigs?.power_factor_1,
175
+ title: 'Power Factor 1',
176
+ color: Colors.Green6,
177
+ },
178
+ {
179
+ id: listConfigs?.power_factor_2,
180
+ title: 'Power Factor 2',
181
+ color: Colors.Green9,
182
+ },
183
+ {
184
+ id: listConfigs?.power_factor_3,
185
+ title: 'Power Factor 3',
186
+ color: Colors.Green10,
187
+ },
188
+ ];
138
189
  }, [listConfigs]);
139
190
 
140
191
  const [startDate, setStartDate] = useState(
@@ -168,7 +219,7 @@ const ThreePhasePowerConsumption = memo(({ unit, summary, summaryDetail }) => {
168
219
  if (listConfigs?.total_power) {
169
220
  fetchData();
170
221
  }
171
- }, [startDate, endDate, listConfigs, groupBy]);
222
+ }, [startDate, endDate, listConfigs?.total_power, groupBy]);
172
223
  return (
173
224
  <>
174
225
  <Section type={'border'}>
@@ -180,60 +231,7 @@ const ThreePhasePowerConsumption = memo(({ unit, summary, summaryDetail }) => {
180
231
  />
181
232
  {showBoxHistory && (
182
233
  <View>
183
- <ConfigHistoryChart
184
- configs={[
185
- {
186
- id: listIdsConfig.volt_1,
187
- title: 'Volt 1',
188
- color: Colors.Red6,
189
- },
190
- {
191
- id: listIdsConfig.volt_2,
192
- title: 'Volt 2',
193
- color: Colors.Red8,
194
- },
195
- {
196
- id: listIdsConfig.volt_3,
197
- title: 'Volt 3',
198
- color: Colors.Red9,
199
- },
200
- {
201
- id: listIdsConfig.current_1,
202
- title: 'Current 1',
203
- color: Colors.Blue10,
204
- },
205
- {
206
- id: listIdsConfig.current_2,
207
- title: 'Current 2',
208
- color: Colors.Blue11,
209
- },
210
- {
211
- id: listIdsConfig.current_3,
212
- title: 'Current 3',
213
- color: Colors.Blue12,
214
- },
215
- {
216
- id: listIdsConfig.active_power,
217
- title: 'Active Power',
218
- color: Colors.Orange6,
219
- },
220
- {
221
- id: listIdsConfig.power_factor_1,
222
- title: 'Power Factor 1',
223
- color: Colors.Green6,
224
- },
225
- {
226
- id: listIdsConfig.power_factor_2,
227
- title: 'Power Factor 2',
228
- color: Colors.Green9,
229
- },
230
- {
231
- id: listIdsConfig.power_factor_3,
232
- title: 'Power Factor 3',
233
- color: Colors.Green10,
234
- },
235
- ]}
236
- />
234
+ <ConfigHistoryChart configs={configs} />
237
235
  </View>
238
236
  )}
239
237
  </Section>
@@ -108,7 +108,29 @@ const PowerConsumption = memo(({ summaryDetail }) => {
108
108
  if (listConfigs?.total_power) {
109
109
  fetchData();
110
110
  }
111
- }, [startDate, endDate, listConfigs, groupBy]);
111
+ }, [startDate, endDate, listConfigs?.total_power, groupBy]);
112
+
113
+ const configs = useMemo(() => {
114
+ return [
115
+ { id: listIdsConfig?.volt, title: 'Volt', color: 'red' },
116
+ {
117
+ id: listIdsConfig?.current,
118
+ title: 'Current',
119
+ color: 'blue',
120
+ },
121
+ {
122
+ id: listIdsConfig?.active_power,
123
+ title: 'Active Power',
124
+ color: 'orange',
125
+ },
126
+ {
127
+ id: listIdsConfig?.power_factor,
128
+ title: 'Power Factor',
129
+ color: 'green',
130
+ },
131
+ ];
132
+ }, [listIdsConfig]);
133
+
112
134
  return (
113
135
  <>
114
136
  <Section type={'border'}>
@@ -120,26 +142,7 @@ const PowerConsumption = memo(({ summaryDetail }) => {
120
142
  />
121
143
  {showBoxHistory && (
122
144
  <View>
123
- <ConfigHistoryChart
124
- configs={[
125
- { id: listIdsConfig.volt, title: 'Volt', color: 'red' },
126
- {
127
- id: listIdsConfig.active_power,
128
- title: 'Current',
129
- color: 'blue',
130
- },
131
- {
132
- id: listIdsConfig.current,
133
- title: 'Active Power',
134
- color: 'orange',
135
- },
136
- {
137
- id: listIdsConfig.power_factor,
138
- title: 'Power Factor',
139
- color: 'green',
140
- },
141
- ]}
142
- />
145
+ <ConfigHistoryChart configs={configs} />
143
146
  </View>
144
147
  )}
145
148
  </Section>
@@ -160,6 +163,7 @@ const PowerConsumption = memo(({ summaryDetail }) => {
160
163
  endDate={endDate}
161
164
  setEndDate={setEndDate}
162
165
  setStartDate={setStartDate}
166
+ groupBy={groupBy}
163
167
  setGroupBy={setGroupBy}
164
168
  configuration={{
165
169
  type: 'horizontal_bar_chart',
@@ -56,6 +56,20 @@ const Temperature = memo(({ summaryDetail }) => {
56
56
  [summaryDetail]
57
57
  );
58
58
 
59
+ const configs = useMemo(() => {
60
+ return [
61
+ {
62
+ id: listConfigs?.temp,
63
+ title: t('text_temperature'),
64
+ color: Colors.Blue10,
65
+ },
66
+ {
67
+ id: listConfigs?.humi,
68
+ title: t('text_humidity'),
69
+ color: Colors.Red6,
70
+ },
71
+ ];
72
+ }, [listConfigs?.humi, listConfigs?.temp, t]);
59
73
  return (
60
74
  <>
61
75
  <Section type={'border'}>
@@ -78,20 +92,7 @@ const Temperature = memo(({ summaryDetail }) => {
78
92
  </Section>
79
93
  {showBoxHistory && (
80
94
  <Section type={'border'}>
81
- <ConfigHistoryChart
82
- configs={[
83
- {
84
- id: listConfigs.temp,
85
- title: t('text_temperature'),
86
- color: Colors.Blue10,
87
- },
88
- {
89
- id: listConfigs.humi,
90
- title: t('text_humidity'),
91
- color: Colors.Red6,
92
- },
93
- ]}
94
- />
95
+ <ConfigHistoryChart configs={configs} />
95
96
  </Section>
96
97
  )}
97
98
  </>
@@ -22,6 +22,11 @@ const UvIndex = memo(({ summaryDetail }) => {
22
22
  } else if (summaryDetail.uv_value > 10) {
23
23
  valueRefined = 10;
24
24
  }
25
+
26
+ const configs = useMemo(() => {
27
+ return [{ id: uv_id, title: t('text_uv_index'), color: Colors.Blue10 }];
28
+ }, [t, uv_id]);
29
+
25
30
  return (
26
31
  <>
27
32
  <Section type={'border'}>
@@ -70,11 +75,7 @@ const UvIndex = memo(({ summaryDetail }) => {
70
75
  </Section>
71
76
  {showBoxHistory && (
72
77
  <Section type={'border'}>
73
- <ConfigHistoryChart
74
- configs={[
75
- { id: uv_id, title: t('text_uv_index'), color: Colors.Blue10 },
76
- ]}
77
- />
78
+ <ConfigHistoryChart configs={configs} />
78
79
  </Section>
79
80
  )}
80
81
  </>
@@ -12,6 +12,14 @@ const WaterQuality = memo(({ summaryDetail }) => {
12
12
  const showBoxHistory = useMemo(() => {
13
13
  return ph_id || tur_id || clo_id ? true : false;
14
14
  }, [ph_id, tur_id, clo_id]);
15
+
16
+ const configs = useMemo(() => {
17
+ return [
18
+ { id: ph_id, title: 'pH', color: 'red' },
19
+ { id: tur_id, title: 'Turbidity', color: 'blue' },
20
+ { id: clo_id, title: 'Chlorine residual', color: 'orange' },
21
+ ];
22
+ }, [ph_id, tur_id, clo_id]);
15
23
  return (
16
24
  <>
17
25
  <Section type={'border'}>
@@ -52,13 +60,7 @@ const WaterQuality = memo(({ summaryDetail }) => {
52
60
  </Section>
53
61
  {showBoxHistory && (
54
62
  <Section type={'border'}>
55
- <ConfigHistoryChart
56
- configs={[
57
- { id: ph_id, title: 'pH', color: 'red' },
58
- { id: tur_id, title: 'Turbidity', color: 'blue' },
59
- { id: clo_id, title: 'Chlorine residual', color: 'orange' },
60
- ]}
61
- />
63
+ <ConfigHistoryChart configs={configs} />
62
64
  </Section>
63
65
  )}
64
66
  </>