@eohjsc/react-native-smart-city 0.2.20 → 0.2.26
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.
- package/README.md +1 -1
- package/assets/images/Add.svg +5 -0
- package/assets/images/AddLocationMaps/Point.svg +3 -0
- package/assets/images/CheckCircle.svg +4 -0
- package/assets/images/Close.svg +3 -0
- package/assets/images/HowToStart.svg +14 -0
- package/assets/images/OneTap.svg +14 -0
- package/assets/images/OneTap@1x.svg +14 -0
- package/assets/images/Rearrange.svg +3 -0
- package/assets/images/Schedule.svg +39 -0
- package/assets/images/WeatherChange.svg +49 -0
- package/package.json +12 -2
- package/src/Images/Common/ActiveButton.png +0 -0
- package/src/Images/Common/ActiveButton@2x.png +0 -0
- package/src/Images/Common/ActiveButton@3x.png +0 -0
- package/src/Images/Common/arrow-back.png +0 -0
- package/src/Images/Common/checked@2x.png +0 -0
- package/src/Images/Common/checked@3x.png +0 -0
- package/src/Images/Common/file.png +0 -0
- package/src/Images/Common/fullscreen.png +0 -0
- package/src/Images/Common/refresh.png +0 -0
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +1 -1
- package/src/commons/ActionGroup/OnOffTemplate/index.js +4 -4
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +7 -4
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +12 -3
- package/src/commons/ActionGroup/ThreeButtonTemplate.js +13 -6
- package/src/commons/ActionGroup/ThreeButtonTemplateStyle.js +1 -1
- package/src/commons/ActionGroup/TimerActionTemplate.js +158 -33
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +8 -13
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +3 -3
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +26 -45
- package/src/commons/ActionGroup/__test__/ThreeButtonTemplate.test.js +11 -5
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +14 -8
- package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +17 -23
- package/src/commons/ActionGroup/__test__/__snapshots__/ThreeButtonTemplate.test.js.snap +241 -223
- package/src/commons/ActionGroup/__test__/index.test.js +39 -107
- package/src/commons/ActionGroup/hooks/useDropdownAction.js +2 -1
- package/src/commons/ActionTemplate/ActionTemplateStyles.js +14 -0
- package/src/commons/ActionTemplate/OnOffButtonAction.js +40 -0
- package/src/commons/ActionTemplate/OnOffButtonActionStyles.js +11 -0
- package/src/commons/ActionTemplate/OneButtonAction.js +26 -0
- package/src/commons/ActionTemplate/OneButtonActionStyles.js +11 -0
- package/src/commons/ActionTemplate/ThreeButtonAction.js +55 -0
- package/src/commons/ActionTemplate/ThreeButtonActionStyles.js +11 -0
- package/src/commons/ActionTemplate/__test__/OnOffButtonAction.test.js +34 -0
- package/src/commons/ActionTemplate/__test__/OneButtonAction.test.js +33 -0
- package/src/commons/ActionTemplate/__test__/ThreeButtonAction.test.js +35 -0
- package/src/commons/ActionTemplate/__test__/index.test.js +71 -0
- package/src/commons/ActionTemplate/index.js +69 -0
- package/src/commons/Automate/ItemAddNewScriptAction.js +30 -0
- package/src/commons/Automate/ItemAddNewScriptActionStyles.js +38 -0
- package/src/commons/Automate/ItemAutomate.js +33 -0
- package/src/commons/Automate/ItemAutomateStyles.js +33 -0
- package/src/commons/Automate/ItemScriptAction.js +45 -0
- package/src/commons/Automate/ItemScriptActionStyles.js +42 -0
- package/src/commons/BottomScrollPicker/index.js +58 -0
- package/src/commons/BottomScrollPicker/styles.js +13 -0
- package/src/commons/BottomSheet/index.js +36 -0
- package/src/commons/BottomSheet/styles.js +37 -0
- package/src/commons/Button/index.js +6 -1
- package/src/commons/CameraDevice/index.js +2 -1
- package/src/commons/ChartLoading/__test__/ChartLoading.test.js +9 -7
- package/src/commons/ChartLoading/index.js +2 -1
- package/src/commons/DateTimeRangeChange/index.js +2 -1
- package/src/commons/Device/ConnectedViewHeader.js +3 -1
- package/src/commons/Device/DeviceAlertStatus.js +5 -2
- package/src/commons/Device/DisconnectedView.js +34 -26
- package/src/commons/Device/Emergency/EmergencyButton.js +2 -1
- package/src/commons/Device/Emergency/EmergencyDetail.js +2 -1
- package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +14 -6
- package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +10 -2
- package/src/commons/Device/FlatListItems.js +3 -2
- package/src/commons/Device/FooterInfo.js +2 -1
- package/src/commons/Device/HistoryChart.js +2 -1
- package/src/commons/Device/ItemAddNew/index.js +6 -1
- package/src/commons/Device/SensorConnectedStatus.js +2 -1
- package/src/commons/Device/WindDirection/Compass/Compass.test.js +19 -11
- package/src/commons/Device/WindDirection/Compass/index.js +1 -1
- package/src/commons/Device/WindSpeed/LinearChart/__test__/LinearChart.test.js +9 -3
- package/src/commons/Device/WindSpeed/LinearChart/__test__/__snapshots__/LinearChart.test.js.snap +0 -81
- package/src/commons/Device/WindSpeed/LinearChart/index.js +2 -1
- package/src/commons/Device/__test__/ConnectedViewHeader.test.js +16 -8
- package/src/commons/Device/__test__/DeviceAlertStatus.test.js +13 -5
- package/src/commons/Device/__test__/DisconnectedView.test.js +13 -5
- package/src/commons/Device/__test__/FlatListItems.test.js +9 -1
- package/src/commons/Device/__test__/FooterInfo.test.js +13 -4
- package/src/commons/Device/__test__/SensorConnectedStatus.test.js +9 -1
- package/src/commons/Device/__test__/__snapshots__/DisconnectedView.test.js.snap +20 -20
- package/src/commons/DisplayChecking/__test__/DisplayChecking.test.js +28 -0
- package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -1
- package/src/commons/EmergencyButton/AlertSent.js +3 -2
- package/src/commons/Explore/CityItem/index.js +2 -1
- package/src/commons/Explore/HeaderExplore/index.js +2 -1
- package/src/commons/Explore/HeaderLabel/index.js +2 -1
- package/src/commons/Explore/SearchBox/__test__/SearchBox.test.js +9 -2
- package/src/commons/Explore/SearchBox/index.js +2 -1
- package/src/commons/Explore/__test__/CityItem.test.js +13 -15
- package/src/commons/Explore/__test__/HeaderLabel.test.js +15 -9
- package/src/commons/Header/HeaderCustom.js +17 -1
- package/src/commons/Header/Styles/HeaderCustomStyles.js +2 -2
- package/src/commons/Header/__test__/HeaderCT.test.js +12 -4
- package/src/commons/HeaderAni/index.js +6 -3
- package/src/commons/IconComponent/index.js +18 -3
- package/src/commons/ImagePicker/__test__/ImagePicker.test.js +19 -13
- package/src/commons/ImagePicker/index.js +3 -1
- package/src/commons/MediaPlayer/index.js +2 -1
- package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +14 -8
- package/src/commons/MediaPlayerDetail/index.js +4 -1
- package/src/commons/MenuActionAddnew/__test__/MenuActionAddNew.test.js +11 -20
- package/src/commons/MenuActionAddnew/index.js +2 -1
- package/src/commons/Modal/ModalBottom.js +51 -0
- package/src/commons/Modal/ModalFullVideo.js +2 -1
- package/src/commons/Modal/Styles/ModalBottomStyles.js +35 -0
- package/src/commons/Modal/index.js +2 -1
- package/src/commons/NavBar/index.js +2 -2
- package/src/commons/SelectActionCard/SelectActionStyles.js +16 -0
- package/src/commons/SelectActionCard/index.js +30 -0
- package/src/commons/Sharing/DevicePermissionsCheckbox.js +2 -1
- package/src/commons/Sharing/MemberList.js +3 -1
- package/src/commons/Sharing/RowMember.js +3 -2
- package/src/commons/Sharing/StationDevicePermissions.js +2 -1
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +15 -9
- package/src/commons/Sharing/__test__/MemberList.test.js +17 -25
- package/src/commons/Sharing/__test__/StationDevicePermission.test.js +17 -12
- package/src/commons/Sharing/__test__/WrapHeaderScrollable.test.js +0 -9
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +97 -0
- package/src/commons/SubUnit/OneTap/ItemOneTapStyles.js +41 -0
- package/src/commons/SubUnit/OneTap/OneTapStyles.js +36 -0
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +149 -0
- package/src/commons/SubUnit/OneTap/index.js +39 -0
- package/src/commons/SubUnit/ShortDetail.js +11 -6
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +14 -6
- package/src/commons/Today/__test__/Today.test.js +9 -1
- package/src/commons/Today/__test__/__snapshots__/Today.test.js.snap +1 -1
- package/src/commons/Today/index.js +2 -1
- package/src/commons/Unit/SharedUnit.js +2 -1
- package/src/commons/UnitSummary/AirQuality/SegmentedRoundDisplay/index.js +1 -2
- package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +16 -17
- package/src/commons/UnitSummary/AirQuality/index.js +5 -120
- package/src/commons/UnitSummary/AirQuality/styles.js +112 -0
- package/src/commons/UnitSummary/TotalPowerConsumption/index.js +2 -1
- package/src/commons/UnitSummary/__test__/TotalPowerConsumption.test.js +15 -9
- package/src/commons/WheelDateTimePicker/Picker.js +57 -0
- package/src/commons/WheelDateTimePicker/index.js +160 -0
- package/src/commons/WheelDateTimePicker/styles.js +21 -0
- package/src/configs/API.js +25 -0
- package/src/configs/Colors.js +1 -0
- package/src/configs/Constants.js +46 -0
- package/src/configs/Images.js +1 -0
- package/src/configs/SCConfig.js +7 -0
- package/src/context/SCContext.tsx +7 -37
- package/src/context/actionType.ts +11 -0
- package/src/context/mockStore.ts +49 -0
- package/src/context/reducer.ts +23 -0
- package/src/hooks/Common/__test__/useTranslations.test.js +23 -0
- package/src/hooks/Common/index.js +2 -0
- package/src/hooks/Common/useGetIdUser.js +9 -0
- package/src/hooks/Common/useTranslations.ts +34 -0
- package/src/iot/Monitor.js +2 -1
- package/src/iot/RemoteControl/Bluetooth.js +2 -6
- package/src/iot/RemoteControl/GoogleHome.js +1 -1
- package/src/iot/RemoteControl/Internet.js +1 -1
- package/src/iot/RemoteControl/LG.js +57 -15
- package/src/iot/RemoteControl/__test__/Bluetooth.test.js +3 -5
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +3 -3
- package/src/iot/RemoteControl/__test__/Internet.test.js +1 -8
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +7 -10
- package/src/iot/RemoteControl/index.js +1 -1
- package/src/iot/states.js +1 -0
- package/src/navigations/SharedStack.js +2 -1
- package/src/navigations/UnitStack.js +62 -1
- package/src/screens/AQIGuide/__test__/AQIGuide.test.js +9 -1
- package/src/screens/AQIGuide/index.js +2 -2
- package/src/screens/ActivityLog/__test__/index.test.js +14 -39
- package/src/screens/ActivityLog/index.js +2 -1
- package/src/screens/AddCommon/SelectSubUnit.js +5 -4
- package/src/screens/AddCommon/SelectUnit.js +3 -2
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +61 -0
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +18 -10
- package/src/screens/AddLocationMaps/index.js +2 -1
- package/src/screens/AddNewAction/Device/DeviceStyles.js +43 -0
- package/src/screens/AddNewAction/Device/__test__/index.test.js +42 -0
- package/src/screens/AddNewAction/Device/index.js +33 -0
- package/src/screens/AddNewAction/SelectAction.js +152 -0
- package/src/screens/AddNewAction/SelectDevice.js +120 -0
- package/src/screens/AddNewAction/Styles/SelectActionStyles.js +24 -0
- package/src/screens/AddNewAction/Styles/SelectDeviceStyles.js +36 -0
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +172 -0
- package/src/screens/AddNewAction/__test__/SelectDevice.test.js +191 -0
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +55 -0
- package/src/screens/AddNewAutoSmart/index.js +85 -0
- package/src/screens/AddNewAutoSmart/styles/AddNewAutoSmartStyles.js +36 -0
- package/src/screens/AddNewDevice/ConnectDevices.js +2 -1
- package/src/screens/AddNewDevice/ConnectingDevices.js +2 -1
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +29 -13
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +19 -7
- package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +16 -6
- package/src/screens/AddNewDevice/hooks/useStateAlertRename.js +2 -1
- package/src/screens/AddNewDevice/index.js +2 -1
- package/src/screens/AddNewGateway/ConnectedGateway.js +2 -1
- package/src/screens/AddNewGateway/ConnectingGateway.js +99 -24
- package/src/screens/AddNewGateway/ConnectingGatewayStyles.js +92 -0
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +3 -2
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +35 -72
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +14 -4
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +20 -10
- package/src/screens/AddNewGateway/hooks/useStateAlertRename.js +2 -1
- package/src/screens/AddNewGateway/index.js +2 -1
- package/src/screens/AddNewOneTap/AddNewOneTapStyles.js +43 -0
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +129 -0
- package/src/screens/AddNewOneTap/index.js +80 -0
- package/src/screens/AddNewScriptAction/AddNewScriptActionStyles.js +28 -0
- package/src/screens/AddNewScriptAction/index.js +100 -0
- package/src/screens/AllCamera/index.js +2 -1
- package/src/screens/Device/HeaderDevice/styles.js +2 -2
- package/src/screens/Device/__test__/detail.test.js +26 -18
- package/src/screens/Device/detail.js +56 -28
- package/src/screens/Device/hooks/useCountUp.js +4 -0
- package/src/screens/Device/hooks/useEmergencyButton.js +3 -2
- package/src/screens/Device/styles.js +5 -1
- package/src/screens/DeviceInfo/__test__/index.test.js +12 -3
- package/src/screens/DeviceInfo/index.js +2 -1
- package/src/screens/EditActionsList/Styles/indexStyles.js +84 -0
- package/src/screens/EditActionsList/index.js +186 -0
- package/src/screens/EmergencyContacts/EmergencyContactsAddNew.js +3 -2
- package/src/screens/EmergencyContacts/EmergencyContactsList.js +9 -2
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +2 -1
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +15 -18
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +19 -23
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +10 -25
- package/src/screens/EmergencyContacts/hook.js +3 -2
- package/src/screens/Explore/index.js +3 -2
- package/src/screens/GuestInfo/components/AccessScheduleItem.js +27 -0
- package/src/screens/GuestInfo/components/AccessScheduleSheet.js +193 -0
- package/src/screens/GuestInfo/components/HeaderGuestInfo.js +31 -0
- package/src/screens/GuestInfo/components/RecurringDetail.js +99 -0
- package/src/screens/GuestInfo/components/RowGuestInfo.js +31 -0
- package/src/screens/GuestInfo/components/TemporaryDetail.js +46 -0
- package/src/screens/GuestInfo/constant.js +59 -0
- package/src/screens/GuestInfo/index.js +151 -0
- package/src/screens/GuestInfo/styles/AccessScheduleDetailStyles.js +31 -0
- package/src/screens/GuestInfo/styles/AccessScheduleItemStyles.js +22 -0
- package/src/screens/GuestInfo/styles/HeaderGuestInfoStyles.js +31 -0
- package/src/screens/GuestInfo/styles/indexStyles.js +38 -0
- package/src/screens/ManageAccess/__test__/ManageAccess.test.js +13 -1
- package/src/screens/ManageAccess/hooks/index.js +4 -0
- package/src/screens/ManageAccess/index.js +49 -20
- package/src/screens/ManageAccess/styles/ManageAccessStyles.js +3 -0
- package/src/screens/PlayBackCamera/index.js +9 -5
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +2 -11
- package/src/screens/ScanChipQR/components/QRScan/index.js +2 -1
- package/src/screens/ScriptDetail/Styles/indexStyles.js +143 -0
- package/src/screens/ScriptDetail/index.js +243 -0
- package/src/screens/SharedUnit/TabHeader.js +2 -1
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +40 -0
- package/src/screens/SharedUnit/index.js +3 -2
- package/src/screens/Sharing/MemberList.js +2 -1
- package/src/screens/Sharing/SelectPermission.js +2 -1
- package/src/screens/Sharing/SelectUser.js +3 -2
- package/src/screens/Sharing/__test__/MemberList.test.js +17 -13
- package/src/screens/Sharing/__test__/SelectPermission.test.js +16 -8
- package/src/screens/Sharing/__test__/SelectUser.test.js +33 -15
- package/src/screens/Sharing/hooks/index.js +22 -17
- package/src/screens/SubUnit/AddSubUnit.js +3 -2
- package/src/screens/SubUnit/Detail.js +5 -4
- package/src/screens/SubUnit/ManageSubUnit.js +10 -9
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +17 -11
- package/src/screens/SubUnit/__test__/Detail.test.js +11 -31
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +42 -31
- package/src/screens/SyncLGDevice/AddLGDevice.js +3 -2
- package/src/screens/TDSGuide/__test__/TDSGuide.test.js +9 -1
- package/src/screens/TDSGuide/index.js +2 -1
- package/src/screens/UVIndexGuide/__test__/UVIndexGuide.test.js +9 -1
- package/src/screens/UVIndexGuide/index.js +2 -1
- package/src/screens/Unit/AddMenu.js +3 -2
- package/src/screens/Unit/Detail.js +65 -20
- package/src/screens/Unit/ManageUnit/index.js +4 -3
- package/src/screens/Unit/ManageUnit.js +5 -4
- package/src/screens/Unit/MoreMenu.js +3 -2
- package/src/screens/Unit/SelectLocation.js +8 -2
- package/src/screens/Unit/SelectLocationStyles.js +11 -0
- package/src/screens/Unit/__test__/AddMenu.test.js +15 -15
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +19 -10
- package/src/screens/Unit/__test__/Detail.test.js +92 -33
- package/src/screens/Unit/__test__/ManageUnit.test.js +16 -23
- package/src/screens/Unit/components/Header/index.js +2 -1
- package/src/screens/Unit/components/ListMyAllUnit/index.js +2 -1
- package/src/screens/Unit/components/MyUnit/index.js +2 -1
- package/src/screens/Unit/components/SearchLocation/index.js +2 -1
- package/src/screens/Unit/components/SharedUnit/index.js +2 -1
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +11 -2
- package/src/screens/UnitSummary/__test__/index.test.js +12 -4
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +13 -3
- package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +2 -1
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +16 -12
- package/src/screens/UnitSummary/components/PowerConsumption/index.js +2 -1
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -2
- package/src/screens/UnitSummary/components/Temperature/index.js +2 -1
- package/src/screens/UnitSummary/components/TotalPowerConsumption/index.js +2 -1
- package/src/screens/UnitSummary/components/UvIndex/__test__/__snapshots__/index.test.js.snap +37 -37
- package/src/screens/UnitSummary/components/UvIndex/__test__/index.test.js +14 -6
- package/src/screens/UnitSummary/components/UvIndex/index.js +2 -1
- package/src/screens/UnitSummary/components/WaterQuality/__test__/index.test.js +11 -5
- package/src/screens/UnitSummary/components/WaterQuality/index.js +2 -1
- package/src/screens/UnitSummary/components/__test__/TotalPowerConsumption.test.js +13 -7
- package/src/screens/UnitSummary/index.js +2 -1
- package/src/screens/WaterQualityGuide/__test__/index.test.js +12 -12
- package/src/screens/WaterQualityGuide/index.js +2 -1
- package/src/utils/Converter/array.js +4 -0
- package/src/utils/Converter/time.js +29 -4
- package/src/utils/I18n/index.ts +6 -0
- package/src/utils/I18n/translations/en.json +48 -2
- package/src/utils/I18n/translations/vi.json +45 -1
- package/src/utils/I18n/translations.ts +45 -0
- package/src/utils/Route/index.js +8 -0
- package/src/commons/ChartLoading/__test__/__snapshots__/ChartLoading.test.js.snap +0 -66
- package/src/commons/Device/HistoryChart/__test__/HistoryChart.test.js +0 -57
- package/src/commons/Device/HistoryChart/__test__/__snapshots__/HistoryChart.test.js.snap +0 -593
- package/src/commons/Explore/SearchBox/__test__/__snapshots__/SearchBox.test.js.snap +0 -59
- package/src/commons/Explore/__test__/HeaderExplore.test.js +0 -21
- package/src/commons/Header/__test__/Header.test.js +0 -24
- package/src/commons/MenuActionAddnew/__test__/__snapshots__/MenuActionAddNew.test.js.snap +0 -788
- package/src/commons/Sharing/__test__/__snapshots__/WrapHeaderScrollable.test.js.snap +0 -174
- package/src/commons/UnitSummary/AirQuality/__test__/__snapshots__/index.test.js.snap +0 -26679
- package/src/iot/RemoteControl/__test__/index.test.js +0 -101
- package/src/iot/__test__/Monitor.test.js +0 -119
- package/src/screens/EmergencyContacts/__test__/__snapshots__/EmergencyContactAddNew.test.js.snap +0 -1706
- package/src/screens/EmergencyContacts/__test__/__snapshots__/EmergencyContactList.test.js.snap +0 -4276
- package/src/screens/EmergencyContacts/__test__/__snapshots__/EmergencyContactsSelectContacts.test.js.snap +0 -2240
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +0 -358
- package/src/screens/Unit/MyAllUnit/__test__/__snapshots__/index.test.js.snap +0 -1001
- package/src/screens/Unit/MyAllUnit/__test__/index.test.js +0 -48
- package/src/screens/Unit/components/MyAllUnit/__test__/__snapshots__/index.test.js.snap +0 -1001
- package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -48
- package/src/screens/Unit/components/__test__/MyUnit.test.js +0 -85
- package/src/screens/UnitSummary/components/WaterQuality/__test__/__snapshots__/index.test.js.snap +0 -1574
- package/src/screens/WaterQualityGuide/__test__/__snapshots__/index.test.js.snap +0 -3375
- package/src/utils/Converter/__test__/time.test.js +0 -126
- package/src/utils/I18n/index.js +0 -19
- package/src/utils/I18n/index.test.js +0 -7
package/src/configs/API.js
CHANGED
|
@@ -24,6 +24,10 @@ const API = {
|
|
|
24
24
|
SCConfig.apiRoot + `/property_manager/units/${id}/chip_scan/`,
|
|
25
25
|
MANAGE_ACCESS: (id) =>
|
|
26
26
|
SCConfig.apiRoot + `/property_manager/manage_access/${id}/`,
|
|
27
|
+
AUTOMATE: (id) =>
|
|
28
|
+
SCConfig.apiRoot + `/property_manager/units/${id}/automate/`,
|
|
29
|
+
DEVICE_CONTROL: (id) =>
|
|
30
|
+
SCConfig.apiRoot + `/property_manager/units/${id}/device_control/`,
|
|
27
31
|
},
|
|
28
32
|
SUB_UNIT: {
|
|
29
33
|
REMOVE_SUB_UNIT: (unitId, id) =>
|
|
@@ -67,11 +71,32 @@ const API = {
|
|
|
67
71
|
REMOVE_FROM_FAVOURITES: (unit_id, station_id, id) =>
|
|
68
72
|
SCConfig.apiRoot +
|
|
69
73
|
`/property_manager/${unit_id}/sub_units/${station_id}/devices/${id}/remove_from_favourites/`,
|
|
74
|
+
DISPLAY_ACTIONS: (id) =>
|
|
75
|
+
SCConfig.apiRoot + `/property_manager/sensors/${id}/display_actions/`,
|
|
76
|
+
},
|
|
77
|
+
SHARED_SENSOR: {
|
|
78
|
+
ACCESS: (id) =>
|
|
79
|
+
SCConfig.apiRoot + `/property_manager/shared_sensors/${id}/access/`,
|
|
70
80
|
},
|
|
71
81
|
CONFIG: {
|
|
72
82
|
DISPLAY_HISTORY: () =>
|
|
73
83
|
SCConfig.apiRoot + '/property_manager/configs/display_history/',
|
|
74
84
|
},
|
|
85
|
+
AUTOMATE: {
|
|
86
|
+
ACTION_ONE_TAP: (id) =>
|
|
87
|
+
SCConfig.apiRoot + `/property_manager/automate/${id}/action_one_tap/`,
|
|
88
|
+
ONE_TAP_DETAIL: (id) =>
|
|
89
|
+
SCConfig.apiRoot + `/property_manager/automate/${id}/script/`,
|
|
90
|
+
ORDER_SCRIPT_ACTION: (id) =>
|
|
91
|
+
SCConfig.apiRoot +
|
|
92
|
+
`/property_manager/automate/${id}/order_script_action/`,
|
|
93
|
+
DELETE_SCRIPT_ACTION: (automateId, actionId) =>
|
|
94
|
+
SCConfig.apiRoot +
|
|
95
|
+
`/property_manager/automate/${automateId}/script_action/${actionId}/`,
|
|
96
|
+
ADD_SCRIPT_ACTION: (id) =>
|
|
97
|
+
SCConfig.apiRoot + `/property_manager/automate/${id}/add_script_action/`,
|
|
98
|
+
CREATE_AUTOMATE: () => SCConfig.apiRoot + '/property_manager/automate/',
|
|
99
|
+
},
|
|
75
100
|
GOOGLE_HOME: {
|
|
76
101
|
CHECK_SEND_EMAIL: () =>
|
|
77
102
|
SCConfig.apiRoot + '/connection_manager/googlehome/check_send_email/',
|
package/src/configs/Colors.js
CHANGED
package/src/configs/Constants.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Platform, Dimensions, StatusBar } from 'react-native';
|
|
2
2
|
import { RFValue } from 'react-native-responsive-fontsize';
|
|
3
|
+
import OneTap from '../../assets/images/OneTap.svg';
|
|
4
|
+
import WeatherChange from '../../assets/images/WeatherChange.svg';
|
|
5
|
+
import Schedule from '../../assets/images/Schedule.svg';
|
|
3
6
|
|
|
4
7
|
const X_WIDTH = 375;
|
|
5
8
|
const X_HEIGHT = 812;
|
|
@@ -67,6 +70,10 @@ export const Constants = {
|
|
|
67
70
|
DEEP_LINK,
|
|
68
71
|
};
|
|
69
72
|
|
|
73
|
+
export const DEVICE_TYPE = {
|
|
74
|
+
LG_THINQ: 'LG_THINQ',
|
|
75
|
+
};
|
|
76
|
+
|
|
70
77
|
export const SCANNING_STATUS = {
|
|
71
78
|
BOOKING_ACTIVATED: 'booking_activated',
|
|
72
79
|
WRONG_SPOT: 'wrong_spot',
|
|
@@ -76,6 +83,37 @@ export const SCANNING_STATUS = {
|
|
|
76
83
|
SPOT_DOES_NOT_EXIST: 'spot_does_not_exist',
|
|
77
84
|
};
|
|
78
85
|
|
|
86
|
+
export const SubUnitName = {
|
|
87
|
+
scenario: 'Kịch Bản',
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const AUTOMATE_TYPE = {
|
|
91
|
+
ONE_TAP: 'one_tap',
|
|
92
|
+
VALUE_CHANGE: 'value_change',
|
|
93
|
+
SCHEDULE: 'schedule',
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const AUTOMATES = {
|
|
97
|
+
one_tap: {
|
|
98
|
+
value: AUTOMATE_TYPE.ONE_TAP,
|
|
99
|
+
title: 'Launch One-Tap',
|
|
100
|
+
explanation: 'Do everything with just one button',
|
|
101
|
+
icon: OneTap,
|
|
102
|
+
},
|
|
103
|
+
value_change: {
|
|
104
|
+
value: AUTOMATE_TYPE.VALUE_CHANGE,
|
|
105
|
+
title: 'When weather change',
|
|
106
|
+
explanation: 'Short Explanation',
|
|
107
|
+
icon: WeatherChange,
|
|
108
|
+
},
|
|
109
|
+
schedule: {
|
|
110
|
+
value: AUTOMATE_TYPE.SCHEDULE,
|
|
111
|
+
title: 'Schedule',
|
|
112
|
+
explanation: 'Short Explanation',
|
|
113
|
+
icon: Schedule,
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
|
|
79
117
|
export const TESTID = {
|
|
80
118
|
// Dashboard
|
|
81
119
|
DASHBOARD_TAB_HOME: 'DASHBOARD_TAB_HOME',
|
|
@@ -115,6 +153,7 @@ export const TESTID = {
|
|
|
115
153
|
MY_UNIT_NO_UNIT: 'MY_UNIT_NO_UNIT',
|
|
116
154
|
|
|
117
155
|
// sub unit
|
|
156
|
+
SUB_UNIT_FULL_CAMERA: 'SUB_UNIT_FULL_CAMERA',
|
|
118
157
|
SUB_UNIT_CAMERA_VIEW: 'SUB_UNIT_CAMERA_VIEW',
|
|
119
158
|
SUB_UNIT_BACKGROUND: 'SUB_UNIT_BACKGROUND',
|
|
120
159
|
SUB_UNIT_GO_TO_DETAIL: 'SUB_UNIT_GO_TO_DETAIL',
|
|
@@ -216,6 +255,11 @@ export const TESTID = {
|
|
|
216
255
|
ITEM_TEXT_INPUT: 'ITEM_TEXT_INPUT',
|
|
217
256
|
ITEM_TEXT_ERROR: 'ITEM_TEXT_ERROR',
|
|
218
257
|
SEARCH_BAR_INPUT: 'SEARCH_BAR_INPUT',
|
|
258
|
+
GO_DETAIL: 'GO_DETAIL',
|
|
259
|
+
|
|
260
|
+
// Automate
|
|
261
|
+
AUTOMATE_SCRIPT_ACTION: 'AUTOMATE_SCRIPT_ACTION',
|
|
262
|
+
NAME_YOUR_BUTTON: 'NAME_YOUR_BUTTON',
|
|
219
263
|
|
|
220
264
|
// Parking input maunaly spot
|
|
221
265
|
PARKING_SPOT_INFO_BUTTON: 'PARKING_SPOT_INFO_BUTTON',
|
|
@@ -259,6 +303,7 @@ export const TESTID = {
|
|
|
259
303
|
SENSOR_DISPLAY_ITEM: 'SENSOR_DISPLAY_ITEM',
|
|
260
304
|
ITEM_QUICK_ACTION_PRESS: 'ITEM_QUICK_ACTION_PRESS',
|
|
261
305
|
TIME_COUNT_DOWN_TEXT: 'TIME_COUNT_DOWN_TEXT',
|
|
306
|
+
ACTION_ITEM: 'ACTION_ITEM',
|
|
262
307
|
|
|
263
308
|
// DeviceInfo
|
|
264
309
|
DEVICE_INFO_BATTERY: 'DEVICE_INFO_BATTERY',
|
|
@@ -389,6 +434,7 @@ export const TESTID = {
|
|
|
389
434
|
MANAGE_UNIT: 'MANAGE_UNIT',
|
|
390
435
|
MANAGE_UNIT_ALERT: 'MANAGE_UNIT_ALERT',
|
|
391
436
|
SELECT_UNIT: 'SELECT_UNIT',
|
|
437
|
+
BUTTON_ADD_AUTO_SMART: 'BUTTON_ADD_AUTO_SMART',
|
|
392
438
|
},
|
|
393
439
|
|
|
394
440
|
TERM_AND_POLICY_TITLE: 'TERM_AND_POLICY_TITLE',
|
package/src/configs/Images.js
CHANGED
package/src/configs/SCConfig.js
CHANGED
|
@@ -90,6 +90,8 @@ const SCDefaultConfig = {
|
|
|
90
90
|
LG_CLIENT_ID: '2b85aee334f046848341547894bb7c4e',
|
|
91
91
|
LG_REDIRECT_URI_APP: 'app://eoh/sync-lg-device',
|
|
92
92
|
LG_URL: 'https://qt-vn.m.lgaccount.com/emp/v2',
|
|
93
|
+
pusherAppKey: '9a591ae4a764acc08714',
|
|
94
|
+
pusherAppCluster: 'ap1',
|
|
93
95
|
};
|
|
94
96
|
|
|
95
97
|
export class SCConfig {
|
|
@@ -98,6 +100,8 @@ export class SCConfig {
|
|
|
98
100
|
static LG_CLIENT_ID = SCDefaultConfig.LG_CLIENT_ID;
|
|
99
101
|
static LG_REDIRECT_URI_APP = SCDefaultConfig.LG_REDIRECT_URI_APP;
|
|
100
102
|
static LG_URL = SCDefaultConfig.LG_URL;
|
|
103
|
+
static pusherAppKey = SCDefaultConfig.pusherAppKey;
|
|
104
|
+
static pusherAppCluste = SCDefaultConfig.pusherAppCluster;
|
|
101
105
|
}
|
|
102
106
|
|
|
103
107
|
export const initSCConfig = (config) => {
|
|
@@ -109,4 +113,7 @@ export const initSCConfig = (config) => {
|
|
|
109
113
|
SCConfig.LG_REDIRECT_URI_APP =
|
|
110
114
|
config.LG_REDIRECT_URI_APP ?? SCDefaultConfig.LG_REDIRECT_URI_APP;
|
|
111
115
|
SCConfig.LG_URL = config.LG_URL ?? SCDefaultConfig.LG_URL;
|
|
116
|
+
SCConfig.pusherAppKey = config.pusherAppKey ?? SCDefaultConfig.pusherAppKey;
|
|
117
|
+
SCConfig.pusherAppCluster =
|
|
118
|
+
config.pusherAppCluster ?? SCDefaultConfig.pusherAppCluster;
|
|
112
119
|
};
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import React, { useContext, useReducer } from 'react';
|
|
2
|
-
import { StyleSheet, View, Text } from 'react-native';
|
|
3
|
-
import Toast from 'react-native-toast-message';
|
|
4
2
|
|
|
5
|
-
import { Alert } from '../commons';
|
|
6
|
-
import { Colors } from '../configs';
|
|
7
|
-
import { setLanguage, updateTranslation } from '../utils/I18n';
|
|
8
3
|
import {
|
|
9
4
|
ActionDataMap,
|
|
10
5
|
ActionType,
|
|
@@ -13,22 +8,13 @@ import {
|
|
|
13
8
|
StatusBar,
|
|
14
9
|
} from './actionType';
|
|
15
10
|
import { initialState, Action, ContextData, reducer } from './reducer';
|
|
16
|
-
|
|
17
|
-
const toastConfig = {
|
|
18
|
-
// only for error for now
|
|
19
|
-
error: (internalState) => (
|
|
20
|
-
<View style={styles.toastContainer}>
|
|
21
|
-
<Text style={styles.textWhite}>{internalState.text1}</Text>
|
|
22
|
-
</View>
|
|
23
|
-
),
|
|
24
|
-
};
|
|
11
|
+
import { setConfigGlobalState } from '../iot/states.js';
|
|
25
12
|
|
|
26
13
|
type SCContextType = {
|
|
27
14
|
stateData: ContextData;
|
|
28
15
|
setAuth: (authData: AuthData) => void;
|
|
29
16
|
setLocale: (language: Language) => void;
|
|
30
17
|
setStatusBar: (statusBar: StatusBar) => void;
|
|
31
|
-
updateLocale: (langTranslate: any) => void;
|
|
32
18
|
setAction: <T extends ActionType>(
|
|
33
19
|
action: T,
|
|
34
20
|
payload?: ActionDataMap[T]
|
|
@@ -53,17 +39,13 @@ export const SCProvider = ({ children }) => {
|
|
|
53
39
|
setAction('UPDATE_AUTH', authData);
|
|
54
40
|
};
|
|
55
41
|
|
|
56
|
-
const setLocale = (language: Language) => {
|
|
57
|
-
setLanguage(language);
|
|
58
|
-
setAction('UPDATE_LANGUAGE', language);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
42
|
const setStatusBar = (statusBar: StatusBar) => {
|
|
62
43
|
setAction('STORE_STATUS_BAR', statusBar);
|
|
63
44
|
};
|
|
64
45
|
|
|
65
|
-
const
|
|
66
|
-
|
|
46
|
+
const setLocale = (language: Language) => {
|
|
47
|
+
setConfigGlobalState('lang', language);
|
|
48
|
+
setAction('UPDATE_LANGUAGE', language);
|
|
67
49
|
};
|
|
68
50
|
|
|
69
51
|
const setAction = <T extends ActionType>(
|
|
@@ -76,17 +58,16 @@ export const SCProvider = ({ children }) => {
|
|
|
76
58
|
const providerValue = {
|
|
77
59
|
stateData,
|
|
78
60
|
setAuth,
|
|
79
|
-
setLocale,
|
|
80
61
|
setAction,
|
|
62
|
+
setLocale,
|
|
81
63
|
setStatusBar,
|
|
82
|
-
updateLocale,
|
|
83
64
|
};
|
|
84
65
|
|
|
85
66
|
return (
|
|
86
67
|
<SCContext.Provider value={providerValue}>
|
|
87
68
|
{children}
|
|
88
|
-
<Alert ref={(ref) => Alert.setRef(ref)} />
|
|
89
|
-
<Toast config={toastConfig} ref={(ref) => Toast.setRef(ref)} />
|
|
69
|
+
{/* <Alert ref={(ref) => Alert.setRef(ref)} />
|
|
70
|
+
<Toast config={toastConfig} ref={(ref) => Toast.setRef(ref)} /> */}
|
|
90
71
|
</SCContext.Provider>
|
|
91
72
|
);
|
|
92
73
|
};
|
|
@@ -97,14 +78,3 @@ export const useSCContextSelector = (
|
|
|
97
78
|
const { stateData } = useContext(SCContext);
|
|
98
79
|
return selector(stateData);
|
|
99
80
|
};
|
|
100
|
-
|
|
101
|
-
const styles = StyleSheet.create({
|
|
102
|
-
toastContainer: {
|
|
103
|
-
borderRadius: 5,
|
|
104
|
-
padding: 10,
|
|
105
|
-
backgroundColor: Colors.Black,
|
|
106
|
-
},
|
|
107
|
-
textWhite: {
|
|
108
|
-
color: Colors.White,
|
|
109
|
-
},
|
|
110
|
-
});
|
|
@@ -3,6 +3,7 @@ export const Action = {
|
|
|
3
3
|
UPDATE_LANGUAGE: 'UPDATE_LANGUAGE',
|
|
4
4
|
STORE_STATUS_BAR: 'STORE_STATUS_BAR',
|
|
5
5
|
LIST_DEVICE_TYPES: 'LIST_DEVICE_TYPES',
|
|
6
|
+
LIST_ACTION: 'LIST_ACTION',
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
export type AuthData = {
|
|
@@ -25,6 +26,15 @@ export type ListDevice = {
|
|
|
25
26
|
sentEmail: boolean;
|
|
26
27
|
};
|
|
27
28
|
|
|
29
|
+
export type ListAction = {
|
|
30
|
+
action: string;
|
|
31
|
+
unit_name: string;
|
|
32
|
+
action_name: string;
|
|
33
|
+
sensor_name: string;
|
|
34
|
+
sensor_icon_kit: string;
|
|
35
|
+
station_name: string;
|
|
36
|
+
}[];
|
|
37
|
+
|
|
28
38
|
export type ActionType = keyof typeof Action;
|
|
29
39
|
|
|
30
40
|
export type ActionDataMap = {
|
|
@@ -32,4 +42,5 @@ export type ActionDataMap = {
|
|
|
32
42
|
UPDATE_LANGUAGE: Language;
|
|
33
43
|
STORE_STATUS_BAR: StatusBar;
|
|
34
44
|
LIST_DEVICE_TYPES: ListDevice;
|
|
45
|
+
LIST_ACTION: ListAction;
|
|
35
46
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ContextData } from './reducer';
|
|
2
|
+
|
|
3
|
+
export const mockDataStore: ContextData = {
|
|
4
|
+
auth: {
|
|
5
|
+
account: {
|
|
6
|
+
token: 'TOKEN',
|
|
7
|
+
user: {
|
|
8
|
+
avatar: null,
|
|
9
|
+
email: 'test@gmail.com',
|
|
10
|
+
id: 1,
|
|
11
|
+
is_using_social_avatar: false,
|
|
12
|
+
name: 'TEST',
|
|
13
|
+
org: 2,
|
|
14
|
+
phone_number: '012345678',
|
|
15
|
+
social_avatar_hash: '',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
language: 'vi',
|
|
20
|
+
listDevice: {
|
|
21
|
+
sentEmail: false,
|
|
22
|
+
},
|
|
23
|
+
statusBar: {
|
|
24
|
+
backgroundColor: '',
|
|
25
|
+
barStyle: '',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const mockSCStore = (data: ContextData): ContextData => {
|
|
30
|
+
return {
|
|
31
|
+
auth: {
|
|
32
|
+
account: {
|
|
33
|
+
...mockDataStore.auth.account,
|
|
34
|
+
...data.auth?.account,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
language: data.language ? data.language : mockDataStore.language,
|
|
38
|
+
listDevice: {
|
|
39
|
+
...mockDataStore.listDevice,
|
|
40
|
+
...data.listDevice,
|
|
41
|
+
},
|
|
42
|
+
statusBar: {
|
|
43
|
+
backgroundColor:
|
|
44
|
+
data?.statusBar?.backgroundColor ||
|
|
45
|
+
mockDataStore?.statusBar?.backgroundColor,
|
|
46
|
+
barStyle: data?.statusBar?.barStyle || mockDataStore?.statusBar?.barStyle,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
};
|
package/src/context/reducer.ts
CHANGED
|
@@ -6,12 +6,15 @@ import {
|
|
|
6
6
|
StatusBar,
|
|
7
7
|
Action,
|
|
8
8
|
ListDevice,
|
|
9
|
+
ListAction,
|
|
9
10
|
} from './actionType';
|
|
10
11
|
|
|
11
12
|
export type ContextData = {
|
|
12
13
|
auth: AuthData;
|
|
13
14
|
language: Language;
|
|
14
15
|
listDevice: ListDevice;
|
|
16
|
+
listAction: ListAction;
|
|
17
|
+
statusBar: StatusBar;
|
|
15
18
|
};
|
|
16
19
|
|
|
17
20
|
export type Action = {
|
|
@@ -31,6 +34,7 @@ export const initialState = {
|
|
|
31
34
|
language: 'en' as Language,
|
|
32
35
|
statusBar: {} as StatusBar,
|
|
33
36
|
listDevice: {} as ListDevice,
|
|
37
|
+
listAction: [] as ListAction,
|
|
34
38
|
};
|
|
35
39
|
|
|
36
40
|
export const reducer = (currentState: ContextData, action: Action) => {
|
|
@@ -41,6 +45,8 @@ export const reducer = (currentState: ContextData, action: Action) => {
|
|
|
41
45
|
return { ...currentState, auth: payload };
|
|
42
46
|
case Action.STORE_STATUS_BAR:
|
|
43
47
|
return { ...currentState, statusBar: payload };
|
|
48
|
+
case Action.UPDATE_LANGUAGE:
|
|
49
|
+
return { ...currentState, language: payload };
|
|
44
50
|
case Action.LIST_DEVICE_TYPES:
|
|
45
51
|
if (currentState.listDevice) {
|
|
46
52
|
currentState.listDevice[action.payload.chipId] = {
|
|
@@ -60,6 +66,23 @@ export const reducer = (currentState: ContextData, action: Action) => {
|
|
|
60
66
|
};
|
|
61
67
|
}
|
|
62
68
|
|
|
69
|
+
case Action.LIST_ACTION:
|
|
70
|
+
let newListAction = [...currentState.listAction];
|
|
71
|
+
|
|
72
|
+
if (Object.keys(payload).length === 0) {
|
|
73
|
+
newListAction = [];
|
|
74
|
+
} else {
|
|
75
|
+
const order = newListAction.length + 1;
|
|
76
|
+
|
|
77
|
+
const isHaveAction = newListAction.findIndex(
|
|
78
|
+
(item) => item.action === payload.action
|
|
79
|
+
);
|
|
80
|
+
if (isHaveAction < 0) {
|
|
81
|
+
newListAction.push({ ...payload, order });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return { ...currentState, listAction: newListAction };
|
|
63
86
|
default:
|
|
64
87
|
return currentState;
|
|
65
88
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { renderHook } from '@testing-library/react-hooks';
|
|
3
|
+
import { SCProvider } from '../../../context';
|
|
4
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
5
|
+
import { useTranslations } from '../useTranslations';
|
|
6
|
+
|
|
7
|
+
const mockedSetAction = jest.fn();
|
|
8
|
+
|
|
9
|
+
const wrapper = ({ children }) => <SCProvider>{children}</SCProvider>;
|
|
10
|
+
|
|
11
|
+
const mockUseContext = jest.fn().mockImplementation(() => ({
|
|
12
|
+
stateData: mockSCStore({}),
|
|
13
|
+
setAction: mockedSetAction,
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
React.useContext = mockUseContext;
|
|
17
|
+
|
|
18
|
+
describe('Test useTranslations', () => {
|
|
19
|
+
it('test useTranslations', () => {
|
|
20
|
+
// eslint-disable-next-line no-unused-vars
|
|
21
|
+
const { result } = renderHook(() => useTranslations(), { wrapper });
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -8,6 +8,7 @@ import useControllList from './useControllList';
|
|
|
8
8
|
import { useBlockBackAndroid } from './useBlockBackAndroid';
|
|
9
9
|
import { useIsOwnerOfUnit } from './useIsOwnerOfUnit';
|
|
10
10
|
import { useStatusBar } from './useStatusBar';
|
|
11
|
+
import { useGetIdUser } from './useGetIdUser';
|
|
11
12
|
|
|
12
13
|
export {
|
|
13
14
|
useAndroidTranslucentStatusBar,
|
|
@@ -20,4 +21,5 @@ export {
|
|
|
20
21
|
useBlockBackAndroid,
|
|
21
22
|
useIsOwnerOfUnit,
|
|
22
23
|
useStatusBar,
|
|
24
|
+
useGetIdUser,
|
|
23
25
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getTranslate,
|
|
3
|
+
InterPolateString,
|
|
4
|
+
Language,
|
|
5
|
+
TranslationString,
|
|
6
|
+
} from '../../utils/I18n';
|
|
7
|
+
import { useCallback } from 'react';
|
|
8
|
+
import { useSCContextSelector } from '../../context';
|
|
9
|
+
import { getConfigGlobalState } from '../../iot/states.js';
|
|
10
|
+
|
|
11
|
+
export const useTranslations = () => {
|
|
12
|
+
const lang = useSCContextSelector((state) => state.language);
|
|
13
|
+
|
|
14
|
+
const language: Language = lang as Language;
|
|
15
|
+
|
|
16
|
+
const t = useCallback(
|
|
17
|
+
(translations: TranslationString, interpolateStr?: InterPolateString) =>
|
|
18
|
+
getTranslate(language, translations, interpolateStr),
|
|
19
|
+
[language]
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const t = (
|
|
26
|
+
translations: TranslationString,
|
|
27
|
+
interpolateStr?: InterPolateString
|
|
28
|
+
) => {
|
|
29
|
+
const lang = getConfigGlobalState('lang');
|
|
30
|
+
const language: Language = lang as Language;
|
|
31
|
+
return getTranslate(language, translations, interpolateStr);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default t;
|
package/src/iot/Monitor.js
CHANGED
|
@@ -3,13 +3,14 @@ import { getConfigGlobalState, setConfigGlobalState } from './states';
|
|
|
3
3
|
import _ from 'lodash';
|
|
4
4
|
import Pusher from 'pusher-js/react-native';
|
|
5
5
|
import { axiosPost } from '../utils/Apis/axios';
|
|
6
|
+
import { SCConfig } from '../configs';
|
|
6
7
|
|
|
7
8
|
Pusher.logToConsole = true;
|
|
8
9
|
let pusher = null;
|
|
9
10
|
|
|
10
11
|
const getPusher = () => {
|
|
11
12
|
if (!pusher) {
|
|
12
|
-
pusher = new Pusher(
|
|
13
|
+
pusher = new Pusher(SCConfig.pusherAppKey, {
|
|
13
14
|
cluster: 'ap1',
|
|
14
15
|
authorizer: function (channel, option) {
|
|
15
16
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable promise/prefer-await-to-then */
|
|
2
2
|
/* eslint-disable promise/prefer-await-to-callbacks */
|
|
3
3
|
import { BLE } from '../../configs';
|
|
4
|
-
import
|
|
4
|
+
import t from '../../hooks/Common/useTranslations';
|
|
5
5
|
import base64 from 'react-native-base64';
|
|
6
6
|
import { BleManager } from 'react-native-ble-plx';
|
|
7
7
|
import { ToastBottomHelper } from '../../utils/Utils';
|
|
@@ -68,11 +68,7 @@ const realScanBluetoothDevices = () => {
|
|
|
68
68
|
const index = needToScanDevices.indexOf(name);
|
|
69
69
|
needToScanDevices.splice(index, 1);
|
|
70
70
|
|
|
71
|
-
ToastBottomHelper.success(
|
|
72
|
-
t('Found bluetooth %{name} for remote control', {
|
|
73
|
-
name,
|
|
74
|
-
})
|
|
75
|
-
);
|
|
71
|
+
ToastBottomHelper.success(t(`Found bluetooth ${name} for remote control`));
|
|
76
72
|
|
|
77
73
|
bluetoothDevices[name] = device;
|
|
78
74
|
if (!needToScanDevices.length) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Auth, createConnection, getStates } from 'home-assistant-js-websocket';
|
|
2
|
-
import
|
|
2
|
+
import t from '../../hooks/Common/useTranslations';
|
|
3
3
|
import { getConfigGlobalState, setConfigGlobalState } from '../states';
|
|
4
4
|
import { ToastBottomHelper } from '../../utils/Utils';
|
|
5
5
|
import { API } from '../../configs';
|
|
@@ -4,12 +4,19 @@ import { getConfigGlobalState, setConfigGlobalState } from '../states';
|
|
|
4
4
|
import { sendCommandOverInternet } from './Internet';
|
|
5
5
|
|
|
6
6
|
let deviceMaps = {};
|
|
7
|
-
|
|
7
|
+
const propertyListMaps = {
|
|
8
8
|
temperature: 'targetTemperature',
|
|
9
9
|
doorStatus: 'doorState',
|
|
10
10
|
};
|
|
11
|
+
const propertyTimer = [
|
|
12
|
+
'absoluteHourToStart',
|
|
13
|
+
'absoluteMinuteToStart',
|
|
14
|
+
'absoluteHourToStop',
|
|
15
|
+
'absoluteMinuteToStop',
|
|
16
|
+
];
|
|
11
17
|
|
|
12
18
|
function updateConfigValues(device, configValues, name, value) {
|
|
19
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
13
20
|
if (device.hasOwnProperty(name)) {
|
|
14
21
|
const [configId] = device[name];
|
|
15
22
|
configValues[configId] = value;
|
|
@@ -17,16 +24,9 @@ function updateConfigValues(device, configValues, name, value) {
|
|
|
17
24
|
return configValues;
|
|
18
25
|
}
|
|
19
26
|
|
|
20
|
-
|
|
21
|
-
const device = deviceMaps[device_id];
|
|
22
|
-
|
|
23
|
-
if (!device) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let configValues = getConfigGlobalState('configValues');
|
|
28
|
-
// eslint-disable-next-line no-unused-vars
|
|
27
|
+
function parseData(configValues, device, data) {
|
|
29
28
|
for (const [resource, property] of Object.entries(data)) {
|
|
29
|
+
// base on data
|
|
30
30
|
if (Array.isArray(property)) {
|
|
31
31
|
const valueName = propertyListMaps[resource];
|
|
32
32
|
if (valueName) {
|
|
@@ -52,6 +52,41 @@ export async function updateStateByLgThinq(device_id, data) {
|
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
+
|
|
56
|
+
// For timer, if there is not exist in data, set undefined
|
|
57
|
+
for (let i = 0; i < propertyTimer.length; i++) {
|
|
58
|
+
// base on device
|
|
59
|
+
const name = propertyTimer[i];
|
|
60
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
61
|
+
if (device.hasOwnProperty(name)) {
|
|
62
|
+
const timer = data.timer;
|
|
63
|
+
const value = timer ? timer[name] : -1;
|
|
64
|
+
const [configId] = device[name];
|
|
65
|
+
configValues[configId] = value;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return configValues;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export async function updateStateByLgThinq(device_id, data) {
|
|
73
|
+
const device = deviceMaps[device_id];
|
|
74
|
+
|
|
75
|
+
if (!device) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let configValues = getConfigGlobalState('configValues');
|
|
80
|
+
|
|
81
|
+
if (Array.isArray(data)) {
|
|
82
|
+
for (let i = 0; i < data.length; i++) {
|
|
83
|
+
const dataItem = data[i];
|
|
84
|
+
configValues = parseData(configValues, device, dataItem);
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
configValues = parseData(configValues, device, data);
|
|
88
|
+
}
|
|
89
|
+
|
|
55
90
|
setConfigGlobalState('configValues', { ...configValues });
|
|
56
91
|
}
|
|
57
92
|
|
|
@@ -110,13 +145,21 @@ export const sendCommandOverLGThinq = async (sensor, action, data) => {
|
|
|
110
145
|
|
|
111
146
|
const item = action.lg_actions[i];
|
|
112
147
|
let new_message = {};
|
|
148
|
+
let isFirstResourceDone = false;
|
|
113
149
|
for (const [key, value] of Object.entries(item.message)) {
|
|
114
150
|
let new_property = {};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
151
|
+
|
|
152
|
+
if (!isFirstResourceDone) {
|
|
153
|
+
let index = 0;
|
|
154
|
+
for (const [key1, value1] of Object.entries(value)) {
|
|
155
|
+
new_property[key1] = data[index] ? data[index] : value1; // new or keep old one
|
|
156
|
+
index += 1;
|
|
157
|
+
}
|
|
158
|
+
isFirstResourceDone = true;
|
|
159
|
+
} else {
|
|
160
|
+
new_property = value; // from next resource, keep old one
|
|
119
161
|
}
|
|
162
|
+
|
|
120
163
|
new_message[key] = new_property;
|
|
121
164
|
}
|
|
122
165
|
|
|
@@ -127,5 +170,4 @@ export const sendCommandOverLGThinq = async (sensor, action, data) => {
|
|
|
127
170
|
'lg_thinq'
|
|
128
171
|
);
|
|
129
172
|
}
|
|
130
|
-
await fetchDeviceStatusLG(sensor);
|
|
131
173
|
};
|