@eohjsc/react-native-smart-city 0.3.31 → 0.3.34
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/assets/images/AddNewDevice/add-gateway-icon.svg +13 -0
- package/assets/images/AddNewDevice/add-modbus-device-icon.svg +8 -0
- package/assets/images/AddNewDevice/add-wifi-device-icon.svg +4 -0
- package/assets/images/AddNewDevice/add-zigbee-device-icon.svg +4 -0
- package/assets/images/AddNewDevice/interact-smartphone-icon.svg +14 -0
- package/index.js +2 -0
- package/package.json +8 -5
- package/src/Images/SmartAccount/DienQuang.png +0 -0
- package/src/Images/SmartAccount/DienQuang@2x.png +0 -0
- package/src/Images/SmartAccount/DienQuang@3x.png +0 -0
- package/src/Images/SmartAccount/LG.png +0 -0
- package/src/Images/SmartAccount/LG@2x.png +0 -0
- package/src/Images/SmartAccount/LG@3x.png +0 -0
- package/src/Images/SmartAccount/Samsung.png +0 -0
- package/src/Images/SmartAccount/Samsung@2x.png +0 -0
- package/src/Images/SmartAccount/Samsung@3x.png +0 -0
- package/src/commons/Action/ItemQuickAction.js +20 -4
- package/src/commons/Action/__test__/ItemQuickAction.test.js +35 -11
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +6 -6
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +9 -6
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapper.js +5 -2
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +10 -4
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +4 -4
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/index.test.js +2 -2
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +2 -2
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/ButtonWrapper.js +2 -2
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +12 -6
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +8 -4
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +4 -6
- package/src/commons/ActionGroup/OnOffTemplate/index.js +28 -10
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +1 -1
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +25 -12
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +25 -9
- package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/ControlPlay.test.js +13 -7
- package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/RectangleButton.test.js +9 -5
- package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/SmartTiviActionTemplate.test.js +25 -9
- package/src/commons/ActionGroup/SmartTiviActionTemplate/component/CircleButton.js +16 -6
- package/src/commons/ActionGroup/SmartTiviActionTemplate/component/ControlPlay.js +10 -4
- package/src/commons/ActionGroup/SmartTiviActionTemplate/component/RectangleButton.js +7 -3
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +21 -7
- package/src/commons/ActionGroup/ThreeButtonTemplate.js +5 -5
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +4 -4
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +7 -7
- package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +3 -3
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +3 -3
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +9 -5
- package/src/commons/ActionGroup/__test__/index.test.js +5 -3
- package/src/commons/ActionTemplate/OnOffButtonAction.js +14 -5
- package/src/commons/ActionTemplate/__test__/OnOffButtonAction.test.js +23 -2
- package/src/commons/ActionTemplate/__test__/index.test.js +2 -0
- package/src/commons/ActionTemplate/index.js +1 -0
- package/src/commons/AlertAction/index.js +2 -2
- package/src/commons/Auth/AccountItem.js +9 -3
- package/src/commons/Auth/__test__/AccountItem.test.js +6 -3
- package/src/commons/Automate/ItemAutomate.js +22 -3
- package/src/commons/BackDefault/index.js +2 -2
- package/src/commons/BottomButtonView/index.js +4 -5
- package/src/commons/Button/index.js +0 -2
- package/src/commons/ButtonPopup/index.js +3 -3
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +3 -2
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +4 -2
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +6 -3
- package/src/commons/Dashboard/MyUnit/index.js +5 -3
- package/src/commons/Device/ConnectedViewHeader.js +2 -2
- package/src/commons/Device/DeviceAlertStatus.js +2 -2
- package/src/commons/Device/DisconnectedView.js +2 -2
- package/src/commons/Device/Emergency/EmergencyButton.js +2 -2
- package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +3 -2
- package/src/commons/Device/FlatListItems.js +2 -2
- package/src/commons/Device/ItemAddNew/index.js +7 -12
- package/src/commons/Device/ItemDevice.js +16 -11
- package/src/commons/Device/SensorConnectedStatus.js +5 -2
- package/src/commons/Device/WindDirection/Compass/index.js +5 -2
- package/src/commons/Device/__test__/DeviceAlertStatus.test.js +8 -4
- package/src/commons/Device/__test__/FlatListItems.test.js +3 -2
- package/src/commons/Device/__test__/SensorConnectedStatus.test.js +4 -2
- package/src/commons/Explore/ActivityIndicator/index.js +5 -2
- package/src/commons/Explore/SearchBox/__test__/SearchBox.test.js +3 -3
- package/src/commons/Explore/SearchBox/index.js +2 -2
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +4 -4
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +11 -8
- package/src/commons/FieldTemplate/ChooseUserField/index.js +2 -2
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +3 -2
- package/src/commons/FieldTemplate/PasscodeField/index.js +2 -2
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +12 -7
- package/src/commons/Form/TextInput.js +2 -2
- package/src/commons/Form/TextInputPassword.js +2 -2
- package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +5 -3
- package/src/commons/GroupCheckBox/index.js +2 -2
- package/src/commons/HeaderAni/index.js +2 -3
- package/src/commons/MediaPlayerDetail/index.js +2 -2
- package/src/commons/MenuActionList/index.js +2 -2
- package/src/commons/MenuActionMore/index.js +2 -3
- package/src/commons/NavBar/index.js +2 -3
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +12 -6
- package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +7 -3
- package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +4 -2
- package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +11 -8
- package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +9 -5
- package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +5 -3
- package/src/commons/Popover/index.js +2 -13
- package/src/commons/PreventAccess/__test__/PreventAccess.test.js +5 -3
- package/src/commons/PreventAccess/index.js +3 -3
- package/src/commons/{Connecting → Processing}/__test__/Connecting.test.js +5 -4
- package/src/commons/Processing/index.js +93 -0
- package/src/commons/{Connecting → Processing}/styles.js +9 -1
- package/src/commons/SelectGateway/index.js +105 -0
- package/src/commons/SelectGateway/styles.js +55 -0
- package/src/commons/SelectSubUnit/__test__/SelectSubUnit.test.js +106 -0
- package/src/commons/SelectSubUnit/index.js +124 -0
- package/src/commons/SelectSubUnit/styles.js +52 -0
- package/src/commons/SelectUnit/__test__/SelectUnit.test.js +120 -0
- package/src/commons/SelectUnit/index.js +105 -0
- package/src/commons/SelectUnit/styles.js +53 -0
- package/src/commons/Sharing/WrapHeaderScrollable.js +2 -2
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +4 -4
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +25 -10
- package/src/commons/SubUnit/OneTap/index.js +9 -4
- package/src/commons/SubUnit/ShortDetail.js +11 -29
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +15 -10
- package/src/commons/SummaryItem/index.js +2 -2
- package/src/commons/Tabbar/__test__/index.test.js +97 -0
- package/src/commons/Unit/HeaderUnit/index.js +4 -5
- package/src/commons/Unit/SharedUnit.js +10 -8
- package/src/commons/Unit/__test__/HeaderUnit.test.js +13 -5
- package/src/commons/Unit/__test__/SharedUnit.test.js +30 -11
- package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +13 -8
- package/src/commons/UnitSummary/AirQuality/index.js +7 -3
- package/src/commons/UnitSummary/TotalPowerBox.js +2 -2
- package/src/commons/UnitSummary/TotalPowerConsumption/index.js +2 -2
- package/src/commons/UnitSummary/__test__/TotalPowerBox.test.js +3 -2
- package/src/commons/UnitSummary/__test__/TotalPowerConsumption.test.js +4 -2
- package/src/commons/ViewButtonBottom/index.js +4 -4
- package/src/commons/WheelDateTimePicker/index.js +5 -3
- package/src/commons/WrapParallaxScrollView/index.js +2 -1
- package/src/configs/API.js +16 -14
- package/src/configs/AccessibilityLabel.js +629 -0
- package/src/configs/Constants.js +1 -604
- package/src/configs/Images.js +2 -0
- package/src/context/actionType.ts +10 -3
- package/src/context/mockStore.ts +6 -3
- package/src/context/reducer.ts +45 -8
- package/src/hoc/__test__/withRemoteControl.test.js +24 -0
- package/src/hoc/withRemoteControl.js +1 -0
- package/src/hooks/Common/__test__/useAndroidTranslucentStatusBar.test.js +55 -0
- package/src/hooks/Common/index.js +2 -2
- package/src/hooks/Common/useDevicesStatus.js +19 -15
- package/src/hooks/Common/{useGGHomeDeviceConnected.js → useHomeAssistantDeviceConnected.js} +3 -3
- package/src/hooks/Common/usePopover.js +6 -1
- package/src/hooks/IoT/__test__/{useGGHomeConnection.test.js → useHomeAssistantConnection.test.js} +18 -18
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +17 -12
- package/src/hooks/IoT/index.js +2 -2
- package/src/hooks/IoT/useHomeAssistantConnection.js +91 -0
- package/src/hooks/IoT/useRemoteControl.js +6 -6
- package/src/hooks/__test__/useInitDeepLink.test.js +28 -0
- package/src/hooks/useReceiveNotifications.js +2 -4
- package/src/iot/RemoteControl/{GoogleHome.js → HomeAssistant.js} +21 -17
- package/src/iot/RemoteControl/LG.js +2 -1
- package/src/iot/RemoteControl/__test__/{GoogleHome.test.js → HomeAssistant.test.js} +30 -30
- package/src/navigations/AddDeviceStack.js +0 -14
- package/src/navigations/AddGatewayStack.js +56 -21
- package/src/navigations/Main.js +2 -2
- package/src/navigations/SmartAccountStack.js +52 -0
- package/src/navigations/SmartIrStack.js +3 -3
- package/src/navigations/UnitStack.js +1 -1
- package/src/screens/AQIGuide/__test__/AQIGuide.test.js +5 -3
- package/src/screens/AQIGuide/index.js +5 -3
- package/src/screens/ActivityLog/FilterPopup.js +2 -2
- package/src/screens/ActivityLog/__test__/FilterPopup.test.js +2 -2
- package/src/screens/ActivityLog/__test__/index.test.js +3 -2
- package/src/screens/ActivityLog/index.js +3 -3
- package/src/screens/AddCommon/SelectSubUnit.js +49 -192
- package/src/screens/AddCommon/SelectUnit.js +58 -204
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +25 -61
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +41 -32
- package/src/screens/AddLocationMaps/__test__/index.test.js +13 -7
- package/src/screens/AddLocationMaps/index.js +3 -3
- package/src/screens/AddNewAction/Device/index.js +2 -2
- package/src/screens/AddNewAction/SelectAction.js +16 -7
- package/src/screens/AddNewAction/SelectSensorDevices.js +3 -3
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +2 -2
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +8 -3
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +11 -7
- package/src/screens/AddNewAutoSmart/index.js +9 -12
- package/src/screens/AddNewDevice/ConnectingDevices.js +1 -1
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +7 -4
- package/src/screens/AddNewDevice/index.js +4 -4
- package/src/screens/AddNewGateway/ConnectingDevice.js +40 -0
- package/src/screens/AddNewGateway/ConnectingModbusDevice.js +61 -0
- package/src/screens/AddNewGateway/ConnectingWifiDevice.js +70 -0
- package/src/screens/AddNewGateway/ConnectingWifiGuide.js +167 -0
- package/src/screens/AddNewGateway/ConnectingWifiGuideStyles.js +58 -0
- package/src/screens/AddNewGateway/ConnectingZigbeeDevice.js +60 -0
- package/src/screens/AddNewGateway/PlugAndPlay/FirstWarning.js +16 -8
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +23 -4
- package/src/screens/AddNewGateway/RenameNewDevices.js +141 -0
- package/src/screens/AddNewGateway/RenameNewDevicesStyles.js +75 -0
- package/src/screens/AddNewGateway/ScanGatewayQR.js +80 -0
- package/src/screens/AddNewGateway/ScanModbusQR.js +53 -0
- package/src/screens/AddNewGateway/ScanWifiDeviceQR.js +55 -0
- package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +31 -0
- package/src/screens/AddNewGateway/SelectDeviceType.js +147 -0
- package/src/screens/AddNewGateway/SelectDeviceTypeStyles.js +51 -0
- package/src/screens/AddNewGateway/SelectDeviceUnit.js +29 -0
- package/src/screens/AddNewGateway/SelectModbusGateway.js +34 -0
- package/src/screens/AddNewGateway/SelectZigbeeGateway.js +34 -0
- package/src/screens/AddNewGateway/ShareWifiPassword.js +198 -0
- package/src/screens/AddNewGateway/ShareWifiPasswordStyles.js +44 -0
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +7 -4
- package/src/screens/AddNewGateway/__test__/ConnectingModbusDevice.test.js +63 -0
- package/src/screens/AddNewGateway/__test__/{SelectGateway.test.js → ConnectingWifiDevice.test.js} +15 -10
- package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +224 -0
- package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +62 -0
- package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +191 -0
- package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +72 -0
- package/src/screens/AddNewGateway/__test__/ScanModbusQR.test.js +75 -0
- package/src/screens/AddNewGateway/__test__/ScanWifiDeviceQR.test.js +73 -0
- package/src/screens/AddNewGateway/__test__/SelectDeviceSubUnit.test.js +47 -0
- package/src/screens/AddNewGateway/__test__/SelectDeviceType.test.js +124 -0
- package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +48 -0
- package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +77 -0
- package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +77 -0
- package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +155 -0
- package/src/screens/AddNewGateway/hooks/__Tests__/index.test.js +1 -1
- package/src/screens/AddNewGateway/index.js +4 -4
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +5 -4
- package/src/screens/AddNewOneTap/index.js +4 -4
- package/src/screens/Automate/__test__/index.test.js +2 -2
- package/src/screens/Automate/index.js +6 -2
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +3 -2
- package/src/screens/ConfirmUnitDeletion/index.js +3 -3
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +5 -5
- package/src/screens/Device/EditDevice/index.js +3 -3
- package/src/screens/Device/__test__/detail.test.js +38 -22
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +6 -6
- package/src/screens/Device/components/SensorDisplayItem.js +2 -2
- package/src/screens/Device/detail.js +28 -22
- package/src/screens/Device/hooks/useEvaluateValue.js +0 -2
- package/src/screens/DeviceInfo/__test__/index.test.js +8 -4
- package/src/screens/DeviceInfo/index.js +10 -6
- package/src/screens/Drawer/index.js +21 -9
- package/src/screens/EditActionsList/__tests__/index.test.js +120 -0
- package/src/screens/EditActionsList/index.js +15 -5
- package/src/screens/EmergencyContacts/EmergencyContactsAddNew.js +8 -4
- package/src/screens/EmergencyContacts/EmergencyContactsList.js +1 -1
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +5 -3
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +9 -5
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +7 -3
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +7 -3
- package/src/screens/EmergencySetting/__test__/DropDownItem.test.js +3 -2
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +6 -3
- package/src/screens/EnterPassword/index.js +5 -3
- package/src/screens/GuestInfo/__test__/index.test.js +18 -12
- package/src/screens/GuestInfo/components/AccessScheduleItem.js +2 -2
- package/src/screens/GuestInfo/components/AccessScheduleSheet.js +3 -3
- package/src/screens/GuestInfo/components/HeaderGuestInfo.js +2 -2
- package/src/screens/GuestInfo/components/RecurringDetail.js +4 -4
- package/src/screens/GuestInfo/components/TemporaryDetail.js +3 -3
- package/src/screens/GuestInfo/index.js +1 -1
- package/src/screens/HanetCamera/Detail.js +10 -4
- package/src/screens/HanetCamera/ManageAccess.js +4 -4
- package/src/screens/HanetCamera/MemberInfo.js +1 -1
- package/src/screens/HanetCamera/__test__/Detail.test.js +5 -3
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +10 -4
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +4 -2
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -2
- package/src/screens/ManageAccess/index.js +1 -1
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +4 -4
- package/src/screens/MoveToAnotherSubUnit/index.js +2 -2
- package/src/screens/PlayBackCamera/__test__/index.test.js +9 -6
- package/src/screens/PlayBackCamera/index.js +6 -6
- package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +1 -1
- package/src/screens/ScanChipQR/components/QRScan/index.js +10 -3
- package/src/screens/ScriptDetail/__test__/index.test.js +43 -38
- package/src/screens/ScriptDetail/index.js +26 -16
- package/src/screens/SelectUnit/__test__/index.test.js +4 -3
- package/src/screens/SelectUnit/index.js +3 -3
- package/src/screens/SetSchedule/index.js +1 -1
- package/src/screens/SharedUnit/__test__/ShareUnit.test.js +25 -0
- package/src/screens/SharedUnit/index.js +2 -0
- package/src/screens/Sharing/Components/{SensorItem.js → DeviceItem.js} +40 -30
- package/src/screens/Sharing/Components/Styles/{SensorItemStyles.js → DeviceItemStyles.js} +0 -0
- package/src/screens/Sharing/Components/__test__/{SensorItem.test.js → DeviceItem.test.js} +10 -8
- package/src/screens/Sharing/Components/index.js +2 -2
- package/src/screens/Sharing/InfoMemberUnit.js +7 -6
- package/src/screens/Sharing/MemberList.js +4 -4
- package/src/screens/Sharing/SelectPermission.js +139 -123
- package/src/screens/Sharing/SelectUser.js +9 -5
- package/src/screens/Sharing/Styles/SelectPermissionStyles.js +2 -2
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +3 -2
- package/src/screens/Sharing/__test__/SelectPermission.test.js +67 -14
- package/src/screens/Sharing/__test__/SelectUser.test.js +7 -4
- package/src/screens/SideMenuDetail/__test__/index.test.js +11 -7
- package/src/screens/SideMenuDetail/index.js +2 -2
- package/src/screens/SmartAccount/Connecting/index.js +171 -0
- package/src/{commons/ConnectingProcess/styles.js → screens/SmartAccount/Connecting/style.js} +3 -22
- package/src/screens/SmartAccount/ListDevice/DeviceItem.js +45 -0
- package/src/screens/SmartAccount/ListDevice/__test__/DeviceItem.test.js +34 -0
- package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +139 -0
- package/src/screens/SmartAccount/ListDevice/index.js +186 -0
- package/src/screens/SmartAccount/ListDevice/styles/DeviceItemStyles.js +70 -0
- package/src/screens/SmartAccount/ListDevice/styles/index.js +85 -0
- package/src/screens/SmartAccount/SuccessfullyConnected/DeviceItem.js +37 -0
- package/src/{commons/ConnectingProcess/DeviceItem → screens/SmartAccount/SuccessfullyConnected}/DeviceItemStyles.js +13 -5
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/DeviceItem.test.js +65 -0
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +88 -0
- package/src/screens/SmartAccount/SuccessfullyConnected/index.js +101 -0
- package/src/screens/SmartAccount/SuccessfullyConnected/styles.js +42 -0
- package/src/screens/SmartAccount/__test__/Connecting.test.js +86 -0
- package/src/screens/SmartAccount/__test__/SmartAccount.test.js +249 -0
- package/src/screens/SmartAccount/index.js +172 -0
- package/src/screens/SmartAccount/style.js +70 -0
- package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +4 -2
- package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +5 -5
- package/src/screens/SmartIr/__test__/SmartIr.test.js +14 -6
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +4 -2
- package/src/screens/SmartIr/components/{SelectDeviceType.js → SelectIrDeviceType.js} +2 -2
- package/src/screens/SmartIr/index.js +1 -1
- package/src/screens/SubUnit/AddSubUnit.js +7 -3
- package/src/screens/SubUnit/Detail.js +6 -6
- package/src/screens/SubUnit/EditSubUnit.js +10 -6
- package/src/screens/SubUnit/ManageSubUnit.js +2 -2
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +6 -3
- package/src/screens/SubUnit/__test__/Detail.test.js +5 -3
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +9 -5
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +3 -2
- package/src/screens/SyncLGDevice/AddLGDevice.js +4 -4
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +44 -14
- package/src/screens/TDSGuide/__test__/TDSGuide.test.js +4 -2
- package/src/screens/TDSGuide/index.js +2 -2
- package/src/screens/Template/EditTemplate.js +2 -1
- package/src/screens/Template/__test__/detail.test.js +9 -1
- package/src/screens/Template/index.js +0 -1
- package/src/screens/UVIndexGuide/__test__/UVIndexGuide.test.js +3 -2
- package/src/screens/UVIndexGuide/index.js +2 -2
- package/src/screens/Unit/AddMenu.js +10 -25
- package/src/screens/Unit/ChooseLocation.js +1 -1
- package/src/screens/Unit/Detail.js +10 -10
- package/src/screens/Unit/ManageUnit.js +21 -15
- package/src/screens/Unit/MyAllUnit/index.js +1 -1
- package/src/screens/Unit/SelectAddToFavorites.js +7 -8
- package/src/screens/Unit/SelectAddress.js +4 -4
- package/src/screens/Unit/SmartAccount.js +8 -5
- package/src/screens/Unit/SmartAccountItem.js +3 -3
- package/src/screens/Unit/Station/__test__/index.test.js +1 -1
- package/src/screens/Unit/Station/index.js +2 -2
- package/src/screens/Unit/Summaries.js +2 -2
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +6 -6
- package/src/screens/Unit/__test__/Detail.test.js +17 -12
- package/src/screens/Unit/__test__/ManageUnit.test.js +40 -18
- package/src/screens/Unit/__test__/SelectAddress.test.js +15 -8
- package/src/screens/Unit/__test__/SmartAccount.test.js +8 -5
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +4 -3
- package/src/screens/Unit/components/AutomateScript/index.js +5 -2
- package/src/screens/Unit/components/ListMyAllUnit/index.js +1 -1
- package/src/screens/Unit/components/MyAllUnit/__test__/Header.test.js +9 -5
- package/src/screens/Unit/components/MyAllUnit/index.js +1 -1
- package/src/screens/Unit/components/MyUnitDevice/index.js +8 -5
- package/src/screens/Unit/components/SharedUnit/index.js +12 -6
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +24 -9
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +25 -11
- package/src/screens/UnitSummary/__test__/index.test.js +4 -2
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +4 -2
- package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +2 -2
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +4 -2
- package/src/screens/UnitSummary/components/PowerConsumption/index.js +2 -2
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +5 -4
- package/src/screens/UnitSummary/components/RunningDevices/index.js +6 -3
- package/src/screens/UnitSummary/components/TotalPowerBox/index.js +2 -2
- package/src/screens/UnitSummary/components/TotalPowerConsumption/index.js +2 -2
- package/src/screens/UnitSummary/components/__test__/TotalPowerBox.test.js +3 -2
- package/src/screens/UnitSummary/components/__test__/TotalPowerConsumption.test.js +4 -2
- package/src/screens/UnitSummary/index.js +10 -8
- package/src/screens/WaterQualityGuide/__test__/index.test.js +17 -12
- package/src/screens/WaterQualityGuide/index.js +26 -10
- package/src/utils/Apis/axios.js +1 -0
- package/src/utils/I18n/translations/en.json +36 -11
- package/src/utils/I18n/translations/vi.json +36 -10
- package/src/utils/Route/index.js +19 -10
- package/src/utils/Utils.js +6 -7
- package/src/utils/Validation.js +4 -0
- package/src/commons/Connecting/index.js +0 -67
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +0 -28
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +0 -163
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +0 -19
- package/src/commons/ConnectingProcess/index.js +0 -213
- package/src/hooks/IoT/useGGHomeConnection.js +0 -91
- package/src/iot/RemoteControl/index.js +0 -55
- package/src/screens/AddNewDevice/ConnectDevices.js +0 -184
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -131
- package/src/screens/AddNewGateway/ConnectedGateway.js +0 -139
- package/src/screens/AddNewGateway/ConnectingGateway.js +0 -137
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +0 -214
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +0 -319
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectWifiWarning.test.js +0 -75
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +0 -130
- package/src/screens/AddNewGateway/SelectGateway.js +0 -133
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +0 -207
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -71
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +0 -96
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -120
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +0 -115
- package/src/screens/ScanChipQR/hooks/index.js +0 -120
- package/src/screens/ScanChipQR/index.js +0 -29
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +0 -111
- package/src/screens/ScanSensorQR/hooks/index.js +0 -40
- package/src/screens/ScanSensorQR/index.js +0 -39
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { View, Image, TouchableOpacity } from 'react-native';
|
|
3
|
+
import { useNavigation, useIsFocused } from '@react-navigation/native';
|
|
4
|
+
|
|
5
|
+
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
6
|
+
import { Button } from '../../../commons';
|
|
7
|
+
import Text from '../../../commons/Text';
|
|
8
|
+
import WrapHeaderScrollable from '../../../commons/Sharing/WrapHeaderScrollable';
|
|
9
|
+
import DeviceItem from './DeviceItem';
|
|
10
|
+
import { API, Colors, Images } from '../../../configs';
|
|
11
|
+
import { axiosGet } from '../../../utils/Apis/axios';
|
|
12
|
+
import Routes from '../../../utils/Route';
|
|
13
|
+
import styles from './styles/index';
|
|
14
|
+
import AccessibilityLabel from '../../../configs/AccessibilityLabel';
|
|
15
|
+
|
|
16
|
+
const ListDeviceSmartAccount = ({ route }) => {
|
|
17
|
+
const {
|
|
18
|
+
username,
|
|
19
|
+
brand,
|
|
20
|
+
device_data,
|
|
21
|
+
unit_id,
|
|
22
|
+
smart_account_id,
|
|
23
|
+
smart_account_id_from_backend,
|
|
24
|
+
} = route.params;
|
|
25
|
+
const t = useTranslations();
|
|
26
|
+
const isFocused = useIsFocused();
|
|
27
|
+
const [listSelectedDevice, setListSelectedDevice] = useState([]);
|
|
28
|
+
const [listDeviceSuccess, setListDeviceSuccess] = useState([]);
|
|
29
|
+
const [listDevices, setListDevices] = useState(device_data || []);
|
|
30
|
+
const { navigate, goBack } = useNavigation();
|
|
31
|
+
let circleOfSelectAll = useRef(false);
|
|
32
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
+
const listSelectAll = [];
|
|
34
|
+
|
|
35
|
+
const fetchSensorData = useCallback(async () => {
|
|
36
|
+
const { success, data } = await axiosGet(
|
|
37
|
+
API.SMART_ACCOUNT.FETCH_UNIDENTIFIED_DEVICE_OF_SMART_ACCOUNT(
|
|
38
|
+
smart_account_id
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
if (success) {
|
|
42
|
+
setListDevices(data);
|
|
43
|
+
}
|
|
44
|
+
}, [smart_account_id]);
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!device_data && smart_account_id && isFocused) {
|
|
48
|
+
fetchSensorData();
|
|
49
|
+
setListDeviceSuccess([]);
|
|
50
|
+
setListSelectedDevice([]);
|
|
51
|
+
}
|
|
52
|
+
}, [fetchSensorData, isFocused, device_data, smart_account_id]);
|
|
53
|
+
|
|
54
|
+
const handleSelectedDevice = useCallback(
|
|
55
|
+
(id, item) => {
|
|
56
|
+
if (listSelectedDevice.includes(id)) {
|
|
57
|
+
setListSelectedDevice((oldArray) =>
|
|
58
|
+
oldArray.filter((itemDevice) => itemDevice !== id)
|
|
59
|
+
);
|
|
60
|
+
setListDeviceSuccess((oldArray) =>
|
|
61
|
+
oldArray.filter((itemDevice) => itemDevice !== item)
|
|
62
|
+
);
|
|
63
|
+
circleOfSelectAll.current = false;
|
|
64
|
+
} else {
|
|
65
|
+
setListSelectedDevice((oldArray) => [...oldArray, id]);
|
|
66
|
+
setListDeviceSuccess((oldArray) => [...oldArray, item]);
|
|
67
|
+
if (listDevices.length - 1 === listSelectedDevice.length) {
|
|
68
|
+
circleOfSelectAll.current = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
[listSelectedDevice, listDevices.length]
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const gotoSelectSubUnit = useCallback(() => {
|
|
76
|
+
navigate(Routes.AddDeviceStack, {
|
|
77
|
+
screen: Routes.AddCommonSelectSubUnit,
|
|
78
|
+
params: {
|
|
79
|
+
username,
|
|
80
|
+
brand,
|
|
81
|
+
listDeviceIds: listSelectedDevice,
|
|
82
|
+
unit_id: unit_id,
|
|
83
|
+
addType: 'AddHassiDevice',
|
|
84
|
+
device_data: device_data,
|
|
85
|
+
smart_account_id: smart_account_id,
|
|
86
|
+
listSelectDevice: listDeviceSuccess,
|
|
87
|
+
smart_account_id_from_backend: smart_account_id_from_backend,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
}, [
|
|
91
|
+
brand,
|
|
92
|
+
listDeviceSuccess,
|
|
93
|
+
listSelectedDevice,
|
|
94
|
+
navigate,
|
|
95
|
+
device_data,
|
|
96
|
+
smart_account_id,
|
|
97
|
+
smart_account_id_from_backend,
|
|
98
|
+
unit_id,
|
|
99
|
+
username,
|
|
100
|
+
]);
|
|
101
|
+
|
|
102
|
+
const handleSelectAll = useCallback(() => {
|
|
103
|
+
for (let i = 0; i < listDevices.length; i++) {
|
|
104
|
+
listSelectAll.push(listDevices[i].id);
|
|
105
|
+
}
|
|
106
|
+
if (listSelectAll.length !== listSelectedDevice.length) {
|
|
107
|
+
setListSelectedDevice(listSelectAll);
|
|
108
|
+
setListDeviceSuccess(listDevices);
|
|
109
|
+
circleOfSelectAll.current = true;
|
|
110
|
+
}
|
|
111
|
+
if (listSelectAll.length === listSelectedDevice.length) {
|
|
112
|
+
setListSelectedDevice([]);
|
|
113
|
+
setListDeviceSuccess([]);
|
|
114
|
+
circleOfSelectAll.current = false;
|
|
115
|
+
}
|
|
116
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
117
|
+
}, [listSelectAll, listSelectedDevice.length, listDevices]);
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<View style={styles.wrap}>
|
|
121
|
+
<WrapHeaderScrollable
|
|
122
|
+
onLeft={() => (device_data ? navigate(Routes.Dashboard) : goBack())}
|
|
123
|
+
title={brand === 'google_home' && 'Điện Quang'}
|
|
124
|
+
headerAniStyle={styles.headerAniStyle}
|
|
125
|
+
>
|
|
126
|
+
<View style={styles.contentContainer}>
|
|
127
|
+
<View style={styles.rowUsername}>
|
|
128
|
+
<Image width={50} source={Images.dienquang} />
|
|
129
|
+
<Text style={styles.textUsername}>{username}</Text>
|
|
130
|
+
</View>
|
|
131
|
+
<View style={styles.containerTypeDevice}>
|
|
132
|
+
<View style={styles.typeDeviceItem}>
|
|
133
|
+
<Text type="Body" color={Colors.Green7}>
|
|
134
|
+
{t('unidentified')}
|
|
135
|
+
</Text>
|
|
136
|
+
</View>
|
|
137
|
+
</View>
|
|
138
|
+
<View style={styles.textAllDevice}>
|
|
139
|
+
<Text style={styles.allDevices} type="H3">
|
|
140
|
+
{`${t('text_all_devices')} (${
|
|
141
|
+
device_data ? device_data.length : listDevices.length
|
|
142
|
+
})`}
|
|
143
|
+
</Text>
|
|
144
|
+
<TouchableOpacity
|
|
145
|
+
onPress={handleSelectAll}
|
|
146
|
+
style={styles.selectAll}
|
|
147
|
+
accessibilityLabel={AccessibilityLabel.TOUCH_SELECT_ALL}
|
|
148
|
+
>
|
|
149
|
+
<View
|
|
150
|
+
style={[
|
|
151
|
+
circleOfSelectAll.current
|
|
152
|
+
? styles.circle
|
|
153
|
+
: styles.circleNotChange,
|
|
154
|
+
]}
|
|
155
|
+
/>
|
|
156
|
+
<Text style={styles.allDevices} type="H3">
|
|
157
|
+
{t('select_all')}
|
|
158
|
+
</Text>
|
|
159
|
+
</TouchableOpacity>
|
|
160
|
+
</View>
|
|
161
|
+
<View style={styles.boxDevices}>
|
|
162
|
+
{(device_data ? device_data : listDevices).map((item) => (
|
|
163
|
+
<DeviceItem
|
|
164
|
+
id={item.id}
|
|
165
|
+
name={item.name}
|
|
166
|
+
icon={item.icon_kit}
|
|
167
|
+
item={item}
|
|
168
|
+
setListSelectedDevice={handleSelectedDevice}
|
|
169
|
+
isSelected={listSelectedDevice.includes(item.id)}
|
|
170
|
+
/>
|
|
171
|
+
))}
|
|
172
|
+
</View>
|
|
173
|
+
</View>
|
|
174
|
+
</WrapHeaderScrollable>
|
|
175
|
+
<View style={styles.btnFixed}>
|
|
176
|
+
<Button
|
|
177
|
+
onPress={gotoSelectSubUnit}
|
|
178
|
+
type={listSelectedDevice.length ? 'primary' : 'disabled'}
|
|
179
|
+
title={t('next')}
|
|
180
|
+
/>
|
|
181
|
+
</View>
|
|
182
|
+
</View>
|
|
183
|
+
);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export default ListDeviceSmartAccount;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors, Constants } from '../../../../configs';
|
|
3
|
+
|
|
4
|
+
const marginItem = 12;
|
|
5
|
+
const marginHorizontal = 16;
|
|
6
|
+
const widthItem = (Constants.width - marginHorizontal * 2 - marginItem) / 2;
|
|
7
|
+
const heightItem = (widthItem / 166) * 145;
|
|
8
|
+
|
|
9
|
+
export default StyleSheet.create({
|
|
10
|
+
container: {
|
|
11
|
+
padding: 12,
|
|
12
|
+
borderRadius: 10,
|
|
13
|
+
shadowRadius: 1,
|
|
14
|
+
width: widthItem,
|
|
15
|
+
height: heightItem,
|
|
16
|
+
borderWidth: 1,
|
|
17
|
+
borderColor: Colors.Gray4,
|
|
18
|
+
backgroundColor: Colors.White,
|
|
19
|
+
justifyContent: 'space-between',
|
|
20
|
+
marginBottom: 16,
|
|
21
|
+
},
|
|
22
|
+
colorUnSelected: {
|
|
23
|
+
shadowColor: Colors.Shadow,
|
|
24
|
+
shadowOpacity: 0.3,
|
|
25
|
+
shadowOffset: {
|
|
26
|
+
width: 0,
|
|
27
|
+
height: 2,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
colorSelected: {
|
|
31
|
+
shadowColor: Colors.Green,
|
|
32
|
+
shadowOpacity: 1,
|
|
33
|
+
shadowOffset: {
|
|
34
|
+
width: 0,
|
|
35
|
+
height: 0,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
iconSensor: {
|
|
39
|
+
width: 40,
|
|
40
|
+
height: 40,
|
|
41
|
+
resizeMode: 'contain',
|
|
42
|
+
},
|
|
43
|
+
nameSensor: {
|
|
44
|
+
color: Colors.Gray9,
|
|
45
|
+
marginTop: 5,
|
|
46
|
+
},
|
|
47
|
+
redText: {
|
|
48
|
+
color: Colors.Red,
|
|
49
|
+
},
|
|
50
|
+
opticalPower: {
|
|
51
|
+
flexDirection: 'row',
|
|
52
|
+
justifyContent: 'space-between',
|
|
53
|
+
},
|
|
54
|
+
circle: {
|
|
55
|
+
backgroundColor: Colors.Primary,
|
|
56
|
+
width: 15,
|
|
57
|
+
height: 15,
|
|
58
|
+
borderRadius: 15,
|
|
59
|
+
borderWidth: 1,
|
|
60
|
+
borderColor: Colors.Primary,
|
|
61
|
+
},
|
|
62
|
+
circleNotChange: {
|
|
63
|
+
backgroundColor: Colors.White,
|
|
64
|
+
width: 15,
|
|
65
|
+
height: 15,
|
|
66
|
+
borderRadius: 15,
|
|
67
|
+
borderWidth: 1,
|
|
68
|
+
borderColor: Colors.Gray6,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { getBottomSpace } from 'react-native-iphone-x-helper';
|
|
3
|
+
import { Colors } from '../../../../configs';
|
|
4
|
+
|
|
5
|
+
export default StyleSheet.create({
|
|
6
|
+
wrap: {
|
|
7
|
+
flex: 1,
|
|
8
|
+
backgroundColor: Colors.White,
|
|
9
|
+
},
|
|
10
|
+
boxDevices: {
|
|
11
|
+
flexWrap: 'wrap',
|
|
12
|
+
flexDirection: 'row',
|
|
13
|
+
marginTop: 16,
|
|
14
|
+
justifyContent: 'space-between',
|
|
15
|
+
},
|
|
16
|
+
textUsername: {
|
|
17
|
+
color: Colors.Gray9,
|
|
18
|
+
fontSize: 16,
|
|
19
|
+
paddingLeft: 10,
|
|
20
|
+
},
|
|
21
|
+
contentContainer: {
|
|
22
|
+
paddingLeft: 16,
|
|
23
|
+
paddingRight: 16,
|
|
24
|
+
paddingBottom: 120,
|
|
25
|
+
},
|
|
26
|
+
rowUsername: {
|
|
27
|
+
flexDirection: 'row',
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
},
|
|
30
|
+
allDevices: {
|
|
31
|
+
paddingTop: 20,
|
|
32
|
+
color: Colors.Gray9,
|
|
33
|
+
},
|
|
34
|
+
typeDeviceItem: {
|
|
35
|
+
backgroundColor: Colors.Gray3,
|
|
36
|
+
borderRadius: 30,
|
|
37
|
+
paddingHorizontal: 20,
|
|
38
|
+
paddingVertical: 5,
|
|
39
|
+
alignSelf: 'flex-start',
|
|
40
|
+
},
|
|
41
|
+
containerTypeDevice: {
|
|
42
|
+
paddingTop: 20,
|
|
43
|
+
},
|
|
44
|
+
btnFixed: {
|
|
45
|
+
position: 'absolute',
|
|
46
|
+
bottom: 0,
|
|
47
|
+
left: 0,
|
|
48
|
+
right: 0,
|
|
49
|
+
paddingBottom: getBottomSpace() > 0 ? getBottomSpace() : 24,
|
|
50
|
+
paddingTop: 16,
|
|
51
|
+
backgroundColor: Colors.White,
|
|
52
|
+
marginHorizontal: 16,
|
|
53
|
+
},
|
|
54
|
+
headerAniStyle: {
|
|
55
|
+
borderBottomWidth: 0,
|
|
56
|
+
borderColor: Colors.White,
|
|
57
|
+
},
|
|
58
|
+
textAllDevice: {
|
|
59
|
+
flexDirection: 'row',
|
|
60
|
+
justifyContent: 'space-between',
|
|
61
|
+
},
|
|
62
|
+
circle: {
|
|
63
|
+
backgroundColor: Colors.Primary,
|
|
64
|
+
width: 15,
|
|
65
|
+
height: 15,
|
|
66
|
+
borderRadius: 15,
|
|
67
|
+
borderWidth: 1,
|
|
68
|
+
borderColor: Colors.Primary,
|
|
69
|
+
marginTop: 25,
|
|
70
|
+
marginRight: 15,
|
|
71
|
+
},
|
|
72
|
+
circleNotChange: {
|
|
73
|
+
backgroundColor: Colors.White,
|
|
74
|
+
width: 15,
|
|
75
|
+
height: 15,
|
|
76
|
+
borderRadius: 15,
|
|
77
|
+
borderWidth: 1,
|
|
78
|
+
borderColor: Colors.Gray6,
|
|
79
|
+
marginTop: 25,
|
|
80
|
+
marginRight: 15,
|
|
81
|
+
},
|
|
82
|
+
selectAll: {
|
|
83
|
+
flexDirection: 'row',
|
|
84
|
+
},
|
|
85
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { memo, useCallback, useState } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import FImage from '../../../commons/FImage';
|
|
5
|
+
import { API } from '../../../configs';
|
|
6
|
+
import { axiosPatch } from '../../../utils/Apis/axios';
|
|
7
|
+
import _TextInput from '../../../commons/Form/TextInput';
|
|
8
|
+
import AccessibilityLabel from '../../../configs/AccessibilityLabel';
|
|
9
|
+
import styles from './DeviceItemStyles';
|
|
10
|
+
|
|
11
|
+
const DeviceItem = memo(({ icon, name, itemId }) => {
|
|
12
|
+
const [newName, setNewName] = useState(name);
|
|
13
|
+
|
|
14
|
+
const handleBlur = useCallback(async () => {
|
|
15
|
+
await axiosPatch(API.DEVICE.END_DEVICE_DETAIL(itemId), {
|
|
16
|
+
name: newName,
|
|
17
|
+
});
|
|
18
|
+
}, [itemId, newName]);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<View style={styles.container}>
|
|
22
|
+
<FImage source={{ uri: icon }} style={styles.iconSensor} />
|
|
23
|
+
<_TextInput
|
|
24
|
+
value={newName}
|
|
25
|
+
textInputStyle={styles.textItem}
|
|
26
|
+
onChange={setNewName}
|
|
27
|
+
onBlur={handleBlur}
|
|
28
|
+
maxLength={64}
|
|
29
|
+
accessibilityLabel={
|
|
30
|
+
AccessibilityLabel.ON_CHANGE_NAME_DEVICE_SMART_ACCOUNT
|
|
31
|
+
}
|
|
32
|
+
/>
|
|
33
|
+
</View>
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export default DeviceItem;
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import { Colors } from '../../../configs';
|
|
2
|
+
import { Colors, Constants } from '../../../configs';
|
|
3
|
+
|
|
4
|
+
const marginItem = 12;
|
|
5
|
+
const marginHorizontal = 5;
|
|
6
|
+
const widthItem = (Constants.width - marginHorizontal * 2 - marginItem) / 2;
|
|
7
|
+
const heightItem = (widthItem / 166) * 60;
|
|
3
8
|
|
|
4
9
|
export default StyleSheet.create({
|
|
5
10
|
container: {
|
|
11
|
+
paddingHorizontal: 15,
|
|
6
12
|
borderRadius: 10,
|
|
7
13
|
width: 250,
|
|
14
|
+
height: heightItem,
|
|
8
15
|
borderWidth: 1,
|
|
9
16
|
borderColor: Colors.Gray4,
|
|
10
17
|
backgroundColor: Colors.White,
|
|
11
18
|
justifyContent: 'center',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
marginBottom: 16,
|
|
12
21
|
flexDirection: 'row',
|
|
13
22
|
shadowColor: Colors.Shadow,
|
|
14
23
|
shadowOffset: {
|
|
@@ -20,8 +29,6 @@ export default StyleSheet.create({
|
|
|
20
29
|
elevation: 6,
|
|
21
30
|
paddingLeft: 30,
|
|
22
31
|
paddingRight: 30,
|
|
23
|
-
display: 'flex',
|
|
24
|
-
alignItems: 'center',
|
|
25
32
|
},
|
|
26
33
|
iconSensor: {
|
|
27
34
|
width: 32,
|
|
@@ -29,13 +36,14 @@ export default StyleSheet.create({
|
|
|
29
36
|
resizeMode: 'contain',
|
|
30
37
|
},
|
|
31
38
|
textItem: {
|
|
39
|
+
display: 'flex',
|
|
40
|
+
justifyContent: 'center',
|
|
41
|
+
alignItems: 'center',
|
|
32
42
|
borderWidth: 0,
|
|
33
43
|
borderBottomWidth: 1,
|
|
34
44
|
borderBottomColor: Colors.Primary,
|
|
35
45
|
textAlign: 'center',
|
|
36
46
|
marginTop: -10,
|
|
37
|
-
padding: 5,
|
|
38
47
|
fontSize: 16,
|
|
39
|
-
height: 50,
|
|
40
48
|
},
|
|
41
49
|
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { act, create } from 'react-test-renderer';
|
|
3
|
+
import _TextInput from '../../../../commons/Form/TextInput';
|
|
4
|
+
import { API } from '../../../../configs';
|
|
5
|
+
import AccessibilityLabel from '../../../../configs/AccessibilityLabel';
|
|
6
|
+
import { SCProvider } from '../../../../context';
|
|
7
|
+
import { mockSCStore } from '../../../../context/mockStore';
|
|
8
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
9
|
+
import DeviceItem from '../DeviceItem';
|
|
10
|
+
import api from '../../../../utils/Apis/axios';
|
|
11
|
+
|
|
12
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
13
|
+
|
|
14
|
+
const wrapComponent = (props) => (
|
|
15
|
+
<SCProvider initState={mockSCStore({})}>
|
|
16
|
+
<DeviceItem {...props} />
|
|
17
|
+
</SCProvider>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
jest.mock('react', () => {
|
|
21
|
+
return {
|
|
22
|
+
...jest.requireActual('react'),
|
|
23
|
+
memo: (x) => x,
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('Test SmartAccount', () => {
|
|
28
|
+
let tree;
|
|
29
|
+
test('test DeviceItem', async () => {
|
|
30
|
+
let props = {
|
|
31
|
+
icon: '',
|
|
32
|
+
name: 'test',
|
|
33
|
+
itemId: 2,
|
|
34
|
+
};
|
|
35
|
+
await act(() => {
|
|
36
|
+
tree = create(wrapComponent(props));
|
|
37
|
+
});
|
|
38
|
+
const instance = tree.root;
|
|
39
|
+
const texts = instance.findAllByType(_TextInput);
|
|
40
|
+
expect(texts).toHaveLength(1);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('test onchange name device', async () => {
|
|
44
|
+
let props = {
|
|
45
|
+
icon: '',
|
|
46
|
+
name: 'test',
|
|
47
|
+
itemId: 2,
|
|
48
|
+
};
|
|
49
|
+
act(() => {
|
|
50
|
+
tree = create(wrapComponent(props));
|
|
51
|
+
});
|
|
52
|
+
const instance = tree.root;
|
|
53
|
+
const textInput = instance.find(
|
|
54
|
+
(el) =>
|
|
55
|
+
el.props.accessibilityLabel ===
|
|
56
|
+
AccessibilityLabel.ON_CHANGE_NAME_DEVICE_SMART_ACCOUNT &&
|
|
57
|
+
el.type === _TextInput
|
|
58
|
+
);
|
|
59
|
+
await act(async () => {
|
|
60
|
+
await textInput.props.onBlur('new name');
|
|
61
|
+
});
|
|
62
|
+
mock.onPatch(API.DEVICE.END_DEVICE_DETAIL(1)).reply(200);
|
|
63
|
+
expect(textInput).toBeDefined();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import { SafeAreaView } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import SuccessfullyConnected from '../index';
|
|
6
|
+
import { SCProvider } from '../../../../context';
|
|
7
|
+
import { mockSCStore } from '../../../../context/mockStore';
|
|
8
|
+
import Text from '../../../../commons/Text';
|
|
9
|
+
import AccessibilityLabel from '../../../../configs/AccessibilityLabel';
|
|
10
|
+
import Routes from '../../../../utils/Route';
|
|
11
|
+
|
|
12
|
+
const mockedNavigate = jest.fn();
|
|
13
|
+
jest.mock('@react-navigation/native', () => {
|
|
14
|
+
return {
|
|
15
|
+
...jest.requireActual('@react-navigation/native'),
|
|
16
|
+
useNavigation: () => ({
|
|
17
|
+
navigate: mockedNavigate,
|
|
18
|
+
}),
|
|
19
|
+
useIsFocused: () => true,
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const wrapComponent = (route) => (
|
|
24
|
+
<SCProvider initState={mockSCStore({})}>
|
|
25
|
+
<SuccessfullyConnected route={route} />
|
|
26
|
+
</SCProvider>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
describe('Test SuccessfullyConnected', () => {
|
|
30
|
+
let tree;
|
|
31
|
+
const route = {
|
|
32
|
+
params: {
|
|
33
|
+
nameSubUnit: 'test NameSubUnit',
|
|
34
|
+
smart_account_id: 1,
|
|
35
|
+
unit_id: 1,
|
|
36
|
+
username: 'textEoh@gmail.com',
|
|
37
|
+
brand: 'test brand',
|
|
38
|
+
listSelectDevice: [
|
|
39
|
+
{
|
|
40
|
+
icon_kit: '',
|
|
41
|
+
name: 'text device',
|
|
42
|
+
id: 1,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
icon_kit: '',
|
|
46
|
+
name: 'text device 2',
|
|
47
|
+
id: 2,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
afterEach(() => {
|
|
53
|
+
mockedNavigate.mockClear();
|
|
54
|
+
});
|
|
55
|
+
test('render SuccessfullyConnected', () => {
|
|
56
|
+
act(() => {
|
|
57
|
+
tree = renderer.create(wrapComponent(route));
|
|
58
|
+
});
|
|
59
|
+
const instance = tree.root;
|
|
60
|
+
const texts = instance.findAllByType(Text);
|
|
61
|
+
const safeAreaView = instance.findAllByType(SafeAreaView);
|
|
62
|
+
expect(texts).toHaveLength(6);
|
|
63
|
+
expect(safeAreaView).toHaveLength(1);
|
|
64
|
+
});
|
|
65
|
+
test('render onPress finish', () => {
|
|
66
|
+
act(() => {
|
|
67
|
+
tree = renderer.create(wrapComponent(route));
|
|
68
|
+
});
|
|
69
|
+
const instance = tree.root;
|
|
70
|
+
|
|
71
|
+
const next = instance.find(
|
|
72
|
+
(item) =>
|
|
73
|
+
item.props.accessibilityLabel ===
|
|
74
|
+
`${AccessibilityLabel.PREFIX.BUTTON_FINISH_SMART_ACCOUNT}${AccessibilityLabel.VIEW_BUTTON_BOTTOM_RIGHT_BUTTON}`
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
act(async () => {
|
|
78
|
+
next.props.onPress();
|
|
79
|
+
});
|
|
80
|
+
expect(mockedNavigate).toBeCalledWith(Routes.UnitStack, {
|
|
81
|
+
screen: Routes.UnitDetail,
|
|
82
|
+
params: {
|
|
83
|
+
unitId: 1,
|
|
84
|
+
isSuccessfullyConnected: true,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React, { memo, useCallback } from 'react';
|
|
2
|
+
import { View, SafeAreaView, ScrollView } from 'react-native';
|
|
3
|
+
import { CommonActions, useNavigation } from '@react-navigation/native';
|
|
4
|
+
import { IconOutline } from '@ant-design/icons-react-native';
|
|
5
|
+
|
|
6
|
+
import DeviceItem from './DeviceItem';
|
|
7
|
+
import Routes from '../../../utils/Route';
|
|
8
|
+
import Text from '../../../commons/Text';
|
|
9
|
+
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
10
|
+
import { ViewButtonBottom } from '../../../commons';
|
|
11
|
+
import { Colors } from '../../../configs';
|
|
12
|
+
import AccessibilityLabel from '../../../configs/AccessibilityLabel';
|
|
13
|
+
import styles from './styles';
|
|
14
|
+
|
|
15
|
+
const SuccessfullyConnected = memo(({ route }) => {
|
|
16
|
+
const {
|
|
17
|
+
nameSubUnit,
|
|
18
|
+
listSelectDevice,
|
|
19
|
+
smart_account_id,
|
|
20
|
+
unit_id,
|
|
21
|
+
stationId,
|
|
22
|
+
smart_account_id_from_backend,
|
|
23
|
+
username,
|
|
24
|
+
brand,
|
|
25
|
+
} = route.params;
|
|
26
|
+
const t = useTranslations();
|
|
27
|
+
const { navigate, dispatch } = useNavigation();
|
|
28
|
+
|
|
29
|
+
const handleContinue = useCallback(() => {
|
|
30
|
+
navigate(Routes.ListDeviceSmartAccount, {
|
|
31
|
+
smart_account_id: smart_account_id || smart_account_id_from_backend,
|
|
32
|
+
username,
|
|
33
|
+
brand,
|
|
34
|
+
unit_id,
|
|
35
|
+
});
|
|
36
|
+
}, [
|
|
37
|
+
brand,
|
|
38
|
+
navigate,
|
|
39
|
+
smart_account_id,
|
|
40
|
+
smart_account_id_from_backend,
|
|
41
|
+
unit_id,
|
|
42
|
+
username,
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
const handleFinish = useCallback(() => {
|
|
46
|
+
navigate(Routes.UnitStack, {
|
|
47
|
+
screen: Routes.UnitDetail,
|
|
48
|
+
params: {
|
|
49
|
+
unitId: unit_id,
|
|
50
|
+
stationId,
|
|
51
|
+
isSuccessfullyConnected: true,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
dispatch((state) => {
|
|
55
|
+
const routes = [];
|
|
56
|
+
return CommonActions.reset({
|
|
57
|
+
...state,
|
|
58
|
+
...routes.push({ name: Routes.Dashboard, key: Routes.Dashboard }),
|
|
59
|
+
index: routes.length - 1,
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}, [dispatch, navigate, stationId, unit_id]);
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<>
|
|
66
|
+
<SafeAreaView style={styles.wrap}>
|
|
67
|
+
<ScrollView>
|
|
68
|
+
<View style={styles.body}>
|
|
69
|
+
<IconOutline name="check-circle" size={28} color={Colors.Green6} />
|
|
70
|
+
<Text bold style={styles.connectingText}>
|
|
71
|
+
{t('successfully_connected')}
|
|
72
|
+
</Text>
|
|
73
|
+
<Text size={14} style={styles.textHome}>
|
|
74
|
+
Home - {nameSubUnit}
|
|
75
|
+
</Text>
|
|
76
|
+
{listSelectDevice.map((item) => (
|
|
77
|
+
<DeviceItem
|
|
78
|
+
icon={item?.icon_kit}
|
|
79
|
+
name={item?.name}
|
|
80
|
+
itemId={item.id}
|
|
81
|
+
/>
|
|
82
|
+
))}
|
|
83
|
+
</View>
|
|
84
|
+
</ScrollView>
|
|
85
|
+
</SafeAreaView>
|
|
86
|
+
<View style={styles.ViewButtonBottom}>
|
|
87
|
+
<ViewButtonBottom
|
|
88
|
+
leftTitle={t('continue')}
|
|
89
|
+
onLeftClick={handleContinue}
|
|
90
|
+
rightTitle={t('finish')}
|
|
91
|
+
onRightClick={handleFinish}
|
|
92
|
+
accessibilityLabelPrefix={
|
|
93
|
+
AccessibilityLabel.PREFIX.BUTTON_FINISH_SMART_ACCOUNT
|
|
94
|
+
}
|
|
95
|
+
/>
|
|
96
|
+
</View>
|
|
97
|
+
</>
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
export default SuccessfullyConnected;
|