@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,11 +1,9 @@
|
|
|
1
1
|
import { act, renderHook } from '@testing-library/react-hooks';
|
|
2
|
-
import MockAdapter from 'axios-mock-adapter';
|
|
3
2
|
import useManageSubUnit from '../useManageSubUnit';
|
|
3
|
+
import axios from 'axios';
|
|
4
4
|
import API from '../../../../configs/API';
|
|
5
|
-
import api from '../../../../utils/Apis/axios';
|
|
6
5
|
|
|
7
6
|
const mockRoute = jest.fn();
|
|
8
|
-
const mock = new MockAdapter(api.axiosInstance);
|
|
9
7
|
|
|
10
8
|
jest.mock('react', () => {
|
|
11
9
|
return {
|
|
@@ -25,64 +23,63 @@ jest.mock('@react-navigation/native', () => {
|
|
|
25
23
|
};
|
|
26
24
|
});
|
|
27
25
|
|
|
26
|
+
jest.mock('axios');
|
|
27
|
+
|
|
28
28
|
describe('Test Manage Access', () => {
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
axios.get.mockClear();
|
|
31
|
+
});
|
|
29
32
|
const unit = { id: 1, name: 'unit name' };
|
|
30
33
|
|
|
31
34
|
it('Test init', () => {
|
|
32
35
|
const { result } = renderHook(() => useManageSubUnit(unit));
|
|
33
|
-
expect(result.current.
|
|
36
|
+
expect(result.current.station).toEqual([]);
|
|
34
37
|
expect(result.current.isLoading).toBeFalsy();
|
|
35
38
|
expect(result.current.isRefreshing).toBeFalsy();
|
|
36
39
|
});
|
|
37
40
|
|
|
38
41
|
it('Test onRefresh', () => {
|
|
39
42
|
const { result } = renderHook(() => useManageSubUnit(unit));
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
expect(result.current.isRefreshing).toBeFalsy();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('Test get unit failure', () => {
|
|
81
|
-
const { result } = renderHook(() => useManageSubUnit(unit));
|
|
82
|
-
mock.onGet(API.UNIT.UNIT_DETAIL(unit?.id)).reply(400);
|
|
43
|
+
axios.get.mockImplementation(() => ({
|
|
44
|
+
status: 200,
|
|
45
|
+
data: [
|
|
46
|
+
{
|
|
47
|
+
id: 1,
|
|
48
|
+
name: 'unit 1',
|
|
49
|
+
stations: [
|
|
50
|
+
{
|
|
51
|
+
id: 1,
|
|
52
|
+
name: 'station 1',
|
|
53
|
+
sensors: [
|
|
54
|
+
{
|
|
55
|
+
id: 1,
|
|
56
|
+
icon: '',
|
|
57
|
+
action: { icon: '', color: '' },
|
|
58
|
+
name: 'sensor name',
|
|
59
|
+
value: '',
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 2,
|
|
65
|
+
name: 'station 2',
|
|
66
|
+
sensors: [
|
|
67
|
+
{
|
|
68
|
+
id: 1,
|
|
69
|
+
icon: '',
|
|
70
|
+
action: { icon: '', color: '' },
|
|
71
|
+
name: 'sensor name',
|
|
72
|
+
value: '',
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
}));
|
|
83
80
|
act(() => {
|
|
84
81
|
result.current.onRefresh();
|
|
85
82
|
});
|
|
86
|
-
expect(
|
|
83
|
+
expect(axios.get).toHaveBeenCalledWith(API.UNIT.UNIT_DETAIL(unit?.id), {});
|
|
87
84
|
});
|
|
88
85
|
});
|
|
@@ -3,11 +3,11 @@ import { axiosGet } from '../../../utils/Apis/axios';
|
|
|
3
3
|
import API from '../../../configs/API';
|
|
4
4
|
|
|
5
5
|
export default (unit) => {
|
|
6
|
-
const [
|
|
6
|
+
const [station, setStation] = useState([]);
|
|
7
7
|
const [isLoading, setIsLoading] = useState(false);
|
|
8
8
|
const [isRefresh, setRefresh] = useState(false);
|
|
9
9
|
|
|
10
|
-
const fetchData = useCallback(async () => {
|
|
10
|
+
const fetchData = useCallback(async (unit) => {
|
|
11
11
|
setIsLoading(true);
|
|
12
12
|
const { success, data } = await axiosGet(
|
|
13
13
|
API.UNIT.UNIT_DETAIL(unit?.id),
|
|
@@ -15,19 +15,19 @@ export default (unit) => {
|
|
|
15
15
|
true
|
|
16
16
|
);
|
|
17
17
|
if (success) {
|
|
18
|
-
|
|
18
|
+
setStation(data?.stations);
|
|
19
19
|
}
|
|
20
20
|
setIsLoading(false);
|
|
21
|
-
}, [
|
|
21
|
+
}, []);
|
|
22
22
|
|
|
23
23
|
const onRefresh = useCallback(async () => {
|
|
24
24
|
setRefresh(true);
|
|
25
|
-
await fetchData();
|
|
25
|
+
await fetchData(unit);
|
|
26
26
|
setRefresh(false);
|
|
27
|
-
}, [fetchData]);
|
|
27
|
+
}, [unit, fetchData]);
|
|
28
28
|
|
|
29
29
|
return {
|
|
30
|
-
|
|
30
|
+
station,
|
|
31
31
|
isRefresh,
|
|
32
32
|
onRefresh,
|
|
33
33
|
isLoading,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
|
-
import
|
|
3
|
+
import axios from 'axios';
|
|
4
4
|
import AddLGDevice from '../AddLGDevice';
|
|
5
5
|
import API from '../../../configs/API';
|
|
6
6
|
import GroupCheckBox from '../../../commons/GroupCheckBox';
|
|
@@ -11,9 +11,8 @@ import { ToastBottomHelper } from '../../../utils/Utils';
|
|
|
11
11
|
import Routes from '../../../utils/Route';
|
|
12
12
|
import { SCProvider } from '../../../context';
|
|
13
13
|
import { mockSCStore } from '../../../context/mockStore';
|
|
14
|
-
import api from '../../../utils/Apis/axios';
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
jest.mock('axios');
|
|
17
16
|
|
|
18
17
|
const mockedNavigate = jest.fn();
|
|
19
18
|
const mockedGoBack = jest.fn();
|
|
@@ -53,7 +52,11 @@ describe('Test Add LG Device', () => {
|
|
|
53
52
|
backend_url: 'https://doamin.com',
|
|
54
53
|
},
|
|
55
54
|
};
|
|
56
|
-
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
afterEach(() => {
|
|
58
|
+
axios.get.mockClear();
|
|
59
|
+
axios.post.mockClear();
|
|
57
60
|
});
|
|
58
61
|
|
|
59
62
|
const getText = (instance, id) => {
|
|
@@ -88,11 +91,16 @@ describe('Test Add LG Device', () => {
|
|
|
88
91
|
stations: [{ id: 2, name: 'Station name' }],
|
|
89
92
|
},
|
|
90
93
|
};
|
|
91
|
-
|
|
94
|
+
axios.get.mockImplementation(async () => {
|
|
95
|
+
return response;
|
|
96
|
+
});
|
|
97
|
+
|
|
92
98
|
await act(async () => {
|
|
93
99
|
tree = await create(wrapComponent(route));
|
|
94
100
|
});
|
|
95
101
|
const instance = tree.root;
|
|
102
|
+
expect(axios.get).toHaveBeenCalledWith(API.UNIT.UNIT_DETAIL(1), {});
|
|
103
|
+
|
|
96
104
|
const groupCheckBox = instance.findByType(GroupCheckBox);
|
|
97
105
|
expect(groupCheckBox.props.data).toEqual([
|
|
98
106
|
{ id: 2, name: 'Station name', title: 'Station name' },
|
|
@@ -100,19 +108,21 @@ describe('Test Add LG Device', () => {
|
|
|
100
108
|
});
|
|
101
109
|
|
|
102
110
|
test('fetchDetails fail', async () => {
|
|
103
|
-
|
|
111
|
+
const response = {
|
|
112
|
+
data: {},
|
|
113
|
+
};
|
|
114
|
+
axios.get.mockImplementation(async () => {
|
|
115
|
+
return response;
|
|
116
|
+
});
|
|
117
|
+
|
|
104
118
|
await act(async () => {
|
|
105
119
|
tree = await create(wrapComponent(route));
|
|
106
120
|
});
|
|
107
121
|
const instance = tree.root;
|
|
122
|
+
expect(axios.get).toHaveBeenCalledWith(API.UNIT.UNIT_DETAIL(1), {});
|
|
123
|
+
|
|
108
124
|
const groupCheckBox = instance.findByType(GroupCheckBox);
|
|
109
|
-
expect(groupCheckBox.props.data).toEqual([
|
|
110
|
-
{
|
|
111
|
-
id: 2,
|
|
112
|
-
name: 'Station name',
|
|
113
|
-
title: 'Station name',
|
|
114
|
-
},
|
|
115
|
-
]);
|
|
125
|
+
expect(groupCheckBox.props.data).toEqual([]);
|
|
116
126
|
});
|
|
117
127
|
|
|
118
128
|
test('ViewButtonBottom', async () => {
|
|
@@ -151,7 +161,7 @@ describe('Test Add LG Device', () => {
|
|
|
151
161
|
await act(async () => {
|
|
152
162
|
viewButtonBottom.props.onRightClick();
|
|
153
163
|
});
|
|
154
|
-
expect(mockedNavigate).toHaveBeenCalled();
|
|
164
|
+
expect(mockedNavigate).not.toHaveBeenCalled();
|
|
155
165
|
});
|
|
156
166
|
|
|
157
167
|
test('ViewButtonBottom onRightClick with stationId', async () => {
|
|
@@ -163,7 +173,9 @@ describe('Test Add LG Device', () => {
|
|
|
163
173
|
stations: [{ id: 2, name: 'Station name' }],
|
|
164
174
|
},
|
|
165
175
|
};
|
|
166
|
-
|
|
176
|
+
axios.get.mockImplementation(async () => {
|
|
177
|
+
return response;
|
|
178
|
+
});
|
|
167
179
|
|
|
168
180
|
const responseToken = {
|
|
169
181
|
status: 200,
|
|
@@ -171,9 +183,20 @@ describe('Test Add LG Device', () => {
|
|
|
171
183
|
access_token: 'ACCESS_TOKEN',
|
|
172
184
|
},
|
|
173
185
|
};
|
|
174
|
-
|
|
175
|
-
|
|
186
|
+
axios.post.mockImplementationOnce(async () => {
|
|
187
|
+
return responseToken;
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const responseSync = {
|
|
191
|
+
status: 200,
|
|
192
|
+
data: {},
|
|
193
|
+
};
|
|
194
|
+
axios.post.mockImplementationOnce(async () => {
|
|
195
|
+
return responseSync;
|
|
196
|
+
});
|
|
197
|
+
|
|
176
198
|
const spyToastSuccess = jest.spyOn(ToastBottomHelper, 'success');
|
|
199
|
+
|
|
177
200
|
await act(async () => {
|
|
178
201
|
tree = await create(wrapComponent(route));
|
|
179
202
|
});
|
|
@@ -187,6 +210,10 @@ describe('Test Add LG Device', () => {
|
|
|
187
210
|
await act(async () => {
|
|
188
211
|
viewButtonBottom.props.onRightClick();
|
|
189
212
|
});
|
|
213
|
+
|
|
214
|
+
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
215
|
+
expect(axios.post).toHaveBeenCalledTimes(2);
|
|
216
|
+
expect(spyToastSuccess).toBeCalled();
|
|
190
217
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.Dashboard);
|
|
191
218
|
|
|
192
219
|
spyToastSuccess.mockReset();
|
|
@@ -202,8 +229,27 @@ describe('Test Add LG Device', () => {
|
|
|
202
229
|
stations: [{ id: 2, name: 'Station name' }],
|
|
203
230
|
},
|
|
204
231
|
};
|
|
205
|
-
|
|
206
|
-
|
|
232
|
+
axios.get.mockImplementation(async () => {
|
|
233
|
+
return response;
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
const responseToken = {
|
|
237
|
+
status: 200,
|
|
238
|
+
data: {
|
|
239
|
+
access_token: 'ACCESS_TOKEN',
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
axios.post.mockImplementationOnce(async () => {
|
|
243
|
+
return responseToken;
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
const responseSync = {
|
|
247
|
+
data: {},
|
|
248
|
+
};
|
|
249
|
+
axios.post.mockImplementationOnce(async () => {
|
|
250
|
+
return responseSync;
|
|
251
|
+
});
|
|
252
|
+
|
|
207
253
|
const spyToastSuccess = jest.spyOn(ToastBottomHelper, 'success');
|
|
208
254
|
const spyToastError = jest.spyOn(ToastBottomHelper, 'error');
|
|
209
255
|
|
|
@@ -220,9 +266,13 @@ describe('Test Add LG Device', () => {
|
|
|
220
266
|
await act(async () => {
|
|
221
267
|
viewButtonBottom.props.onRightClick();
|
|
222
268
|
});
|
|
269
|
+
|
|
270
|
+
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
271
|
+
expect(axios.post).toHaveBeenCalledTimes(2);
|
|
223
272
|
expect(spyToastSuccess).not.toBeCalled();
|
|
224
273
|
expect(spyToastError).toBeCalled();
|
|
225
274
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.Dashboard);
|
|
275
|
+
|
|
226
276
|
spyToastSuccess.mockReset();
|
|
227
277
|
spyToastSuccess.mockRestore();
|
|
228
278
|
});
|
|
@@ -236,7 +286,10 @@ describe('Test Add LG Device', () => {
|
|
|
236
286
|
stations: [{ id: 2, name: 'Station name' }],
|
|
237
287
|
},
|
|
238
288
|
};
|
|
239
|
-
|
|
289
|
+
axios.get.mockImplementation(async () => {
|
|
290
|
+
return response;
|
|
291
|
+
});
|
|
292
|
+
|
|
240
293
|
const responseToken = {
|
|
241
294
|
status: 200,
|
|
242
295
|
data: {
|
|
@@ -247,7 +300,10 @@ describe('Test Add LG Device', () => {
|
|
|
247
300
|
},
|
|
248
301
|
},
|
|
249
302
|
};
|
|
250
|
-
|
|
303
|
+
axios.post.mockImplementationOnce(async () => {
|
|
304
|
+
return responseToken;
|
|
305
|
+
});
|
|
306
|
+
|
|
251
307
|
const spyToastSuccess = jest.spyOn(ToastBottomHelper, 'success');
|
|
252
308
|
const spyToastError = jest.spyOn(ToastBottomHelper, 'error');
|
|
253
309
|
|
|
@@ -265,6 +321,8 @@ describe('Test Add LG Device', () => {
|
|
|
265
321
|
viewButtonBottom.props.onRightClick();
|
|
266
322
|
});
|
|
267
323
|
|
|
324
|
+
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
325
|
+
expect(axios.post).toHaveBeenCalledTimes(1); // called once
|
|
268
326
|
expect(spyToastSuccess).not.toBeCalled();
|
|
269
327
|
expect(spyToastError).toBeCalled();
|
|
270
328
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.Dashboard);
|
|
@@ -282,7 +340,16 @@ describe('Test Add LG Device', () => {
|
|
|
282
340
|
stations: [{ id: 2, name: 'Station name' }],
|
|
283
341
|
},
|
|
284
342
|
};
|
|
285
|
-
|
|
343
|
+
axios.get.mockImplementation(async () => {
|
|
344
|
+
return response;
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
const responseToken = {
|
|
348
|
+
data: {},
|
|
349
|
+
};
|
|
350
|
+
axios.post.mockImplementationOnce(async () => {
|
|
351
|
+
return responseToken;
|
|
352
|
+
});
|
|
286
353
|
|
|
287
354
|
const spyToastSuccess = jest.spyOn(ToastBottomHelper, 'success');
|
|
288
355
|
const spyToastError = jest.spyOn(ToastBottomHelper, 'error');
|
|
@@ -301,6 +368,8 @@ describe('Test Add LG Device', () => {
|
|
|
301
368
|
viewButtonBottom.props.onRightClick();
|
|
302
369
|
});
|
|
303
370
|
|
|
371
|
+
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
372
|
+
expect(axios.post).toHaveBeenCalledTimes(1); // called once
|
|
304
373
|
expect(spyToastSuccess).not.toBeCalled();
|
|
305
374
|
expect(spyToastError).toBeCalled();
|
|
306
375
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.Dashboard);
|
|
@@ -13,10 +13,7 @@ const TDSGuide = memo(() => {
|
|
|
13
13
|
|
|
14
14
|
return (
|
|
15
15
|
<View style={styles.container}>
|
|
16
|
-
<ScrollView
|
|
17
|
-
style={styles.paddingHorizontal16}
|
|
18
|
-
scrollIndicatorInsets={{ right: 1 }}
|
|
19
|
-
>
|
|
16
|
+
<ScrollView style={styles.paddingHorizontal16}>
|
|
20
17
|
<Text
|
|
21
18
|
type="H3"
|
|
22
19
|
semibold
|
|
@@ -73,7 +73,7 @@ const UVIndexGuide = memo(() => {
|
|
|
73
73
|
const onPress = useCallback((item) => {}, []);
|
|
74
74
|
return (
|
|
75
75
|
<SafeAreaView style={styles.container}>
|
|
76
|
-
<ScrollView style={styles.container}
|
|
76
|
+
<ScrollView style={styles.container}>
|
|
77
77
|
{titles.map((item, index) => {
|
|
78
78
|
const { title, des } = item;
|
|
79
79
|
return (
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
1
2
|
import React, { memo, useCallback, useRef, useState } from 'react';
|
|
2
3
|
import { View } from 'react-native';
|
|
3
4
|
import MapView, { PROVIDER_GOOGLE } from 'react-native-maps';
|
|
@@ -7,17 +8,24 @@ import BottomButtonView from '../../commons/BottomButtonView';
|
|
|
7
8
|
import { FullLoading } from '../../commons';
|
|
8
9
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
9
10
|
|
|
11
|
+
navigator.geolocation = require('@react-native-community/geolocation');
|
|
12
|
+
|
|
10
13
|
import styles from './ChooseLocationStyles';
|
|
11
14
|
import { API } from '../../configs';
|
|
12
15
|
import { axiosGet } from '../../utils/Apis/axios';
|
|
13
16
|
import { SCConfig } from '../../configs';
|
|
14
|
-
import { MAP_INITIAL_REGION, EOH_LOCATION } from '../../configs/Constants';
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
const initialRegion = {
|
|
19
|
+
latitudeDelta: 0.0922,
|
|
20
|
+
longitudeDelta: 0.0421,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const DEFAULT_LATITUDE = 10.7974046; // EoH center
|
|
24
|
+
const DEFAULT_LONGITUDE = 106.7035663;
|
|
17
25
|
|
|
18
26
|
const ChooseLocation = memo(({ route }) => {
|
|
19
27
|
const t = useTranslations();
|
|
20
|
-
const { location, setAddress, setLocation } = route.params
|
|
28
|
+
const { location, setAddress, setLocation } = route.params;
|
|
21
29
|
const { goBack } = useNavigation();
|
|
22
30
|
const [currentLocation, setCurrentLocation] = useState(location);
|
|
23
31
|
const [loading, setLoading] = useState(false);
|
|
@@ -68,10 +76,9 @@ const ChooseLocation = memo(({ route }) => {
|
|
|
68
76
|
provider={PROVIDER_GOOGLE}
|
|
69
77
|
style={styles.mapView}
|
|
70
78
|
initialRegion={{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
longitudeDelta: MAP_INITIAL_REGION.LNG,
|
|
79
|
+
...initialRegion,
|
|
80
|
+
latitude: location?.latitude || DEFAULT_LATITUDE,
|
|
81
|
+
longitude: location?.longitude || DEFAULT_LONGITUDE,
|
|
75
82
|
}}
|
|
76
83
|
followUserLocation={true}
|
|
77
84
|
onRegionChangeComplete={onRegionChange}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
useCallback,
|
|
3
|
+
useContext,
|
|
3
4
|
useEffect,
|
|
4
5
|
useState,
|
|
5
6
|
useRef,
|
|
6
|
-
useContext,
|
|
7
7
|
} from 'react';
|
|
8
8
|
import { AppState, RefreshControl, View } from 'react-native';
|
|
9
9
|
import { useIsFocused } from '@react-navigation/native';
|
|
10
|
-
import { VLCPlayer } from 'react-native-vlc-media-player';
|
|
11
|
-
|
|
12
10
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
11
|
+
|
|
13
12
|
import styles from './styles';
|
|
14
13
|
import AddMenu from './AddMenu';
|
|
15
14
|
import MoreMenu from './MoreMenu';
|
|
@@ -24,8 +23,10 @@ import {
|
|
|
24
23
|
usePopover,
|
|
25
24
|
} from '../../hooks/Common';
|
|
26
25
|
import { useFavorites } from './hook/useFavorites';
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
26
|
+
import { scanBluetoothDevices } from '../../iot/RemoteControl/Bluetooth';
|
|
27
|
+
import { googleHomeConnect } from '../../iot/RemoteControl/GoogleHome';
|
|
28
|
+
import { axiosPost, fetchWithCache, axiosGet } from '../../utils/Apis/axios';
|
|
29
|
+
import { lgThinqConnect } from '../../iot/RemoteControl/LG';
|
|
29
30
|
import ShortDetailSubUnit from '../../commons/SubUnit/ShortDetail';
|
|
30
31
|
import NavBar from '../../commons/NavBar';
|
|
31
32
|
import WrapParallaxScrollView from '../../commons/WrapParallaxScrollView';
|
|
@@ -50,7 +51,6 @@ import PreventAccess from '../../commons/PreventAccess';
|
|
|
50
51
|
|
|
51
52
|
const UnitDetail = ({ route }) => {
|
|
52
53
|
const t = useTranslations();
|
|
53
|
-
const { setAction } = useContext(SCContext);
|
|
54
54
|
|
|
55
55
|
const {
|
|
56
56
|
unitId,
|
|
@@ -63,6 +63,7 @@ const UnitDetail = ({ route }) => {
|
|
|
63
63
|
} = route.params;
|
|
64
64
|
|
|
65
65
|
const isFocused = useIsFocused();
|
|
66
|
+
const { stateData, setAction } = useContext(SCContext);
|
|
66
67
|
const { navigate, goBack } = useNavigation();
|
|
67
68
|
const RouterHardware = useCallback(
|
|
68
69
|
(routeHardware) => () => {
|
|
@@ -75,14 +76,15 @@ const UnitDetail = ({ route }) => {
|
|
|
75
76
|
isSuccessfullyConnected ? RouterHardware(Routes.Dashboard) : goBack
|
|
76
77
|
);
|
|
77
78
|
const user = useSCContextSelector((state) => state?.auth?.account?.user);
|
|
78
|
-
const
|
|
79
|
-
(state) => state.app
|
|
79
|
+
const isLavidaSource = useSCContextSelector(
|
|
80
|
+
(state) => state.app.isLavidaSource
|
|
80
81
|
);
|
|
81
82
|
|
|
82
83
|
const [unit, setUnit] = useState(unitData || { id: unitId });
|
|
83
84
|
const [listMenuItem, setListMenuItem] = useState([]);
|
|
84
85
|
const [listStation, setListStation] = useState([]);
|
|
85
86
|
const [listAutomate, setListAutomate] = useState([]);
|
|
87
|
+
const [isGGHomeConnected, setIsGGHomeConnected] = useState(false);
|
|
86
88
|
const [station, setStation] = useState({});
|
|
87
89
|
const [indexStation, setIndexStation] = useState(0);
|
|
88
90
|
const [showAdd, setShowAdd, setHideAdd] = useBoolean();
|
|
@@ -189,7 +191,61 @@ const UnitDetail = ({ route }) => {
|
|
|
189
191
|
};
|
|
190
192
|
}, [fetchDetails]);
|
|
191
193
|
|
|
192
|
-
|
|
194
|
+
const handleGoogleHomeConnect = useCallback(
|
|
195
|
+
async (options) => {
|
|
196
|
+
let isConnected = await googleHomeConnect(options); // this may wrong if have multiple connection
|
|
197
|
+
setIsGGHomeConnected(isConnected);
|
|
198
|
+
let chipId = options[0].chip_id;
|
|
199
|
+
if (!isConnected) {
|
|
200
|
+
setAction(Action.LIST_DEVICE_TYPES, {
|
|
201
|
+
chipId: chipId,
|
|
202
|
+
sentEmail: true,
|
|
203
|
+
});
|
|
204
|
+
await axiosPost(API.GOOGLE_HOME.CHECK_SEND_EMAIL(), {
|
|
205
|
+
chip_id: chipId,
|
|
206
|
+
is_connected: false,
|
|
207
|
+
});
|
|
208
|
+
} else if (isConnected && stateData?.listDevice[chipId]?.sentEmail) {
|
|
209
|
+
setAction(Action.LIST_DEVICE_TYPES, {
|
|
210
|
+
chipId: chipId,
|
|
211
|
+
sentEmail: false,
|
|
212
|
+
});
|
|
213
|
+
await axiosPost(API.GOOGLE_HOME.CHECK_SEND_EMAIL(), {
|
|
214
|
+
chip_id: chipId,
|
|
215
|
+
is_connected: true,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
220
|
+
[]
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
let isCalled = false;
|
|
224
|
+
|
|
225
|
+
const handleLgThinqConnect = useCallback(async (options) => {
|
|
226
|
+
if (isCalled) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
230
|
+
isCalled = true;
|
|
231
|
+
await lgThinqConnect(options);
|
|
232
|
+
}, []);
|
|
233
|
+
|
|
234
|
+
useEffect(() => {
|
|
235
|
+
if (unit.remote_control_options) {
|
|
236
|
+
if (unit.remote_control_options.bluetooth) {
|
|
237
|
+
scanBluetoothDevices(unit.remote_control_options.bluetooth);
|
|
238
|
+
}
|
|
239
|
+
if (unit.remote_control_options.googlehome?.length) {
|
|
240
|
+
handleGoogleHomeConnect(unit.remote_control_options.googlehome);
|
|
241
|
+
}
|
|
242
|
+
if (unit.remote_control_options.lg_thinq) {
|
|
243
|
+
(async () => {
|
|
244
|
+
await handleLgThinqConnect(unit.remote_control_options.lg_thinq);
|
|
245
|
+
})();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}, [handleGoogleHomeConnect, handleLgThinqConnect, unit]);
|
|
193
249
|
|
|
194
250
|
useEffect(() => {
|
|
195
251
|
if (isFocused) {
|
|
@@ -208,7 +264,7 @@ const UnitDetail = ({ route }) => {
|
|
|
208
264
|
setListMenuItem(listMenu);
|
|
209
265
|
setListStation(listMenu.concat([{ text: '' }]));
|
|
210
266
|
}
|
|
211
|
-
}, [unit, indexStation]);
|
|
267
|
+
}, [unit, indexStation, isGGHomeConnected]);
|
|
212
268
|
|
|
213
269
|
useEffect(() => {
|
|
214
270
|
isOneTap && setIndexStation(1);
|
|
@@ -252,6 +308,7 @@ const UnitDetail = ({ route }) => {
|
|
|
252
308
|
favoriteDevices={favoriteDevices}
|
|
253
309
|
favoriteAutomates={favoriteAutomates}
|
|
254
310
|
wrapItemStyle={styles.wrapItemStyle}
|
|
311
|
+
isGGHomeConnected={isGGHomeConnected}
|
|
255
312
|
/>
|
|
256
313
|
);
|
|
257
314
|
}
|
|
@@ -273,7 +330,13 @@ const UnitDetail = ({ route }) => {
|
|
|
273
330
|
/>
|
|
274
331
|
);
|
|
275
332
|
} else if (station) {
|
|
276
|
-
return
|
|
333
|
+
return (
|
|
334
|
+
<ShortDetailSubUnit
|
|
335
|
+
unit={unit}
|
|
336
|
+
station={station}
|
|
337
|
+
isGGHomeConnected={isGGHomeConnected}
|
|
338
|
+
/>
|
|
339
|
+
);
|
|
277
340
|
}
|
|
278
341
|
};
|
|
279
342
|
|
|
@@ -290,15 +353,6 @@ const UnitDetail = ({ route }) => {
|
|
|
290
353
|
return () => unwatchNotificationData(user);
|
|
291
354
|
}, [user, onRefresh]);
|
|
292
355
|
|
|
293
|
-
useEffect(() => {
|
|
294
|
-
if (isFirstOpenCamera) {
|
|
295
|
-
const to = setTimeout(() => {
|
|
296
|
-
setAction(Action.IS_FIRST_OPEN_CAMERA, false);
|
|
297
|
-
clearTimeout(to);
|
|
298
|
-
}, 5000);
|
|
299
|
-
}
|
|
300
|
-
}, [isFirstOpenCamera, setAction]);
|
|
301
|
-
|
|
302
356
|
return (
|
|
303
357
|
<WrapParallaxScrollView
|
|
304
358
|
uriImg={unit.background}
|
|
@@ -313,16 +367,6 @@ const UnitDetail = ({ route }) => {
|
|
|
313
367
|
hideRightPlus={!isOwner}
|
|
314
368
|
onBack={(isSuccessfullyConnected && Dashboard) || (routeName && onBack)}
|
|
315
369
|
>
|
|
316
|
-
{/* NOTE: This is a trick to fix camera not full screen on first open app */}
|
|
317
|
-
{isFirstOpenCamera && (
|
|
318
|
-
<VLCPlayer
|
|
319
|
-
source={{
|
|
320
|
-
uri: 'rtsp://admin:Eoh@2020@101.99.33.220:30554/main',
|
|
321
|
-
}}
|
|
322
|
-
style={styles.camera}
|
|
323
|
-
/>
|
|
324
|
-
)}
|
|
325
|
-
|
|
326
370
|
<View style={styles.container}>
|
|
327
371
|
<Summaries unit={unit} />
|
|
328
372
|
<NavBar
|
|
@@ -339,6 +383,7 @@ const UnitDetail = ({ route }) => {
|
|
|
339
383
|
</View>
|
|
340
384
|
)}
|
|
341
385
|
</View>
|
|
386
|
+
|
|
342
387
|
<AddMenu
|
|
343
388
|
unit={unit}
|
|
344
389
|
afterItemClick={hidePopover}
|