@eohjsc/react-native-smart-city 0.2.72 → 0.2.76

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 (82) hide show
  1. package/index.js +2 -1
  2. package/package.json +2 -2
  3. package/src/Images/Common/disney.svg +20 -0
  4. package/src/Images/Common/home.svg +3 -0
  5. package/src/Images/Common/input.svg +3 -0
  6. package/src/Images/Common/keyboard_arrow_down.svg +3 -0
  7. package/src/Images/Common/keyboard_arrow_up.svg +3 -0
  8. package/src/Images/Common/keyboard_return.svg +3 -0
  9. package/src/Images/Common/netflix.svg +9 -0
  10. package/src/Images/Common/pause.svg +3 -0
  11. package/src/Images/Common/shadowButton.png +0 -0
  12. package/src/Images/Common/spotify.svg +5 -0
  13. package/src/Images/Common/volume_up.svg +3 -0
  14. package/src/Images/Common/youtube.svg +13 -0
  15. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +214 -0
  16. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplateStyles.js +69 -0
  17. package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/CircleButton.test.js +129 -0
  18. package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/ControlPlay.test.js +138 -0
  19. package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/RectangleButton.test.js +110 -0
  20. package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/SmartTiviActionTemplate.test.js +144 -0
  21. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/CircleButton.js +91 -0
  22. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/CircleButtonStyles.js +79 -0
  23. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/ControlPlay.js +51 -0
  24. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/ControlPlayStyles.js +24 -0
  25. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/Icon.js +25 -0
  26. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/RectangleButton.js +49 -0
  27. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/RectangleButtonStyles.js +47 -0
  28. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +1 -1
  29. package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +1 -1
  30. package/src/commons/ActionGroup/__test__/index.test.js +3 -3
  31. package/src/commons/ActionGroup/index.js +3 -0
  32. package/src/commons/ActionTemplate/__test__/index.test.js +2 -2
  33. package/src/commons/Automate/__test__/ItemAutomate.test.js +1 -1
  34. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +1 -1
  35. package/src/commons/Device/HistoryChart.js +11 -7
  36. package/src/commons/Device/HorizontalBarChart.js +2 -1
  37. package/src/commons/Device/ItemDevice.js +17 -2
  38. package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +1 -1
  39. package/src/commons/Device/WindDirection/Compass/Compass.test.js +2 -2
  40. package/src/commons/Device/__test__/ConnectedViewHeader.test.js +2 -2
  41. package/src/commons/Device/__test__/DisconnectedView.test.js +5 -5
  42. package/src/commons/Explore/__test__/HeaderExplore.test.js +1 -1
  43. package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +1 -1
  44. package/src/commons/Modal/__test__/ModalBottom.test.js +2 -2
  45. package/src/commons/Sharing/__test__/MemberList.test.js +3 -3
  46. package/src/commons/Sharing/__test__/RowMember.test.js +2 -2
  47. package/src/commons/SubUnit/Favorites/index.js +32 -1
  48. package/src/commons/SubUnit/ShortDetail.js +33 -3
  49. package/src/commons/SubUnit/__test__/Favorites.test.js +1 -0
  50. package/src/commons/SubUnit/__test__/ShortDetail.test.js +1 -0
  51. package/src/commons/Today/__test__/Today.test.js +1 -1
  52. package/src/configs/API.js +4 -0
  53. package/src/configs/Constants.js +23 -0
  54. package/src/configs/Images.js +1 -0
  55. package/src/context/SCContext.tsx +35 -2
  56. package/src/context/index.ts +6 -1
  57. package/src/navigations/UnitStack.js +1 -3
  58. package/src/screens/ActivityLog/__test__/index.test.js +10 -11
  59. package/src/screens/AddNewAction/Device/__test__/index.test.js +2 -2
  60. package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +1 -1
  61. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +37 -50
  62. package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +1 -1
  63. package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +1 -1
  64. package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +1 -1
  65. package/src/screens/AddNewGateway/index.js +5 -1
  66. package/src/screens/ConfirmUnitDeletion/index.js +1 -1
  67. package/src/screens/Device/EditDevice/index.js +1 -1
  68. package/src/screens/Device/EditDevice/styles/EditDeviceStyles.js +2 -0
  69. package/src/screens/Notification/Monitor.js +12 -0
  70. package/src/screens/Notification/components/NotificationItem.js +11 -0
  71. package/src/screens/Notification/index.js +8 -0
  72. package/src/screens/PlayBackCamera/__test__/index.test.js +1 -1
  73. package/src/screens/Unit/Detail.js +2 -2
  74. package/src/screens/Unit/ManageUnit.js +9 -6
  75. package/src/screens/Unit/__test__/Detail.test.js +7 -1
  76. package/src/screens/Unit/components/MyUnitDevice/index.js +4 -1
  77. package/src/screens/Unit/components/__test__/Header.test.js +5 -5
  78. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
  79. package/src/screens/UnitSummary/components/PowerConsumption/index.js +4 -2
  80. package/src/utils/I18n/translations/en.json +3 -1
  81. package/src/utils/I18n/translations/vi.json +3 -1
  82. package/src/utils/Pusher/index.js +36 -0
@@ -0,0 +1,49 @@
1
+ import React, { memo } from 'react';
2
+ import { TouchableOpacity, View } from 'react-native';
3
+
4
+ import styles from './RectangleButtonStyles';
5
+ import { KeyboardArrowUp, KeyboardArrowDown } from './Icon';
6
+ import { TESTID } from '../../../../configs/Constants';
7
+
8
+ const RectangleButton = memo(
9
+ ({ icon, onPressUp, onPressDown, wrapStyle, type, onPress }) => {
10
+ switch (type) {
11
+ case 'row':
12
+ return (
13
+ <View style={[styles.wrapRowRectangle, wrapStyle]}>
14
+ <TouchableOpacity style={[styles.rectangleRow]} onPress={onPress}>
15
+ {!!icon && icon}
16
+ </TouchableOpacity>
17
+ </View>
18
+ );
19
+ case 'column':
20
+ return (
21
+ <View style={[styles.wrapColumnRectangle, wrapStyle]}>
22
+ <TouchableOpacity
23
+ style={[styles.rectangleColumn]}
24
+ onPress={onPressUp}
25
+ testID={TESTID.SMART_TIVI_TEMPLATE.CH_VOLUME_UP_BUTTON}
26
+ >
27
+ <KeyboardArrowUp size={24} name={'up'} style={styles.padding8} />
28
+ </TouchableOpacity>
29
+ <View style={styles.iconKeyboardRetangle}>{!!icon && icon}</View>
30
+ <TouchableOpacity
31
+ style={[styles.rectangleColumn]}
32
+ onPress={onPressDown}
33
+ testID={TESTID.SMART_TIVI_TEMPLATE.CH_VOLUME_DOWN_BUTTON}
34
+ >
35
+ <KeyboardArrowDown
36
+ size={24}
37
+ name={'down'}
38
+ style={styles.padding8}
39
+ />
40
+ </TouchableOpacity>
41
+ </View>
42
+ );
43
+ default:
44
+ return <></>;
45
+ }
46
+ }
47
+ );
48
+
49
+ export default RectangleButton;
@@ -0,0 +1,47 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { Colors, Device } from '../../../../configs';
3
+ const widthMonitor = Device.screenWidth;
4
+
5
+ const centerRowItem = {
6
+ justifyContent: 'center',
7
+ alignItems: 'center',
8
+ };
9
+ const centerColumnItem = {
10
+ flexDirection: 'column',
11
+ justifyContent: 'space-between',
12
+ };
13
+ const borderItem = {
14
+ borderWidth: 1,
15
+ borderColor: Colors.Gray4,
16
+ borderRadius: 10,
17
+ };
18
+ export default StyleSheet.create({
19
+ rectangleColumn: {
20
+ padding: 16,
21
+ ...centerRowItem,
22
+ },
23
+ rectangleRow: {
24
+ ...centerRowItem,
25
+ },
26
+ wrapRowRectangle: {
27
+ flexWrap: 'nowrap',
28
+ ...centerColumnItem,
29
+ width: widthMonitor / 2 - 37,
30
+ ...borderItem,
31
+ margin: 12,
32
+ padding: 10,
33
+ },
34
+ wrapColumnRectangle: {
35
+ width: 63,
36
+ height: 186,
37
+ ...centerColumnItem,
38
+ backgroundColor: Colors.White,
39
+ ...borderItem,
40
+ },
41
+ iconKeyboardRetangle: {
42
+ ...centerRowItem,
43
+ },
44
+ padding8: {
45
+ padding: 8,
46
+ },
47
+ });
@@ -60,7 +60,7 @@ describe('Test TimerActionTemplate success with config value', () => {
60
60
  const instance = wrapper.root;
61
61
 
62
62
  const texts = instance.findAllByType(Text);
63
- expect(texts).toHaveLength(6);
63
+ expect(texts).toHaveLength(8);
64
64
  expect(texts[0].props.children).toEqual('Timer');
65
65
  expect(texts[1].props.children).toEqual('Setting at 18:30');
66
66
 
@@ -62,7 +62,7 @@ describe('Test TimerActionTemplate without config value', () => {
62
62
  const instance = wrapper.root;
63
63
 
64
64
  const texts = instance.findAllByType(Text);
65
- expect(texts).toHaveLength(5);
65
+ expect(texts).toHaveLength(7);
66
66
  expect(texts[0].props.children).toEqual('Timer');
67
67
 
68
68
  const switchButton = instance.findByType(Switch);
@@ -332,8 +332,8 @@ describe('Test ActionGroup', () => {
332
332
  wrapper = renderer.create(wrapComponent(actionGroup, mockDoAction, {}));
333
333
  });
334
334
  const instance = wrapper.root;
335
- const text = instance.findByType(Text);
336
- expect(text.props.children).toEqual('28 *C');
335
+ const text = instance.findAllByType(Text);
336
+ expect(text[0].props.children).toEqual('28 *C');
337
337
 
338
338
  const touchs = instance.findAllByType(TouchableOpacity);
339
339
  expect(touchs).toHaveLength(2);
@@ -418,7 +418,7 @@ describe('Test ActionGroup', () => {
418
418
  const instance = wrapper.root;
419
419
 
420
420
  const texts = instance.findAllByType(Text);
421
- expect(texts).toHaveLength(5);
421
+ expect(texts).toHaveLength(7);
422
422
  expect(texts[0].props.children).toEqual('Timer');
423
423
 
424
424
  const switchButton = instance.findByType(Switch);
@@ -9,6 +9,7 @@ import OptionsDropdownActionTemplate from './OptionsDropdownActionTemplate';
9
9
  import OnOffTemplate from './OnOffTemplate';
10
10
  import TimerActionTemplate from './TimerActionTemplate';
11
11
  import CurtainButtonTemplate from './CurtainButtonTemplate';
12
+ import SmartTiviActionTemplate from './SmartTiviActionTemplate/SmartTiviActionTemplate';
12
13
 
13
14
  export const getActionComponent = (template) => {
14
15
  switch (template) {
@@ -32,6 +33,8 @@ export const getActionComponent = (template) => {
32
33
  return TimerActionTemplate;
33
34
  case 'curtain_action_template':
34
35
  return CurtainButtonTemplate;
36
+ case 'SmartTiviActionTemplate':
37
+ return SmartTiviActionTemplate;
35
38
  default:
36
39
  return null;
37
40
  }
@@ -77,11 +77,11 @@ describe('Test ActionTemplate', () => {
77
77
  const instance = tree.root;
78
78
 
79
79
  const selectActionCard = instance.findByType(SelectActionCard);
80
- const modal = instance.findByType(Modal);
80
+ const modal = instance.findAllByType(Modal);
81
81
  act(() => {
82
82
  selectActionCard.props.onPress();
83
83
  });
84
- expect(modal.props.isVisible).toBe(true);
84
+ expect(modal[0].props.isVisible).toBe(true);
85
85
  });
86
86
  test('test onPressSelectAction', () => {
87
87
  act(() => {
@@ -19,6 +19,6 @@ describe('Test ItemAutomate', () => {
19
19
  });
20
20
  const instance = tree.root;
21
21
  const texts = instance.findAllByType(Text);
22
- expect(texts).toHaveLength(2);
22
+ expect(texts).toHaveLength(4);
23
23
  });
24
24
  });
@@ -49,7 +49,7 @@ describe('Test MyPinnedSharedUnit', () => {
49
49
  });
50
50
  const instance = tree.root;
51
51
  const texts = instance.findAllByType(Text);
52
- expect(texts).toHaveLength(2);
52
+ expect(texts).toHaveLength(4);
53
53
  expect(texts[0].props.children).toEqual(
54
54
  getTranslate('en', 'text_shared_units')
55
55
  );
@@ -190,13 +190,17 @@ const HistoryChart = memo(
190
190
  />
191
191
  )}
192
192
  </View>
193
- <DateTimeRangeChange
194
- startTime={eventPicker.startTime}
195
- onStart={onStart}
196
- onEnd={onEnd}
197
- endTime={eventPicker.endTime}
198
- formatType={formatType}
199
- />
193
+ {!(
194
+ configuration.type === 'horizontal_bar_chart' && groupBy !== 'date'
195
+ ) && (
196
+ <DateTimeRangeChange
197
+ startTime={eventPicker.startTime}
198
+ onStart={onStart}
199
+ onEnd={onEnd}
200
+ endTime={eventPicker.endTime}
201
+ formatType={formatType}
202
+ />
203
+ )}
200
204
  </View>
201
205
  {configuration.config === 'power_consumption' && (
202
206
  <View style={styles.wrapCalculateCost}>
@@ -65,8 +65,9 @@ const HorizontalBarChart = memo(({ datas, config }) => {
65
65
  }
66
66
 
67
67
  const formatMoney = (number) => {
68
+ const formatNumber = number.toFixed();
68
69
  return (
69
- parseInt(number, 10)
70
+ parseInt(formatNumber, 10)
70
71
  .toFixed(0)
71
72
  .toString()
72
73
  .replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1.') + 'đ'
@@ -8,8 +8,10 @@ import {
8
8
  import Routes from '../../utils/Route';
9
9
  import { IconFill, IconOutline } from '@ant-design/icons-react-native';
10
10
  import { useNavigation } from '@react-navigation/native';
11
+ import { useTranslations } from '../../hooks/Common/useTranslations';
11
12
  import ItemQuickAction from '../../commons/Action/ItemQuickAction';
12
13
  import Text from '../../commons/Text';
14
+ import { isDeviceConnected } from '../../iot/RemoteControl/Bluetooth';
13
15
 
14
16
  import { Colors, Constants } from '../../configs';
15
17
  import { TESTID } from '../../configs/Constants';
@@ -29,8 +31,10 @@ const ItemDevice = memo(
29
31
  unit,
30
32
  station,
31
33
  isGGHomeConnected,
34
+ status,
32
35
  wrapStyle,
33
36
  }) => {
37
+ const t = useTranslations();
34
38
  const navigation = useNavigation();
35
39
 
36
40
  const goToSensorDisplay = useCallback(() => {
@@ -52,10 +56,20 @@ const ItemDevice = memo(
52
56
  );
53
57
  };
54
58
 
59
+ const isNetworkConnected =
60
+ status === undefined ? sensor.is_connected : status.is_connected;
61
+ const isBLEConnected = isDeviceConnected(
62
+ sensor?.remote_control_options?.bluetooth?.address
63
+ );
64
+ const isConnected =
65
+ isNetworkConnected || isGGHomeConnected || isBLEConnected;
66
+ const borderColor = isConnected ? Colors.Gray4 : Colors.Red6;
67
+ const textConnected = isConnected ? t('connected') : t('disconnected');
68
+
55
69
  return (
56
70
  <TouchableWithoutFeedback onPress={goToSensorDisplay}>
57
71
  <View
58
- style={[styles.container, wrapStyle]}
72
+ style={[styles.container, wrapStyle, { borderColor }]}
59
73
  testID={TESTID.SUB_UNIT_DEVICES}
60
74
  >
61
75
  <View style={styles.boxIcon}>
@@ -82,7 +96,7 @@ const ItemDevice = memo(
82
96
  color={Colors.Gray8}
83
97
  style={styles.lineHeight20}
84
98
  >
85
- {description}
99
+ {description || textConnected}
86
100
  </Text>
87
101
  <IconOutline name="right" size={12} />
88
102
  </View>
@@ -112,6 +126,7 @@ const styles = StyleSheet.create({
112
126
  backgroundColor: Colors.White,
113
127
  justifyContent: 'space-between',
114
128
  marginBottom: 8,
129
+ borderWidth: 1,
115
130
  },
116
131
  boxIcon: {
117
132
  flexDirection: 'row',
@@ -68,7 +68,7 @@ const styles = StyleSheet.create({
68
68
  borderWidth: 1,
69
69
  borderColor: Colors.Gray4,
70
70
  marginRight: 8,
71
- width: (width / 375) * 112,
71
+ width: (width / 375) * 120,
72
72
  },
73
73
  rowFlex: {
74
74
  flexDirection: 'row',
@@ -37,7 +37,7 @@ describe('Test Compass', () => {
37
37
  });
38
38
  const instance = tree.root;
39
39
  const textInputs = instance.findAllByType(Text);
40
- expect(textInputs.length).toEqual(1);
40
+ expect(textInputs.length).toEqual(3);
41
41
  expect(textInputs[0].props.children).toEqual(list_result[index]);
42
42
  });
43
43
  });
@@ -48,6 +48,6 @@ describe('Test Compass', () => {
48
48
  });
49
49
  const instance = tree.root;
50
50
  const textInputs = instance.findAllByType(Text);
51
- expect(textInputs.length).toEqual(1);
51
+ expect(textInputs.length).toEqual(3);
52
52
  });
53
53
  });
@@ -28,7 +28,7 @@ describe('Test ConnectedViewHeader', () => {
28
28
  });
29
29
  const isntance = tree.root;
30
30
  const texts = isntance.findAllByType(Text);
31
- expect(texts).toHaveLength(1);
31
+ expect(texts).toHaveLength(3);
32
32
  });
33
33
 
34
34
  test('render ConnectedViewHeader no last updated', async () => {
@@ -37,6 +37,6 @@ describe('Test ConnectedViewHeader', () => {
37
37
  });
38
38
  const isntance = tree.root;
39
39
  const texts = isntance.findAllByType(Text);
40
- expect(texts).toHaveLength(1);
40
+ expect(texts).toHaveLength(3);
41
41
  });
42
42
  });
@@ -21,7 +21,7 @@ describe('Test DisconnectedView', () => {
21
21
  });
22
22
  const instance = tree.root;
23
23
  const Views = instance.findAllByType(View);
24
- expect(Views).toHaveLength(10);
24
+ expect(Views).toHaveLength(15);
25
25
  });
26
26
 
27
27
  test('render DisconnectedView icon sensor', () => {
@@ -31,7 +31,7 @@ describe('Test DisconnectedView', () => {
31
31
  });
32
32
  const instance = tree.root;
33
33
  const Views = instance.findAllByType(View);
34
- expect(Views).toHaveLength(10);
34
+ expect(Views).toHaveLength(15);
35
35
  });
36
36
 
37
37
  test('render DisconnectedView icon barrier', () => {
@@ -41,7 +41,7 @@ describe('Test DisconnectedView', () => {
41
41
  });
42
42
  const instance = tree.root;
43
43
  const Views = instance.findAllByType(View);
44
- expect(Views).toHaveLength(10);
44
+ expect(Views).toHaveLength(15);
45
45
  });
46
46
 
47
47
  test('render DisconnectedView icon wind', () => {
@@ -51,7 +51,7 @@ describe('Test DisconnectedView', () => {
51
51
  });
52
52
  const instance = tree.root;
53
53
  const Views = instance.findAllByType(View);
54
- expect(Views).toHaveLength(10);
54
+ expect(Views).toHaveLength(15);
55
55
  });
56
56
 
57
57
  test('render DisconnectedView icon test', () => {
@@ -61,6 +61,6 @@ describe('Test DisconnectedView', () => {
61
61
  });
62
62
  const instance = tree.root;
63
63
  const Views = instance.findAllByType(View);
64
- expect(Views).toHaveLength(10);
64
+ expect(Views).toHaveLength(15);
65
65
  });
66
66
  });
@@ -20,6 +20,6 @@ describe('Test HeaderExplore', () => {
20
20
  });
21
21
  const instance = tree.root;
22
22
  const button = instance.findAllByType(Text);
23
- expect(button.length).toBe(1);
23
+ expect(button.length).toBe(3);
24
24
  });
25
25
  });
@@ -32,7 +32,7 @@ describe('Test MediaPlayerDetail', () => {
32
32
  });
33
33
 
34
34
  const texts = instance.findAllByType(Text);
35
- expect(texts.length).toEqual(2);
35
+ expect(texts.length).toEqual(4);
36
36
  expect(texts[1].props.children).toEqual('cameraName');
37
37
 
38
38
  const pauseIcon = instance.findAllByType(PauseIcon);
@@ -25,7 +25,7 @@ describe('Test ModalBottom', () => {
25
25
  });
26
26
  const instance = tree.root;
27
27
  const Views = instance.findAllByType(View);
28
- expect(Views).toHaveLength(5);
28
+ expect(Views).toHaveLength(10);
29
29
  });
30
30
 
31
31
  it('Test render without isVisible', async () => {
@@ -34,6 +34,6 @@ describe('Test ModalBottom', () => {
34
34
  });
35
35
  const instance = tree.root;
36
36
  const Views = instance.findAllByType(View);
37
- expect(Views).toHaveLength(5);
37
+ expect(Views).toHaveLength(10);
38
38
  });
39
39
  });
@@ -27,7 +27,7 @@ describe('MemberList', () => {
27
27
  });
28
28
  const instance = tree.root;
29
29
  const textInputs = instance.findAllByType(Text);
30
- expect(textInputs.length).toBe(2);
30
+ expect(textInputs.length).toBe(4);
31
31
  });
32
32
  test('MemberList snapshot id dataMember !== ownerId', () => {
33
33
  const dataMember = [{ id: 1, name: 'CEO' }];
@@ -36,7 +36,7 @@ describe('MemberList', () => {
36
36
  });
37
37
  const instance = tree.root;
38
38
  const textInputs = instance.findAllByType(Text);
39
- expect(textInputs.length).toBe(1);
39
+ expect(textInputs.length).toBe(3);
40
40
  });
41
41
  test('MemberList snapshot id dataMember === currentUserId', () => {
42
42
  const dataMember = [{ id: 1, name: 'CEO' }];
@@ -45,7 +45,7 @@ describe('MemberList', () => {
45
45
  });
46
46
  const instance = tree.root;
47
47
  const textInputs = instance.findAllByType(Text);
48
- expect(textInputs.length).toBe(2);
48
+ expect(textInputs.length).toBe(4);
49
49
  });
50
50
  test('MemberList dataMember null', () => {
51
51
  const dataMember = [];
@@ -26,7 +26,7 @@ describe('RowMember', () => {
26
26
  });
27
27
  const instance = tree.root;
28
28
  const textInputs = instance.findAllByType(Text);
29
- expect(textInputs.length).toBe(2);
29
+ expect(textInputs.length).toBe(4);
30
30
  expect(textInputs[0].props.children).toEqual('CEO');
31
31
  });
32
32
  test('RowMember owner dont have name show start of email ', () => {
@@ -36,7 +36,7 @@ describe('RowMember', () => {
36
36
  });
37
37
  const instance = tree.root;
38
38
  const textInputs = instance.findAllByType(Text);
39
- expect(textInputs.length).toBe(2);
39
+ expect(textInputs.length).toBe(4);
40
40
  expect(textInputs[0].props.children).toEqual('abc');
41
41
  });
42
42
  });
@@ -1,12 +1,15 @@
1
- import React from 'react';
1
+ import React, { useState, useEffect, useRef } from 'react';
2
2
  import { View } from 'react-native';
3
3
  import { useTranslations } from '../../../hooks/Common/useTranslations';
4
+ import { useIsFocused } from '@react-navigation/native';
4
5
 
5
6
  import { Section } from '../../Section';
6
7
  import ItemDevice from '../../Device/ItemDevice';
7
8
  import ItemOneTap from '../OneTap/ItemOneTap';
8
9
  import ItemAddNew from '../../Device/ItemAddNew';
9
10
  import styles from './styles';
11
+ import { API } from '../../../configs';
12
+ import { axiosGet } from '../../../utils/Apis/axios';
10
13
 
11
14
  const SubUnitFavorites = ({
12
15
  unit,
@@ -16,6 +19,33 @@ const SubUnitFavorites = ({
16
19
  wrapItemStyle,
17
20
  }) => {
18
21
  const t = useTranslations();
22
+ const isFocused = useIsFocused();
23
+ const intervalSensorStatus = useRef();
24
+ const [sensorsStatus, setSensorsStatus] = useState([]);
25
+
26
+ useEffect(() => {
27
+ if (isFocused) {
28
+ const getSensorsStatus = async () => {
29
+ const params = new URLSearchParams();
30
+ if (favorites?.devices?.length > 0) {
31
+ favorites.devices.forEach((sensor) => {
32
+ params.append('sensors', sensor.id);
33
+ });
34
+ const { success, data } = await axiosGet(API.SENSOR.STATUS(), {
35
+ params: params,
36
+ });
37
+ if (success) {
38
+ setSensorsStatus(data);
39
+ }
40
+ }
41
+ };
42
+ const updateInterval = setInterval(getSensorsStatus, 5000);
43
+ intervalSensorStatus.current = updateInterval;
44
+ return () => clearInterval(updateInterval);
45
+ } else {
46
+ clearInterval(intervalSensorStatus.current);
47
+ }
48
+ }, [isFocused, favorites?.devices]);
19
49
 
20
50
  const handleOnAddNew = () => {
21
51
  alert(t('feature_under_development'));
@@ -39,6 +69,7 @@ const SubUnitFavorites = ({
39
69
  unit={unit}
40
70
  station={sensor.station}
41
71
  isGGHomeConnected={isGGHomeConnected}
72
+ status={sensorsStatus.find((s) => s.id === sensor.id)}
42
73
  wrapStyle={wrapItemStyle}
43
74
  />
44
75
  ))}
@@ -1,9 +1,9 @@
1
- import React from 'react';
1
+ import React, { useState, useEffect, useRef } from 'react';
2
2
  import { StyleSheet, View } from 'react-native';
3
- import { useNavigation } from '@react-navigation/native';
3
+ import { useNavigation, useIsFocused } from '@react-navigation/native';
4
4
  import { useTranslations } from '../../hooks/Common/useTranslations';
5
5
 
6
- import { Images, Device } from '../../configs';
6
+ import { Images, Device, API } from '../../configs';
7
7
  import { SubUnitName, TESTID } from '../../configs/Constants';
8
8
  import { Section } from '../Section';
9
9
  import Text from '../Text';
@@ -13,6 +13,7 @@ import { standardizeCameraScreenSize } from '../../utils/Utils';
13
13
  import Routes from '../../utils/Route';
14
14
  import FastImage from 'react-native-fast-image';
15
15
  import MediaPlayerDetail from '../MediaPlayerDetail';
16
+ import { axiosGet } from '../../utils/Apis/axios';
16
17
 
17
18
  const { standardizeWidth, standardizeHeight } = standardizeCameraScreenSize(
18
19
  Device.screenWidth - 32
@@ -20,7 +21,35 @@ const { standardizeWidth, standardizeHeight } = standardizeCameraScreenSize(
20
21
 
21
22
  const ShortDetailSubUnit = ({ unit, station, isGGHomeConnected }) => {
22
23
  const t = useTranslations();
24
+ const isFocused = useIsFocused();
23
25
  const { navigate } = useNavigation();
26
+ const intervalSensorStatus = useRef();
27
+
28
+ const [sensorsStatus, setSensorsStatus] = useState([]);
29
+
30
+ useEffect(() => {
31
+ if (isFocused) {
32
+ const getSensorsStatus = async () => {
33
+ const params = new URLSearchParams();
34
+ if (station?.sensors?.length > 0) {
35
+ station.sensors.forEach((sensor) => {
36
+ params.append('sensors', sensor.id);
37
+ });
38
+ const { success, data } = await axiosGet(API.SENSOR.STATUS(), {
39
+ params: params,
40
+ });
41
+ if (success) {
42
+ setSensorsStatus(data);
43
+ }
44
+ }
45
+ };
46
+ const updateInterval = setInterval(getSensorsStatus, 5000);
47
+ intervalSensorStatus.current = updateInterval;
48
+ return () => clearInterval(updateInterval);
49
+ } else {
50
+ clearInterval(intervalSensorStatus.current);
51
+ }
52
+ }, [isFocused, station?.sensors]);
24
53
 
25
54
  const renderCamera = () => {
26
55
  if (station?.camera) {
@@ -115,6 +144,7 @@ const ShortDetailSubUnit = ({ unit, station, isGGHomeConnected }) => {
115
144
  unit={unit}
116
145
  station={station}
117
146
  isGGHomeConnected={isGGHomeConnected}
147
+ status={sensorsStatus.find((s) => s.id === sensor.id)}
118
148
  />
119
149
  ))}
120
150
  <ItemAddNew title={itemAddNewTitle} onAddNew={handleOnAddNew} />
@@ -27,6 +27,7 @@ jest.mock('@react-navigation/native', () => {
27
27
  useNavigation: () => ({
28
28
  navigate: mockNavigate,
29
29
  }),
30
+ useIsFocused: () => true,
30
31
  };
31
32
  });
32
33
 
@@ -22,6 +22,7 @@ jest.mock('@react-navigation/native', () => {
22
22
  useNavigation: () => ({
23
23
  navigate: mockedNavigate,
24
24
  }),
25
+ useIsFocused: () => true,
25
26
  };
26
27
  });
27
28
 
@@ -20,6 +20,6 @@ describe('Test Today', () => {
20
20
  });
21
21
  const instance = tree.root;
22
22
  const Views = instance.findAllByType(View);
23
- expect(Views).toHaveLength(1);
23
+ expect(Views).toHaveLength(6);
24
24
  });
25
25
  });
@@ -87,6 +87,7 @@ const API = {
87
87
  CHANGE_SUB_UNIT: (unit_id, station_id, id) =>
88
88
  SCConfig.apiRoot +
89
89
  `/property_manager/${unit_id}/sub_units/${station_id}/devices/${id}/change_sub_unit/`,
90
+ STATUS: () => SCConfig.apiRoot + '/property_manager/sensors/status/',
90
91
  },
91
92
  SHARED_SENSOR: {
92
93
  ACCESS: (id) =>
@@ -204,6 +205,9 @@ const API = {
204
205
  REMOVE_SMART_ACCOUNT: (id) =>
205
206
  SCConfig.apiRoot + `/smart_account/smart_accounts/${id}/`,
206
207
  },
208
+ PUSHER: {
209
+ AUTH: () => SCConfig.apiRoot + '/smart_parking/pusher/auth/',
210
+ },
207
211
  };
208
212
 
209
213
  export default API;
@@ -178,6 +178,28 @@ export const TESTID = {
178
178
  MY_UNIT_NO_UNIT: 'MY_UNIT_NO_UNIT',
179
179
  ITEM_UNIT: 'ITEM_UNIT',
180
180
 
181
+ // SmartTiviTemplate
182
+ SMART_TIVI_TEMPLATE: {
183
+ BIG_BUTTON: 'BIG_BUTTON',
184
+ ONOFF_BUTTON: 'ONOFF_BUTTON',
185
+ EXIT_BUTTON: 'EXIT_BUTTON',
186
+ CH_VOLUME_UP_BUTTON: 'CH_VOLUME_UP_BUTTON',
187
+ CH_VOLUME_DOWN_BUTTON: 'CH_VOLUME_DOWN_BUTTON',
188
+ PREV_BUTTON: 'PREV_BUTTON',
189
+ STOP_BUTTON: 'STOP_BUTTON',
190
+ NEXT_BUTTON: 'NEXT_BUTTON',
191
+ UP_BUTTON: 'UP_BUTTON',
192
+ DOWN_BUTTON: 'DOWN_BUTTON',
193
+ LEFT_BUTTON: 'LEFT_BUTTON',
194
+ RIGHT_BUTTON: 'RIGHT_BUTTON',
195
+ OK_BUTTON: 'OK_BUTTON',
196
+ HOME_BUTTON: 'HOME_BUTTON',
197
+ BACK_BUTTON: 'BACK_BUTTON',
198
+ VOLUME_BUTTON: 'VOLUME_BUTTON',
199
+ CH_BUTTON: 'CH_BUTTON',
200
+ CONTROL_BUTTON: 'CONTROL_BUTTON',
201
+ },
202
+
181
203
  // sub unit
182
204
  SUB_UNIT_FULL_CAMERA: 'SUB_UNIT_FULL_CAMERA',
183
205
  SUB_UNIT_CAMERA_VIEW: 'SUB_UNIT_CAMERA_VIEW',
@@ -612,6 +634,7 @@ export const NOTIFICATION_TYPES = {
612
634
  REMINDER: 'REMINDER',
613
635
  NOTIFY_REMOVE_UNIT: 'NOTIFY_REMOVE_UNIT',
614
636
  NOTIFY_REMOVE_MEMBER: 'NOTIFY_REMOVE_MEMBER',
637
+ NOTIFY_MEMBER_LEAVE_UNIT: 'NOTIFY_MEMBER_LEAVE_UNIT',
615
638
  };
616
639
 
617
640
  export const ACTIVITY_LOG_TYPES = {