@eohjsc/react-native-smart-city 0.7.39 → 0.7.41

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 (28) hide show
  1. package/package.json +1 -1
  2. package/src/commons/FieldTemplate/ChooseUserField/index.js +5 -1
  3. package/src/commons/SelectGateway/index.js +2 -1
  4. package/src/commons/SelectSubUnit/index.js +5 -1
  5. package/src/commons/SelectUnit/index.js +1 -1
  6. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +17 -9
  7. package/src/hooks/IoT/useValueEvaluation.js +7 -3
  8. package/src/hooks/IoT/useWatchSharedChips.js +8 -4
  9. package/src/hooks/useMqtt.js +8 -4
  10. package/src/navigations/AutomateStack.js +5 -1
  11. package/src/screens/ActivityLog/hooks/index.js +12 -4
  12. package/src/screens/AddLocationMaps/index.js +6 -3
  13. package/src/screens/AddNewGateway/RenameNewDevices.js +2 -1
  14. package/src/screens/Automate/AddNewAction/ChooseConfig.js +2 -1
  15. package/src/screens/Automate/AddNewAction/NewActionWrapper.js +2 -3
  16. package/src/screens/Automate/AddNewAction/ReceiverSelect.js +5 -1
  17. package/src/screens/Automate/MultiUnits.js +2 -1
  18. package/src/screens/Automate/ScriptDetail/index.js +13 -4
  19. package/src/screens/Automate/hooks/useAction.js +3 -1
  20. package/src/screens/Device/detail.js +10 -3
  21. package/src/screens/Device/hooks/useEvaluateValue.js +7 -3
  22. package/src/screens/SelectUnit/index.js +3 -1
  23. package/src/screens/Sharing/InfoMemberUnit.js +3 -1
  24. package/src/screens/SideMenuDetail/index.js +3 -1
  25. package/src/screens/Unit/SelectAddToFavorites.js +6 -2
  26. package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +2 -1
  27. package/src/screens/UnitSummary/components/PowerConsumption/index.js +2 -1
  28. package/src/screens/UnitSummary/index.js +2 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eohjsc/react-native-smart-city",
3
3
  "title": "React Native Smart Home",
4
- "version": "0.7.39",
4
+ "version": "0.7.41",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -18,7 +18,11 @@ const ChooseUserField = ({ unit, dataItem, index, setDataForm, dataForm }) => {
18
18
  const [members, setMembers] = useState([]);
19
19
  const t = useTranslations();
20
20
  const fetchMembers = async () => {
21
- const { success, data } = await axiosGet(API.SHARE.UNITS_MEMBERS(unit.id));
21
+ const { success, data } = await axiosGet(
22
+ API.SHARE.UNITS_MEMBERS(unit.id),
23
+ {},
24
+ true
25
+ );
22
26
  if (success) {
23
27
  setMembers(data);
24
28
  }
@@ -67,7 +67,8 @@ const SelectGateway = ({
67
67
  params: {
68
68
  type,
69
69
  },
70
- }
70
+ },
71
+ true
71
72
  );
72
73
  if (success) {
73
74
  setGateways(data);
@@ -54,7 +54,11 @@ const SelectSubUnit = ({ unitId, title, subTitle, onPressNext, route }) => {
54
54
 
55
55
  const fetchDetails = useCallback(async () => {
56
56
  // todo Bang: switch to use simpler APIs
57
- const { success, data } = await axiosGet(API.UNIT.UNIT_DETAIL(unitId));
57
+ const { success, data } = await axiosGet(
58
+ API.UNIT.UNIT_DETAIL(unitId),
59
+ {},
60
+ true
61
+ );
58
62
  if (success) {
59
63
  setUnit(data);
60
64
  }
@@ -67,7 +67,7 @@ const SelectUnit = ({ title, subTitle, onPressNext }) => {
67
67
 
68
68
  useEffect(() => {
69
69
  (async () => {
70
- const { data, success } = await axiosGet(API.SHARE.UNITS());
70
+ const { data, success } = await axiosGet(API.SHARE.UNITS(), {}, true);
71
71
  if (success) {
72
72
  const normalizeData = data.map((unit) => ({
73
73
  name: unit.name,
@@ -6,13 +6,17 @@ import { axiosGet } from '../../../utils/Apis/axios';
6
6
  import { getPusher } from '../../../utils/Pusher';
7
7
 
8
8
  const fetchDataS3 = async (url) => {
9
- const { data } = await axiosGet(url, {
10
- // todo Bang try not to use axiosGet
11
- transformRequest: (rq, headers) => {
12
- delete headers.Authorization;
13
- return rq;
9
+ const { data } = await axiosGet(
10
+ url,
11
+ {
12
+ // todo Bang try not to use axiosGet
13
+ transformRequest: (rq, headers) => {
14
+ delete headers.Authorization;
15
+ return rq;
16
+ },
14
17
  },
15
- });
18
+ true
19
+ );
16
20
  return data;
17
21
  };
18
22
 
@@ -51,9 +55,13 @@ export const useFetchConfigHistory = (
51
55
  params.append('date_from', date_from.format('YYYY-MM-DDTHH:mm:ss'));
52
56
  params.append('date_to', date_to.format('YYYY-MM-DDTHH:mm:ss'));
53
57
 
54
- const { success, data } = await axiosGet(endpoint, {
55
- params,
56
- });
58
+ const { success, data } = await axiosGet(
59
+ endpoint,
60
+ {
61
+ params,
62
+ },
63
+ true
64
+ );
57
65
  await updateConfigChart(success, data, configs, setChartData);
58
66
  setProcessing(false);
59
67
  },
@@ -16,9 +16,13 @@ const useValueEvaluations = (unitId) => {
16
16
  return;
17
17
  }
18
18
  const params = { configs__end_device__station__unit: unitId, page: page };
19
- const { success, data } = await axiosGet(API.VALUE_EVALUATIONS(), {
20
- params,
21
- });
19
+ const { success, data } = await axiosGet(
20
+ API.VALUE_EVALUATIONS(),
21
+ {
22
+ params,
23
+ },
24
+ true
25
+ );
22
26
  if (success) {
23
27
  setAction(Action.UPDATE_VALUE_EVALUATIONS, {
24
28
  unitId,
@@ -60,11 +60,15 @@ const useWatchSharedChips = ({ dashboardId, filterChipIds, ready = true }) => {
60
60
  return;
61
61
  }
62
62
  const getGateways = async () => {
63
- const { success, data } = await axiosGet(API.CHIP.SHARED_CONFIGURATION, {
64
- params: {
65
- unit: dashboardId,
63
+ const { success, data } = await axiosGet(
64
+ API.CHIP.SHARED_CONFIGURATION,
65
+ {
66
+ params: {
67
+ unit: dashboardId,
68
+ },
66
69
  },
67
- });
70
+ true
71
+ );
68
72
  if (success) {
69
73
  setChipIds(data.map((chip) => chip.id));
70
74
  handleUpdateConfigsById(data);
@@ -34,11 +34,15 @@ const useChipJsonConfiguration = ({ dashboardId, ready = true }) => {
34
34
  // get chip data
35
35
  useEffect(() => {
36
36
  const getGateways = async () => {
37
- const { success, data } = await axiosGet(API.CHIP.JSON_CONFIGURATION, {
38
- params: {
39
- unit: dashboardId,
37
+ const { success, data } = await axiosGet(
38
+ API.CHIP.JSON_CONFIGURATION,
39
+ {
40
+ params: {
41
+ unit: dashboardId,
42
+ },
40
43
  },
41
- });
44
+ true
45
+ );
42
46
  if (success) {
43
47
  setChips(data);
44
48
  handleUpdateConfigsById(data);
@@ -29,7 +29,11 @@ const AutomateStack = memo(() => {
29
29
 
30
30
  useEffect(() => {
31
31
  const fetchStarredScripts = async () => {
32
- const { success, data } = await axiosGet(API.AUTOMATE.STARRED_SCRIPTS());
32
+ const { success, data } = await axiosGet(
33
+ API.AUTOMATE.STARRED_SCRIPTS(),
34
+ {},
35
+ true
36
+ );
33
37
  success && setAction(Action.SET_STARRED_SCRIPTS, data);
34
38
  };
35
39
  fetchStarredScripts();
@@ -101,9 +101,13 @@ export default ({ id, type, share, filterEnabled }) => {
101
101
  }
102
102
  params.append('page', page);
103
103
 
104
- const { success, data } = await axiosGet(api.url(id), {
105
- params: params,
106
- });
104
+ const { success, data } = await axiosGet(
105
+ api.url(id),
106
+ {
107
+ params: params,
108
+ },
109
+ true
110
+ );
107
111
  if (success && data) {
108
112
  const { results = [] } = data;
109
113
  if (page === 1) {
@@ -123,7 +127,11 @@ export default ({ id, type, share, filterEnabled }) => {
123
127
  if (!api?.memberUrl || !filterEnabled?.user) {
124
128
  return;
125
129
  }
126
- const { success, data } = await axiosGet(api.memberUrl(share?.id));
130
+ const { success, data } = await axiosGet(
131
+ api.memberUrl(share?.id),
132
+ {},
133
+ true
134
+ );
127
135
  if (success) {
128
136
  data.unshift({ id: 0, name: t('all') });
129
137
  setMembers(data);
@@ -66,7 +66,8 @@ const AddLocationMaps = memo(() => {
66
66
 
67
67
  const { success, data } = await axiosGet(
68
68
  API.EXTERNAL.GOOGLE_MAP.AUTO_COMPLETE,
69
- config
69
+ config,
70
+ true
70
71
  );
71
72
  if (success) {
72
73
  setSearchData(data.predictions);
@@ -103,7 +104,8 @@ const AddLocationMaps = memo(() => {
103
104
 
104
105
  const { success, data } = await axiosGet(
105
106
  API.EXTERNAL.GOOGLE_MAP.GET_LAT_LNG_BY_PLACE_ID,
106
- body
107
+ body,
108
+ true
107
109
  );
108
110
  if (success) {
109
111
  const { location } = data.result.geometry;
@@ -128,7 +130,8 @@ const AddLocationMaps = memo(() => {
128
130
  latlng: `${currentLatitude},${currentLongitude}`,
129
131
  key: SCConfig.GOOGLE_MAP_API_KEY,
130
132
  },
131
- }
133
+ },
134
+ true
132
135
  );
133
136
  if (success && data.results.length > 0) {
134
137
  const result = data.results[0];
@@ -168,7 +168,8 @@ const RenameNewDevices = memo(({ route }) => {
168
168
  API.CHIP.RENAME_DEVICES(chipId),
169
169
  {
170
170
  params,
171
- }
171
+ },
172
+ true
172
173
  );
173
174
  if (success) {
174
175
  setInfo(data);
@@ -27,7 +27,8 @@ const ChooseConfig = ({ route }) => {
27
27
 
28
28
  const { success, data: automateData } = await axiosGet(
29
29
  API.AUTOMATE.DISPLAY_CONFIGS(device.id),
30
- { params }
30
+ { params },
31
+ true
31
32
  );
32
33
 
33
34
  if (success) {
@@ -22,13 +22,12 @@ const NewActionWrapper = ({
22
22
  canNext !== undefined || onNext !== undefined || nextTitle !== undefined;
23
23
  const { navigate } = useNavigation();
24
24
  const { params = {} } = useRoute();
25
- const { automateId } = params;
26
25
 
27
26
  const { closeScreen } = params;
28
27
 
29
28
  const handleClose = useCallback(() => {
30
- navigate(closeScreen, { ...params, automate: { id: automateId } });
31
- }, [closeScreen, navigate, params, automateId]);
29
+ navigate(closeScreen, params);
30
+ }, [closeScreen, navigate, params]);
32
31
 
33
32
  const rightComponent = useMemo(
34
33
  () => (
@@ -32,7 +32,11 @@ const ReceiverSelect = ({
32
32
  );
33
33
 
34
34
  const loadMembers = useCallback(async () => {
35
- const { success, data } = await axiosGet(API.SHARE.UNITS_MEMBERS(unitId));
35
+ const { success, data } = await axiosGet(
36
+ API.SHARE.UNITS_MEMBERS(unitId),
37
+ {},
38
+ true
39
+ );
36
40
  if (success) {
37
41
  setMembers(
38
42
  data.map((item) => ({
@@ -48,7 +48,8 @@ const MultiUnits = () => {
48
48
  } else {
49
49
  const { success, data: automateData } = await axiosGet(
50
50
  API.AUTOMATE.GET_MULTI_UNITS(),
51
- fetchParams
51
+ fetchParams,
52
+ true
52
53
  );
53
54
  success && setData(automateData);
54
55
  }
@@ -97,10 +97,11 @@ const ScriptDetail = ({ route }) => {
97
97
  name,
98
98
  unit,
99
99
  can_edit,
100
- id: automateId,
101
100
  is_need_all_conditions,
102
101
  conditions = [{}],
103
102
  } = automate;
103
+ // Create const automateId Fix error navigation from handleClose NewActionWrapper to ScriptDetail
104
+ const automateId = automate.id || params.automateId;
104
105
  const [needAllCondition, setNeedAllCondition] = useState(
105
106
  is_need_all_conditions
106
107
  );
@@ -276,7 +277,9 @@ const ScriptDetail = ({ route }) => {
276
277
 
277
278
  const fetchAutomateActions = useCallback(async () => {
278
279
  const { success, data: automateData } = await axiosGet(
279
- API.AUTOMATE.SCRIPT_ITEMS(automateId)
280
+ API.AUTOMATE.SCRIPT_ITEMS(automateId),
281
+ {},
282
+ true
280
283
  );
281
284
  if (success) {
282
285
  setData(automateData.script_items || []);
@@ -285,7 +288,9 @@ const ScriptDetail = ({ route }) => {
285
288
 
286
289
  const fetchAutomate = useCallback(async () => {
287
290
  const { success, data: automateData } = await axiosGet(
288
- API.AUTOMATE.FETCH_AUTOMATE(automateId)
291
+ API.AUTOMATE.FETCH_AUTOMATE(automateId),
292
+ {},
293
+ true
289
294
  );
290
295
  if (success) {
291
296
  setAutomate(automateData);
@@ -426,7 +431,11 @@ const ScriptDetail = ({ route }) => {
426
431
  max_conditions_per_automation - conditions.length
427
432
  );
428
433
  } else {
429
- const { success, data: perms } = await axiosGet(API.AUTH.PERMISSIONS());
434
+ const { success, data: perms } = await axiosGet(
435
+ API.AUTH.PERMISSIONS(),
436
+ {},
437
+ true
438
+ );
430
439
  if (success) {
431
440
  setNumberConditionsUsed(
432
441
  perms.max_conditions_per_automation - conditions.length
@@ -43,7 +43,9 @@ const useAction = (device, scriptItems, activatedScript = {}) => {
43
43
 
44
44
  const fetchDisplayActions = useCallback(async () => {
45
45
  const { success, data } = await axiosGet(
46
- API.DEVICE.DISPLAY_ACTIONS(device.id)
46
+ API.DEVICE.DISPLAY_ACTIONS(device.id),
47
+ {},
48
+ true
47
49
  );
48
50
 
49
51
  success && setDisplayActions(data);
@@ -198,7 +198,11 @@ const DeviceDetail = ({ route }) => {
198
198
  const bluetoothDevice = useBluetoothDevice(device);
199
199
 
200
200
  const fetchUnitDetail = useCallback(async () => {
201
- const { success, data } = await axiosGet(API.UNIT.UNIT_DETAIL(unitId));
201
+ const { success, data } = await axiosGet(
202
+ API.UNIT.UNIT_DETAIL(unitId),
203
+ {},
204
+ true
205
+ );
202
206
  if (success) {
203
207
  setUnit(data);
204
208
  }
@@ -249,7 +253,9 @@ const DeviceDetail = ({ route }) => {
249
253
 
250
254
  const fetchSensorDetail = useCallback(async () => {
251
255
  const { success, data, resp_status } = await axiosGet(
252
- API.DEVICE.DEVICE_DETAIL(sensorId || sensorData?.id)
256
+ API.DEVICE.DEVICE_DETAIL(sensorId || sensorData?.id),
257
+ {},
258
+ true
253
259
  );
254
260
  if (success) {
255
261
  setDevice(data);
@@ -611,7 +617,8 @@ const DeviceDetail = ({ route }) => {
611
617
  API.DEVICE.DISPLAY_VALUES_V2(device?.id),
612
618
  {
613
619
  params: params,
614
- }
620
+ },
621
+ true
615
622
  );
616
623
 
617
624
  setLoading((preState) => {
@@ -128,9 +128,13 @@ export const useGetEvaluateValue = (configId, unitId) => {
128
128
 
129
129
  if (configId && valueEvaluations[configId] === undefined) {
130
130
  (async () => {
131
- const { success, data } = await axiosGet(API.VALUE_EVALUATIONS(), {
132
- params: { configs__id: configId },
133
- });
131
+ const { success, data } = await axiosGet(
132
+ API.VALUE_EVALUATIONS(),
133
+ {
134
+ params: { configs__id: configId },
135
+ },
136
+ true
137
+ );
134
138
  if (success) {
135
139
  setAction(Action.INIT_VALUE_EVALUATIONS, {
136
140
  configId: configId,
@@ -40,7 +40,9 @@ const SelectUnit = () => {
40
40
 
41
41
  const getAllUnits = useCallback(async () => {
42
42
  const { success, data: automateData } = await axiosGet(
43
- API.AUTOMATE.GET_ALL_UNITS()
43
+ API.AUTOMATE.GET_ALL_UNITS(),
44
+ {},
45
+ true
44
46
  );
45
47
  if (success) {
46
48
  setData(automateData);
@@ -89,7 +89,9 @@ const InfoMemberUnit = memo(({ route }) => {
89
89
  const fetchMemberInfo = useCallback(async () => {
90
90
  setIsLoading(true);
91
91
  const { success, data } = await axiosGet(
92
- API.SHARE.UNIT_MEMBER_INFO(unit?.id, member?.id)
92
+ API.SHARE.UNIT_MEMBER_INFO(unit?.id, member?.id),
93
+ {},
94
+ true
93
95
  );
94
96
  if (success) {
95
97
  setIsLoading(false);
@@ -117,7 +117,9 @@ const SideMenuDetail = memo(({ route }) => {
117
117
 
118
118
  const fetchSideMenuDetail = useCallback(async () => {
119
119
  const { success, data } = await axiosGet(
120
- API.DEVICE.SIDE_MENU_DETAIL(sensor.id, side_menu.id)
120
+ API.DEVICE.SIDE_MENU_DETAIL(sensor.id, side_menu.id),
121
+ {},
122
+ true
121
123
  );
122
124
  if (success) {
123
125
  setSideMenu(data);
@@ -42,10 +42,14 @@ const SelectAddToFavorites = memo(({ route }) => {
42
42
  const fetchData = useCallback(async () => {
43
43
  setLoading(true);
44
44
  const { success: successDevice, data: dataDevice } = await axiosGet(
45
- API.UNIT.DEVICES_NOT_FAVORITES(unitId)
45
+ API.UNIT.DEVICES_NOT_FAVORITES(unitId),
46
+ {},
47
+ true
46
48
  );
47
49
  const { success: successAutomate, data: dataAutomate } = await axiosGet(
48
- API.UNIT.AUTOMATE_SCRIPTS_NOT_STARRED(unitId)
50
+ API.UNIT.AUTOMATE_SCRIPTS_NOT_STARRED(unitId),
51
+ {},
52
+ true
49
53
  );
50
54
  if (successDevice && successAutomate) {
51
55
  const newData = dataDevice.filter((item) => item.devices.length > 0);
@@ -134,7 +134,8 @@ const ThreePhasePowerConsumption = memo(({ summaryDetail }) => {
134
134
  API.VALUE_CONSUME.DISPLAY_HISTORY(),
135
135
  {
136
136
  params,
137
- }
137
+ },
138
+ true
138
139
  );
139
140
  if (success) {
140
141
  setData(data);
@@ -93,7 +93,8 @@ const PowerConsumption = memo(({ summaryDetail }) => {
93
93
  API.VALUE_CONSUME.DISPLAY_HISTORY(),
94
94
  {
95
95
  params,
96
- }
96
+ },
97
+ true
97
98
  );
98
99
  if (success) {
99
100
  setData(data);
@@ -104,7 +104,8 @@ const UnitSummary = memo(({ route }) => {
104
104
  const fetchUnitSummary = useCallback(async () => {
105
105
  const { success, data } = await axiosGet(
106
106
  API.UNIT.UNIT_SUMMARY(unit?.id),
107
- {}
107
+ {},
108
+ true
108
109
  );
109
110
  if (success) {
110
111
  const newData = data.filter((item) => item.id === summaryId);