@eohjsc/react-native-smart-city 0.3.21 → 0.3.24

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 (104) hide show
  1. package/index.js +2 -0
  2. package/package.json +2 -1
  3. package/src/Images/Common/buttonLeftCurtain.png +0 -0
  4. package/src/Images/Common/buttonLeftCurtain@2x.png +0 -0
  5. package/src/Images/Common/buttonLeftCurtain@3x.png +0 -0
  6. package/src/commons/Action/ItemQuickAction.js +1 -12
  7. package/src/commons/Action/__test__/ItemQuickAction.test.js +1 -1
  8. package/src/commons/ActionGroup/ColorPickerTemplate.js +2 -9
  9. package/src/commons/ActionGroup/CurtainButtonTemplate.js +14 -21
  10. package/src/commons/ActionGroup/CurtainButtonTemplateStyle.js +5 -0
  11. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +12 -24
  12. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +10 -17
  13. package/src/commons/ActionGroup/OnOffTemplate/index.js +10 -35
  14. package/src/commons/ActionGroup/OneBigButtonTemplate.js +2 -3
  15. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +7 -8
  16. package/src/commons/ActionGroup/SliderRangeTemplate.js +3 -10
  17. package/src/commons/ActionGroup/StatesGridActionTemplate.js +9 -24
  18. package/src/commons/ActionGroup/ThreeButtonTemplate.js +6 -9
  19. package/src/commons/ActionGroup/TimerActionTemplate.js +11 -4
  20. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +18 -33
  21. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +3 -15
  22. package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +38 -4
  23. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +7 -0
  24. package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +17 -12
  25. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +11 -16
  26. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +1 -1
  27. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +11 -10
  28. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +8 -7
  29. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +8 -1
  30. package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +7 -0
  31. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +17 -2
  32. package/src/commons/ActionGroup/__test__/index.test.js +15 -18
  33. package/src/commons/ConnectingProcess/index.js +6 -25
  34. package/src/commons/Device/HistoryChart.js +8 -6
  35. package/src/commons/Device/ItemDevice.js +79 -35
  36. package/src/commons/MediaPlayerDetail/index.js +5 -0
  37. package/src/commons/RowItem/index.js +6 -2
  38. package/src/commons/SubUnit/Favorites/index.js +24 -6
  39. package/src/commons/SubUnit/ShortDetail.js +31 -5
  40. package/src/commons/SubUnit/__test__/Favorites.test.js +1 -0
  41. package/src/commons/SubUnit/__test__/ShortDetail.test.js +1 -0
  42. package/src/configs/API.js +9 -4
  43. package/src/configs/Constants.js +8 -2
  44. package/src/configs/SCConfig.js +4 -0
  45. package/src/context/actionType.ts +7 -5
  46. package/src/context/mockStore.ts +10 -3
  47. package/src/context/reducer.ts +29 -15
  48. package/src/hoc/index.js +3 -0
  49. package/src/hoc/withRemoteControl.js +10 -0
  50. package/src/hooks/Common/index.js +2 -2
  51. package/src/hooks/Common/useDevicesStatus.js +57 -0
  52. package/src/hooks/Common/useGGHomeDeviceConnected.js +3 -3
  53. package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +1 -2
  54. package/src/hooks/IoT/__test__/useRemoteControl.test.js +9 -11
  55. package/src/hooks/IoT/index.js +9 -1
  56. package/src/hooks/IoT/useGGHomeConnection.js +0 -1
  57. package/src/hooks/IoT/useRemoteControl.js +2 -3
  58. package/src/hooks/IoT/useUnwatchLGDeviceConfigControl.js +29 -0
  59. package/src/hooks/IoT/useValueEvaluation.js +17 -4
  60. package/src/hooks/IoT/useWatchConfigs.js +34 -0
  61. package/src/iot/Monitor.js +13 -20
  62. package/src/iot/RemoteControl/GoogleHome.js +12 -13
  63. package/src/iot/RemoteControl/Internet.js +1 -8
  64. package/src/iot/RemoteControl/LG.js +1 -0
  65. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +7 -2
  66. package/src/navigations/UnitStack.js +27 -3
  67. package/src/screens/AddNewAction/SelectAction.js +1 -1
  68. package/src/screens/AddNewAction/SetupSensor.js +4 -0
  69. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +44 -78
  70. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +15 -35
  71. package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +2 -0
  72. package/src/screens/AllCamera/__test__/index.test.js +1 -1
  73. package/src/screens/Device/__test__/detail.test.js +1 -54
  74. package/src/screens/Device/components/SensorConnectStatusViewHeader.js +18 -8
  75. package/src/screens/Device/components/SensorDisplayItem.js +2 -2
  76. package/src/screens/Device/detail.js +36 -30
  77. package/src/screens/Device/hooks/__test__/useEvaluateValue.test.js +102 -0
  78. package/src/screens/Device/hooks/useDeviceWatchConfigControl.js +20 -0
  79. package/src/screens/Device/utils/index.js +45 -0
  80. package/src/screens/Device/utils/index.test.js +111 -0
  81. package/src/screens/EmergencyContacts/EmergencyContactsAddNew.js +35 -22
  82. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +2 -1
  83. package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +36 -2
  84. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +0 -2
  85. package/src/screens/Notification/__test__/NotificationItem.test.js +84 -19
  86. package/src/screens/Notification/components/NotificationItem.js +64 -31
  87. package/src/screens/PlayBackCamera/index.js +22 -6
  88. package/src/screens/ScriptDetail/hooks/useStarredScript.js +2 -2
  89. package/src/screens/SubUnit/AddSubUnit.js +2 -1
  90. package/src/screens/Unit/AddMenu.js +4 -0
  91. package/src/screens/Unit/{SelectFavoritesDevices.js → SelectAddToFavorites.js} +81 -26
  92. package/src/screens/Unit/{SelectFavoritesDevicesStyles.js → SelectAddToFavoritesStyles.js} +0 -0
  93. package/src/screens/Unit/__test__/CheckSendEmail.test.js +12 -0
  94. package/src/screens/Unit/__test__/Detail.test.js +2 -3
  95. package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +267 -0
  96. package/src/screens/Unit/components/AutomateScript/index.js +65 -0
  97. package/src/screens/Unit/components/AutomateScript/styles.js +48 -0
  98. package/src/screens/Unit/components/MyUnitDevice/index.js +4 -2
  99. package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +4 -2
  100. package/src/utils/I18n/translations/en.json +7 -2
  101. package/src/utils/I18n/translations/vi.json +6 -1
  102. package/src/utils/Route/index.js +1 -1
  103. package/src/hooks/Common/useSensorsStatus.js +0 -62
  104. package/src/screens/Unit/__test__/SelectFavoritesDevices.test.js +0 -110
@@ -12,7 +12,6 @@ import styles from './styles';
12
12
  import DeviceItem from './DeviceItem/DeviceItem';
13
13
  import Connecting from '../Connecting';
14
14
  import { useSCContextSelector } from '../../context';
15
- import { ToastBottomHelper } from '../../utils/Utils';
16
15
 
17
16
  const ConnectingSuccess = ({
18
17
  unit,
@@ -76,7 +75,6 @@ const ConnectingProcess = ({ route }) => {
76
75
  setSensor(data);
77
76
  setNewName(data?.name);
78
77
  } else {
79
- ToastBottomHelper.error(JSON.stringify(data));
80
78
  goBack();
81
79
  }
82
80
 
@@ -96,7 +94,6 @@ const ConnectingProcess = ({ route }) => {
96
94
  setSensor(data);
97
95
  setNewName(data?.name);
98
96
  } else {
99
- ToastBottomHelper.error(JSON.stringify(data));
100
97
  goBack();
101
98
  }
102
99
  break;
@@ -113,7 +110,6 @@ const ConnectingProcess = ({ route }) => {
113
110
  setSensor(data);
114
111
  setNewName(data?.name || gateway?.model);
115
112
  } else {
116
- ToastBottomHelper.error(JSON.stringify(data));
117
113
  goBack();
118
114
  }
119
115
  break;
@@ -136,36 +132,21 @@ const ConnectingProcess = ({ route }) => {
136
132
  ]);
137
133
 
138
134
  const handleDone = useCallback(async () => {
139
- let result, message;
140
135
  switch (devicePrefixName) {
141
136
  case 'SENSOR': {
142
- const { success, data } = await axiosPatch(
143
- API.SENSOR.SENSOR_DETAIL(sensor?.id),
144
- {
145
- name: newName,
146
- }
147
- );
148
- result = success;
149
- message = data;
137
+ await axiosPatch(API.SENSOR.SENSOR_DETAIL(sensor?.id), {
138
+ name: newName,
139
+ });
150
140
  break;
151
141
  }
152
142
  case 'ROBOT':
153
143
  case 'LITE': {
154
- const { success, data } = await axiosPatch(
155
- API.CHIP.CHIP_DETAIL(sensor?.id),
156
- {
157
- name: newName,
158
- }
159
- );
160
- result = success;
161
- message = data;
144
+ await axiosPatch(API.CHIP.CHIP_DETAIL(sensor?.id), {
145
+ name: newName,
146
+ });
162
147
  break;
163
148
  }
164
149
  }
165
-
166
- if (!result) {
167
- ToastBottomHelper.error(JSON.stringify(message));
168
- }
169
150
  navigate(Routes.UnitStack, {
170
151
  screen: Routes.UnitDetail,
171
152
  params: {
@@ -76,7 +76,7 @@ const HistoryChart = memo(
76
76
  return {
77
77
  ...state,
78
78
  showModalStart: false,
79
- startTime: moment(date),
79
+ startTime: date ? moment(date) : moment().valueOf(),
80
80
  };
81
81
  } else {
82
82
  setStartDate(moment(date));
@@ -84,8 +84,8 @@ const HistoryChart = memo(
84
84
  return {
85
85
  ...state,
86
86
  showModalStart: false,
87
- startTime: moment(date),
88
- endTime: moment(date).add(1, 'day'),
87
+ startTime: date ? moment(date) : moment().valueOf(),
88
+ endTime: date ? moment(date).add(1, 'day') : moment().valueOf(),
89
89
  };
90
90
  }
91
91
  });
@@ -105,7 +105,7 @@ const HistoryChart = memo(
105
105
  return {
106
106
  ...state,
107
107
  showModalEnd: false,
108
- endTime: moment(date),
108
+ endTime: date ? moment(date) : moment().valueOf(),
109
109
  };
110
110
  } else {
111
111
  setStartDate(moment(date).add(-1, 'day'));
@@ -113,8 +113,10 @@ const HistoryChart = memo(
113
113
  return {
114
114
  ...state,
115
115
  showModalEnd: false,
116
- startTime: moment(date).add(-1, 'day'),
117
- endTime: moment(date),
116
+ startTime: date
117
+ ? moment(date).add(-1, 'day')
118
+ : moment().valueOf(),
119
+ endTime: date ? moment(date) : moment().valueOf(),
118
120
  };
119
121
  }
120
122
  });
@@ -20,17 +20,7 @@ import { TESTID, DEVICE_TYPE, DEVICE_SIZE } from '../../configs/Constants';
20
20
  import IconComponent from '../IconComponent';
21
21
 
22
22
  const ItemDevice = memo(
23
- ({
24
- svgMain,
25
- description,
26
- title,
27
- sensor,
28
- unit,
29
- station,
30
- serverDown,
31
- status,
32
- wrapStyle,
33
- }) => {
23
+ ({ svgMain, description, title, sensor, unit, station, wrapStyle }) => {
34
24
  const t = useTranslations();
35
25
  const navigation = useNavigation();
36
26
  const isBluetoothEnabled = useSCContextSelector(
@@ -39,6 +29,9 @@ const ItemDevice = memo(
39
29
  const isNetworkConnected = useSCContextSelector(
40
30
  (state) => state.app.isNetworkConnected
41
31
  );
32
+ const statuses = useSCContextSelector(
33
+ (state) => state.iot.internet.statuses
34
+ );
42
35
  const { isConnected: isGGHomeConnected, isConnecting: isGGHomeConnecting } =
43
36
  useGGHomeDeviceConnected(sensor);
44
37
 
@@ -52,9 +45,13 @@ const ItemDevice = memo(
52
45
  }, [navigation, sensor, station, title, unit]);
53
46
 
54
47
  const isConnectedViaInternet =
55
- status === undefined
56
- ? !serverDown && isNetworkConnected && sensor.is_connected
57
- : !serverDown && isNetworkConnected && status.is_connected;
48
+ isNetworkConnected &&
49
+ !!sensor &&
50
+ sensor.id in statuses &&
51
+ statuses[sensor.id]?.isConnected;
52
+
53
+ const isFetchingStatus =
54
+ isNetworkConnected && !!sensor && !(sensor.id in statuses);
58
55
 
59
56
  const isConnectedViaBLE =
60
57
  isBluetoothEnabled &&
@@ -62,28 +59,73 @@ const ItemDevice = memo(
62
59
  sensor?.remote_control_options?.bluetooth?.address
63
60
  );
64
61
 
65
- const isConnected =
66
- !!sensor && sensor?.is_other_device
67
- ? sensor?.device_type === DEVICE_TYPE.LG_THINQ
68
- ? true
69
- : isGGHomeConnected
70
- : isConnectedViaInternet || isConnectedViaBLE;
71
-
72
- const isConnecting =
73
- !!sensor &&
74
- sensor?.is_other_device &&
75
- sensor?.device_type !== DEVICE_TYPE.LG_THINQ
76
- ? isGGHomeConnecting
77
- : false;
62
+ const borderColor = (() => {
63
+ if (!!sensor && sensor?.is_managed_by_backend) {
64
+ if (isConnectedViaBLE) {
65
+ return Colors.Gray4;
66
+ }
67
+ if (isFetchingStatus || isConnectedViaInternet) {
68
+ return Colors.Gray4;
69
+ }
70
+ }
71
+ // not managed by backend
72
+ if (sensor?.device_type === DEVICE_TYPE.LG_THINQ) {
73
+ return Colors.Gray4;
74
+ }
75
+ if (sensor?.device_type === DEVICE_TYPE.GOOGLE_HOME) {
76
+ if (isGGHomeConnecting || isGGHomeConnected) {
77
+ return Colors.Gray4;
78
+ }
79
+ }
80
+ return Colors.Red6;
81
+ })();
78
82
 
79
- const borderColor =
80
- isConnected || isConnecting ? Colors.Gray4 : Colors.Red6;
83
+ const textConnected = (() => {
84
+ if (!!sensor && sensor?.is_managed_by_backend) {
85
+ if (isConnectedViaBLE) {
86
+ return t('connected');
87
+ }
88
+ if (isFetchingStatus) {
89
+ return '';
90
+ }
91
+ if (isConnectedViaInternet) {
92
+ return t('connected');
93
+ }
94
+ }
95
+ // not managed by backend
96
+ if (sensor?.device_type === DEVICE_TYPE.LG_THINQ) {
97
+ return t('connected');
98
+ }
99
+ if (sensor?.device_type === DEVICE_TYPE.GOOGLE_HOME) {
100
+ if (isGGHomeConnecting) {
101
+ return t('connecting');
102
+ }
103
+ if (isGGHomeConnected) {
104
+ return t('connected');
105
+ }
106
+ }
107
+ return t('disconnected');
108
+ })();
81
109
 
82
- const textConnected = isConnected
83
- ? t('connected')
84
- : isConnecting
85
- ? t('connecting')
86
- : t('disconnected');
110
+ const canRenderQuickAction = (() => {
111
+ if (!!sensor && sensor?.is_managed_by_backend) {
112
+ if (isConnectedViaBLE) {
113
+ return true;
114
+ }
115
+ if (isFetchingStatus) {
116
+ return false;
117
+ }
118
+ return true;
119
+ }
120
+ // not managed by backend
121
+ if (sensor?.device_type === DEVICE_TYPE.LG_THINQ) {
122
+ return true;
123
+ }
124
+ if (sensor?.device_type === DEVICE_TYPE.GOOGLE_HOME) {
125
+ return !isGGHomeConnecting;
126
+ }
127
+ return true;
128
+ })();
87
129
 
88
130
  return (
89
131
  <TouchableWithoutFeedback
@@ -98,7 +140,9 @@ const ItemDevice = memo(
98
140
  <TouchableOpacity onPress={goToSensorDisplay}>
99
141
  <IconComponent icon={sensor.icon} iconKit={sensor.icon_kit} />
100
142
  </TouchableOpacity>
101
- {!isConnecting && <ItemQuickAction sensor={sensor} unit={unit} />}
143
+ {canRenderQuickAction && (
144
+ <ItemQuickAction sensor={sensor} unit={unit} />
145
+ )}
102
146
  </View>
103
147
  <TouchableOpacity onPress={goToSensorDisplay}>
104
148
  <Text
@@ -149,6 +149,11 @@ const MediaPlayerDetail = ({
149
149
  }, [JSON.stringify(camera_opened), id]);
150
150
 
151
151
  const source = !thumbnail || !thumbnail.uri ? Images.BgDevice : thumbnail;
152
+
153
+ if (!uri) {
154
+ return <></>;
155
+ }
156
+
152
157
  return (
153
158
  <View style={[styles.wrap, wrapStyles]}>
154
159
  <View style={[styles.loadingWrap]}>
@@ -49,9 +49,13 @@ export const RowItem = memo(
49
49
  </View>
50
50
  )}
51
51
  <View style={styles.columeFlex}>
52
- <Text style={styles.titleName}> {text}</Text>
52
+ <Text numberOfLines={1} style={styles.titleName}>
53
+ {text}
54
+ </Text>
53
55
  {!!isShowSubText && (
54
- <Text style={styles.status}> {subtext}</Text>
56
+ <Text numberOfLines={1} style={styles.status}>
57
+ {subtext}
58
+ </Text>
55
59
  )}
56
60
  </View>
57
61
  {!!rightComponent && (
@@ -1,8 +1,9 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import { View } from 'react-native';
3
3
  import { useNavigation } from '@react-navigation/native';
4
4
  import { useTranslations } from '../../../hooks/Common/useTranslations';
5
- import { useSensorsStatus } from '../../../hooks/Common';
5
+ import { useDevicesStatus } from '../../../hooks/Common';
6
+ import { useWatchConfigs } from '../../../hooks/IoT';
6
7
 
7
8
  import { Section } from '../../Section';
8
9
  import ItemDevice from '../../Device/ItemDevice';
@@ -10,6 +11,7 @@ import ItemOneTap from '../OneTap/ItemOneTap';
10
11
  import ItemAddNew from '../../Device/ItemAddNew';
11
12
  import styles from './styles';
12
13
  import Routes from '../../../utils/Route';
14
+ import { DEVICE_TYPE } from '../../../configs/Constants';
13
15
 
14
16
  const SubUnitFavorites = ({
15
17
  isOwner,
@@ -21,10 +23,27 @@ const SubUnitFavorites = ({
21
23
  const t = useTranslations();
22
24
  const { navigate } = useNavigation();
23
25
 
24
- const { getStatus, serverDown } = useSensorsStatus(unit, favoriteDevices);
26
+ useDevicesStatus(unit, favoriteDevices);
27
+
28
+ const configsNeedWatching = useMemo(() => {
29
+ const configIds = [];
30
+ favoriteDevices.forEach((device) => {
31
+ if (
32
+ device?.quick_action?.config_id &&
33
+ ![DEVICE_TYPE.GOOGLE_HOME, DEVICE_TYPE.LG_THINQ].includes(
34
+ device?.device_type
35
+ )
36
+ ) {
37
+ configIds.push(device.quick_action.config_id);
38
+ }
39
+ });
40
+ return configIds;
41
+ }, [favoriteDevices]);
42
+
43
+ useWatchConfigs(configsNeedWatching);
25
44
 
26
45
  const handleOnAddNew = () => {
27
- navigate(Routes.SelectFavoritesDevices, {
46
+ navigate(Routes.SelectAddToFavorites, {
28
47
  unitId: unit.id,
29
48
  });
30
49
  };
@@ -46,8 +65,6 @@ const SubUnitFavorites = ({
46
65
  sensor={sensor}
47
66
  unit={unit}
48
67
  station={sensor.station}
49
- serverDown={serverDown}
50
- status={getStatus(sensor)}
51
68
  wrapStyle={wrapItemStyle}
52
69
  />
53
70
  ))}
@@ -58,6 +75,7 @@ const SubUnitFavorites = ({
58
75
  isOwner={isOwner}
59
76
  automate={automate}
60
77
  unit={unit}
78
+ wrapStyle={wrapItemStyle}
61
79
  />
62
80
  ))}
63
81
  <ItemAddNew
@@ -1,8 +1,9 @@
1
- import React from 'react';
1
+ import React, { useCallback, useMemo } from 'react';
2
2
  import { StyleSheet, View } from 'react-native';
3
3
  import { useNavigation } from '@react-navigation/native';
4
4
  import { useTranslations } from '../../hooks/Common/useTranslations';
5
- import { useSensorsStatus } from '../../hooks/Common';
5
+ import { useDevicesStatus } from '../../hooks/Common';
6
+ import { useWatchConfigs } from '../../hooks/IoT';
6
7
 
7
8
  import { Images, Device } from '../../configs';
8
9
  import { DEVICE_TYPE, TESTID } from '../../configs/Constants';
@@ -30,7 +31,33 @@ const ShortDetailSubUnit = ({ unit, station }) => {
30
31
  const t = useTranslations();
31
32
  const { navigate } = useNavigation();
32
33
 
33
- const { getStatus, serverDown } = useSensorsStatus(unit, station?.sensors);
34
+ useDevicesStatus(unit, station?.sensors);
35
+
36
+ const configsNeedWatching = useMemo(() => {
37
+ const configIds = [];
38
+ (station?.sensors || []).forEach((device) => {
39
+ if (
40
+ device?.quick_action?.config_id &&
41
+ device?.device_type !== DEVICE_TYPE.GOOGLE_HOME
42
+ ) {
43
+ configIds.push(device.quick_action.config_id);
44
+ }
45
+ });
46
+ return configIds;
47
+ }, [station]);
48
+
49
+ useWatchConfigs(configsNeedWatching);
50
+
51
+ const goToPlayBack = useCallback(() => {
52
+ navigate(Routes.PlaybackCamera, {
53
+ item: {
54
+ configuration: station?.camera,
55
+ thumbnail: {
56
+ uri: station?.background,
57
+ },
58
+ },
59
+ });
60
+ }, [navigate, station?.background, station?.camera]);
34
61
 
35
62
  const renderCamera = () => {
36
63
  if (station?.camera) {
@@ -54,6 +81,7 @@ const ShortDetailSubUnit = ({ unit, station }) => {
54
81
  cameraName={station?.camera?.name}
55
82
  width={standardizeWidth}
56
83
  height={standardizeHeight}
84
+ goToPlayBack={goToPlayBack}
57
85
  />
58
86
  </View>
59
87
  );
@@ -139,8 +167,6 @@ const ShortDetailSubUnit = ({ unit, station }) => {
139
167
  sensor={sensor}
140
168
  unit={unit}
141
169
  station={station}
142
- serverDown={serverDown}
143
- status={getStatus(sensor)}
144
170
  />
145
171
  );
146
172
  }
@@ -28,6 +28,7 @@ jest.mock('@react-navigation/native', () => {
28
28
  navigate: mockNavigate,
29
29
  }),
30
30
  useIsFocused: () => true,
31
+ useFocusEffect: jest.fn(),
31
32
  };
32
33
  });
33
34
 
@@ -35,6 +35,7 @@ jest.mock('@react-navigation/native', () => {
35
35
  navigate: mockedNavigate,
36
36
  }),
37
37
  useIsFocused: () => true,
38
+ useFocusEffect: jest.fn(),
38
39
  };
39
40
  });
40
41
 
@@ -29,9 +29,14 @@ const API = {
29
29
  CHANGE_OWNER: (id) => `/property_manager/units/${id}/change_owner/`,
30
30
  FAVOURITE_DEVICES: (id) =>
31
31
  `/property_manager/units/${id}/favourite_devices/`,
32
- DEVICES: (id) => `/property_manager/units/${id}/devices/`,
32
+ DEVICES_NOT_FAVORITES: (id) =>
33
+ `/property_manager/units/${id}/devices_not_favourites/`,
33
34
  ADD_DEVICES_TO_FAVORITES: (id) =>
34
35
  `/property_manager/units/${id}/add_devices_to_favourites/`,
36
+ AUTOMATE_SCRIPTS_NOT_STARRED: (id) =>
37
+ `/property_manager/units/${id}/automate_scripts_not_starred/`,
38
+ STAR_AUTOMATE_SCRIPTS: (id) =>
39
+ `/property_manager/units/${id}/star_automate_scripts/`,
35
40
  },
36
41
  SUB_UNIT: {
37
42
  REMOVE_SUB_UNIT: (unitId, id) =>
@@ -53,7 +58,7 @@ const API = {
53
58
  SENSOR_DETAIL: (id) => `/property_manager/sensors/${id}/`,
54
59
  DISPLAY: (id) => `/property_manager/sensors/${id}/display/`,
55
60
  SIDE_MENU_DETAIL: (id, side_menu_id) =>
56
- `/property_manager/sensors/${id}/display/side_menu/${side_menu_id}/`,
61
+ `/property_manager/devices/${id}/display/side_menu/${side_menu_id}/`,
57
62
  DISPLAY_VALUES_V2: (id) =>
58
63
  `/property_manager/sensors/${id}/display_values_v2/`,
59
64
  DISPLAY_HISTORY: (id, hId) =>
@@ -137,8 +142,8 @@ const API = {
137
142
  },
138
143
  IOT: {
139
144
  CHIP_MANAGER: {
140
- WATCH_CONFIGS: () => '/chip_manager/watch_configs/',
141
- PUSHER_AUTH: () => '/chip_manager/pusher/auth/',
145
+ WATCH_CONFIGS: () => '/chip_manager/watch_configs_v2/',
146
+ PUSHER_AUTH: () => '/chip_manager/pusher/auth_v2/',
142
147
  },
143
148
  LG: {
144
149
  GET_TOKEN: (client_id, code, redirect_uri, backend_url) =>
@@ -161,8 +161,8 @@ export const STATE_VALUE_SENSOR_TYPES = [
161
161
  stateValue: ['not_activated', 'activated'],
162
162
  },
163
163
  {
164
- type: 'filter_water',
165
- stateValue: ['not_detected', 'detected'],
164
+ type: 'door',
165
+ stateValue: ['close', 'open'],
166
166
  },
167
167
  ];
168
168
 
@@ -823,6 +823,7 @@ export const NOTIFICATION_TYPES = {
823
823
  NOTIFY_UPDATE_ADDRESS: 'NOTIFY_UPDATE_ADDRESS',
824
824
  NOTIFY_REMOVE_SUB_UNIT: 'NOTIFY_REMOVE_SUB_UNIT',
825
825
  NOTIFY_REMOVE_DEVICE: 'NOTIFY_REMOVE_DEVICE',
826
+ NOTIFY_EMERGENCY: 'NOTIFY_EMERGENCY',
826
827
  };
827
828
 
828
829
  export const ACTIVITY_LOG_TYPES = {
@@ -843,6 +844,11 @@ export const SENSOR_TYPE = {
843
844
  FILTER_WATER: 'filter_water',
844
845
  };
845
846
 
847
+ export const EMERGENCY_TYPE = {
848
+ CREATED: 'emergency',
849
+ RESOLVE: 'resolved_emergency',
850
+ };
851
+
846
852
  export const PROBLEM_CODE = {
847
853
  CLIENT_ERROR: 'CLIENT_ERROR',
848
854
  SERVER_ERROR: 'SERVER_ERROR',
@@ -95,6 +95,7 @@ const SCDefaultConfig = {
95
95
  VCONNEX_REDIRECT_URI_APP: '',
96
96
  pusherAppKey: '8557fcc63959f564f1aa',
97
97
  pusherAppCluster: 'ap1',
98
+ intervalWatchConfigTime: 30000,
98
99
  };
99
100
 
100
101
  export class SCConfig {
@@ -108,6 +109,7 @@ export class SCConfig {
108
109
  static pusherAppKey = SCDefaultConfig.pusherAppKey;
109
110
  static pusherAppCluste = SCDefaultConfig.pusherAppCluster;
110
111
  static language = 'en';
112
+ static intervalWatchConfigTime = SCDefaultConfig.intervalWatchConfigTime;
111
113
  }
112
114
 
113
115
  export const initSCConfig = (config) => {
@@ -128,4 +130,6 @@ export const initSCConfig = (config) => {
128
130
  SCConfig.pusherAppKey = config.pusherAppKey ?? SCDefaultConfig.pusherAppKey;
129
131
  SCConfig.pusherAppCluster =
130
132
  config.pusherAppCluster ?? SCDefaultConfig.pusherAppCluster;
133
+ SCConfig.intervalWatchConfigTime =
134
+ config.intervalWatchConfigTime ?? SCDefaultConfig.intervalWatchConfigTime;
131
135
  };
@@ -15,13 +15,14 @@ export const Action = {
15
15
  ADD_DEVICES_TO_FAVORITES: 'ADD_DEVICE_TO_FAVORITES',
16
16
  REMOVE_DEVICES_FROM_FAVORITES: 'REMOVE_DEVICE_FROM_FAVORITES',
17
17
  SET_STARRED_SCRIPTS: 'SET_STARRED_SCRIPTS',
18
- STAR_SCRIPT: 'STAR_SCRIPT',
19
- UNSTAR_SCRIPT: 'UNSTAR_SCRIPT',
20
- CONNECTING_GOOGLE_HOME: 'CONNECTING_GOOGLE_HOME',
18
+ STAR_SCRIPTS: 'STAR_SCRIPTS',
19
+ UNSTAR_SCRIPTS: 'UNSTAR_SCRIPTS',
21
20
  SET_GOOGLE_HOME_CONNECTIONS: 'SET_GOOGLE_HOME_CONNECTIONS',
22
21
  CHANGE_GOOGLE_HOME_CONN_STATE: 'CHANGE_GOOGLE_HOME_CONN_STATE',
23
22
  UPDATE_VALUE_EVALUATIONS: 'UPDATE_VALUE_EVALUATIONS',
23
+ NEED_UPDATE_VALUE_EVALUATIONS: 'NEED_UPDATE_VALUE_EVALUATIONS',
24
24
  ON_RECEIVE_NOTIFICATION: 'ON_RECEIVE_NOTIFICATION',
25
+ SET_DEVICES_STATUS: 'SET_DEVICES_STATUS',
25
26
  };
26
27
 
27
28
  export type AuthData = {
@@ -83,8 +84,9 @@ export type AppType = {
83
84
 
84
85
  export type IoTType = {
85
86
  googlehome: {
86
- isFirstTimeConnect: boolean;
87
- isConnecting: boolean;
88
87
  connections: {};
89
88
  };
89
+ internet: {
90
+ statuses: {};
91
+ };
90
92
  };
@@ -41,10 +41,11 @@ export const mockDataStore: ContextData = {
41
41
  },
42
42
  iot: {
43
43
  googlehome: {
44
- isFirstTimeConnect: true,
45
- isConnecting: false,
46
44
  connections: {},
47
45
  },
46
+ internet: {
47
+ statuses: {},
48
+ },
48
49
  },
49
50
  valueEvaluations: {},
50
51
  fetchedValueEvaluationUnits: [],
@@ -94,8 +95,14 @@ export const mockSCStore = (data: ContextData): ContextData => {
94
95
  ...mockDataStore.iot.googlehome,
95
96
  connections: {},
96
97
  },
98
+ internet: {
99
+ statuses: {},
100
+ },
101
+ },
102
+ valueEvaluations: {
103
+ ...mockDataStore.valueEvaluations,
104
+ ...data.valueEvaluations,
97
105
  },
98
- valueEvaluations: {},
99
106
  fetchedValueEvaluationUnits: [],
100
107
  };
101
108
  };