@eohjsc/react-native-smart-city 0.3.53 → 0.3.55

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 (64) hide show
  1. package/package.json +2 -1
  2. package/src/Images/Common/loading-circle.json +1 -0
  3. package/src/commons/ActionGroup/SliderRangeTemplate.js +1 -1
  4. package/src/commons/ActionGroup/index.js +6 -2
  5. package/src/commons/ButtonPopup/index.js +2 -0
  6. package/src/commons/DevMode/EmptyComponent.js +2 -2
  7. package/src/commons/DevMode/Item.js +2 -4
  8. package/src/commons/DevMode/Styles/ItemStyles.js +6 -0
  9. package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +9 -6
  10. package/src/commons/FullLoading/__test__/index.test.js +43 -0
  11. package/src/commons/FullLoading/index.js +13 -3
  12. package/src/commons/Header/HeaderCustom.js +6 -1
  13. package/src/commons/Header/Styles/HeaderCustomStyles.js +4 -1
  14. package/src/commons/Processing/index.js +20 -18
  15. package/src/commons/Processing/styles.js +4 -3
  16. package/src/commons/StatusBox/index.js +23 -5
  17. package/src/commons/StatusBox/styles.js +7 -6
  18. package/src/configs/API.js +1 -1
  19. package/src/configs/AccessibilityLabel.js +1 -1
  20. package/src/configs/Colors.js +2 -0
  21. package/src/hooks/IoT/__test__/useRemoteControl.test.js +22 -21
  22. package/src/hooks/IoT/useRemoteControl.js +8 -7
  23. package/src/iot/RemoteControl/Bluetooth.js +1 -1
  24. package/src/navigations/Main.js +3 -1
  25. package/src/screens/AddNewGateway/ConnectingModbusDevice.js +16 -19
  26. package/src/screens/AddNewGateway/ConnectingWifiGuide.js +139 -75
  27. package/src/screens/AddNewGateway/ConnectingWifiGuideStyles.js +8 -7
  28. package/src/screens/AddNewGateway/RenameNewDevices.js +147 -70
  29. package/src/screens/AddNewGateway/RenameNewDevicesStyles.js +35 -16
  30. package/src/screens/AddNewGateway/ShareWifiPassword.js +176 -107
  31. package/src/screens/AddNewGateway/ShareWifiPasswordStyles.js +14 -1
  32. package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +53 -7
  33. package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +44 -10
  34. package/src/screens/AddNewGateway/hooks/__Tests__/useStateAlertRename.test.js +57 -0
  35. package/src/screens/AddNewGateway/hooks/__Tests__/useWifiManage.test.js +22 -0
  36. package/src/screens/AddNewGateway/hooks/useWifiManage.js +29 -0
  37. package/src/screens/Device/__test__/detail.test.js +7 -1
  38. package/src/screens/Device/components/SensorDisplayItem.js +10 -2
  39. package/src/screens/Gateway/GatewayInfo/__test__/index.test.js +1 -1
  40. package/src/screens/Gateway/__test__/index.test.js +1 -1
  41. package/src/screens/Gateway/components/GatewayItem/index.js +1 -1
  42. package/src/screens/Gateway/components/GatewayItem/styles.js +4 -0
  43. package/src/screens/Gateway/components/Information/__test__/index.test.js +1 -1
  44. package/src/screens/Gateway/components/Information/index.js +5 -3
  45. package/src/screens/Gateway/components/Information/styles.js +3 -0
  46. package/src/screens/Gateway/components/TabPaneCT/index.js +31 -27
  47. package/src/screens/Gateway/components/TabPaneCT/styles.js +7 -1
  48. package/src/screens/Gateway/index.js +10 -10
  49. package/src/screens/Gateway/styles.js +3 -1
  50. package/src/screens/Notification/__test__/Notification.test.js +9 -1
  51. package/src/screens/Notification/index.js +7 -4
  52. package/src/screens/Smart/__test__/index.test.js +16 -4
  53. package/src/screens/Smart/index.js +15 -1
  54. package/src/screens/Smart/styles.js +15 -0
  55. package/src/screens/Template/EditTemplate.js +1 -1
  56. package/src/screens/Template/Styles/indexStyles.js +1 -1
  57. package/src/screens/Template/detail.js +26 -2
  58. package/src/screens/Template/index.js +1 -1
  59. package/src/screens/Unit/MoreMenu.js +56 -58
  60. package/src/screens/Unit/__test__/MoreMenu.test.js +59 -0
  61. package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +6 -3
  62. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +7 -1
  63. package/src/utils/I18n/translations/en.json +10 -8
  64. package/src/utils/I18n/translations/vi.json +10 -7
@@ -4,65 +4,63 @@ import Routes from '../../utils/Route';
4
4
  import { useNavigation } from '@react-navigation/native';
5
5
  import { MenuActionMore } from '../../commons';
6
6
 
7
- const MoreMenu = memo(
8
- ({
9
- unit,
10
- isOwner,
11
- hidePopover,
12
- childRef,
13
- showingPopover,
14
- idLabelPopover,
15
- idLabelScrollView,
16
- idLabelItem,
17
- }) => {
18
- const t = useTranslations();
19
- const navigation = useNavigation();
7
+ const MoreMenu = ({
8
+ unit,
9
+ isOwner,
10
+ hidePopover,
11
+ childRef,
12
+ showingPopover,
13
+ idLabelPopover,
14
+ idLabelScrollView,
15
+ idLabelItem,
16
+ }) => {
17
+ const t = useTranslations();
18
+ const navigation = useNavigation();
20
19
 
21
- const onItemClick = useCallback(
22
- ({ route: routeName, data }) => {
23
- hidePopover();
24
- routeName && navigation.navigate(routeName, data);
25
- },
26
- [hidePopover, navigation]
27
- );
20
+ const onItemClick = useCallback(
21
+ ({ route: routeName, data }) => {
22
+ hidePopover();
23
+ routeName && navigation.navigate(routeName, data);
24
+ },
25
+ [hidePopover, navigation]
26
+ );
28
27
 
29
- const listMenuItem = useMemo(() => {
30
- const RouteManageUnit = {
31
- id: 'mange-unit',
32
- route: Routes.ManageUnit,
33
- text: t('manage_unit'),
34
- data: { unitId: unit.id, unit },
35
- };
36
- const RouteUnitMemberList = {
37
- id: 'unit-member',
38
- route: Routes.UnitMemberList,
39
- text: t('members'),
40
- data: { unitId: unit.id, unit },
41
- };
42
- const ListSmartAccount = {
43
- id: 'smart-account',
44
- route: Routes.ListSmartAccount,
45
- text: t('smart_account'),
46
- data: { unitId: unit.id, unit },
47
- };
48
- return isOwner
49
- ? [RouteManageUnit, RouteUnitMemberList, ListSmartAccount]
50
- : [RouteUnitMemberList];
51
- }, [t, unit, isOwner]);
28
+ const listMenuItem = useMemo(() => {
29
+ const RouteManageUnit = {
30
+ id: 'mange-unit',
31
+ route: Routes.ManageUnit,
32
+ text: t('manage_unit'),
33
+ data: { unitId: unit?.id, unit },
34
+ };
35
+ const RouteUnitMemberList = {
36
+ id: 'unit-member',
37
+ route: Routes.UnitMemberList,
38
+ text: t('members'),
39
+ data: { unitId: unit?.id, unit },
40
+ };
41
+ const ListSmartAccount = {
42
+ id: 'smart-account',
43
+ route: Routes.ListSmartAccount,
44
+ text: t('smart_account'),
45
+ data: { unitId: unit?.id, unit },
46
+ };
47
+ return isOwner
48
+ ? [RouteManageUnit, RouteUnitMemberList, ListSmartAccount]
49
+ : [RouteUnitMemberList];
50
+ }, [t, unit, isOwner]);
52
51
 
53
- return (
54
- <MenuActionMore
55
- isVisible={showingPopover}
56
- hideMore={hidePopover}
57
- listMenuItem={listMenuItem}
58
- childRef={childRef}
59
- onItemClick={onItemClick}
60
- idLabelPopover={idLabelPopover}
61
- idLabelScrollView={idLabelScrollView}
62
- idLabelItem={idLabelItem}
63
- />
64
- );
65
- }
66
- );
52
+ return (
53
+ <MenuActionMore
54
+ isVisible={showingPopover}
55
+ hideMore={hidePopover}
56
+ listMenuItem={listMenuItem}
57
+ childRef={childRef}
58
+ onItemClick={onItemClick}
59
+ idLabelPopover={idLabelPopover}
60
+ idLabelScrollView={idLabelScrollView}
61
+ idLabelItem={idLabelItem}
62
+ />
63
+ );
64
+ };
67
65
 
68
- export default MoreMenu;
66
+ export default memo(MoreMenu);
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ import { act, create } from 'react-test-renderer';
3
+ import { MenuActionMore } from '../../../commons';
4
+ import { SCProvider } from '../../../context';
5
+ import { mockSCStore } from '../../../context/mockStore';
6
+ import MoreMenu from '../MoreMenu';
7
+
8
+ const mockHidePopover = jest.fn();
9
+
10
+ const mockNavigate = jest.fn();
11
+ jest.mock('@react-navigation/native', () => {
12
+ return {
13
+ ...jest.requireActual('@react-navigation/native'),
14
+ useNavigation: () => ({
15
+ navigate: mockNavigate,
16
+ }),
17
+ };
18
+ });
19
+
20
+ const wrapComponent = (showingPopover) => (
21
+ <SCProvider initState={mockSCStore({})}>
22
+ <MoreMenu showingPopover={showingPopover} hidePopover={mockHidePopover} />
23
+ </SCProvider>
24
+ );
25
+
26
+ describe('Test MoreMenu', () => {
27
+ let tree;
28
+
29
+ it('Test render', async () => {
30
+ await act(async () => {
31
+ tree = await create(wrapComponent());
32
+ });
33
+ const menuActionMore = tree.root.findByType(MenuActionMore);
34
+ expect(menuActionMore.props.isVisible).toBeFalsy();
35
+ });
36
+
37
+ it('Test show menu then hide it', async () => {
38
+ await act(async () => {
39
+ tree = await create(wrapComponent(true));
40
+ });
41
+ const menuActionMore = tree.root.findByType(MenuActionMore);
42
+ await act(async () => {
43
+ await menuActionMore.props.hideMore();
44
+ });
45
+ expect(mockHidePopover).toBeCalled();
46
+ });
47
+
48
+ it('Test onItemClick', async () => {
49
+ await act(async () => {
50
+ tree = await create(wrapComponent(true));
51
+ });
52
+ const menuActionMore = tree.root.findByType(MenuActionMore);
53
+ await act(async () => {
54
+ await menuActionMore.props.onItemClick({ route: 'DeviceDetail' });
55
+ });
56
+ expect(mockHidePopover).toBeCalled();
57
+ expect(mockNavigate).toBeCalledWith('DeviceDetail', undefined);
58
+ });
59
+ });
@@ -43,14 +43,17 @@ export const useUnitConnectRemoteDevices = (unit) => {
43
43
  );
44
44
 
45
45
  useEffect(() => {
46
- if (unit?.remote_control_options?.bluetooth && isBluetoothEnabled) {
46
+ if (unit?.remote_control_options?.bluetooth?.length && isBluetoothEnabled) {
47
47
  bluetoothScanDevices(unit.remote_control_options.bluetooth);
48
48
  }
49
49
  // eslint-disable-next-line react-hooks/exhaustive-deps
50
50
  }, [unit, isBluetoothEnabled, bluetoothPermGranted]);
51
51
 
52
52
  useEffect(() => {
53
- if (unit?.remote_control_options?.googlehome && isNetworkConnected) {
53
+ if (
54
+ unit?.remote_control_options?.googlehome?.length &&
55
+ isNetworkConnected
56
+ ) {
54
57
  (async () => {
55
58
  await connectHomeAssistant(unit.remote_control_options.googlehome);
56
59
  })();
@@ -59,7 +62,7 @@ export const useUnitConnectRemoteDevices = (unit) => {
59
62
  }, [unit, isNetworkConnected]);
60
63
 
61
64
  useEffect(() => {
62
- if (unit?.remote_control_options?.lg_thinq) {
65
+ if (unit?.remote_control_options?.lg_thinq?.length) {
63
66
  (async () => {
64
67
  await handleLgThinqConnect(unit.remote_control_options.lg_thinq);
65
68
  })();
@@ -52,7 +52,13 @@ describe('test RunningDevices', () => {
52
52
  let tree;
53
53
  let unit = {
54
54
  remote_control_options: {
55
- googlehome: true,
55
+ googlehome: [
56
+ {
57
+ config_maps: [],
58
+ auth: {},
59
+ chip_id: 1,
60
+ },
61
+ ],
56
62
  },
57
63
  };
58
64
  let summaryDetail = {
@@ -684,7 +684,7 @@
684
684
  "text_notification_content_member_leave_unit": "**member_name** has left **unit_name**.",
685
685
  "text_notification_content_rename_unit": "Unit **old_unit_name** has been renamed to **new_unit_name** by **owner_name**.",
686
686
  "text_notification_content_divice_disconnect": "**device_name** at **unit_name**: **sub_unit_name** has been disconnected. Please check and reconnect.",
687
- "text_notification_content_rename_sub_unit": "Sub-unit **old_sub_unit_name**: **unit_name** has been renamed to **new_sub_unit_name** by **unti_owner_name**.",
687
+ "text_notification_content_rename_sub_unit": "Sub-unit **old_sub_unit_name**: **unit_name** has been renamed to **new_sub_unit_name** by **unit_owner_name**.",
688
688
  "text_notification_content_remove_sub_unit": "Sub-unit **sub_unit_name** has been removed from **unit_name** by **unit_owner_name**.",
689
689
  "text_notification_content_remove_device": "Device **device_name** has been removed from **unit_name** by **unit_owner_name**.",
690
690
  "text_notification_content_update_address": "New address of **unit_name** has been updated by **unit_owner_name** to **unit_address**.",
@@ -991,7 +991,7 @@
991
991
  "create_contact_success": "Create contact success!",
992
992
  "can_not_login_to_current_ssid":"Can't login to current SSID",
993
993
  "confirm_password_not_match": "Confirm password does not match",
994
- "templates": "Templates",
994
+ "dashboard": "Dashboard",
995
995
  "template": "Template",
996
996
  "gateways": "Gateways",
997
997
  "help": "Help",
@@ -999,20 +999,20 @@
999
999
  "exit_dev_mode": "Exit developer mode",
1000
1000
  "developer_mode": "Developer Mode",
1001
1001
  "what_are_you_looking_for": "What are you looking for?",
1002
- "no_template_yet": "No Template yet",
1003
- "add_your_template": "Add your template at web app",
1004
- "edit_template": "Edit template",
1002
+ "no_dashboard_yet": "No Dashboard yet",
1003
+ "add_your_dashboard": "Add your dashboard at web app",
1004
+ "edit_dashboard": "Edit dashboard",
1005
1005
  "no_gateway_yet": "No Gateway yet",
1006
1006
  "you_dont_have_any_gateway": "You don't have any gateway",
1007
1007
  "gateway_information": "Gateway information",
1008
1008
  "reboot": "Reboot",
1009
1009
  "information": "Information",
1010
1010
  "gateway_list": "Gateway list",
1011
- "delete_template": "Delete template",
1012
- "template_name": "Template name",
1011
+ "delete_dashboard": "Delete dashboard",
1012
+ "dashboard_name": "Dashboard name",
1013
1013
  "add_widget": "Add widget",
1014
1014
  "no_widgets": "No Widgets",
1015
- "add_your_widget": "Add your widget in dashboard template",
1015
+ "add_your_widget": "Add your widget in dashboard",
1016
1016
  "label": "Label",
1017
1017
  "choose_type_of_device": "Choose Type of Device",
1018
1018
  "central_controller": "Central controller",
@@ -1097,6 +1097,8 @@
1097
1097
  "continue_to_wait": "Continue to wait?",
1098
1098
  "it_has_been_5_minutes": "It has been 5 minutes...",
1099
1099
  "click_here_to_setup_device": "Click here to setup device",
1100
+ "text_under_development": "This feature is under development.",
1101
+ "text_working_hard": "We are working hard to get this running",
1100
1102
  "photo_request_permission": "Photo request permission",
1101
1103
  "photo_request_permission_des": "To select photo from gallery, please unlock access photo permission"
1102
1104
  }
@@ -699,7 +699,7 @@
699
699
  "text_notification_content_member_leave_unit": "**member_name** vừa rời khỏi **unit_name**.",
700
700
  "text_notification_content_rename_unit": "Địa điểm **old_unit_name** vừa được đổi tên thành **new_unit_name** bởi **owner_name**.",
701
701
  "text_notification_content_divice_disconnect": "**device_name** tại **unit_name**: **sub_unit_name** vừa bị mất kết nối. Vui lòng kiểm tra và kết nối lại.",
702
- "text_notification_content_rename_sub_unit": "Khu vực **old_sub_unit_name**: **unit_name** vừa được đổi tên thành **new_sub_unit_name** bởi **unti_owner_name**.",
702
+ "text_notification_content_rename_sub_unit": "Khu vực **old_sub_unit_name**: **unit_name** vừa được đổi tên thành **new_sub_unit_name** bởi **unit_owner_name**.",
703
703
  "text_notification_content_remove_sub_unit": "Khu vực **sub_unit_name** vừa được xoá khỏi **%unit_name** bởi **unit_owner_name**.",
704
704
  "text_notification_content_remove_device": "Thiết bị **device_name** vừa được xoá khỏi **unit_name** bởi **unit_owner_name**.",
705
705
  "text_notification_content_update_address": "Địa chỉ mới của **unit_name** vừa được cập nhật bởi **unit_owner_name** thành **unit_address**.",
@@ -990,7 +990,7 @@
990
990
  "create_contact_success": "Tạo liên hệ thành công!",
991
991
  "can_not_login_to_current_ssid":"Không thể đăng nhập vào SSID hiện tại",
992
992
  "confirm_password_not_match": "Mật khẩu xác nhận không trùng khớp",
993
- "templates": "Mẫu",
993
+ "dashboard": "Bảng điều khiển",
994
994
  "template": "Mẫu",
995
995
  "gateways": "Cổng vào",
996
996
  "help": "Hỗ trợ",
@@ -998,18 +998,19 @@
998
998
  "exit_dev_mode": "Thoát khỏi chế độ nhà phát triển",
999
999
  "developer_mode": "Chế độ nhà phát triển",
1000
1000
  "what_are_you_looking_for": "Bạn đang tìm kiếm cái gì?",
1001
- "no_template_yet": "Chưa có mẫu nào",
1002
- "add_your_template": "Thêm mẫu của bạn trên web",
1003
- "edit_template": "Chỉnh sửa mẫu",
1001
+ "no_dashboard_yet": "Chưa có bảng điều khiển nào",
1002
+ "add_your_dashboard": "Thêm bảng điều khiển của bạn trên web",
1003
+ "edit_dashboard": "Chỉnh sửa bảng điều khiển",
1004
1004
  "no_gateway_yet": "Chưa có cổng nào",
1005
1005
  "you_dont_have_any_gateway": "Bạn không có bất kỳ cổng nào",
1006
1006
  "gateway_information": "Thông tin cổng",
1007
1007
  "reboot": "Khởi động lại",
1008
1008
  "information": "Thông tin",
1009
1009
  "gateway_list": "Danh sách cổng vào",
1010
- "delete_template": "Xóa mẫu",
1010
+ "delete_dashboard": "Xóa bảng điều khiển",
1011
+ "dashboard_name": "Dashboard name",
1011
1012
  "add_widget": "Thêm tiện ích con",
1012
- "add_your_widget": "Thêm tiện ích của bạn vào mẫu trang tổng quan",
1013
+ "add_your_widget": "Thêm tiện ích của bạn vào ba",
1013
1014
  "label": "Nhãn",
1014
1015
  "choose_type_of_device": "Chọn Loại Thiết bị",
1015
1016
  "central_controller": "Bộ điều khiển trung tâm",
@@ -1095,6 +1096,8 @@
1095
1096
  "continue_to_wait": "Bạn có muốn đợi tiếp?",
1096
1097
  "it_has_been_5_minutes": "Đã 5 phút trôi qua...",
1097
1098
  "click_here_to_setup_device": "Chọn thiết bị thêm vào phòng",
1099
+ "text_under_development": "Tính năng này đang được phát triển.",
1100
+ "text_working_hard": "Chúng tôi đang làm việc chăm chỉ để làm cho điều này hoạt động",
1098
1101
  "photo_request_permission": "Quyền yêu cầu ảnh",
1099
1102
  "photo_request_permission_des": "Để chọn ảnh từ thư viện, vui lòng mở khóa quyền truy cập ảnh"
1100
1103
  }