@eohjsc/react-native-smart-city 0.2.67 → 0.2.71

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 (86) hide show
  1. package/assets/images/Popover/Dashboard/SmartAccount.svg +5 -0
  2. package/assets/images/scan-qr-gateway.svg +14 -0
  3. package/assets/images/wifi-gateway.svg +18 -0
  4. package/assets/images/wifi.svg +3 -0
  5. package/package.json +3 -1
  6. package/src/Images/Common/buttonLeftCurtain@2x.png +0 -0
  7. package/src/Images/Common/buttonLeftCurtain@3x.png +0 -0
  8. package/src/Images/Common/{buttonPause-center-curtain.png → buttonPauseCurtain.png} +0 -0
  9. package/src/Images/Common/buttonPauseCurtain@2x.png +0 -0
  10. package/src/Images/Common/buttonPauseCurtain@3x.png +0 -0
  11. package/src/Images/Common/buttonRightCurtain@2x.png +0 -0
  12. package/src/Images/Common/buttonRightCurtain@3x.png +0 -0
  13. package/src/commons/Action/ItemQuickAction.js +4 -3
  14. package/src/commons/ActionGroup/CurtainButtonTemplate.js +0 -30
  15. package/src/commons/ActionGroup/CurtainButtonTemplateStyle.js +0 -12
  16. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +1 -1
  17. package/src/commons/AlertAction/index.js +4 -3
  18. package/src/commons/CameraDevice/index.js +1 -1
  19. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +70 -0
  20. package/src/commons/Device/HistoryChart.js +18 -18
  21. package/src/commons/Device/HorizontalBarChart.js +1 -2
  22. package/src/commons/Device/ItemDevice.js +1 -13
  23. package/src/commons/Device/LinearChart.js +13 -3
  24. package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +1 -1
  25. package/src/commons/SubUnit/OneTap/OneTapStyles.js +14 -5
  26. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +5 -68
  27. package/src/commons/SubUnit/OneTap/index.js +24 -33
  28. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +29 -0
  29. package/src/commons/UnitSummary/ConfigHistoryChart.js +4 -6
  30. package/src/commons/ViewButtonBottom/index.js +4 -0
  31. package/src/configs/API.js +2 -0
  32. package/src/configs/BLE.js +3 -0
  33. package/src/configs/Constants.js +2 -0
  34. package/src/configs/Images.js +1 -1
  35. package/src/context/SCContext.tsx +2 -0
  36. package/src/iot/RemoteControl/Bluetooth.js +34 -6
  37. package/src/iot/RemoteControl/__test__/Bluetooth.test.js +1 -0
  38. package/src/iot/RemoteControl/__test__/index.mock.js +1 -0
  39. package/src/iot/RemoteControl/index.js +7 -2
  40. package/src/navigations/AddDeviceStack.js +2 -0
  41. package/src/navigations/AddGatewayStack.js +11 -0
  42. package/src/navigations/AddLGDeviceStack.js +2 -0
  43. package/src/navigations/AddMemberStack.js +2 -0
  44. package/src/navigations/AddSubUnitStack.js +2 -0
  45. package/src/navigations/AddUnitStack.js +2 -0
  46. package/src/navigations/EmergencyContactsStack.js +2 -0
  47. package/src/navigations/SharedStack.js +2 -0
  48. package/src/navigations/UnitStack.js +2 -0
  49. package/src/navigations/utils.js +3 -0
  50. package/src/screens/AddCommon/SelectSubUnit.js +12 -2
  51. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +190 -0
  52. package/src/screens/AddNewGateway/PlugAndPlay/FirstWarning.js +73 -0
  53. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +154 -0
  54. package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +60 -0
  55. package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +35 -0
  56. package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +90 -0
  57. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +0 -22
  58. package/src/screens/AddNewOneTap/index.js +15 -13
  59. package/src/screens/Device/components/SensorDisplayItem.js +4 -2
  60. package/src/screens/Notification/components/NotificationItem.js +24 -1
  61. package/src/screens/Notification/styles/NotificationItemStyles.js +1 -1
  62. package/src/screens/ScanChipQR/hooks/index.js +14 -5
  63. package/src/screens/SharedUnit/index.js +7 -5
  64. package/src/screens/Sharing/Components/SensorItem.js +27 -12
  65. package/src/screens/Sharing/Components/Styles/SensorItemStyles.js +4 -0
  66. package/src/screens/Sharing/SelectPermission.js +44 -32
  67. package/src/screens/Sharing/SelectUser.js +13 -1
  68. package/src/screens/Sharing/__test__/SelectPermission.test.js +2 -1
  69. package/src/screens/SubUnit/AddSubUnit.js +4 -1
  70. package/src/screens/Unit/AddMenu.js +15 -0
  71. package/src/screens/Unit/Detail.js +15 -4
  72. package/src/screens/Unit/SmartAccount.js +36 -15
  73. package/src/screens/Unit/SmartAccountStyles.js +20 -0
  74. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +10 -6
  75. package/src/screens/Unit/hook/useStateAlertRemove.js +4 -6
  76. package/src/screens/UnitSummary/components/PowerConsumption/index.js +2 -4
  77. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +10 -6
  78. package/src/utils/I18n/translations/en.json +33 -4
  79. package/src/utils/I18n/translations/vi.json +34 -4
  80. package/src/utils/Route/index.js +4 -0
  81. package/src/utils/Utils.js +0 -4
  82. package/src/commons/ActionGroup/__test__/MenuActionAddSchedule.test.js +0 -71
  83. package/src/commons/ActionGroup/hooks/AccessScheduleDetailStyles.js +0 -41
  84. package/src/commons/ActionGroup/hooks/MenuActionAddSchedule.js +0 -110
  85. package/src/commons/ActionGroup/hooks/MenuActionAddScheduleStyle.js +0 -69
  86. package/src/commons/ActionGroup/hooks/RecurringDetail.js +0 -97
@@ -5,10 +5,10 @@ export const useStateAlertRemove = () => {
5
5
  const t = useTranslations();
6
6
  const [stateAlertRemove, setStateAlertRemove] = useState({
7
7
  visible: false,
8
- title: t('delete_smart_account'),
8
+ title: t('remove_account'),
9
9
  message: '',
10
- leftButton: t('cancel'),
11
- rightButton: t('remove'),
10
+ leftButton: t('yes_remove'),
11
+ rightButton: t('cancel'),
12
12
  });
13
13
  const hideAlertAction = useCallback(() => {
14
14
  setStateAlertRemove((state) => ({
@@ -22,9 +22,7 @@ export const useStateAlertRemove = () => {
22
22
  setStateAlertRemove((state) => ({
23
23
  ...state,
24
24
  visible: true,
25
- message: `${t('are_you_sure_want_to_delete', {
26
- text: brand === 'google_home' ? 'Điện Quang' : brand,
27
- })}`,
25
+ message: t('this_action_will_remove_all_related_devices'),
28
26
  }));
29
27
  },
30
28
  [t]
@@ -77,10 +77,8 @@ const PowerConsumption = memo(({ summaryDetail }) => {
77
77
  const dataTotal = [];
78
78
  dataTotal.push(totalPower);
79
79
 
80
- const [startDate, setStartDate] = useState(
81
- moment().subtract(6, 'days').valueOf()
82
- );
83
- const [endDate, setEndDate] = useState(moment().valueOf());
80
+ const [startDate, setStartDate] = useState(moment().subtract(6, 'days'));
81
+ const [endDate, setEndDate] = useState(moment());
84
82
  const [groupBy, setGroupBy] = useState('date');
85
83
  const [getData, setData] = useState([]);
86
84
  const [chartConfig, setChartConfig] = useState({
@@ -3,6 +3,14 @@ import { act, create } from 'react-test-renderer';
3
3
  import RunningDevices from '..';
4
4
  import { TouchableOpacity } from 'react-native';
5
5
  import ItemDevice from '../../../../../commons/Device/ItemDevice';
6
+ import { mockSCStore } from '../../../../../context/mockStore';
7
+ import { SCProvider } from '../../../../../context';
8
+
9
+ const wrapComponent = (unit, summaryDetail) => (
10
+ <SCProvider initState={mockSCStore({})}>
11
+ <RunningDevices unit={unit} summaryDetail={summaryDetail} />
12
+ </SCProvider>
13
+ );
6
14
 
7
15
  const mockedNavigate = jest.fn();
8
16
 
@@ -55,9 +63,7 @@ describe('test RunningDevices', () => {
55
63
  };
56
64
 
57
65
  await act(async () => {
58
- tree = await create(
59
- <RunningDevices unit={unit} summaryDetail={summaryDetail} />
60
- );
66
+ tree = await create(wrapComponent(unit, summaryDetail));
61
67
  });
62
68
  const instance = tree.root;
63
69
  const texts = instance.findAllByType(ItemDevice);
@@ -95,9 +101,7 @@ describe('test RunningDevices', () => {
95
101
  };
96
102
 
97
103
  await act(async () => {
98
- tree = await create(
99
- <RunningDevices unit={unit} summaryDetail={summaryDetail} />
100
- );
104
+ tree = await create(wrapComponent(unit, summaryDetail));
101
105
  });
102
106
  const instance = tree.root;
103
107
  const texts = instance.findAllByType(ItemDevice);
@@ -240,8 +240,10 @@
240
240
  "invalid_phone_number": "Invalid phone number",
241
241
  "Found bluetooth %{name} for remote control": "Found bluetooth %{name} for remote control",
242
242
  "Sending command via bluetooth": "Sending command via bluetooth",
243
- "Command is sent to device via bluetooth": "Command is sent to device via bluetooth",
244
- "Command is fail to send via bluetooth": "Command is fail to send via bluetooth",
243
+ "command_is_sent_to_device_via_bluetooth": "Command is sent to device via bluetooth",
244
+ "command_is_fail_to_send_via_bluetooth": "Command is fail to send via bluetooth",
245
+ "control_device_via_bluetooth_successfully": "Control device via bluetooth successfully",
246
+ "control_device_via_bluetooth_failed": "Control device via bluetooth failed",
245
247
  "Sending command via internet": "Sending command via internet",
246
248
  "Command is sent to device via internet": "Command is sent to device via internet",
247
249
  "Command is fail to send via internet": "Command is fail to send via internet",
@@ -666,6 +668,9 @@
666
668
  "text_notification_content_pay_fine_successfully": "Your violation **%{booking}** has been paid successfully.",
667
669
  "text_notification_content_pay_fine_and_extend_successfully": "Your violation **%{booking_id_old}** has been paid successfully. The new parking session **%{booking_id_new}** is now extended until **%{leave_time}**.",
668
670
  "text_notification_content_stop_violation_free_parking_zone": "Free parking zone. You have an unpaid violation. Please complete your fine.",
671
+ "text_notification_content_remove_unit_to_owner": "Unit **%{unit_name}** has been removed successfully.",
672
+ "text_notification_content_remove_unit_to_member": "Unit **%{unit_name}** has been removed by **%{unit_owner_name}**. You cannot access to this unit anymore.",
673
+ "text_notification_content_remove_member": "You were remove from **%{unit_name}** by **%{unit_owner_name}**. You cannot access to this unit anymore.",
669
674
  "this_spot_does_not_exsit": "This spot does not exist",
670
675
  "please_scan_again_or_contact_the_parking_manager": "Please scan again or contact the parking manager",
671
676
  "this_spot_does_not_support_to_scan": "This spot does not support to scan",
@@ -796,7 +801,7 @@
796
801
  "smart": "Smart",
797
802
  "smart_account": "Smart account",
798
803
  "delete_smart_account": "Delete smart account",
799
- "are_you_sure_want_to_delete": "Are you sure you want to delete {text} ?",
804
+ "this_action_will_remove_all_related_devices": "This action will remove all related devices and it’s setting forever. Do you wish to continue?",
800
805
  "multi_unit": "Multi Units",
801
806
  "edit_device": "Edit Device",
802
807
  "device_name": "Device name",
@@ -856,6 +861,21 @@
856
861
  "volume": "Volume",
857
862
  "this_notification_will_be_updated_soon": "This notification will be updated soon",
858
863
  "text_submit": "Submit",
864
+ "connecting": "Connecting",
865
+ "connect_device": "Connect Device",
866
+ "connect": "Connect",
867
+ "server_error": "Server Error",
868
+ "add_gateway_success": "Add gateway success",
869
+ "set_network": "Set network",
870
+ "select_wifi": "Select your wifi network",
871
+ "enter_wifi_password": "Enter wifi password",
872
+ "gateway_warning_content_1": "To bring you good experiences, ",
873
+ "gateway_warning_content_2": "your device needs a permanent wifi connection.",
874
+ "gateway_warning_content_3": "In the next steps, you will be instructed to connect to wifi for the device. ",
875
+ "gateway_warning_content_4": "To give you a good experience, you need to know the name and password of the wifi network and make sure the device is placed in a good location.",
876
+ "warning_beta_test_feature": "This feature is in beta test, not official yet",
877
+ "connecting_gateway_warning_1": "By continuing, EoH needs to connect to the device's wifi.",
878
+ "connecting_gateway_warning_2": "A message will appear asking you to connect.",
859
879
  "remove_account": "Remove Account",
860
880
  "text_sub_unit_not_have_device": "You don't have sub-unit with a device to control",
861
881
  "tap_to_add_new_schedule": "Tap + to add new schedule",
@@ -866,5 +886,14 @@
866
886
  "curtain_opens": "Curtain opens",
867
887
  "curtain_closes": "Curtain closes",
868
888
  "schedule_name": "Schedule name",
869
- "enter_name": "Enter name"
889
+ "enter_name": "Enter name",
890
+ "name_smart_account": "Smart Account",
891
+ "location_permission_required_wifi_title": "Location permission is required for WiFi connections",
892
+ "location_permission_required_wifi_message": "This app needs location permission as this is required to scan for wifi networks.",
893
+ "deny": "DENY",
894
+ "allow": "ALLOW",
895
+ "error_share_permission": "{text} {data} does not exist!",
896
+ "text_phone_share_permission": "The phone",
897
+ "text_email_share_permission": "Email",
898
+ "yes_remove": "Yes,remove"
870
899
  }
@@ -276,8 +276,10 @@
276
276
  "invalid_phone_number": "Số điện thoại không hợp lệ.",
277
277
  "Found bluetooth %{name} for remote control": "Tìm thấy thiết bị điều khiển bluetooth %{name}",
278
278
  "Sending command via bluetooth": "Đang gởi lệnh thông qua bluetooth",
279
- "Command is sent to device via bluetooth": "Lệnh được gởi tới thiết bị thông qua bluetooth",
280
- "Command is fail to send via bluetooth": "Không thế gởi tới thiết bị thông qua bluetooth",
279
+ "command_is_sent_to_device_via_bluetooth": "Lệnh được gởi tới thiết bị thông qua bluetooth",
280
+ "command_is_fail_to_send_via_bluetooth": "Không thế gởi tới thiết bị thông qua bluetooth",
281
+ "control_device_via_bluetooth_successfully": "Điều khiển thiết bị qua bluetooth thành công",
282
+ "control_device_via_bluetooth_failed": "Điều khiển thiết bị qua bluetooth thất bại",
281
283
  "Sending command via internet": "Đang gởi lệnh thông qua internet",
282
284
  "Command is sent to device via internet": "Lệnh được gởi tới thiết bị thông qua internet",
283
285
  "Command is fail to send via internet": "Không thế gởi tới thiết bị thông qua internet",
@@ -674,6 +676,9 @@
674
676
  "text_notification_content_pay_fine_successfully": "Đỗ xe vi phạm **%{booking}** của bạn đã được thanh toán.",
675
677
  "text_notification_content_pay_fine_and_extend_successfully": "Đỗ xe vi phạm **%{oldbooking}** của bạn đã được thanh toán thành công. Phiên đỗ xe mới **%{newbooking}** sẽ kết thúc vào lúc **%{time}**.",
676
678
  "text_notification_content_stop_violation_free_parking_zone": "Thời gian đậu xe miễn phí. Bạn có một vi phạm chưa được thanh toán. Vui lòng hoàn thành tiền phạt của bạn.",
679
+ "text_notification_content_remove_unit_to_owner": "Địa điểm **%{unit_name}** vừa được xoá thành công.",
680
+ "text_notification_content_remove_unit_to_member": "Địa điểm **%{unit_name}** vừa được xoá bởi **%{unit_owner_name}**. Bạn không thể truy cập vào địa điểm này được nữa.",
681
+ "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.",
677
682
  "this_spot_does_not_exsit": "Vị trí đỗ này không tồn tại",
678
683
  "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",
679
684
  "this_spot_does_not_support_to_scan": "Vị trí đỗ này không hỗ trợ quét",
@@ -683,6 +688,7 @@
683
688
  "command_send_fail_googlehome": "Lệnh gởi thất bại đến google home",
684
689
  "command_googlehome_ready": "Google Home kết nối thành công",
685
690
  "command_googlehome_lost": "Google Home bị mất kết nối. Đang kết nối lại...",
691
+ "text_sub_unit_not_have_device": "Khu vực không có thiết bị để điều khiển",
686
692
  "confirm": "Xác nhận",
687
693
  "car_validate_warning": "Vui lòng nhập đúng định dạng biển số xe \nVD: %{example}",
688
694
  "are_you_sure_this_resolved": "Bạn có chắc tình huống khẩn cấp này đã được xử lý xong? Các thành viên thuộc địa điểm này cũng sẽ nhận được thông báo.",
@@ -797,7 +803,7 @@
797
803
  "smart": "Thông minh",
798
804
  "smart_account": "Tài khoản thông minh",
799
805
  "delete_smart_account": "Xóa tài khoản thông minh",
800
- "are_you_sure_want_to_delete": "Bạn có muốn xóa {text} ?",
806
+ "this_action_will_remove_all_related_devices": "Hành động này sẽ xóa tất cả các thiết bị liên quan và nó sẽ cài đặt vĩnh viễn. Bạn có muốn tiếp tục không?",
801
807
  "edit_device": "Chỉnh sửa thiết bị",
802
808
  "device_name": "Tên thiết bị",
803
809
  "rename_successfully": "Đổi tên thành công!",
@@ -857,6 +863,21 @@
857
863
  "volume": "Âm lượng",
858
864
  "this_notification_will_be_updated_soon": "Thông báo này sẽ sớm được cập nhật",
859
865
  "text_submit": "Xác nhận",
866
+ "connecting": "Đang kết nối",
867
+ "connect_device": "Kết nối thiết bị",
868
+ "connect": "Kết nối",
869
+ "server_error": "Lỗi hệ thống",
870
+ "set_network": "Chọn mạng",
871
+ "select_wifi": "Chọn mạng wifi của bạn",
872
+ "enter_wifi_password": "Nhập mật khẩu wifi",
873
+ "gateway_warning_content_1": "Để mang đến cho bạn những trải nghiệm tốt, ",
874
+ "gateway_warning_content_2": "thiết bị cần kết nối wifi thường trực.",
875
+ "gateway_warning_content_3": "Trong các bước tiếp theo, bạn sẽ được hướng dẫn kết nối wifi cho thiết bị. ",
876
+ "gateway_warning_content_4": "Bạn cần biết tên và mật khẩu của mạng wifi và đảm bảo thiết bị được đặt ở vị trí tốt.",
877
+ "warning_beta_test_feature": "Tính năng này đang ở giai đoạn beta test, chưa phải bản chính thức.",
878
+ "connecting_gateway_warning_1": "Bằng việc tiếp tục, EoH cần kết nối với Wifi của thiết bị.",
879
+ "connecting_gateway_warning_2": "Một thông báo sẽ hiện lên và yêu cầu bạn kết nối.",
880
+ "add_gateway_success": "Thêm gateway thành công",
860
881
  "tap_to_add_new_schedule": "Nhấn + để thêm lịch trình mới",
861
882
  "remove_account": "Xóa tài khoản",
862
883
  "text_subunit_not_have_device": "Bạn không có khu vực nào có thiết bị để điều khiển",
@@ -868,5 +889,14 @@
868
889
  "curtain_opens": "Rèm mở",
869
890
  "curtain_closes": "Rèm đóng",
870
891
  "schedule_name": "Tên lịch trình",
871
- "enter_name": "Nhập tên"
892
+ "enter_name": "Nhập tên",
893
+ "name_smart_account": "Smart Account",
894
+ "location_permission_required_wifi_title": "Quyền vị trí là bắt buộc đối với kết nối WiFi",
895
+ "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.",
896
+ "deny": "Từ chối",
897
+ "allow": "Cho phép",
898
+ "error_share_permission": "{text} {data} không tồn tại!",
899
+ "text_phone_share_permission": "Số điện thoại",
900
+ "text_email_share_permission": "Email",
901
+ "yes_remove": "Có,loại bỏ"
872
902
  }
@@ -121,7 +121,11 @@ const Routes = {
121
121
  ListDeviceSmartAccount: 'ListDeviceSmartAccount',
122
122
  SmartAccountConnecting: 'SmartAccountConnecting',
123
123
  EmergencySetting: 'EmergencySetting',
124
+ FirstWarning: 'FirstWarning',
125
+ ConnectWifiWarning: 'ConnectWifiWarning',
126
+ GatewayWifiList: 'GatewayWifiList',
124
127
  ConfirmUnitDeletion: 'ConfirmUnitDeletion',
128
+ SmartAccount: 'SmartAccount',
125
129
  };
126
130
 
127
131
  export default Routes;
@@ -120,10 +120,6 @@ export const removeFromString = (str, index) => {
120
120
  return str.substr(0, index) + str.substr(index + 1);
121
121
  };
122
122
 
123
- export const arePropsEqual = (prevProps, nextProps) => {
124
- return JSON.stringify(prevProps) === JSON.stringify(nextProps);
125
- };
126
-
127
123
  export default {
128
124
  validateEmail,
129
125
  isObjectEmpty,
@@ -1,71 +0,0 @@
1
- import React from 'react';
2
- import renderer, { act } from 'react-test-renderer';
3
-
4
- import MenuActionAddSchedule from '../hooks/MenuActionAddSchedule';
5
- import { SCProvider } from '../../../context';
6
- import { mockSCStore } from '../../../context/mockStore';
7
- import RecurringDetail from '../hooks/RecurringDetail';
8
- import WheelDateTimePicker from '../../WheelDateTimePicker';
9
-
10
- const mockSetState = jest.fn();
11
- jest.mock('react', () => {
12
- return {
13
- ...jest.requireActual('react'),
14
- memo: (x) => x,
15
- useState: jest.fn((init) => [init, mockSetState]),
16
- };
17
- });
18
-
19
- const wrapComponent = (actionGroup) => (
20
- <SCProvider initState={mockSCStore({})}>
21
- <MenuActionAddSchedule />
22
- </SCProvider>
23
- );
24
-
25
- const mockedNavigate = jest.fn();
26
-
27
- jest.mock('@react-navigation/native', () => {
28
- return {
29
- ...jest.requireActual('@react-navigation/native'),
30
- useNavigation: () => ({
31
- goBack: mockedNavigate,
32
- }),
33
- };
34
- });
35
-
36
- jest.mock('react', () => {
37
- return {
38
- ...jest.requireActual('react'),
39
- memo: (x) => x,
40
- };
41
- });
42
-
43
- jest.mock('axios');
44
-
45
- describe('Test MenuActionAddSchedule', () => {
46
- let tree;
47
-
48
- test('test render MenuActionAddSchedule', async () => {
49
- await act(async () => {
50
- tree = await renderer.create(wrapComponent());
51
- });
52
- const instance = tree.root;
53
-
54
- const recurringDetail = instance.findByType(RecurringDetail);
55
- await act(async () => {
56
- recurringDetail.props.onShowSetDateTime();
57
- });
58
-
59
- const wheelDateTimePicker = instance.findByType(WheelDateTimePicker);
60
-
61
- await act(async () => {
62
- wheelDateTimePicker.props.onPicked();
63
- });
64
-
65
- await act(async () => {
66
- wheelDateTimePicker.props.onCancel();
67
- });
68
-
69
- expect(wheelDateTimePicker.props.isVisible).toEqual(false);
70
- });
71
- });
@@ -1,41 +0,0 @@
1
- import { StyleSheet } from 'react-native';
2
- import { Colors } from '../../../configs';
3
-
4
- export default StyleSheet.create({
5
- title: {
6
- marginTop: 16,
7
- },
8
- value: {
9
- marginTop: 8,
10
- marginBottom: 12,
11
- },
12
- repeatWrap: {
13
- flexDirection: 'row',
14
- justifyContent: 'space-around',
15
- marginTop: 16,
16
- },
17
- repeatItem: {
18
- width: 24,
19
- height: 24,
20
- justifyContent: 'center',
21
- alignItems: 'center',
22
- borderRadius: 12,
23
- borderWidth: 0,
24
- borderColor: Colors.Orange,
25
- },
26
- repeatItemSelected: {
27
- borderWidth: 1,
28
- },
29
- repeatText: {
30
- lineHeight: 16,
31
- },
32
- curtainText: {
33
- fontSize: 17,
34
- marginTop: 12,
35
- color: Colors.Gray9,
36
- },
37
- boder: {
38
- borderBottomWidth: 1,
39
- borderColor: Colors.Gray4,
40
- },
41
- });
@@ -1,110 +0,0 @@
1
- import React, { memo, useCallback, useState } from 'react';
2
- import { View } from 'react-native';
3
- import { useTranslations } from '../../../hooks/Common/useTranslations';
4
-
5
- import Text from '../../Text';
6
- import { ModalCustom } from '../../Modal';
7
- import ViewButtonBottom from '../../ViewButtonBottom';
8
- import WheelDateTimePicker from '../../WheelDateTimePicker';
9
- import moment from 'moment';
10
- import { useBoolean } from '../../../hooks/Common';
11
- import RecurringDetail from './RecurringDetail';
12
- import _TextInput from '../../../commons/Form/TextInput';
13
- import styles from './MenuActionAddScheduleStyle';
14
-
15
- const MenuActionAddSchedule = memo(({ visible, hideModal, onItemClick }) => {
16
- const t = useTranslations();
17
-
18
- const [stateDateTimePicker, setStateDateTimePicker] = useState({
19
- isVisible: false,
20
- mode: 'time',
21
- defaultValue: moment().valueOf(),
22
- setter: null,
23
- });
24
-
25
- const [lockShowing, releaseLockShowing, acquireLockShowing] =
26
- useBoolean(true);
27
- const [recurringTimeStart, setRecurringTimeStart] = useState('');
28
- const [recurringTimeEnd, setRecurringTimeEnd] = useState('');
29
- const [recurringTimeRepeat, setRecurringTimeRepeat] = useState('');
30
-
31
- const onShowSetDateTime = useCallback(
32
- (currentValue, setter, mode) => {
33
- acquireLockShowing();
34
- setStateDateTimePicker((state) => ({
35
- ...state,
36
- isVisible: true,
37
- mode: mode,
38
- defaultValue: currentValue,
39
- setter: setter,
40
- }));
41
- },
42
- [setStateDateTimePicker, acquireLockShowing]
43
- );
44
-
45
- const onDateTimePicked = useCallback(
46
- (timeData) => {
47
- const setter = stateDateTimePicker.setter;
48
- setter && setter(moment(timeData));
49
- },
50
- [stateDateTimePicker]
51
- );
52
-
53
- const onHideSetDateTime = useCallback(() => {
54
- acquireLockShowing();
55
- setStateDateTimePicker((state) => ({
56
- ...state,
57
- isVisible: false,
58
- }));
59
- }, [setStateDateTimePicker, acquireLockShowing]);
60
-
61
- return (
62
- <ModalCustom
63
- isVisible={visible}
64
- onBackButtonPress={hideModal}
65
- onBackdropPress={hideModal}
66
- style={styles.container}
67
- >
68
- <View style={styles.popoverStyle}>
69
- <View style={styles.modalWrapper}>
70
- <View style={styles.modalHeader}>
71
- <Text style={styles.modalHeaderText}>{t('add_schedule')}</Text>
72
- <View style={styles.boder} />
73
- <RecurringDetail
74
- onShowSetDateTime={onShowSetDateTime}
75
- recurringTimeStart={recurringTimeStart}
76
- recurringTimeEnd={recurringTimeEnd}
77
- recurringTimeRepeat={recurringTimeRepeat}
78
- setRecurringTimeStart={setRecurringTimeStart}
79
- setRecurringTimeEnd={setRecurringTimeEnd}
80
- setRecurringTimeRepeat={setRecurringTimeRepeat}
81
- />
82
-
83
- <Text style={styles.subName}>{t('schedule_name')}</Text>
84
- <_TextInput
85
- placeholder={t('enter_name')}
86
- wrapStyle={styles.noMarginTop}
87
- textInputStyle={styles.textInput}
88
- />
89
- <View style={styles.ViewButtonBottom}>
90
- <ViewButtonBottom
91
- leftTitle={t('cancel')}
92
- onLeftClick={hideModal}
93
- rightTitle={t('done')}
94
- />
95
- </View>
96
- <WheelDateTimePicker
97
- mode={stateDateTimePicker.mode}
98
- isVisible={stateDateTimePicker.isVisible && lockShowing}
99
- defaultValue={stateDateTimePicker.defaultValue}
100
- onPicked={onDateTimePicked}
101
- onCancel={onHideSetDateTime}
102
- onHide={releaseLockShowing}
103
- />
104
- </View>
105
- </View>
106
- </View>
107
- </ModalCustom>
108
- );
109
- });
110
- export default MenuActionAddSchedule;
@@ -1,69 +0,0 @@
1
- import { Colors } from '../../../configs';
2
- import { StyleSheet } from 'react-native';
3
-
4
- export default StyleSheet.create({
5
- container: {
6
- flex: 1,
7
- margin: 0,
8
- },
9
- popoverStyle: {
10
- width: '100%',
11
- backgroundColor: Colors.White,
12
- bottom: 0,
13
- left: 0,
14
- position: 'absolute',
15
- borderRadius: 10,
16
- },
17
- modalWrapper: {
18
- flex: 1,
19
- flexDirection: 'column',
20
- backgroundColor: Colors.White,
21
- borderRadius: 10,
22
- },
23
- modalHeader: {
24
- padding: 16,
25
- backgroundColor: Colors.White,
26
- justifyContent: 'flex-start',
27
- },
28
- modalHeaderText: {
29
- fontSize: 17,
30
- lineHeight: 24,
31
- color: Colors.Gray9,
32
- fontWeight: 'bold',
33
- borderTopLeftRadius: 20,
34
- borderTopRightRadius: 20,
35
- marginVertical: 20,
36
- },
37
- boder: {
38
- borderBottomWidth: 1,
39
- borderColor: Colors.Gray4,
40
- },
41
- subName: {
42
- color: Colors.Gray8,
43
- marginTop: 12,
44
- },
45
- ViewButtonBottom: {
46
- borderTopWidth: 1,
47
- borderTopColor: Colors.Gray4,
48
- },
49
- scheduleName: {
50
- fontSize: 17,
51
- marginTop: 12,
52
- color: Colors.Gray9,
53
- marginBottom: 12,
54
- },
55
- noMarginTop: {
56
- marginTop: 0,
57
- backgroundColor: Colors.White,
58
- },
59
- textInput: {
60
- marginTop: 0,
61
- borderWidth: 0,
62
- borderBottomWidth: 1,
63
- borderBottomColor: Colors.Gray4,
64
- paddingLeft: 0,
65
- backgroundColor: Colors.White,
66
- fontSize: 17,
67
- color: Colors.Gray9,
68
- },
69
- });
@@ -1,97 +0,0 @@
1
- import React, { useCallback } from 'react';
2
- import { View, TouchableOpacity } from 'react-native';
3
- import { useTranslations } from '../../../hooks/Common/useTranslations';
4
-
5
- import Text from '../../../commons/Text';
6
- import { Colors } from '../../../configs';
7
- import { REPEAT_ITEMS } from '../../../screens/GuestInfo/constant';
8
- import styles from './AccessScheduleDetailStyles';
9
-
10
- const RecurringDetail = ({
11
- onShowSetDateTime,
12
- recurringTimeStart,
13
- recurringTimeEnd,
14
- recurringTimeRepeat,
15
- setRecurringTimeStart,
16
- setRecurringTimeEnd,
17
- setRecurringTimeRepeat,
18
- }) => {
19
- const t = useTranslations();
20
- const onSetTimeStart = useCallback(() => {
21
- onShowSetDateTime();
22
- }, [onShowSetDateTime]);
23
-
24
- const onSetTimeEnd = useCallback(() => {
25
- onShowSetDateTime();
26
- }, [onShowSetDateTime]);
27
-
28
- const onSetRepeat = useCallback(
29
- (item) => {
30
- const index = recurringTimeRepeat.indexOf(item.value);
31
- if (index !== -1) {
32
- setRecurringTimeRepeat([
33
- ...recurringTimeRepeat.slice(0, index),
34
- ...recurringTimeRepeat.slice(index + 1),
35
- ]);
36
- } else {
37
- setRecurringTimeRepeat([...recurringTimeRepeat, item.value]);
38
- }
39
- },
40
- [recurringTimeRepeat, setRecurringTimeRepeat]
41
- );
42
-
43
- const renderRepeatItem = useCallback(
44
- (item, index, isSelected) => {
45
- return (
46
- <TouchableOpacity
47
- key={index}
48
- style={[styles.repeatItem, isSelected && styles.repeatItemSelected]}
49
- onPress={() => onSetRepeat(item)}
50
- >
51
- <Text
52
- type="Body"
53
- lineHeight={16}
54
- color={isSelected ? Colors.Orange : item.color}
55
- style={styles.repeatText}
56
- >
57
- {item.text}
58
- </Text>
59
- </TouchableOpacity>
60
- );
61
- },
62
- [onSetRepeat]
63
- );
64
-
65
- return (
66
- <View>
67
- <Text style={styles.curtainText}>{t('curtain_opens')}</Text>
68
- <TouchableOpacity onPress={onSetTimeStart}>
69
- <Text type="Body" color={Colors.Orange} style={styles.value}>
70
- 07:00 AM
71
- </Text>
72
- </TouchableOpacity>
73
- <View style={styles.boder} />
74
- <Text style={styles.curtainText}>{t('curtain_closes')}</Text>
75
- <TouchableOpacity onPress={onSetTimeEnd}>
76
- <Text type="Body" color={Colors.Orange} style={styles.value}>
77
- 12:00 AM
78
- </Text>
79
- </TouchableOpacity>
80
- <View style={styles.boder} />
81
- <Text type="Body" color={Colors.Gray8} style={styles.title}>
82
- {t('repeat')}
83
- </Text>
84
- <View style={styles.repeatWrap}>
85
- {REPEAT_ITEMS.map((item, index) =>
86
- renderRepeatItem(
87
- item,
88
- index,
89
- recurringTimeRepeat.includes(item.value)
90
- )
91
- )}
92
- </View>
93
- </View>
94
- );
95
- };
96
-
97
- export default RecurringDetail;