@eohjsc/react-native-smart-city 0.2.65 → 0.2.69

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 (70) 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/commons/Action/ItemQuickAction.js +4 -3
  7. package/src/commons/ActionGroup/CurtainButtonTemplate.js +0 -30
  8. package/src/commons/ActionGroup/CurtainButtonTemplateStyle.js +0 -12
  9. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +1 -1
  10. package/src/commons/AlertAction/index.js +4 -3
  11. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +70 -0
  12. package/src/commons/Device/HistoryChart.js +18 -18
  13. package/src/commons/Device/HorizontalBarChart.js +1 -2
  14. package/src/commons/Device/LinearChart.js +13 -3
  15. package/src/commons/SubUnit/OneTap/OneTapStyles.js +14 -5
  16. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +5 -68
  17. package/src/commons/SubUnit/OneTap/index.js +24 -33
  18. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +29 -0
  19. package/src/commons/UnitSummary/ConfigHistoryChart.js +4 -6
  20. package/src/commons/ViewButtonBottom/index.js +4 -0
  21. package/src/configs/API.js +2 -0
  22. package/src/configs/BLE.js +3 -0
  23. package/src/iot/RemoteControl/Bluetooth.js +34 -6
  24. package/src/iot/RemoteControl/__test__/Bluetooth.test.js +1 -0
  25. package/src/iot/RemoteControl/__test__/index.mock.js +1 -0
  26. package/src/iot/RemoteControl/index.js +7 -2
  27. package/src/navigations/AddDeviceStack.js +2 -0
  28. package/src/navigations/AddGatewayStack.js +11 -0
  29. package/src/navigations/AddLGDeviceStack.js +2 -0
  30. package/src/navigations/AddMemberStack.js +2 -0
  31. package/src/navigations/AddSubUnitStack.js +2 -0
  32. package/src/navigations/AddUnitStack.js +2 -0
  33. package/src/navigations/EmergencyContactsStack.js +2 -0
  34. package/src/navigations/SharedStack.js +2 -0
  35. package/src/navigations/UnitStack.js +2 -0
  36. package/src/screens/AddCommon/SelectSubUnit.js +14 -1
  37. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +190 -0
  38. package/src/screens/AddNewGateway/PlugAndPlay/FirstWarning.js +73 -0
  39. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +154 -0
  40. package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +60 -0
  41. package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +35 -0
  42. package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +90 -0
  43. package/src/screens/Device/EditDevice/index.js +3 -3
  44. package/src/screens/Device/components/SensorDisplayItem.js +4 -2
  45. package/src/screens/ScanChipQR/hooks/index.js +14 -5
  46. package/src/screens/SharedUnit/index.js +7 -5
  47. package/src/screens/Sharing/Components/SensorItem.js +27 -12
  48. package/src/screens/Sharing/Components/Styles/SensorItemStyles.js +4 -0
  49. package/src/screens/Sharing/SelectPermission.js +44 -32
  50. package/src/screens/Sharing/__test__/SelectPermission.test.js +2 -1
  51. package/src/screens/SubUnit/AddSubUnit.js +4 -24
  52. package/src/screens/TDSGuide/index.js +5 -2
  53. package/src/screens/Unit/AddMenu.js +15 -0
  54. package/src/screens/Unit/Detail.js +15 -4
  55. package/src/screens/Unit/SmartAccount.js +36 -15
  56. package/src/screens/Unit/SmartAccountStyles.js +20 -0
  57. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +10 -6
  58. package/src/screens/Unit/hook/useStateAlertRemove.js +4 -6
  59. package/src/screens/UnitSummary/components/PowerConsumption/index.js +2 -4
  60. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +10 -6
  61. package/src/utils/Apis/axios.js +2 -3
  62. package/src/utils/I18n/translations/en.json +27 -4
  63. package/src/utils/I18n/translations/vi.json +27 -4
  64. package/src/utils/Route/index.js +4 -0
  65. package/src/utils/Utils.js +0 -4
  66. package/src/commons/ActionGroup/__test__/MenuActionAddSchedule.test.js +0 -71
  67. package/src/commons/ActionGroup/hooks/AccessScheduleDetailStyles.js +0 -41
  68. package/src/commons/ActionGroup/hooks/MenuActionAddSchedule.js +0 -110
  69. package/src/commons/ActionGroup/hooks/MenuActionAddScheduleStyle.js +0 -69
  70. package/src/commons/ActionGroup/hooks/RecurringDetail.js +0 -97
@@ -2,7 +2,6 @@ import axios from 'axios';
2
2
  import { deleteData, getData, storeData } from '../Storage';
3
3
  import { ToastBottomHelper } from '../Utils';
4
4
  import NetInfo from '@react-native-community/netinfo';
5
- import { Platform } from 'react-native';
6
5
 
7
6
  export const replaceParams = (apiURL, params) => {
8
7
  let _result = apiURL;
@@ -166,9 +165,9 @@ export function createFormData(data, list_file_field) {
166
165
  }
167
166
 
168
167
  formData.append(key, {
169
- uri: Platform.OS === 'ios' ? item.sourceURL : item.path,
170
- type: item.mime,
171
168
  name: item.filename || item.path?.split('/').pop(),
169
+ type: item.mime,
170
+ uri: item.path,
172
171
  });
173
172
  return;
174
173
  }
@@ -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",
@@ -796,7 +798,7 @@
796
798
  "smart": "Smart",
797
799
  "smart_account": "Smart account",
798
800
  "delete_smart_account": "Delete smart account",
799
- "are_you_sure_want_to_delete": "Are you sure you want to delete {text} ?",
801
+ "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
802
  "multi_unit": "Multi Units",
801
803
  "edit_device": "Edit Device",
802
804
  "device_name": "Device name",
@@ -856,6 +858,21 @@
856
858
  "volume": "Volume",
857
859
  "this_notification_will_be_updated_soon": "This notification will be updated soon",
858
860
  "text_submit": "Submit",
861
+ "connecting": "Connecting",
862
+ "connect_device": "Connect Device",
863
+ "connect": "Connect",
864
+ "server_error": "Server Error",
865
+ "add_gateway_success": "Add gateway success",
866
+ "set_network": "Set network",
867
+ "select_wifi": "Select your wifi network",
868
+ "enter_wifi_password": "Enter wifi password",
869
+ "gateway_warning_content_1": "To bring you good experiences, ",
870
+ "gateway_warning_content_2": "your device needs a permanent wifi connection.",
871
+ "gateway_warning_content_3": "In the next steps, you will be instructed to connect to wifi for the device. ",
872
+ "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.",
873
+ "warning_beta_test_feature": "This feature is in beta test, not official yet",
874
+ "connecting_gateway_warning_1": "By continuing, EoH needs to connect to the device's wifi.",
875
+ "connecting_gateway_warning_2": "A message will appear asking you to connect.",
859
876
  "remove_account": "Remove Account",
860
877
  "text_sub_unit_not_have_device": "You don't have sub-unit with a device to control",
861
878
  "tap_to_add_new_schedule": "Tap + to add new schedule",
@@ -866,5 +883,11 @@
866
883
  "curtain_opens": "Curtain opens",
867
884
  "curtain_closes": "Curtain closes",
868
885
  "schedule_name": "Schedule name",
869
- "enter_name": "Enter name"
886
+ "enter_name": "Enter name",
887
+ "name_smart_account": "Smart Account",
888
+ "location_permission_required_wifi_title": "Location permission is required for WiFi connections",
889
+ "location_permission_required_wifi_message": "This app needs location permission as this is required to scan for wifi networks.",
890
+ "deny": "DENY",
891
+ "allow": "ALLOW",
892
+ "yes_remove": "Yes,remove"
870
893
  }
@@ -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",
@@ -797,7 +799,7 @@
797
799
  "smart": "Thông minh",
798
800
  "smart_account": "Tài khoản thông minh",
799
801
  "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} ?",
802
+ "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
803
  "edit_device": "Chỉnh sửa thiết bị",
802
804
  "device_name": "Tên thiết bị",
803
805
  "rename_successfully": "Đổi tên thành công!",
@@ -857,6 +859,21 @@
857
859
  "volume": "Âm lượng",
858
860
  "this_notification_will_be_updated_soon": "Thông báo này sẽ sớm được cập nhật",
859
861
  "text_submit": "Xác nhận",
862
+ "connecting": "Đang kết nối",
863
+ "connect_device": "Kết nối thiết bị",
864
+ "connect": "Kết nối",
865
+ "server_error": "Lỗi hệ thống",
866
+ "set_network": "Chọn mạng",
867
+ "select_wifi": "Chọn mạng wifi của bạn",
868
+ "enter_wifi_password": "Nhập mật khẩu wifi",
869
+ "gateway_warning_content_1": "Để mang đến cho bạn những trải nghiệm tốt, ",
870
+ "gateway_warning_content_2": "thiết bị cần kết nối wifi thường trực.",
871
+ "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ị. ",
872
+ "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.",
873
+ "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.",
874
+ "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ị.",
875
+ "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.",
876
+ "add_gateway_success": "Thêm gateway thành công",
860
877
  "tap_to_add_new_schedule": "Nhấn + để thêm lịch trình mới",
861
878
  "remove_account": "Xóa tài khoản",
862
879
  "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 +885,11 @@
868
885
  "curtain_opens": "Rèm mở",
869
886
  "curtain_closes": "Rèm đóng",
870
887
  "schedule_name": "Tên lịch trình",
871
- "enter_name": "Nhập tên"
888
+ "enter_name": "Nhập tên",
889
+ "name_smart_account": "Smart Account",
890
+ "location_permission_required_wifi_title": "Quyền vị trí là bắt buộc đối với kết nối WiFi",
891
+ "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.",
892
+ "deny": "Từ chối",
893
+ "allow": "Cho phép",
894
+ "yes_remove": "Có,loại bỏ"
872
895
  }
@@ -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;