@eohjsc/react-native-smart-city 0.2.84 → 0.2.85

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 (48) hide show
  1. package/assets/images/brightness.svg +12 -0
  2. package/package.json +3 -1
  3. package/src/Images/Common/SuccessfullyConnected.svg +4 -0
  4. package/src/Images/Common/eye-closed.png +0 -0
  5. package/src/Images/Common/eye-closed@2x.png +0 -0
  6. package/src/Images/Common/eye-closed@3x.png +0 -0
  7. package/src/Images/Common/eye.png +0 -0
  8. package/src/Images/Common/eye@2x.png +0 -0
  9. package/src/Images/Common/eye@3x.png +0 -0
  10. package/src/commons/ActionGroup/LightActionTemplate.js +103 -0
  11. package/src/commons/ActionGroup/LightActionTemplateStyles.js +57 -0
  12. package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +33 -31
  13. package/src/commons/ActionGroup/__test__/LightActionTemplate.test.js +59 -0
  14. package/src/commons/ActionGroup/index.js +3 -0
  15. package/src/commons/CardShadow/index.js +5 -2
  16. package/src/commons/CardShadow/styles.js +2 -3
  17. package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +16 -0
  18. package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +42 -0
  19. package/src/commons/ConnectingProcess/__test__/Connecting.test.js +27 -0
  20. package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +18 -0
  21. package/src/commons/ConnectingProcess/index.js +202 -0
  22. package/src/commons/ConnectingProcess/styles.js +69 -0
  23. package/src/commons/Device/LinearChart.js +1 -0
  24. package/src/commons/Form/TextInputPassword.js +1 -1
  25. package/src/configs/API.js +2 -0
  26. package/src/configs/Constants.js +15 -0
  27. package/src/configs/Images.js +2 -0
  28. package/src/context/actionType.ts +2 -0
  29. package/src/context/reducer.ts +10 -0
  30. package/src/hooks/Common/useBlockBackAndroid.js +3 -1
  31. package/src/navigations/AddDeviceStack.js +10 -0
  32. package/src/screens/AddCommon/SelectSubUnit.js +29 -6
  33. package/src/screens/AddCommon/SelectUnit.js +24 -2
  34. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +120 -1
  35. package/src/screens/AddCommon/__test__/SelectUnit.test.js +16 -1
  36. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +45 -15
  37. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +52 -23
  38. package/src/screens/AddNewGateway/SelectGateway.js +132 -0
  39. package/src/screens/AddNewGateway/SelectGatewayStyles.js +55 -0
  40. package/src/screens/Device/detail.js +6 -6
  41. package/src/screens/Notification/__test__/NotificationItem.test.js +12 -2
  42. package/src/screens/Notification/components/NotificationItem.js +60 -12
  43. package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +10 -7
  44. package/src/screens/ScanChipQR/hooks/index.js +46 -22
  45. package/src/screens/Unit/Detail.js +23 -1
  46. package/src/utils/I18n/translations/en.json +8 -0
  47. package/src/utils/I18n/translations/vi.json +8 -1
  48. package/src/utils/Route/index.js +2 -0
@@ -62,7 +62,7 @@ describe('test ScanChipQR', () => {
62
62
  expect(qrScan[0].props.loading).toEqual(false);
63
63
  });
64
64
 
65
- test('onScan success', async () => {
65
+ test('onScan addDeviceNewFlow success', async () => {
66
66
  const new_chip = {
67
67
  id: 1,
68
68
  name: 'ABC',
@@ -76,7 +76,7 @@ describe('test ScanChipQR', () => {
76
76
  });
77
77
 
78
78
  let tree;
79
- const body = { id: 1, imei: 'IMEI_X', name: 'New Chip' };
79
+ const body = { id: 1, imei: 'SENSOR-X341241', name: 'New Chip' };
80
80
  await act(async () => {
81
81
  tree = await create(wrapComponent(route));
82
82
  });
@@ -87,10 +87,14 @@ describe('test ScanChipQR', () => {
87
87
  qrScan.props.onScan(JSON.stringify(body));
88
88
  });
89
89
  expect(qrScan.props.loading).toEqual(true);
90
- expect(axios.post).toHaveBeenCalled();
91
- expect(mockedNavigate).toHaveBeenCalledWith(Routes.ConnectingGateway, {
92
- new_chip,
93
- ...route.params,
90
+ expect(mockedNavigate).toHaveBeenCalledWith(Routes.AddDeviceStack, {
91
+ params: {
92
+ scan_sensor_data: { id: 1, imei: 'SENSOR-X341241', name: 'New Chip' },
93
+ addType: 'AddDeviceNewFlow',
94
+ devicePrefixName: 'SENSOR',
95
+ unit_id: undefined,
96
+ },
97
+ screen: 'AddGatewaySelectGateway',
94
98
  });
95
99
  });
96
100
 
@@ -118,7 +122,6 @@ describe('test ScanChipQR', () => {
118
122
  qrScan.props.onScan(JSON.stringify(body));
119
123
  });
120
124
  expect(qrScan.props.loading).toEqual(true);
121
- expect(axios.post).toHaveBeenCalled();
122
125
  expect(mockedGoBack).toHaveBeenCalled();
123
126
  });
124
127
  });
@@ -13,29 +13,53 @@ const useChipScan = (route) => {
13
13
  async (data) => {
14
14
  setLoading(true);
15
15
  const body = JSON.parse(data);
16
- const { success, data: new_chip } = await axiosPost(
17
- API.UNIT.CHIP_SCAN_GET_WIFI_INFO(),
18
- {
19
- imei: imei || body.imei,
20
- qr_code: body.imei,
21
- }
22
- );
23
- if (success) {
24
- if (new_chip.is_wifi) {
25
- navigation.navigate(Routes.ConnectWifiWarning, {
26
- wifi_ssid: new_chip.wifi_ssid,
27
- wifi_pass: new_chip.wifi_pass,
28
- chip_id: new_chip.id,
29
- unit_id: unit_id,
16
+ const devicePrefixName = body?.imei.split('-')[0];
17
+ switch (devicePrefixName) {
18
+ case 'SENSOR':
19
+ navigation.navigate(Routes.AddDeviceStack, {
20
+ screen: Routes.AddGatewaySelectGateway,
21
+ params: {
22
+ scan_sensor_data: { ...body },
23
+ addType: 'AddDeviceNewFlow',
24
+ unit_id: unit_id,
25
+ devicePrefixName,
26
+ },
30
27
  });
31
- } else {
32
- navigation.navigate(Routes.ConnectingGateway, {
33
- new_chip,
34
- ...route.params,
35
- });
36
- }
37
- } else {
38
- navigation.goBack();
28
+ break;
29
+ case 'ROBOT':
30
+ case 'LITE':
31
+ {
32
+ const { success, data: new_chip } = await axiosPost(
33
+ API.UNIT.CHIP_SCAN_GET_WIFI_INFO(),
34
+ {
35
+ imei: imei || body.imei,
36
+ qr_code: body.imei,
37
+ }
38
+ );
39
+ if (success) {
40
+ if (new_chip.is_wifi) {
41
+ navigation.navigate(Routes.ConnectWifiWarning, {
42
+ wifi_ssid: new_chip.wifi_ssid,
43
+ wifi_pass: new_chip.wifi_pass,
44
+ chip_id: new_chip.id,
45
+ unit_id: unit_id,
46
+ devicePrefixName,
47
+ body,
48
+ });
49
+ } else {
50
+ navigation.navigate(Routes.ConnectingGateway, {
51
+ new_chip,
52
+ ...route.params,
53
+ });
54
+ }
55
+ } else {
56
+ navigation.goBack();
57
+ }
58
+ }
59
+ break;
60
+ default:
61
+ navigation.goBack();
62
+ break;
39
63
  }
40
64
  },
41
65
  [imei, navigation, route.params, unit_id]
@@ -11,7 +11,12 @@ import Summaries from './Summaries';
11
11
 
12
12
  import Text from '../../commons/Text';
13
13
  import { API } from '../../configs';
14
- import { useBoolean, useIsOwnerOfUnit, usePopover } from '../../hooks/Common';
14
+ import {
15
+ useBlockBackAndroid,
16
+ useBoolean,
17
+ useIsOwnerOfUnit,
18
+ usePopover,
19
+ } from '../../hooks/Common';
15
20
  import { scanBluetoothDevices } from '../../iot/RemoteControl/Bluetooth';
16
21
  import { googleHomeConnect } from '../../iot/RemoteControl/GoogleHome';
17
22
  import { axiosPost, fetchWithCache } from '../../utils/Apis/axios';
@@ -41,6 +46,7 @@ const UnitDetail = ({ route }) => {
41
46
  unitData,
42
47
  isOneTap,
43
48
  routeName,
49
+ stationId,
44
50
  isAddSubUnit,
45
51
  isSuccessfullyConnected,
46
52
  } = route.params;
@@ -48,6 +54,13 @@ const UnitDetail = ({ route }) => {
48
54
  const isFocused = useIsFocused();
49
55
  const { stateData, setAction } = useContext(SCContext);
50
56
  const { navigate } = useNavigation();
57
+ const RouterHardware = useCallback(
58
+ (routeHardware) => () => {
59
+ navigate(routeHardware);
60
+ },
61
+ [navigate]
62
+ );
63
+ useBlockBackAndroid(RouterHardware(Routes.Dashboard));
51
64
  const user = useSCContextSelector((state) => state?.auth?.account?.user);
52
65
  const isLavidaSource = useSCContextSelector(
53
66
  (state) => state.app.isLavidaSource
@@ -268,6 +281,15 @@ const UnitDetail = ({ route }) => {
268
281
  }
269
282
  }, [listMenuItem.length, isAddSubUnit]);
270
283
 
284
+ useEffect(() => {
285
+ if (listMenuItem.length && stationId) {
286
+ const getStationCurrent = listMenuItem.filter(
287
+ (item) => item?.station.id === stationId
288
+ );
289
+ setIndexStation(getStationCurrent[0]?.index);
290
+ }
291
+ }, [listMenuItem, listMenuItem.length, stationId]);
292
+
271
293
  const onSnapToItem = useCallback(
272
294
  (item, index) => {
273
295
  setStation(unit.stations[index]);
@@ -276,7 +276,11 @@
276
276
  "manage_unit": "Manage unit",
277
277
  "text_bad": "Bad",
278
278
  "text_select_a_unit": "Select a unit",
279
+ "text_select_sub_unit": "Select sub unit",
280
+ "text_select_a_gateway": "Select a gateway",
279
281
  "text_select_a_unit_desc": "Select a unit you want to add new members",
282
+ "select_a_sub_unit_want_add_device": "Then, select a sub-unit that you want to add this device in",
283
+ "text_select_a_unit_have_device": "First, select a unit that has this device",
280
284
  "text_select_permissions": "Select permissions",
281
285
  "text_select_permissions_desc": "Select permissions will be grant",
282
286
  "text_read_config": "Read configs",
@@ -681,6 +685,9 @@
681
685
  "text_notification_content_remove_member": "You were remove from **%{unit_name}** by **%{unit_owner_name}**. You cannot access to this unit anymore.",
682
686
  "text_notification_content_member_leave_unit": "**%{member_name}** has left **%{unit_name}**.",
683
687
  "text_notification_content_rename_unit": "Unit **%{old_unit_name}** has been renamed to **%{new_unit_name}** by **%{owner_name}**.",
688
+ "text_notification_content_divice_disconnect": "**%{device_name}** at **%{unit_name}**: **%{sub_unit_name}** has been disconnected. Please check and reconnect.",
689
+ "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}**.",
690
+ "text_notification_content_update_address": "New address of **%{unit_name}** has been updated by **%{unit_owner_name}** to **%{unit_address}**.",
684
691
  "this_spot_does_not_exsit": "This spot does not exist",
685
692
  "please_scan_again_or_contact_the_parking_manager": "Please scan again or contact the parking manager",
686
693
  "this_spot_does_not_support_to_scan": "This spot does not support to scan",
@@ -889,6 +896,7 @@
889
896
  "connecting_gateway_warning_2": "A message will appear asking you to connect.",
890
897
  "remove_account": "Remove Account",
891
898
  "text_sub_unit_not_have_device": "You don't have sub-unit with a device to control",
899
+ "brightness": "Brightness",
892
900
  "tap_to_add_new_schedule": "Tap + to add new schedule",
893
901
  "confirmation": "Confirmation",
894
902
  "enter_yes_to_perform": "You need to enter 'YES' to perform this action",
@@ -311,7 +311,11 @@
311
311
  "manage_unit": "Quản lý địa điểm",
312
312
  "text_bad": "Xấu",
313
313
  "text_select_a_unit": "Chọn một địa điểm",
314
+ "text_select_sub_unit": "Chọn đơn vị",
315
+ "text_select_a_gateway": "Chọn một gateway",
314
316
  "text_select_a_unit_desc": "Chọn 1 địa điểm bạn muốn thêm thành viên",
317
+ "text_select_a_unit_have_device": "Đầu tiên, chọn một địa điểm có thiết bị này",
318
+ "select_a_sub_unit_want_add_device": "Sau đó, chọn một đơn vị con mà bạn muốn thêm thiết bị này vào",
315
319
  "text_select_permissions": "Chọn hành động",
316
320
  "text_select_permissions_desc": "Chọn các hành động cho phép",
317
321
  "text_read_config": "Thông số đọc",
@@ -689,6 +693,9 @@
689
693
  "text_notification_content_remove_member": "Bạn vừa được xoá khỏi **%{unit_name}** bởi **%{unit_owner_name}**. Bạn không thể truy cập vào địa điểm này được nữa.",
690
694
  "text_notification_content_member_leave_unit": "**%{member_name}** vừa rời khỏi **%{unit_name}**.",
691
695
  "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}**.",
696
+ "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.",
697
+ "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}**.",
698
+ "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}**.",
692
699
  "this_spot_does_not_exsit": "Vị trí đỗ này không tồn tại",
693
700
  "please_scan_again_or_contact_the_parking_manager": "Vui lòng quét lại hoặc liên hệ với người quản lý bãi đậu xe",
694
701
  "this_spot_does_not_support_to_scan": "Vị trí đỗ này không hỗ trợ quét",
@@ -891,7 +898,6 @@
891
898
  "add_gateway_success": "Thêm gateway thành công",
892
899
  "tap_to_add_new_schedule": "Nhấn + để thêm lịch trình mới",
893
900
  "remove_account": "Xóa tài khoản",
894
- "text_subunit_not_have_device": "Bạn không có khu vực nào có thiết bị để điều khiển",
895
901
  "choose_at_least_one": "Vui lòng chọn ít nhất 1 thiết bị.",
896
902
  "confirmation": "Xác Nhận",
897
903
  "enter_yes_to_perform": "Bạn cần nhập 'YES' để thực hiện hành động này",
@@ -901,6 +907,7 @@
901
907
  "curtain_closes": "Rèm đóng",
902
908
  "schedule_name": "Tên lịch trình",
903
909
  "enter_name": "Nhập tên",
910
+ "brightness": "Độ sáng",
904
911
  "name_smart_account": "Smart Account",
905
912
  "location_permission_required_wifi_title": "Quyền vị trí là bắt buộc đối với kết nối WiFi",
906
913
  "location_permission_required_wifi_message": "Ứng dụng này cần có quyền định vị vì ứng dụng này được yêu cầu để quét các mạng Wi-Fi.",
@@ -55,6 +55,8 @@ const Routes = {
55
55
  AddSubUnit: 'AddSubUnit',
56
56
  AddCommonSelectUnit: 'AddCommonSelectUnit',
57
57
  AddCommonSelectSubUnit: 'AddCommonSelectSubUnit',
58
+ AddGatewaySelectGateway: 'AddGatewaySelectGateway',
59
+ ConnectingProcess: 'ConnectingProcess',
58
60
  UnitMemberList: 'UnitMemberList',
59
61
  SharingSelectPermission: 'SharingSelectPermission',
60
62
  SharingInviteMembers: 'SharingInviteMembers',