@eohjsc/react-native-smart-city 0.3.92 → 0.3.94

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 (87) hide show
  1. package/package.json +5 -1
  2. package/src/commons/ActionGroup/SliderRangeTemplate.js +2 -2
  3. package/src/commons/AlertAction/index.js +5 -0
  4. package/src/commons/BottomButtonView/index.js +22 -4
  5. package/src/commons/Button/index.js +5 -0
  6. package/src/commons/Device/ConnectedViewHeader.js +0 -1
  7. package/src/commons/Device/Emergency/EmergencyDetail.js +4 -2
  8. package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +4 -2
  9. package/src/commons/Device/ProgressBar/index.js +3 -1
  10. package/src/commons/Device/ProgressBar/styles.js +1 -4
  11. package/src/commons/Device/WindSpeed/Anemometer/index.js +1 -1
  12. package/src/commons/Header/HeaderCustom.js +8 -18
  13. package/src/commons/SubUnit/OneTap/ItemOneTap.js +84 -129
  14. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +74 -39
  15. package/src/commons/SubUnit/OneTap/index.js +24 -4
  16. package/src/commons/ViewButtonBottom/index.js +32 -4
  17. package/src/configs/API.js +4 -0
  18. package/src/configs/AccessibilityLabel.js +1 -0
  19. package/src/configs/BLE.js +1 -0
  20. package/src/context/actionType.ts +2 -1
  21. package/src/context/mockStore.ts +1 -0
  22. package/src/context/reducer.ts +12 -1
  23. package/src/hooks/Explore/useKeyboardAnimated.js +10 -4
  24. package/src/hooks/IoT/useBluetoothConnection.js +14 -26
  25. package/src/hooks/useMqtt.js +95 -0
  26. package/src/iot/Monitor.js +2 -1
  27. package/src/iot/RemoteControl/Bluetooth.js +56 -19
  28. package/src/iot/RemoteControl/__test__/Bluetooth.test.js +140 -0
  29. package/src/iot/mqtt.js +233 -0
  30. package/src/navigations/UnitStack.js +11 -3
  31. package/src/screens/AddLocationMaps/index.js +18 -16
  32. package/src/screens/AddLocationMaps/indexStyle.js +3 -0
  33. package/src/screens/AddNewGateway/ConnectingDevice.js +7 -0
  34. package/src/screens/AddNewGateway/RenameNewDevices.js +2 -2
  35. package/src/screens/AddNewGateway/SelectDeviceType.js +67 -9
  36. package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +35 -0
  37. package/src/screens/AddNewGateway/__test__/SelectDeviceType.test.js +183 -29
  38. package/src/screens/Automate/AddNewAction/NewActionWrapper.js +3 -6
  39. package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +29 -29
  40. package/src/screens/Automate/AddNewAction/__test__/SetupSensor.test.js +45 -39
  41. package/src/screens/Automate/AddNewAutoSmart/AddAutomationTypeSmart.js +25 -0
  42. package/src/screens/{AddNewAutoSmart/index.js → Automate/AddNewAutoSmart/AddTypeSmart.js} +16 -51
  43. package/src/screens/Automate/AddNewAutoSmart/AddUnknownTypeSmart.js +29 -0
  44. package/src/screens/{AddNewAutoSmart → Automate/AddNewAutoSmart}/__test__/AddNewAutoSmart.test.js +11 -11
  45. package/src/screens/{AddNewAutoSmart → Automate/AddNewAutoSmart}/styles/AddNewAutoSmartStyles.js +1 -1
  46. package/src/screens/Automate/Components/InputNameStyles.js +1 -1
  47. package/src/screens/Automate/EditActionsList/__tests__/index.test.js +11 -25
  48. package/src/screens/Automate/EditActionsList/index.js +32 -33
  49. package/src/screens/Automate/MultiUnits.js +29 -19
  50. package/src/screens/Automate/ScriptDetail/__test__/index.test.js +78 -5
  51. package/src/screens/Automate/ScriptDetail/index.js +38 -10
  52. package/src/screens/Automate/Styles/MultiUnitsStyles.js +1 -1
  53. package/src/screens/Automate/__test__/MultiUnits.test.js +64 -7
  54. package/src/screens/Automate/__test__/index.test.js +45 -11
  55. package/src/screens/Automate/index.js +53 -38
  56. package/src/screens/Device/__test__/detail.test.js +1 -1
  57. package/src/screens/Device/__test__/mqttDetail.test.js +599 -0
  58. package/src/screens/Device/components/SensorDisplayItem.js +1 -7
  59. package/src/screens/Device/detail.js +64 -30
  60. package/src/screens/Device/hooks/__test__/useEvaluateValue.test.js +24 -1
  61. package/src/screens/Device/hooks/useDeviceWatchConfigControl.js +13 -3
  62. package/src/screens/SelectUnit/__test__/index.test.js +8 -13
  63. package/src/screens/Sharing/InfoMemberUnit.js +2 -2
  64. package/src/screens/Sharing/MemberList.js +28 -7
  65. package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +32 -18
  66. package/src/screens/Sharing/__test__/MemberList.test.js +37 -4
  67. package/src/screens/SmartAccount/__test__/SmartAccount.test.js +8 -4
  68. package/src/screens/SmartAccount/index.js +8 -9
  69. package/src/screens/SmartAccount/style.js +8 -7
  70. package/src/screens/Unit/AddMenu.js +42 -19
  71. package/src/screens/Unit/Detail.js +4 -19
  72. package/src/screens/Unit/Summaries.js +6 -17
  73. package/src/screens/Unit/__test__/AddMenu.test.js +68 -15
  74. package/src/screens/Unit/__test__/Summaries.test.js +2 -2
  75. package/src/screens/Unit/components/AutomateScript/index.js +1 -1
  76. package/src/utils/FactoryGateway.js +525 -0
  77. package/src/utils/I18n/translations/en.js +1409 -0
  78. package/src/utils/I18n/translations/vi.js +1411 -0
  79. package/src/utils/I18n/translations.ts +2 -2
  80. package/src/utils/Permission/backend.js +7 -0
  81. package/src/utils/Route/index.js +2 -1
  82. package/src/utils/Utils.js +11 -0
  83. package/src/commons/Device/SensorConnectedStatus.js +0 -56
  84. package/src/commons/Device/__test__/SensorConnectedStatus.test.js +0 -29
  85. package/src/screens/Sharing/__test__/MemberList2.test.js +0 -74
  86. package/src/utils/I18n/translations/en.json +0 -1138
  87. package/src/utils/I18n/translations/vi.json +0 -1136
@@ -1,7 +1,7 @@
1
1
  import MessageFormat from '@messageformat/core';
2
2
 
3
- import en from './translations/en.json';
4
- import vi from './translations/vi.json';
3
+ import en from './translations/en.js';
4
+ import vi from './translations/vi.js';
5
5
 
6
6
  export type TranslationString = keyof typeof en;
7
7
  export type Language = 'en' | 'vi';
@@ -0,0 +1,7 @@
1
+ import { useSCContextSelector } from '../../context';
2
+
3
+ export const useBackendPermission = () => {
4
+ return useSCContextSelector(
5
+ (state) => state?.auth?.account?.user?.permissions
6
+ );
7
+ };
@@ -126,7 +126,8 @@ const Routes = {
126
126
  EditActionsList: 'EditActionsList',
127
127
  PlaybackCamera: 'PlaybackCamera',
128
128
  SetupConfigCondition: 'SetupConfigCondition',
129
- AddNewAutoSmart: 'AddNewAutoSmart',
129
+ AddAutomationTypeSmart: 'AddAutomationTypeSmart',
130
+ AddUnknownTypeSmart: 'AddUnknownTypeSmart',
130
131
  ScenarioName: 'ScenarioName',
131
132
  ValueChangeName: 'ValueChangeName',
132
133
  AllCamera: 'AllCamera',
@@ -1,5 +1,6 @@
1
1
  import { PixelRatio, Linking, Alert } from 'react-native';
2
2
  import Toast from 'react-native-toast-message';
3
+ import { decode } from 'base-64';
3
4
  import validator from 'validator';
4
5
  import api from './Apis/axios';
5
6
  import {
@@ -266,3 +267,13 @@ export const getDateRangeOfWeek = (weekNumber, year) => {
266
267
  rangeIsTo = d1.getDate() + '.' + (d1.getMonth() + 1);
267
268
  return rangeIsFrom + '-' + rangeIsTo;
268
269
  };
270
+
271
+ export const base64ToHex = (str) => {
272
+ const raw = decode(str);
273
+ let result = '';
274
+ for (let i = 0; i < raw.length; i++) {
275
+ const hex = raw.charCodeAt(i).toString(16);
276
+ result += hex.length === 2 ? hex : '0' + hex;
277
+ }
278
+ return result.toUpperCase();
279
+ };
@@ -1,56 +0,0 @@
1
- import React, { memo } from 'react';
2
- import { View, StyleSheet } from 'react-native';
3
- import { useTranslations } from '../../hooks/Common/useTranslations';
4
-
5
- import { Colors } from '../../configs';
6
- import Text from '../../commons/Text';
7
- import Connect from '../../../assets/images/Device/Connect.svg';
8
- import { AccessibilityLabel } from '../../configs/Constants';
9
-
10
- const SensorConnectedStatus = memo(({ txtSensor, timeLastUpdate }) => {
11
- const t = useTranslations();
12
- return (
13
- <View
14
- style={styles.container}
15
- accessibilityLabel={AccessibilityLabel.SENSOR_CONNECTED_STATUS}
16
- >
17
- <View style={styles.connectStatus}>
18
- <Connect />
19
- <Text color={Colors.Green6} size={14} style={styles.txtStatus}>
20
- {t('connected')}
21
- </Text>
22
- </View>
23
- <Text color={Colors.Gray9} size={16} style={styles.txtCurrent}>
24
- {txtSensor}
25
- </Text>
26
- <Text color={Colors.Gray7} size={12} style={styles.txtLastUpdate}>
27
- {t('last_updated_%{minutes}_minutes_ago', { minutes: timeLastUpdate })}
28
- </Text>
29
- </View>
30
- );
31
- });
32
-
33
- export default SensorConnectedStatus;
34
-
35
- const styles = StyleSheet.create({
36
- container: {
37
- alignItems: 'center',
38
- },
39
- connectStatus: {
40
- flexDirection: 'row',
41
- alignItems: 'center',
42
- },
43
- txtStatus: {
44
- marginLeft: 8,
45
- },
46
- txtCurrent: {
47
- marginLeft: 8,
48
- lineHeight: 24,
49
- marginTop: 16,
50
- },
51
- txtLastUpdate: {
52
- marginLeft: 8,
53
- lineHeight: 20,
54
- marginTop: 8,
55
- },
56
- });
@@ -1,29 +0,0 @@
1
- import SensorConnectedStatus from '../SensorConnectedStatus';
2
- import React from 'react';
3
- import renderer, { act } from 'react-test-renderer';
4
- import { AccessibilityLabel } from '../../../configs/Constants';
5
- import { SCProvider } from '../../../context';
6
- import { mockSCStore } from '../../../context/mockStore';
7
-
8
- const wrapComponent = () => (
9
- <SCProvider initState={mockSCStore({})}>
10
- <SensorConnectedStatus />
11
- </SCProvider>
12
- );
13
-
14
- describe('Test Sensor Connected Status', () => {
15
- let tree;
16
-
17
- it('render Sensor Connected Status', async () => {
18
- await act(async () => {
19
- tree = await renderer.create(wrapComponent());
20
- });
21
- const instance = tree.root;
22
- const item = instance.find(
23
- (el) =>
24
- el.props.accessibilityLabel ===
25
- AccessibilityLabel.SENSOR_CONNECTED_STATUS
26
- );
27
- expect(item).not.toBeUndefined();
28
- });
29
- });
@@ -1,74 +0,0 @@
1
- import React from 'react';
2
- import { create, act } from 'react-test-renderer';
3
-
4
- import MemberList from '../MemberList';
5
- import { AlertAction } from '../../../commons';
6
- import { SCProvider } from '../../../context';
7
- import { mockSCStore } from '../../../context/mockStore';
8
- import { TouchableOpacity } from 'react-native';
9
- import Routes from '../../../utils/Route';
10
- import { useNavigation } from '@react-navigation/native';
11
- import MockAdapter from 'axios-mock-adapter';
12
- import api from '../../../utils/Apis/axios';
13
-
14
- jest.mock('../../../hooks/Common', () => {
15
- return {
16
- useIsOwnerOfUnit: () => ({ isOwner: false }),
17
- };
18
- });
19
-
20
- const wrapComponent = (route, state) => (
21
- <SCProvider initState={mockSCStore({})}>
22
- <MemberList route={route} />
23
- </SCProvider>
24
- );
25
-
26
- new MockAdapter(api.axiosInstance);
27
-
28
- describe('test MemberList', () => {
29
- let route;
30
- let localState = {
31
- auth: {
32
- account: {
33
- user: {
34
- id: 2,
35
- },
36
- },
37
- },
38
- };
39
- const mockedNavigate = useNavigation().navigate;
40
-
41
- beforeEach(() => {
42
- route = {
43
- params: {
44
- unitId: 1,
45
- unit: {
46
- id: 1,
47
- user_id: 2,
48
- name: '',
49
- },
50
- },
51
- };
52
- mockedNavigate.mockReset();
53
- });
54
-
55
- it('AlertAction rightButtonClick', async () => {
56
- let tree;
57
- await act(async () => {
58
- tree = await create(wrapComponent(route, localState));
59
- });
60
- const instance = tree.root;
61
- const alertAction = instance.findByType(AlertAction);
62
- await act(async () => {
63
- alertAction.props.rightButtonClick();
64
- });
65
- const MemberListButtons = instance.findAllByType(TouchableOpacity);
66
- await act(async () => {
67
- await MemberListButtons[1].props.onPress();
68
- });
69
- expect(mockedNavigate).not.toBeCalledWith(Routes.AddMemberStack, {
70
- screen: Routes.SharingSelectPermission,
71
- params: { unit: { id: 1 } },
72
- });
73
- });
74
- });