@eohjsc/react-native-smart-city 0.3.4 → 0.3.7
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 +15 -36
- package/package.json +5 -9
- package/react-native-smart-city.podspec +0 -1
- package/src/commons/Action/ItemQuickAction.js +4 -16
- package/src/commons/Action/__test__/ItemQuickAction.test.js +6 -11
- package/src/commons/ActionGroup/ColorPickerTemplate.js +24 -37
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +5 -10
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +31 -12
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +0 -4
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +0 -14
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +0 -1
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +2 -8
- package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +10 -10
- package/src/commons/ActionGroup/OnOffTemplate/index.js +2 -3
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +9 -7
- package/src/commons/ActionGroup/SliderRangeTemplate.js +2 -6
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +3 -7
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +8 -22
- package/src/commons/ActionGroup/TimerActionTemplate.js +3 -11
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +5 -1
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +4 -53
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +83 -3
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +78 -53
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +20 -36
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +57 -1
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +6 -58
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +1 -49
- package/src/commons/ActionGroup/__test__/index.test.js +4 -142
- package/src/commons/Auth/AccountList.js +1 -1
- package/src/commons/Automate/ItemAutomate.js +3 -1
- package/src/commons/Connecting/__test__/Connecting.test.js +2 -19
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +3 -7
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +11 -8
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +3 -136
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +2 -3
- package/src/commons/ConnectingProcess/index.js +25 -75
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +13 -16
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +5 -0
- package/src/commons/Device/ConnectedViewHeader.js +1 -1
- package/src/commons/Device/HistoryChart.js +3 -7
- package/src/commons/Device/ItemDevice.js +12 -19
- package/src/commons/Device/LinearChart.js +0 -15
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +12 -16
- package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +0 -3
- package/src/commons/Device/SonosSpeaker/index.js +1 -1
- package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +0 -1
- package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +2 -7
- package/src/commons/Explore/__test__/CityItem.test.js +54 -33
- package/src/commons/Form/CurrencyInput.js +1 -15
- package/src/commons/Form/TextInputPassword.js +1 -1
- package/src/commons/FullLoading/index.js +1 -2
- package/src/commons/Header/HeaderCustom.js +1 -2
- package/src/commons/HeaderAni/index.js +1 -6
- package/src/commons/HorizontalPicker/index.js +2 -2
- package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +6 -0
- package/src/commons/MediaPlayerDetail/index.js +47 -25
- package/src/commons/MenuActionAddnew/index.js +0 -1
- package/src/commons/MenuActionList/index.js +0 -1
- package/src/commons/MenuActionMore/index.js +1 -1
- package/src/commons/PreventAccess/index.js +1 -9
- package/src/commons/Sharing/MemberList.js +2 -10
- package/src/commons/Sharing/WrapHeaderScrollable.js +0 -2
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +1 -0
- package/src/commons/SubUnit/Favorites/index.js +3 -2
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +35 -8
- package/src/commons/SubUnit/OneTap/index.js +2 -1
- package/src/commons/SubUnit/ShortDetail.js +9 -25
- package/src/commons/SubUnit/__test__/Item.test.js +1 -0
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +2 -9
- package/src/commons/Unit/SharedUnit.js +0 -1
- package/src/commons/Unit/__test__/SharedUnit.test.js +183 -38
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +13 -2
- package/src/commons/UnitSummary/ConfigHistoryChart.js +13 -22
- package/src/commons/WheelDateTimePicker/index.js +3 -4
- package/src/configs/API.js +143 -87
- package/src/configs/Constants.js +2 -57
- package/src/configs/SCConfig.js +0 -4
- package/src/context/actionType.ts +0 -8
- package/src/context/mockStore.ts +0 -10
- package/src/context/reducer.ts +2 -38
- package/src/hooks/Common/index.js +0 -2
- package/src/hooks/Common/useGetIdUser.js +5 -1
- package/src/hooks/Common/useSensorsStatus.js +4 -4
- package/src/hooks/useReceiveNotifications.js +5 -9
- package/src/iot/Monitor.js +2 -3
- package/src/iot/RemoteControl/Bluetooth.js +1 -1
- package/src/iot/RemoteControl/GoogleHome.js +49 -75
- package/src/iot/RemoteControl/Internet.js +1 -1
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +48 -95
- package/src/iot/RemoteControl/__test__/Internet.test.js +7 -18
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +177 -36
- package/src/iot/RemoteControl/index.js +52 -52
- package/src/navigations/UnitStack.js +20 -11
- package/src/screens/AQIGuide/index.js +1 -1
- package/src/screens/ActivityLog/FilterPopup.js +0 -2
- package/src/screens/ActivityLog/__test__/index.test.js +23 -38
- package/src/screens/ActivityLog/hooks/__test__/index.test.js +90 -51
- package/src/screens/ActivityLog/hooks/index.js +1 -1
- package/src/screens/ActivityLog/index.js +2 -2
- package/src/screens/AddCommon/SelectSubUnit.js +0 -1
- package/src/screens/AddCommon/SelectUnit.js +0 -1
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +24 -13
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +33 -9
- package/src/screens/AddLocationMaps/index.js +5 -9
- package/src/screens/AddNewAction/SelectAction.js +8 -8
- package/src/screens/AddNewAction/SelectSensorDevices.js +2 -8
- package/src/screens/AddNewAction/SetupSensor.js +7 -7
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +91 -10
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +26 -40
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +1 -3
- package/src/screens/AddNewAutoSmart/index.js +2 -5
- package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +34 -42
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +4 -0
- package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +22 -22
- package/src/screens/AddNewDevice/hooks/ConnectDevices.js +1 -1
- package/src/screens/AddNewDevice/index.js +0 -1
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +17 -23
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +4 -7
- package/src/screens/AddNewGateway/SelectGateway.js +0 -1
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +0 -2
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +6 -4
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +4 -0
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +29 -5
- package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +4 -0
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +4 -0
- package/src/screens/AddNewGateway/index.js +0 -1
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +24 -10
- package/src/screens/AddNewOneTap/index.js +2 -3
- package/src/screens/AllCamera/index.js +4 -4
- package/src/screens/Automate/MultiUnits.js +8 -8
- package/src/screens/Automate/__test__/MultiUnits.test.js +9 -6
- package/src/screens/Automate/__test__/index.test.js +12 -7
- package/src/screens/Automate/index.js +3 -5
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +8 -36
- package/src/screens/ConfirmUnitDeletion/index.js +1 -7
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +22 -71
- package/src/screens/Device/EditDevice/index.js +15 -17
- package/src/screens/Device/__test__/detail.test.js +86 -33
- package/src/screens/Device/components/DetailHistoryChart.js +1 -1
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +0 -1
- package/src/screens/Device/components/SensorDisplayItem.js +2 -5
- package/src/screens/Device/detail.js +24 -80
- package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
- package/src/screens/Device/hooks/useFavoriteDevice.js +9 -5
- package/src/screens/DeviceInfo/__test__/index.test.js +2 -0
- package/src/screens/EditActionsList/index.js +1 -1
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +3 -6
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +19 -7
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +2 -20
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +23 -40
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EmergencySetting/index.js +1 -4
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +25 -41
- package/src/screens/Explore/index.js +0 -2
- package/src/screens/GuestInfo/__test__/index.test.js +41 -14
- package/src/screens/GuestInfo/components/RecurringDetail.js +0 -1
- package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
- package/src/screens/HanetCamera/Detail.js +1 -1
- package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +12 -8
- package/src/screens/HanetCamera/__test__/Detail.test.js +42 -27
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +5 -8
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +32 -10
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -3
- package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +35 -43
- package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +21 -10
- package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +11 -11
- package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
- package/src/screens/ManageAccess/__test__/ManageAccess.test.js +22 -33
- package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +45 -44
- package/src/screens/ManageAccess/hooks/index.js +4 -7
- package/src/screens/ManageAccess/index.js +1 -2
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +12 -35
- package/src/screens/MoveToAnotherSubUnit/index.js +6 -6
- package/src/screens/Notification/__test__/Notification.test.js +25 -14
- package/src/screens/Notification/__test__/NotificationItem.test.js +7 -8
- package/src/screens/Notification/components/NotificationItem.js +20 -17
- package/src/screens/Notification/index.js +2 -9
- package/src/screens/PlayBackCamera/Timer.js +2 -2
- package/src/screens/PlayBackCamera/__test__/index.test.js +2 -87
- package/src/screens/PlayBackCamera/index.js +6 -22
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +20 -7
- package/src/screens/ScanChipQR/components/QRScan/index.js +0 -1
- package/src/screens/ScanChipQR/hooks/index.js +16 -15
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +24 -8
- package/src/screens/ScriptDetail/__test__/index.test.js +86 -17
- package/src/screens/ScriptDetail/index.js +14 -19
- package/src/screens/SelectUnit/__test__/index.test.js +55 -12
- package/src/screens/SelectUnit/index.js +4 -9
- package/src/screens/SetSchedule/index.js +11 -15
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +2 -0
- package/src/screens/SharedUnit/index.js +0 -2
- package/src/screens/Sharing/Components/SensorItem.js +12 -10
- package/src/screens/Sharing/InfoMemberUnit.js +1 -1
- package/src/screens/Sharing/MemberList.js +11 -12
- package/src/screens/Sharing/SelectPermission.js +76 -121
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +29 -47
- package/src/screens/Sharing/__test__/MemberList.test.js +127 -13
- package/src/screens/Sharing/__test__/SelectPermission.test.js +38 -28
- package/src/screens/Sharing/__test__/SelectUser.test.js +38 -17
- package/src/screens/Sharing/hooks/index.js +0 -3
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +2 -3
- package/src/screens/SmartIr/components/SelectBrand.js +1 -1
- package/src/screens/SubUnit/AddSubUnit.js +17 -23
- package/src/screens/SubUnit/Detail.js +2 -1
- package/src/screens/SubUnit/EditSubUnit.js +13 -15
- package/src/screens/SubUnit/ManageSubUnit.js +7 -13
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +89 -29
- package/src/screens/SubUnit/__test__/Detail.test.js +8 -31
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +89 -21
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +1 -27
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +45 -48
- package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
- package/src/screens/SyncLGDevice/AddLGDevice.js +0 -1
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +91 -22
- package/src/screens/TDSGuide/index.js +1 -4
- package/src/screens/UVIndexGuide/index.js +1 -1
- package/src/screens/Unit/ChooseLocation.js +14 -7
- package/src/screens/Unit/Detail.js +75 -30
- package/src/screens/Unit/ManageUnit.js +0 -1
- package/src/screens/Unit/SelectAddress.js +23 -45
- package/src/screens/Unit/SmartAccount.js +4 -4
- package/src/screens/Unit/Station/index.js +0 -4
- package/src/screens/Unit/Summaries.js +2 -18
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +29 -24
- package/src/screens/Unit/__test__/ChooseLocation.test.js +14 -27
- package/src/screens/Unit/__test__/Detail.test.js +200 -99
- package/src/screens/Unit/__test__/ManageUnit.test.js +42 -18
- package/src/screens/Unit/__test__/SelectAddress.test.js +49 -159
- package/src/screens/Unit/__test__/SmartAccount.test.js +9 -17
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +1 -0
- package/src/screens/Unit/components/MyUnitDevice/index.js +4 -4
- package/src/screens/Unit/components/SharedUnit/index.js +0 -1
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +34 -31
- package/src/screens/Unit/styles.js +0 -4
- package/src/screens/UnitSummary/__test__/index.test.js +30 -91
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +2 -31
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +4 -7
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +13 -2
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +1 -0
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +16 -14
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -11
- package/src/screens/UnitSummary/components/RunningDevices/index.js +10 -7
- package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +2 -10
- package/src/screens/UnitSummary/index.js +1 -15
- package/src/screens/WaterQualityGuide/index.js +1 -1
- package/src/utils/Apis/axios.js +31 -54
- package/src/utils/Converter/time.js +18 -0
- package/src/utils/I18n/translations/en.json +1 -7
- package/src/utils/I18n/translations/vi.json +1 -8
- package/src/utils/Route/index.js +0 -1
- package/src/utils/Utils.js +7 -11
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +0 -24
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplateWithNullConfigValue.test.js +0 -60
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +0 -77
- package/src/commons/Calendar/__test__/Calendar.test.js +0 -33
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +0 -58
- package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +0 -25
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +0 -96
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +0 -39
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +0 -118
- package/src/commons/FieldTemplate/ChooseUserField/index.js +0 -62
- package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +0 -30
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +0 -90
- package/src/commons/FieldTemplate/PasscodeField/index.js +0 -43
- package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +0 -13
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +0 -179
- package/src/commons/FieldTemplate/ScheduleField/index.js +0 -176
- package/src/commons/PreventAccess/__test__/PreventAccess.test.js +0 -62
- package/src/hooks/Common/useGGHomeDeviceConnected.js +0 -16
- package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +0 -198
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +0 -198
- package/src/hooks/IoT/index.js +0 -4
- package/src/hooks/IoT/useGGHomeConnection.js +0 -91
- package/src/hooks/IoT/useRemoteControl.js +0 -79
- package/src/hooks/index.js +0 -4
- package/src/navigations/UnitStackStyles.js +0 -21
- package/src/screens/Sharing/__test__/MemberList2.test.js +0 -80
- package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +0 -28
- package/src/screens/SideMenuDetail/__test__/index.test.js +0 -154
- package/src/screens/SideMenuDetail/index.js +0 -148
- package/src/screens/Unit/__test__/Summaries.test.js +0 -100
- package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +0 -36
- package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -54
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +0 -50
- package/src/utils/Permission/common.js +0 -67
- package/src/utils/Setting/Location.js +0 -30
- package/src/utils/__test__/Utils.test.js +0 -12
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
1
2
|
import React, { memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
2
3
|
import { TouchableOpacity, View, ScrollView } from 'react-native';
|
|
3
4
|
import MapView, { Marker, Circle, PROVIDER_GOOGLE } from 'react-native-maps';
|
|
4
5
|
import { useNavigation } from '@react-navigation/native';
|
|
5
6
|
import { IconOutline, IconFill } from '@ant-design/icons-react-native';
|
|
6
|
-
import { check, RESULTS } from 'react-native-permissions';
|
|
7
|
-
import { openPromptEnableLocation } from '../../utils/Setting/Location';
|
|
8
7
|
|
|
9
8
|
import BottomButtonView from '../../commons/BottomButtonView';
|
|
10
9
|
import SearchBarLocation from '../../commons/SearchLocation';
|
|
@@ -12,23 +11,22 @@ import RowLocation from '../../commons/SearchLocation/RowLocation';
|
|
|
12
11
|
import Text from '../../commons/Text';
|
|
13
12
|
import { FullLoading } from '../../commons';
|
|
14
13
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
keyPermission,
|
|
18
|
-
OpenSetting,
|
|
19
|
-
} from '../../utils/Permission/common';
|
|
14
|
+
|
|
15
|
+
navigator.geolocation = require('@react-native-community/geolocation');
|
|
20
16
|
|
|
21
17
|
import styles from './SelectAddressStyles';
|
|
22
18
|
import { API, Colors, SCConfig } from '../../configs';
|
|
23
19
|
import { axiosGet } from '../../utils/Apis/axios';
|
|
24
20
|
import Routes from '../../utils/Route';
|
|
25
|
-
import {
|
|
26
|
-
TESTID,
|
|
27
|
-
MAP_INITIAL_REGION,
|
|
28
|
-
EOH_LOCATION,
|
|
29
|
-
} from '../../configs/Constants';
|
|
21
|
+
import { TESTID } from '../../configs/Constants';
|
|
30
22
|
|
|
31
|
-
|
|
23
|
+
const initialRegion = {
|
|
24
|
+
latitudeDelta: 0.0922,
|
|
25
|
+
longitudeDelta: 0.0421,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const DEFAULT_LATITUDE = 10.7974046; // EoH center
|
|
29
|
+
const DEFAULT_LONGITUDE = 106.7035663;
|
|
32
30
|
|
|
33
31
|
const SelectAddress = memo(({ route }) => {
|
|
34
32
|
const t = useTranslations();
|
|
@@ -48,9 +46,9 @@ const SelectAddress = memo(({ route }) => {
|
|
|
48
46
|
goBack();
|
|
49
47
|
}, [goBack, updateLocation, searchedLocation]);
|
|
50
48
|
|
|
51
|
-
const onTextInput = useCallback(async (
|
|
52
|
-
setInput(
|
|
53
|
-
if (
|
|
49
|
+
const onTextInput = useCallback(async (input) => {
|
|
50
|
+
setInput(input);
|
|
51
|
+
if (input === '') {
|
|
54
52
|
setSearchData([]);
|
|
55
53
|
setSearchedLocation(null);
|
|
56
54
|
return;
|
|
@@ -58,7 +56,7 @@ const SelectAddress = memo(({ route }) => {
|
|
|
58
56
|
try {
|
|
59
57
|
const config = {
|
|
60
58
|
params: {
|
|
61
|
-
input:
|
|
59
|
+
input: input,
|
|
62
60
|
key: SCConfig.GOOGLE_MAP_API_KEY,
|
|
63
61
|
sessiontoken: 123456324,
|
|
64
62
|
strictBounds: false,
|
|
@@ -73,7 +71,6 @@ const SelectAddress = memo(({ route }) => {
|
|
|
73
71
|
if (success) {
|
|
74
72
|
setSearchData(data.predictions);
|
|
75
73
|
}
|
|
76
|
-
// eslint-disable-next-line no-empty
|
|
77
74
|
} catch (error) {}
|
|
78
75
|
}, []);
|
|
79
76
|
|
|
@@ -86,8 +83,7 @@ const SelectAddress = memo(({ route }) => {
|
|
|
86
83
|
{
|
|
87
84
|
latitude: lat,
|
|
88
85
|
longitude: lng,
|
|
89
|
-
|
|
90
|
-
longitudeDelta: MAP_INITIAL_REGION.LNG,
|
|
86
|
+
...initialRegion,
|
|
91
87
|
},
|
|
92
88
|
600
|
|
93
89
|
);
|
|
@@ -144,24 +140,10 @@ const SelectAddress = memo(({ route }) => {
|
|
|
144
140
|
setLoading(false);
|
|
145
141
|
},
|
|
146
142
|
// eslint-disable-next-line promise/prefer-await-to-callbacks
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const permissionResult = await check(keyPermission.LOCATION);
|
|
150
|
-
permissionResult === RESULTS.BLOCKED &&
|
|
151
|
-
OpenSetting(
|
|
152
|
-
t('location_rationale_title'),
|
|
153
|
-
t('location_require_message')
|
|
154
|
-
);
|
|
155
|
-
} else if (error.code === GEOLOCATION_ERROR.POSITION_UNAVAILABLE) {
|
|
156
|
-
const locationEnabaled = await openPromptEnableLocation();
|
|
157
|
-
process.env.NODE_ENV !== 'test' &&
|
|
158
|
-
locationEnabaled &&
|
|
159
|
-
getCurrentPosition();
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
// { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 } // enable on emulator
|
|
143
|
+
(error) => {}
|
|
144
|
+
// { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 } enable on emulator
|
|
163
145
|
);
|
|
164
|
-
}, [
|
|
146
|
+
}, []);
|
|
165
147
|
|
|
166
148
|
const chooseOnMap = useCallback(() => {
|
|
167
149
|
navigate(Routes.ChooseLocation, {
|
|
@@ -181,10 +163,7 @@ const SelectAddress = memo(({ route }) => {
|
|
|
181
163
|
<View style={styles.wrap}>
|
|
182
164
|
<View style={styles.searchLocation}>
|
|
183
165
|
<SearchBarLocation input={input} onTextInput={onTextInput} />
|
|
184
|
-
<ScrollView
|
|
185
|
-
style={styles.searchData}
|
|
186
|
-
scrollIndicatorInsets={{ right: 1 }}
|
|
187
|
-
>
|
|
166
|
+
<ScrollView style={styles.searchData}>
|
|
188
167
|
{searchData.map((item, index) => (
|
|
189
168
|
<RowLocation key={index} item={item} onPress={onPressRowLocation} />
|
|
190
169
|
))}
|
|
@@ -220,10 +199,9 @@ const SelectAddress = memo(({ route }) => {
|
|
|
220
199
|
provider={PROVIDER_GOOGLE}
|
|
221
200
|
style={styles.mapView}
|
|
222
201
|
initialRegion={{
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
longitudeDelta: MAP_INITIAL_REGION.LNG,
|
|
202
|
+
...initialRegion,
|
|
203
|
+
latitude: DEFAULT_LATITUDE,
|
|
204
|
+
longitude: DEFAULT_LONGITUDE,
|
|
227
205
|
}}
|
|
228
206
|
followUserLocation={true}
|
|
229
207
|
>
|
|
@@ -29,13 +29,13 @@ const ListSmartAccount = ({ route }) => {
|
|
|
29
29
|
const [loadingRemoveItem, setLoadingRemoveItem] = useState(false);
|
|
30
30
|
|
|
31
31
|
const getAllSmartAccounts = useCallback(async () => {
|
|
32
|
-
const { success, data
|
|
33
|
-
API.SMART_ACCOUNT.LIST_SMART_ACCOUNT(
|
|
32
|
+
const { success, data } = await axiosGet(
|
|
33
|
+
API.SMART_ACCOUNT.LIST_SMART_ACCOUNT()
|
|
34
34
|
);
|
|
35
35
|
if (success) {
|
|
36
|
-
setData(
|
|
36
|
+
setData(data);
|
|
37
37
|
}
|
|
38
|
-
}, [
|
|
38
|
+
}, []);
|
|
39
39
|
|
|
40
40
|
const { childRef, showingPopover, showPopoverWithRef, hidePopover } =
|
|
41
41
|
usePopover();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { memo, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { View, Text, TouchableOpacity, FlatList } from 'react-native';
|
|
3
|
-
import { TESTID } from '../../../configs/Constants';
|
|
4
3
|
import styles from './StationStyles';
|
|
5
4
|
|
|
6
5
|
const Station = ({ listStation = [], onSnapToItem, indexStation }) => {
|
|
@@ -24,7 +23,6 @@ const Station = ({ listStation = [], onSnapToItem, indexStation }) => {
|
|
|
24
23
|
key={index}
|
|
25
24
|
style={styles.wrapTitle}
|
|
26
25
|
onPress={handleOnSnapToItem(item, index)}
|
|
27
|
-
testID={`${TESTID.SUB_UNIT_NAME}-${item?.station?.id}`}
|
|
28
26
|
>
|
|
29
27
|
<Text
|
|
30
28
|
style={[styles.title, index === indexStation && styles.titleActive]}
|
|
@@ -72,8 +70,6 @@ const Station = ({ listStation = [], onSnapToItem, indexStation }) => {
|
|
|
72
70
|
extraData={data}
|
|
73
71
|
renderItem={renderItem}
|
|
74
72
|
showsHorizontalScrollIndicator={false}
|
|
75
|
-
scrollIndicatorInsets={{ right: 1 }}
|
|
76
|
-
testID={TESTID.NAV_LIST}
|
|
77
73
|
/>
|
|
78
74
|
</View>
|
|
79
75
|
);
|
|
@@ -5,7 +5,6 @@ import Routes from '../../utils/Route';
|
|
|
5
5
|
import { useIsFocused, useNavigation } from '@react-navigation/native';
|
|
6
6
|
import { axiosGet } from '../../utils/Apis/axios';
|
|
7
7
|
import { API } from '../../configs';
|
|
8
|
-
import { useReceiveNotifications } from '../../hooks';
|
|
9
8
|
|
|
10
9
|
const Summaries = memo(({ unit }) => {
|
|
11
10
|
const [unitSummaries, setUnitSummaries] = useState([]);
|
|
@@ -34,8 +33,6 @@ const Summaries = memo(({ unit }) => {
|
|
|
34
33
|
const goToSummary = useCallback(
|
|
35
34
|
(summary) => {
|
|
36
35
|
navigation.navigate(Routes.UnitSummary, {
|
|
37
|
-
summaryId: summary.id,
|
|
38
|
-
unitId: unit.id,
|
|
39
36
|
summaryData: summary,
|
|
40
37
|
unitData: unit,
|
|
41
38
|
});
|
|
@@ -53,7 +50,7 @@ const Summaries = memo(({ unit }) => {
|
|
|
53
50
|
if (success) {
|
|
54
51
|
localState.timeoutId = setTimeout(() => {
|
|
55
52
|
continuousFetchSummary();
|
|
56
|
-
},
|
|
53
|
+
}, 5000);
|
|
57
54
|
}
|
|
58
55
|
}, [localState, fetchUnitSummary]);
|
|
59
56
|
|
|
@@ -85,23 +82,10 @@ const Summaries = memo(({ unit }) => {
|
|
|
85
82
|
};
|
|
86
83
|
}, [localState, continuousFetchSummary, isFocused]);
|
|
87
84
|
|
|
88
|
-
const { dataNotification } = useReceiveNotifications();
|
|
89
|
-
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
if (dataNotification) {
|
|
92
|
-
const { params = {} } = dataNotification;
|
|
93
|
-
const { summary_id } = params;
|
|
94
|
-
if (summary_id) {
|
|
95
|
-
fetchUnitSummary();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
99
|
-
}, [dataNotification]);
|
|
100
|
-
|
|
101
85
|
return (
|
|
102
86
|
<>
|
|
103
87
|
{!unitSummaries || !unitSummaries.length ? null : (
|
|
104
|
-
<ScrollView horizontal={true}
|
|
88
|
+
<ScrollView horizontal={true}>
|
|
105
89
|
{unitSummaries.map((item, index) => (
|
|
106
90
|
<SummaryItem key={index} item={item} goToSummary={goToSummary} />
|
|
107
91
|
))}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { act, create } from 'react-test-renderer';
|
|
3
|
-
import MockAdapter from 'axios-mock-adapter';
|
|
4
|
-
|
|
1
|
+
import axios from 'axios';
|
|
5
2
|
import { API } from '../../../configs';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import renderer, { act } from 'react-test-renderer';
|
|
6
5
|
import UnitDetail from '../Detail';
|
|
6
|
+
import { useIsFocused } from '@react-navigation/native';
|
|
7
|
+
import AsyncStorage from '@react-native-community/async-storage';
|
|
7
8
|
import { SCProvider } from '../../../context';
|
|
8
9
|
import { mockSCStore } from '../../../context/mockStore';
|
|
9
|
-
import api from '../../../utils/Apis/axios';
|
|
10
|
-
import NavBar from '../../../commons/NavBar';
|
|
11
|
-
|
|
12
|
-
const mock = new MockAdapter(api.axiosInstance);
|
|
13
10
|
|
|
14
11
|
const mockDispatch = jest.fn();
|
|
15
12
|
|
|
@@ -24,11 +21,11 @@ jest.mock('react-redux', () => ({
|
|
|
24
21
|
|
|
25
22
|
jest.mock('../../../iot/RemoteControl/GoogleHome', () => ({
|
|
26
23
|
...jest.requireActual('../../../iot/RemoteControl/GoogleHome'),
|
|
27
|
-
googleHomeConnect: jest.fn(
|
|
28
|
-
[1]: {},
|
|
29
|
-
})),
|
|
24
|
+
googleHomeConnect: jest.fn(() => false),
|
|
30
25
|
}));
|
|
31
26
|
|
|
27
|
+
jest.mock('axios');
|
|
28
|
+
|
|
32
29
|
jest.mock('@react-native-community/netinfo', () => {
|
|
33
30
|
return {
|
|
34
31
|
useNetInfo: () => {
|
|
@@ -39,12 +36,6 @@ jest.mock('@react-native-community/netinfo', () => {
|
|
|
39
36
|
};
|
|
40
37
|
});
|
|
41
38
|
|
|
42
|
-
jest.mock('react-native-onesignal', () => {
|
|
43
|
-
return {
|
|
44
|
-
setNotificationWillShowInForegroundHandler: jest.fn(),
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
|
|
48
39
|
const wrapComponent = (route, unitData, account) => (
|
|
49
40
|
<SCProvider initState={mockSCStore({})}>
|
|
50
41
|
<UnitDetail
|
|
@@ -55,7 +46,6 @@ const wrapComponent = (route, unitData, account) => (
|
|
|
55
46
|
);
|
|
56
47
|
|
|
57
48
|
describe('Test UnitDetail google home disconnect', () => {
|
|
58
|
-
let tree;
|
|
59
49
|
const route = {
|
|
60
50
|
params: {
|
|
61
51
|
unitId: 1,
|
|
@@ -63,6 +53,15 @@ describe('Test UnitDetail google home disconnect', () => {
|
|
|
63
53
|
};
|
|
64
54
|
const account = {};
|
|
65
55
|
|
|
56
|
+
axios.get.mockImplementation(() => ({ status: 200 }));
|
|
57
|
+
|
|
58
|
+
beforeEach(() => {
|
|
59
|
+
jest.clearAllTimers();
|
|
60
|
+
axios.get.mockClear();
|
|
61
|
+
useIsFocused.mockImplementation(() => true);
|
|
62
|
+
AsyncStorage.clear();
|
|
63
|
+
});
|
|
64
|
+
|
|
66
65
|
test('when unit has google home disconnect call api check send email', async () => {
|
|
67
66
|
const unitData = {
|
|
68
67
|
remote_control_options: {
|
|
@@ -77,12 +76,18 @@ describe('Test UnitDetail google home disconnect', () => {
|
|
|
77
76
|
],
|
|
78
77
|
},
|
|
79
78
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
jest.useFakeTimers();
|
|
80
|
+
|
|
81
|
+
await act(async () => {
|
|
82
|
+
await renderer.create(wrapComponent(route, unitData, account));
|
|
83
83
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
|
|
85
|
+
expect(axios.post).toHaveBeenCalledWith(
|
|
86
|
+
API.GOOGLE_HOME.CHECK_SEND_EMAIL(),
|
|
87
|
+
{
|
|
88
|
+
chip_id: 1,
|
|
89
|
+
is_connected: false,
|
|
90
|
+
}
|
|
91
|
+
);
|
|
87
92
|
});
|
|
88
93
|
});
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
|
-
import MockAdapter from 'axios-mock-adapter';
|
|
4
|
-
import MapView from 'react-native-maps';
|
|
5
|
-
|
|
6
3
|
import { SCProvider } from '../../../context';
|
|
7
4
|
import { mockSCStore } from '../../../context/mockStore';
|
|
8
5
|
import ChooseLocation from '../ChooseLocation';
|
|
9
|
-
import
|
|
6
|
+
import axios from 'axios';
|
|
7
|
+
import { API, SCConfig } from '../../../configs';
|
|
10
8
|
import BottomButtonView from '../../../commons/BottomButtonView';
|
|
11
|
-
import api from '../../../utils/Apis/axios';
|
|
12
9
|
|
|
13
10
|
const wrapComponent = (route) => (
|
|
14
11
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -46,7 +43,7 @@ jest.mock('react-native-maps', () => {
|
|
|
46
43
|
};
|
|
47
44
|
});
|
|
48
45
|
|
|
49
|
-
|
|
46
|
+
jest.mock('axios');
|
|
50
47
|
|
|
51
48
|
describe('Test ChooseLocation', () => {
|
|
52
49
|
let tree;
|
|
@@ -55,6 +52,7 @@ describe('Test ChooseLocation', () => {
|
|
|
55
52
|
const mockSetLocation = jest.fn();
|
|
56
53
|
|
|
57
54
|
beforeAll(() => {
|
|
55
|
+
axios.get.mockClear();
|
|
58
56
|
route = {
|
|
59
57
|
params: {
|
|
60
58
|
location: {
|
|
@@ -67,24 +65,6 @@ describe('Test ChooseLocation', () => {
|
|
|
67
65
|
};
|
|
68
66
|
});
|
|
69
67
|
|
|
70
|
-
test('test render without location', async () => {
|
|
71
|
-
await act(async () => {
|
|
72
|
-
tree = await create(wrapComponent({}));
|
|
73
|
-
});
|
|
74
|
-
const instance = tree.root;
|
|
75
|
-
const buttonBottom = instance.findByType(BottomButtonView);
|
|
76
|
-
expect(buttonBottom).toBeDefined();
|
|
77
|
-
await act(async () => {
|
|
78
|
-
await buttonBottom.props.onPressMain();
|
|
79
|
-
});
|
|
80
|
-
const MapViews = instance.findByType(MapView);
|
|
81
|
-
await MapViews.props.onRegionChangeComplete({
|
|
82
|
-
latitude: 1,
|
|
83
|
-
longitude: 1,
|
|
84
|
-
});
|
|
85
|
-
expect(mockSetLocation).not.toBeCalled();
|
|
86
|
-
});
|
|
87
|
-
|
|
88
68
|
test('test done choose location', async () => {
|
|
89
69
|
await act(async () => {
|
|
90
70
|
tree = await create(wrapComponent(route));
|
|
@@ -108,12 +88,19 @@ describe('Test ChooseLocation', () => {
|
|
|
108
88
|
],
|
|
109
89
|
},
|
|
110
90
|
};
|
|
111
|
-
|
|
112
|
-
.onGet(API.EXTERNAL.GOOGLE_MAP.GET_LOCATION_FROM_LAT_LNG)
|
|
113
|
-
.reply(200, response.data);
|
|
91
|
+
axios.get.mockImplementation(async () => response);
|
|
114
92
|
await act(async () => {
|
|
115
93
|
await buttonBottom.props.onPressMain();
|
|
116
94
|
});
|
|
95
|
+
expect(axios.get).toBeCalledWith(
|
|
96
|
+
API.EXTERNAL.GOOGLE_MAP.GET_LOCATION_FROM_LAT_LNG,
|
|
97
|
+
{
|
|
98
|
+
params: {
|
|
99
|
+
latlng: '10,10',
|
|
100
|
+
key: SCConfig.GOOGLE_MAP_API_KEY,
|
|
101
|
+
},
|
|
102
|
+
}
|
|
103
|
+
);
|
|
117
104
|
expect(mockSetAddress).toBeCalledWith('address');
|
|
118
105
|
expect(mockSetLocation).toBeCalledWith({
|
|
119
106
|
description: 'address',
|