@eohjsc/react-native-smart-city 0.2.45 → 0.2.46

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 (35) hide show
  1. package/package.json +1 -1
  2. package/src/Images/Common/logo.png +0 -0
  3. package/src/Images/Common/logo@2x.png +0 -0
  4. package/src/Images/Common/logo@3x.png +0 -0
  5. package/src/commons/SubUnit/OneTap/ItemOneTap.js +3 -1
  6. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +2 -0
  7. package/src/commons/SubUnit/ShortDetail.js +1 -1
  8. package/src/configs/Constants.js +7 -0
  9. package/src/configs/Images.js +1 -0
  10. package/src/screens/AddNewAction/SelectAction.js +52 -4
  11. package/src/screens/AddNewAction/SelectSensorDevices.js +27 -5
  12. package/src/screens/AddNewAction/SetupSensor.js +1 -6
  13. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +11 -1
  14. package/src/screens/AddNewAutoSmart/index.js +24 -13
  15. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +9 -1
  16. package/src/screens/AddNewOneTap/index.js +3 -0
  17. package/src/screens/Automate/MultiUnits.js +3 -52
  18. package/src/screens/Automate/__test__/MultiUnits.test.js +3 -246
  19. package/src/screens/Automate/__test__/index.test.js +1 -0
  20. package/src/screens/Automate/index.js +1 -0
  21. package/src/screens/Notification/components/NotificationItem.js +31 -14
  22. package/src/screens/Notification/styles/NotificationItemStyles.js +5 -0
  23. package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +12 -3
  24. package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +11 -2
  25. package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +12 -3
  26. package/src/screens/ScriptDetail/__test__/index.test.js +71 -0
  27. package/src/screens/ScriptDetail/index.js +56 -4
  28. package/src/screens/SetSchedule/__test__/index.test.js +8 -0
  29. package/src/screens/SetSchedule/index.js +28 -6
  30. package/src/screens/Sharing/Components/__test__/TitleCheckBox.test.js +38 -0
  31. package/src/screens/SyncLGDevice/AddLGDevice.js +1 -1
  32. package/src/screens/TDSGuide/index.js +15 -19
  33. package/src/utils/I18n/translations/en.json +8 -0
  34. package/src/utils/I18n/translations/vi.json +20 -12
  35. package/src/utils/Route/index.js +1 -0
@@ -43,6 +43,7 @@ import { AUTOMATE_SELECT, AUTOMATE_TYPE } from '../../configs/Constants';
43
43
  import { popAction } from '../../navigations/utils';
44
44
  import { TESTID } from '../../configs/Constants';
45
45
  import useKeyboardAnimated from '../../hooks/Explore/useKeyboardAnimated';
46
+ import { REPEAT_OPTIONS } from '../SetSchedule/components/RepeatOptionsPopup';
46
47
 
47
48
  const PreventDoubleTouch = withPreventDoubleClick(TouchableOpacity);
48
49
 
@@ -61,6 +62,7 @@ const ScriptDetail = ({ route }) => {
61
62
  const t = useTranslations();
62
63
  const {
63
64
  id,
65
+ automate = {},
64
66
  name = '',
65
67
  type,
66
68
  havePermission,
@@ -70,7 +72,6 @@ const ScriptDetail = ({ route }) => {
70
72
  isAutomateTab,
71
73
  isCreateNewAction,
72
74
  isMultiUnits,
73
- textCondition = '',
74
75
  } = params;
75
76
  const [isStar, setIsStar] = useState(false);
76
77
  const [scriptName, setScriptName] = useState(name);
@@ -214,15 +215,15 @@ const ScriptDetail = ({ route }) => {
214
215
 
215
216
  const handleUpdateAutomate = useCallback(async () => {
216
217
  navigate(Routes.AddNewAutoSmart, {
217
- type: AUTOMATE_TYPE.AUTOMATE,
218
- automateId: id,
218
+ type,
219
+ automate,
219
220
  unit,
220
221
  isAutomateTab,
221
222
  isMultiUnits,
222
223
  scriptName: name,
223
224
  });
224
225
  // eslint-disable-next-line react-hooks/exhaustive-deps
225
- }, [name]);
226
+ }, [name, automate]);
226
227
 
227
228
  const onGoBack = useCallback(() => {
228
229
  if (isCreateScriptSuccess || isCreateNewAction) {
@@ -351,6 +352,57 @@ const ScriptDetail = ({ route }) => {
351
352
  return () => backHandler.remove();
352
353
  }, [isCreateScriptSuccess]);
353
354
  const isHaveScriptActions = data?.length > 0;
355
+
356
+ const textCondition = useMemo(() => {
357
+ const {
358
+ condition,
359
+ config_name,
360
+ value,
361
+ repeat,
362
+ date_repeat,
363
+ time_repeat,
364
+ weekday_repeat,
365
+ } = automate;
366
+
367
+ if (type === AUTOMATE_TYPE.VALUE_CHANGE) {
368
+ let textCondition;
369
+ if (condition === '>') {
370
+ textCondition = 'higher_than';
371
+ } else if (condition === '<') {
372
+ textCondition = 'lower_than';
373
+ } else if (condition === '=') {
374
+ textCondition = 'equal';
375
+ }
376
+ return `${config_name} ${t(textCondition)} ${value}`;
377
+ } else if (type === AUTOMATE_TYPE.SCHEDULE) {
378
+ const time =
379
+ time_repeat.length >= 8
380
+ ? time_repeat.substring(0, time_repeat.length - 3)
381
+ : time_repeat;
382
+ const date = date_repeat.split('-').reverse().join('/');
383
+ const weekday = {
384
+ 0: t('mon'),
385
+ 1: t('tue'),
386
+ 2: t('wed'),
387
+ 3: t('thu'),
388
+ 4: t('fri'),
389
+ 5: t('sat'),
390
+ 6: t('sun'),
391
+ };
392
+
393
+ if (repeat === REPEAT_OPTIONS.ONCE) {
394
+ return `${time} ${date}`;
395
+ } else if (repeat === REPEAT_OPTIONS.EVERYDAY) {
396
+ return `${t('every_day_at', { time })}`;
397
+ } else if (repeat === REPEAT_OPTIONS.EVERYWEEK) {
398
+ const sortWeekday = weekday_repeat.sort((a, b) => a - b);
399
+ const textWeekday = sortWeekday.map((item) => weekday[item]).join(', ');
400
+ return `${textWeekday} ${t('at')} ${time}`;
401
+ }
402
+ }
403
+ return null;
404
+ }, [t, automate, type]);
405
+
354
406
  return (
355
407
  <View style={styles.wrap}>
356
408
  <WrapHeaderScrollable
@@ -162,6 +162,14 @@ describe('Test SetSchedule', () => {
162
162
  isAutomateTab: true,
163
163
  isScript: undefined,
164
164
  isMultiUnits: undefined,
165
+ automateId: undefined,
166
+ scriptName: undefined,
167
+ automate: {
168
+ date_repeat: '2021-01-24',
169
+ repeat: 'once',
170
+ time_repeat: '12:00:00',
171
+ weekday_repeat: [],
172
+ },
165
173
  });
166
174
  });
167
175
  });
@@ -28,13 +28,27 @@ const getDateString = (date) => {
28
28
 
29
29
  const SetSchedule = ({ route }) => {
30
30
  const t = useTranslations();
31
- const { type, unit, isAutomateTab, isMultiUnits, automateId, scriptName } =
32
- route.params;
31
+ const {
32
+ type,
33
+ unit,
34
+ isAutomateTab,
35
+ isMultiUnits,
36
+ automateId, // wilk=l remove later
37
+ automate = {},
38
+ scriptName,
39
+ } = route.params;
33
40
  const { navigate, dispatch, goBack } = useNavigation();
34
- const [repeat, setRepeat] = useState(REPEAT_OPTIONS.ONCE);
35
- const [time, setTime] = useState(moment().second(0));
36
- const [date, setDate] = useState(moment());
37
- const [weekday, setWeekday] = useState([]);
41
+ const [repeat, setRepeat] = useState(automate.repeat || REPEAT_OPTIONS.ONCE);
42
+
43
+ const [time, setTime] = useState(
44
+ automate.time_repeat
45
+ ? moment(automate.time_repeat, 'HH:mm:ss')
46
+ : moment().second(0)
47
+ );
48
+ const [date, setDate] = useState(
49
+ automate.date_repeat ? moment(automate.date_repeat, 'YYYY-MM-DD') : moment()
50
+ );
51
+ const [weekday, setWeekday] = useState(automate.weekday_repeat || []);
38
52
 
39
53
  const [showRepeatOptions, setShowRepeatOptions, setHideRepeatOptions] =
40
54
  useBoolean();
@@ -51,6 +65,13 @@ const SetSchedule = ({ route }) => {
51
65
  date_repeat: date.format('YYYY-MM-DD'),
52
66
  weekday_repeat: weekday,
53
67
  },
68
+ automate: {
69
+ ...automate,
70
+ repeat: repeat,
71
+ time_repeat: time.format('HH:mm:ss'),
72
+ date_repeat: date.format('YYYY-MM-DD'),
73
+ weekday_repeat: weekday,
74
+ },
54
75
  isAutomateTab,
55
76
  isMultiUnits,
56
77
  automateId,
@@ -64,6 +85,7 @@ const SetSchedule = ({ route }) => {
64
85
  time,
65
86
  date,
66
87
  weekday,
88
+ automate,
67
89
  isAutomateTab,
68
90
  isMultiUnits,
69
91
  automateId,
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import { create, act } from 'react-test-renderer';
3
+
4
+ import { SCProvider } from '../../../../context';
5
+ import { mockSCStore } from '../../../../context/mockStore';
6
+ import TitleCheckBox from '../TitleCheckBox';
7
+ import { CheckBoxCustom } from '..';
8
+
9
+ jest.mock('react', () => {
10
+ return {
11
+ ...jest.requireActual('react'),
12
+ memo: (x) => x,
13
+ };
14
+ });
15
+
16
+ const mockOnPress = jest.fn();
17
+ const wrapComponent = (idGroup, id) => (
18
+ <SCProvider initState={mockSCStore({})}>
19
+ <TitleCheckBox idGroup={idGroup} id={id} onPress={mockOnPress} />
20
+ </SCProvider>
21
+ );
22
+
23
+ describe('test TitleCheckBox', () => {
24
+ test('test handleOnPress', () => {
25
+ let tree;
26
+ act(() => {
27
+ tree = create(wrapComponent(1, 2));
28
+ });
29
+ const instance = tree.root;
30
+ const checkBoxCustom = instance.findByType(CheckBoxCustom);
31
+ act(() => {
32
+ checkBoxCustom.props.onPress();
33
+ });
34
+
35
+ expect(checkBoxCustom.props.isChecked).toBe(true);
36
+ expect(mockOnPress).toHaveBeenLastCalledWith(1, true, 2);
37
+ });
38
+ });
@@ -85,7 +85,7 @@ const AddLGDevice = memo(({ route }) => {
85
85
  color={Colors.Black}
86
86
  style={styles.txtHeader}
87
87
  >
88
- {t('add_new_device')}
88
+ {t('add_new')}
89
89
  </Text>
90
90
  <Text
91
91
  testID={TESTID.ADD_NEW_DEVICE_LG_THEN_SELECT}
@@ -1,7 +1,6 @@
1
1
  import React, { memo } from 'react';
2
- import { StyleSheet, SafeAreaView } from 'react-native';
2
+ import { StyleSheet, SafeAreaView, ScrollView } from 'react-native';
3
3
  import { useTranslations } from '../../hooks/Common/useTranslations';
4
- import i18n from 'i18n-js';
5
4
  import { TESTID } from '../../configs/Constants';
6
5
 
7
6
  import { Theme } from '../../configs';
@@ -11,23 +10,22 @@ import useTitleHeader from '../../hooks/Common/useTitleHeader';
11
10
  const TDSGuide = memo(() => {
12
11
  const t = useTranslations();
13
12
  useTitleHeader(t('tds_infomation'));
14
- const currentLanguage = i18n.currentLocale();
15
13
 
16
14
  return (
17
15
  <SafeAreaView style={styles.container}>
18
- <Text
19
- type="H3"
20
- semibold
21
- style={styles.titlePadding}
22
- testID={TESTID.TDS_GUIDE_TITLE}
23
- >
24
- {t('what_is_tds_title')}
25
- </Text>
26
- <Text type="Body">{t('what_is_tds_text')}</Text>
27
- <Text type="H3" semibold style={styles.titlePadding}>
28
- {t('tds_guidlines_title')}
29
- </Text>
30
- {currentLanguage === 'vi' ? (
16
+ <ScrollView>
17
+ <Text
18
+ type="H3"
19
+ semibold
20
+ style={styles.titlePadding}
21
+ testID={TESTID.TDS_GUIDE_TITLE}
22
+ >
23
+ {t('what_is_tds_title')}
24
+ </Text>
25
+ <Text type="Body">{t('what_is_tds_text')}</Text>
26
+ <Text type="H3" semibold style={styles.titlePadding}>
27
+ {t('tds_guidlines_title')}
28
+ </Text>
31
29
  <>
32
30
  <Text type="Body">
33
31
  {t('tds_guidlines_text_1')}
@@ -39,9 +37,7 @@ const TDSGuide = memo(() => {
39
37
  {t('tds_guidlines_text_3')}
40
38
  </Text>
41
39
  </>
42
- ) : (
43
- <Text type="Body">{t('tds_guidlines_text')}</Text>
44
- )}
40
+ </ScrollView>
45
41
  </SafeAreaView>
46
42
  );
47
43
  });
@@ -654,6 +654,7 @@
654
654
  "text_notification_content_pay_fine_successfully": "Your violation **%{booking}** has been paid successfully.",
655
655
  "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}**.",
656
656
  "text_notification_content_stop_violation_free_parking_zone": "Free parking zone. You have an unpaid violation. Please complete your fine.",
657
+ "text_notification_content_update_reminder": "You have an Update Health Value schedule need to complete.",
657
658
  "this_spot_does_not_exsit": "This spot does not exist",
658
659
  "please_scan_again_or_contact_the_parking_manager": "Please scan again or contact the parking manager",
659
660
  "this_spot_does_not_support_to_scan": "This spot does not support to scan",
@@ -812,5 +813,12 @@
812
813
  "every_day_at": "Every day at {time}",
813
814
  "you_do_not_have_the_device_or_have_share_control_device": "You do not have the device or you haven’t been shared the control for the device.",
814
815
  "error_please_try_later": "Error! Please try later",
816
+ "mon": "Mon",
817
+ "tue": "Tue",
818
+ "wed": "Wed",
819
+ "thu": "Thu",
820
+ "fri": "Fri",
821
+ "sat": "Sat",
822
+ "sun": "Sun",
815
823
  "qr_scan_guidelines": "The QR code will be detected automatically when it’s positioned within the guide lines."
816
824
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "account_logout_do_you_really_want_to_logout": "Bạn muốn đăng xuất khỏi tài khoản?",
3
- "add_new": "Thêm",
3
+ "add_new": "Thêm mới",
4
4
  "by_signing_up_you_agree_to_our_cterms_of_usec": "Bằng việc nhấn nút đăng ký, bạn đã đồng ý với các",
5
5
  "cancel": "Hủy",
6
6
  "confirm_password": "Xác nhận mật khẩu",
@@ -28,10 +28,10 @@
28
28
  "remove_device": "Xoá thiết bị",
29
29
  "activity_log": "Nhật kí hoạt động",
30
30
  "no_activity": "Không có nhật kí hoạt động",
31
- "by": "by",
31
+ "by": "bởi",
32
32
  "create_by": "Tạo bởi",
33
- "today": "Today",
34
- "yesterday": "Yesterday",
33
+ "today": "Hôm nay",
34
+ "yesterday": "Hôm qua",
35
35
  "at": "lúc",
36
36
  "video_detail": "Chi tiết Video",
37
37
  "Yesterday": "Hôm qua",
@@ -648,20 +648,21 @@
648
648
  "text_notification_title_system_cancel_emergency_situation": "Đặt chỗ bị huỷ do tình huống khẩn cấp",
649
649
  "text_notification_title_booking_successfully": "Xác nhận đặt chỗ thành công",
650
650
  "text_notification_title_parking_completed": "Hoàn tất đỗ xe",
651
- "text_notification_content_remind_to_make_payment_%{spot}_%{time}": "Đặt chỗ %{spot} chưa hoàn tất. Vui lòng thực hiện thanh toán trước %{time} để giữ đặt trước của bạn.",
652
- "text_notification_content_expire_parking_session_%{spot}_%{time}": "Phiên đỗ xe %{spot} sẽ sớm kết thúc. Vui lòng di chuyển xe trước %{time} hoặc thêm giờ đỗ xe.",
653
- "text_notification_content_remind_to_scan_qr_code_%{spot}": "Đặt chỗ %{spot} chưa được kích hoạt. Vui lòng quét mã QR tại vị trí đỗ xe được cung cấp để kích hoạt đặt chỗ trước của bạn.",
654
- "text_notification_content_user_cancel_%{spot}": "Yêu cầu huỷ đặt chỗ trước của bạn đã được chấp nhận. Đặt chỗ %{spot} đã được huỷ thành công.",
655
- "text_notification_content_system_cancel_no_payment_%{spot}": "Đặt chỗ %{spot} đã tự động huỷ bởi hệ thống không được thanh toán đúng hạn.",
651
+ "text_notification_content_remind_to_make_payment": "Đặt chỗ **%{booking}** chưa hoàn tất. Vui lòng thực hiện thanh toán trước **%{time}** để giữ đặt trước của bạn.",
652
+ "text_notification_content_expire_parking_session": "Phiên đỗ xe **%{booking}** sẽ sớm kết thúc. Vui lòng di chuyển xe trước **%{time}** hoặc thêm giờ đỗ xe.",
653
+ "text_notification_content_remind_to_scan_qr_code": "Đặt chỗ **%{booking}** chưa được kích hoạt. Vui lòng quét mã QR tại vị trí đỗ xe được cung cấp để kích hoạt đặt chỗ trước của bạn.",
654
+ "text_notification_content_user_cancel": "Yêu cầu huỷ đặt chỗ trước của bạn đã được chấp nhận. Đặt chỗ **%{booking}** đã được huỷ thành công.",
655
+ "text_notification_content_system_cancel_no_payment": "Đặt chỗ **%{booking}** đã tự động huỷ bởi hệ thống do quá hạn thanh toán.",
656
656
  "text_notification_content_system_cancel_emergency_situation_%{spot}": "Chúng tôi rất tiếc vì đặt chỗ %{spot} đã bị huỷ vì một tình huống khẩn cấp. Bạn sẽ nhận được phiếu giảm giá cho lần đỗ xe tiếp theo. ",
657
- "text_notification_content_booking_successfully_%{spot}": "Đặt chỗ %{spot} đã được xác nhận.",
658
- "text_notification_content_parking_completed_%{spot}": "Đặt chỗ %{spot} đã hoàn tất. Vui lòng giúp chúng tôi đánh giá về dịch vụ đỗ xe nhé.",
657
+ "text_notification_content_booking_successfully": "Đặt chỗ **%{booking}** đã được xác nhận.",
658
+ "text_notification_content_parking_completed": "Đặt chỗ **%{booking}** đã hoàn tất. Cảm ơn đã sử dụng dịch vụ của chúng tôi.",
659
659
  "text_notification_content_invite_member": "**%{unit_owner_name}** mời bạn đến địa điểm **%{unit_name}**.",
660
660
  "text_notification_content_not_move_car_after_parking_session_expire": "Xe của bạn (booking **%{booking}**) đã bị khóa do vi phạm quy định về giờ đỗ xe của chúng tôi. Vui lòng nộp phạt để mở khóa và di chuyển xe của bạn.",
661
661
  "text_notification_content_move_car_without_pay_violation": "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.",
662
662
  "text_notification_content_pay_fine_successfully": "Đỗ xe vi phạm **%{booking}** của bạn đã được thanh toán.",
663
663
  "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}**.",
664
664
  "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.",
665
+ "text_notification_content_update_reminder": "You have an Update Health Value schedule need to complete.",
665
666
  "this_spot_does_not_exsit": "Vị trí đỗ này không tồn tại",
666
667
  "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",
667
668
  "this_spot_does_not_support_to_scan": "Vị trí đỗ này không hỗ trợ quét",
@@ -676,8 +677,8 @@
676
677
  "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.",
677
678
  "resolve_emergency": "Xử lý tình huống khẩn cấp",
678
679
  "resolve": "Xử lý",
679
- "alert": "Cảnh báo",
680
680
  "your_account_has_not_been_authorized_to_control": "Tài khoản của bạn chưa được phân quyền để điều khiển",
681
+ "alert": "Cảnh báo",
681
682
  "take_photo": "Chụp Ảnh",
682
683
  "choose_from_library": "Chọn Ảnh từ Thư Viện",
683
684
  "setup_my_emergency_contact": "Danh sách liên hệ khẩn cấp của tôi",
@@ -813,5 +814,12 @@
813
814
  "every_day_at": "Mỗi ngày vào lúc {time}",
814
815
  "you_do_not_have_the_device_or_have_share_control_device": "Bạn không có thiết bị nào hoặc chưa được cấp quyền để điều khiển thiết bị.",
815
816
  "error_please_try_later": "Lỗi! Vui lòng thử lại sau",
817
+ "mon": "T2",
818
+ "tue": "T3",
819
+ "wed": "T4",
820
+ "thu": "T5",
821
+ "fri": "T6",
822
+ "sat": "T7",
823
+ "sun": "CN",
816
824
  "qr_scan_guidelines": "Mã QR sẽ được phát hiện tự động khi nó được định vị trong các dòng hướng dẫn."
817
825
  }
@@ -114,6 +114,7 @@ const Routes = {
114
114
  EditDevice: 'EditDevice',
115
115
  SetSchedule: 'SetSchedule',
116
116
  Notification: 'Notification',
117
+ PersonalHealthStack: 'PersonalHealthStack',
117
118
  };
118
119
 
119
120
  export default Routes;