@eohjsc/react-native-smart-city 0.3.7 → 0.3.10
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 +36 -15
- package/package.json +10 -6
- package/react-native-smart-city.podspec +1 -0
- package/src/commons/Action/ItemQuickAction.js +16 -4
- package/src/commons/Action/__test__/ItemQuickAction.test.js +11 -6
- package/src/commons/ActionGroup/ColorPickerTemplate.js +37 -24
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +4 -0
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +24 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +14 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +1 -0
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +8 -2
- package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +10 -10
- package/src/commons/ActionGroup/OnOffTemplate/index.js +3 -2
- package/src/commons/ActionGroup/SliderRangeTemplate.js +6 -2
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -3
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +22 -8
- package/src/commons/ActionGroup/TimerActionTemplate.js +11 -3
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +1 -5
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +53 -78
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +36 -20
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +77 -0
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +58 -6
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +49 -1
- package/src/commons/ActionGroup/__test__/index.test.js +135 -0
- package/src/commons/Auth/AccountList.js +1 -1
- package/src/commons/Automate/ItemAutomate.js +1 -3
- package/src/commons/Calendar/__test__/Calendar.test.js +33 -0
- package/src/commons/Connecting/__test__/Connecting.test.js +19 -2
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +7 -3
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +8 -11
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +136 -3
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +3 -2
- package/src/commons/ConnectingProcess/index.js +76 -26
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +16 -13
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +0 -5
- package/src/commons/Device/ConnectedViewHeader.js +1 -1
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +58 -0
- package/src/commons/Device/HistoryChart.js +7 -3
- package/src/commons/Device/ItemDevice.js +34 -13
- package/src/commons/Device/LinearChart.js +15 -0
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +16 -12
- package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -0
- package/src/commons/Device/SonosSpeaker/index.js +1 -1
- package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -0
- package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +7 -2
- package/src/commons/Explore/__test__/CityItem.test.js +33 -54
- package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +25 -0
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +96 -0
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +39 -0
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +118 -0
- package/src/commons/FieldTemplate/ChooseUserField/index.js +62 -0
- package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +30 -0
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +90 -0
- package/src/commons/FieldTemplate/PasscodeField/index.js +43 -0
- package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +13 -0
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +179 -0
- package/src/commons/FieldTemplate/ScheduleField/index.js +176 -0
- package/src/commons/Form/CurrencyInput.js +15 -1
- package/src/commons/Form/TextInputPassword.js +1 -1
- package/src/commons/FullLoading/index.js +2 -1
- package/src/commons/Header/HeaderCustom.js +2 -1
- package/src/commons/HeaderAni/index.js +6 -1
- package/src/commons/HorizontalPicker/index.js +2 -2
- package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +0 -6
- package/src/commons/MediaPlayerDetail/index.js +29 -47
- package/src/commons/MenuActionAddnew/index.js +1 -0
- package/src/commons/MenuActionList/index.js +1 -0
- package/src/commons/MenuActionMore/index.js +1 -1
- package/src/commons/PreventAccess/__test__/PreventAccess.test.js +62 -0
- package/src/commons/PreventAccess/index.js +9 -1
- package/src/commons/Sharing/MemberList.js +10 -2
- package/src/commons/Sharing/WrapHeaderScrollable.js +2 -0
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +0 -1
- package/src/commons/SubUnit/Favorites/index.js +2 -3
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +8 -35
- package/src/commons/SubUnit/OneTap/index.js +1 -2
- package/src/commons/SubUnit/ShortDetail.js +25 -9
- package/src/commons/SubUnit/__test__/Item.test.js +0 -1
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +9 -2
- package/src/commons/Unit/SharedUnit.js +1 -0
- package/src/commons/Unit/__test__/SharedUnit.test.js +38 -183
- package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +28 -1
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +2 -13
- package/src/commons/UnitSummary/ConfigHistoryChart.js +55 -13
- package/src/commons/WheelDateTimePicker/index.js +4 -3
- package/src/configs/API.js +87 -143
- package/src/configs/Constants.js +80 -1
- package/src/configs/SCConfig.js +4 -0
- package/src/context/actionType.ts +11 -0
- package/src/context/mockStore.ts +12 -0
- package/src/context/reducer.ts +57 -2
- package/src/hooks/Common/index.js +2 -0
- package/src/hooks/Common/useGGHomeDeviceConnected.js +16 -0
- package/src/hooks/Common/useGetIdUser.js +1 -5
- package/src/hooks/Common/useSensorsStatus.js +4 -4
- package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +199 -0
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +198 -0
- package/src/hooks/IoT/index.js +4 -0
- package/src/hooks/IoT/useGGHomeConnection.js +93 -0
- package/src/hooks/IoT/useRemoteControl.js +79 -0
- package/src/hooks/index.js +4 -0
- package/src/hooks/useReceiveNotifications.js +12 -7
- package/src/iot/Monitor.js +3 -2
- package/src/iot/RemoteControl/Bluetooth.js +1 -1
- package/src/iot/RemoteControl/GoogleHome.js +75 -49
- package/src/iot/RemoteControl/Internet.js +1 -1
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +95 -48
- package/src/iot/RemoteControl/__test__/Internet.test.js +18 -7
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +36 -177
- package/src/iot/RemoteControl/index.js +52 -52
- package/src/navigations/UnitStack.js +11 -20
- package/src/navigations/UnitStackStyles.js +21 -0
- package/src/screens/AQIGuide/index.js +1 -1
- package/src/screens/ActivityLog/FilterPopup.js +2 -0
- package/src/screens/ActivityLog/__test__/index.test.js +38 -23
- package/src/screens/ActivityLog/hooks/__test__/index.test.js +51 -90
- package/src/screens/ActivityLog/hooks/index.js +1 -1
- package/src/screens/ActivityLog/index.js +2 -2
- package/src/screens/AddCommon/SelectSubUnit.js +1 -0
- package/src/screens/AddCommon/SelectUnit.js +1 -0
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +13 -24
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +9 -33
- package/src/screens/AddLocationMaps/__test__/index.test.js +265 -0
- package/src/screens/AddLocationMaps/index.js +48 -21
- package/src/screens/AddNewAction/SelectAction.js +32 -13
- package/src/screens/AddNewAction/SelectSensorDevices.js +8 -2
- package/src/screens/AddNewAction/SetupSensor.js +67 -32
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +10 -91
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +40 -26
- package/src/screens/AddNewAction/__test__/SetupSensor.test.js +2 -0
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -1
- package/src/screens/AddNewAutoSmart/index.js +5 -2
- package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +42 -34
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -4
- 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 +1 -0
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +23 -17
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +46 -40
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +64 -10
- package/src/screens/AddNewGateway/SelectGateway.js +1 -0
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +2 -0
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +4 -6
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -4
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +5 -29
- package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +0 -4
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -4
- package/src/screens/AddNewGateway/index.js +1 -0
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +10 -24
- package/src/screens/AddNewOneTap/index.js +3 -2
- package/src/screens/AllCamera/index.js +4 -4
- package/src/screens/Automate/MultiUnits.js +8 -8
- package/src/screens/Automate/__test__/MultiUnits.test.js +6 -9
- package/src/screens/Automate/__test__/index.test.js +7 -12
- package/src/screens/Automate/index.js +5 -3
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +36 -8
- package/src/screens/ConfirmUnitDeletion/index.js +7 -1
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +71 -22
- package/src/screens/Device/EditDevice/index.js +17 -15
- package/src/screens/Device/__test__/detail.test.js +33 -86
- package/src/screens/Device/components/DetailHistoryChart.js +1 -1
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +44 -24
- package/src/screens/Device/components/SensorDisplayItem.js +5 -2
- package/src/screens/Device/detail.js +85 -26
- package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
- package/src/screens/Device/hooks/useFavoriteDevice.js +5 -9
- package/src/screens/DeviceInfo/__test__/index.test.js +0 -2
- package/src/screens/EditActionsList/index.js +1 -1
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +6 -3
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +7 -19
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +20 -2
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +40 -23
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EmergencySetting/index.js +4 -1
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
- package/src/screens/Explore/index.js +2 -0
- package/src/screens/GuestInfo/__test__/index.test.js +14 -41
- package/src/screens/GuestInfo/components/RecurringDetail.js +1 -0
- 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 +8 -12
- package/src/screens/HanetCamera/__test__/Detail.test.js +27 -42
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +8 -5
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -32
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +3 -2
- package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +43 -35
- package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +10 -21
- 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 +33 -22
- package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +44 -45
- package/src/screens/ManageAccess/hooks/index.js +7 -4
- package/src/screens/ManageAccess/index.js +2 -1
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +35 -12
- package/src/screens/MoveToAnotherSubUnit/index.js +6 -6
- package/src/screens/Notification/__test__/Notification.test.js +31 -25
- package/src/screens/Notification/__test__/NotificationItem.test.js +8 -7
- package/src/screens/Notification/components/NotificationItem.js +17 -20
- package/src/screens/Notification/index.js +13 -2
- package/src/screens/PlayBackCamera/Timer.js +2 -2
- package/src/screens/PlayBackCamera/__test__/index.test.js +87 -2
- package/src/screens/PlayBackCamera/index.js +54 -35
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +7 -20
- package/src/screens/ScanChipQR/components/QRScan/index.js +1 -0
- package/src/screens/ScanChipQR/hooks/index.js +15 -16
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +8 -24
- package/src/screens/ScriptDetail/__test__/index.test.js +17 -86
- package/src/screens/ScriptDetail/index.js +19 -14
- package/src/screens/SelectUnit/__test__/index.test.js +12 -55
- package/src/screens/SelectUnit/index.js +9 -4
- package/src/screens/SetSchedule/index.js +15 -11
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
- package/src/screens/SharedUnit/index.js +2 -0
- package/src/screens/Sharing/Components/SensorItem.js +10 -12
- package/src/screens/Sharing/InfoMemberUnit.js +1 -1
- package/src/screens/Sharing/MemberList.js +12 -11
- package/src/screens/Sharing/SelectPermission.js +136 -83
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +47 -29
- package/src/screens/Sharing/__test__/MemberList.test.js +13 -127
- package/src/screens/Sharing/__test__/MemberList2.test.js +80 -0
- package/src/screens/Sharing/__test__/SelectPermission.test.js +28 -38
- package/src/screens/Sharing/__test__/SelectUser.test.js +17 -38
- package/src/screens/Sharing/hooks/index.js +3 -0
- package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +28 -0
- package/src/screens/SideMenuDetail/__test__/index.test.js +154 -0
- package/src/screens/SideMenuDetail/index.js +148 -0
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +3 -2
- package/src/screens/SmartIr/components/SelectBrand.js +1 -1
- package/src/screens/SubUnit/AddSubUnit.js +23 -17
- package/src/screens/SubUnit/Detail.js +1 -2
- package/src/screens/SubUnit/EditSubUnit.js +15 -13
- package/src/screens/SubUnit/ManageSubUnit.js +13 -7
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +29 -89
- package/src/screens/SubUnit/__test__/Detail.test.js +31 -8
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +21 -89
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +27 -1
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +48 -45
- package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
- package/src/screens/SyncLGDevice/AddLGDevice.js +1 -0
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +22 -91
- package/src/screens/TDSGuide/index.js +4 -1
- package/src/screens/UVIndexGuide/index.js +1 -1
- package/src/screens/Unit/ChooseLocation.js +7 -14
- package/src/screens/Unit/Detail.js +32 -75
- package/src/screens/Unit/ManageUnit.js +1 -0
- package/src/screens/Unit/SelectAddress.js +45 -23
- package/src/screens/Unit/SmartAccount.js +4 -4
- package/src/screens/Unit/Station/index.js +4 -0
- package/src/screens/Unit/Summaries.js +18 -2
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +24 -29
- package/src/screens/Unit/__test__/ChooseLocation.test.js +27 -14
- package/src/screens/Unit/__test__/Detail.test.js +98 -199
- package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
- package/src/screens/Unit/__test__/SelectAddress.test.js +159 -49
- package/src/screens/Unit/__test__/SmartAccount.test.js +17 -9
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -1
- package/src/screens/Unit/__test__/Summaries.test.js +100 -0
- package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +36 -0
- package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +54 -0
- package/src/screens/Unit/components/MyUnitDevice/index.js +4 -4
- package/src/screens/Unit/components/SharedUnit/index.js +1 -0
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +31 -34
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +50 -0
- package/src/screens/Unit/styles.js +8 -0
- package/src/screens/UnitSummary/__test__/index.test.js +91 -30
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +31 -2
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +7 -4
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +2 -13
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +0 -1
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +14 -16
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +11 -2
- package/src/screens/UnitSummary/components/RunningDevices/index.js +7 -10
- package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +10 -2
- package/src/screens/UnitSummary/index.js +15 -1
- package/src/screens/WaterQualityGuide/index.js +1 -1
- package/src/utils/Apis/axios.js +54 -31
- package/src/utils/Converter/time.js +0 -18
- package/src/utils/I18n/translations/en.json +11 -1
- package/src/utils/I18n/translations/vi.json +12 -1
- package/src/utils/Permission/common.js +67 -0
- package/src/utils/Route/index.js +1 -0
- package/src/utils/Setting/Location.js +30 -0
- package/src/utils/Utils.js +12 -7
- package/src/utils/__test__/Utils.test.js +12 -0
|
@@ -6,12 +6,13 @@ import { useNavigation } from '@react-navigation/native';
|
|
|
6
6
|
import ImageSuccessfully from '../../Images/Common/SuccessfullyConnected.svg';
|
|
7
7
|
|
|
8
8
|
import Text from '../Text';
|
|
9
|
-
import { axiosPost } from '../../utils/Apis/axios';
|
|
9
|
+
import { axiosPatch, axiosPost } from '../../utils/Apis/axios';
|
|
10
10
|
import { API, Colors } from '../../configs';
|
|
11
11
|
import styles from './styles';
|
|
12
12
|
import DeviceItem from './DeviceItem/DeviceItem';
|
|
13
13
|
import Connecting from '../Connecting';
|
|
14
14
|
import { useSCContextSelector } from '../../context';
|
|
15
|
+
import { ToastBottomHelper } from '../../utils/Utils';
|
|
15
16
|
|
|
16
17
|
const ConnectingProcess = ({ route }) => {
|
|
17
18
|
const { navigate, goBack } = useNavigation();
|
|
@@ -27,29 +28,31 @@ const ConnectingProcess = ({ route }) => {
|
|
|
27
28
|
devicePrefixName,
|
|
28
29
|
wifi_ssid,
|
|
29
30
|
wifi_pass,
|
|
30
|
-
|
|
31
|
-
} = route.params;
|
|
31
|
+
} = route.params || {};
|
|
32
32
|
const [isLoading, setIsLoading] = useState(true);
|
|
33
33
|
const [sensor, setSensor] = useState(null);
|
|
34
34
|
const user = useSCContextSelector((state) => state?.auth?.account?.user);
|
|
35
|
+
const [newName, setNewName] = useState('');
|
|
35
36
|
|
|
36
37
|
const ConnectingDevice = useCallback(async () => {
|
|
37
38
|
setIsLoading(true);
|
|
38
39
|
switch (devicePrefixName) {
|
|
39
|
-
case 'SENSOR':
|
|
40
|
-
{
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
case 'SENSOR': {
|
|
41
|
+
const body = { imei: scan_sensor_data?.imei, chip: gateway?.id };
|
|
42
|
+
const { success, data } = await axiosPost(
|
|
43
|
+
API.SUB_UNIT.SENSOR_SCAN(station.id),
|
|
44
|
+
body
|
|
45
|
+
);
|
|
46
|
+
if (success) {
|
|
47
|
+
setSensor(data);
|
|
48
|
+
setNewName(data?.name);
|
|
49
|
+
} else {
|
|
50
|
+
ToastBottomHelper.error(JSON.stringify(data));
|
|
51
|
+
goBack();
|
|
51
52
|
}
|
|
53
|
+
|
|
52
54
|
break;
|
|
55
|
+
}
|
|
53
56
|
case 'ROBOT': {
|
|
54
57
|
const { success, data } = await axiosPost(API.UNIT.CHIP_SCAN(unit.id), {
|
|
55
58
|
imei: gateway?.imei,
|
|
@@ -62,20 +65,26 @@ const ConnectingProcess = ({ route }) => {
|
|
|
62
65
|
});
|
|
63
66
|
if (success) {
|
|
64
67
|
setSensor(data);
|
|
68
|
+
setNewName(data?.name);
|
|
65
69
|
} else {
|
|
70
|
+
ToastBottomHelper.error(JSON.stringify(data));
|
|
66
71
|
goBack();
|
|
67
72
|
}
|
|
68
73
|
break;
|
|
69
74
|
}
|
|
70
75
|
case 'LITE': {
|
|
71
|
-
const { success } = await axiosPost(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
const { success, data } = await axiosPost(
|
|
77
|
+
API.UNIT.ADD_GATEWAY(unit_id),
|
|
78
|
+
{
|
|
79
|
+
imei: gateway?.imei,
|
|
80
|
+
chip_name: gateway?.model,
|
|
81
|
+
}
|
|
82
|
+
);
|
|
76
83
|
if (success) {
|
|
77
|
-
setSensor(
|
|
84
|
+
setSensor(data);
|
|
85
|
+
setNewName(data?.name || gateway?.model);
|
|
78
86
|
} else {
|
|
87
|
+
ToastBottomHelper.error(JSON.stringify(data));
|
|
79
88
|
goBack();
|
|
80
89
|
}
|
|
81
90
|
break;
|
|
@@ -95,7 +104,6 @@ const ConnectingProcess = ({ route }) => {
|
|
|
95
104
|
wifi_pass,
|
|
96
105
|
user?.phone_number,
|
|
97
106
|
unit_id,
|
|
98
|
-
chip_id,
|
|
99
107
|
]);
|
|
100
108
|
|
|
101
109
|
const ConnectingSuccess = useCallback(() => {
|
|
@@ -110,12 +118,46 @@ const ConnectingProcess = ({ route }) => {
|
|
|
110
118
|
station?.name !== undefined ? '- ' + station?.name : ''
|
|
111
119
|
}`}
|
|
112
120
|
</Text>
|
|
113
|
-
<DeviceItem
|
|
121
|
+
<DeviceItem
|
|
122
|
+
icon={sensor?.icon_kit}
|
|
123
|
+
name={newName}
|
|
124
|
+
setNewName={setNewName}
|
|
125
|
+
/>
|
|
114
126
|
</View>
|
|
115
127
|
);
|
|
116
|
-
}, [
|
|
128
|
+
}, [newName, sensor?.icon_kit, station?.name, t, unit?.name, unit_name]);
|
|
117
129
|
|
|
118
|
-
const handleDone = useCallback(() => {
|
|
130
|
+
const handleDone = useCallback(async () => {
|
|
131
|
+
let result, message;
|
|
132
|
+
switch (devicePrefixName) {
|
|
133
|
+
case 'SENSOR': {
|
|
134
|
+
const { success, data } = await axiosPatch(
|
|
135
|
+
API.SENSOR.SENSOR_DETAIL(sensor?.id),
|
|
136
|
+
{
|
|
137
|
+
name: newName,
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
result = success;
|
|
141
|
+
message = data;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
case 'ROBOT':
|
|
145
|
+
case 'LITE': {
|
|
146
|
+
const { success, data } = await axiosPatch(
|
|
147
|
+
API.CHIP.CHIP_DETAIL(sensor?.id),
|
|
148
|
+
{
|
|
149
|
+
name: newName,
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
result = success;
|
|
153
|
+
message = data;
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (!result) {
|
|
159
|
+
ToastBottomHelper.error(JSON.stringify(message));
|
|
160
|
+
}
|
|
119
161
|
navigate(Routes.UnitStack, {
|
|
120
162
|
screen: Routes.UnitDetail,
|
|
121
163
|
params: {
|
|
@@ -125,7 +167,15 @@ const ConnectingProcess = ({ route }) => {
|
|
|
125
167
|
stationId: station?.id,
|
|
126
168
|
},
|
|
127
169
|
});
|
|
128
|
-
}, [
|
|
170
|
+
}, [
|
|
171
|
+
devicePrefixName,
|
|
172
|
+
navigate,
|
|
173
|
+
newName,
|
|
174
|
+
sensor?.id,
|
|
175
|
+
station?.id,
|
|
176
|
+
unit,
|
|
177
|
+
unit_id,
|
|
178
|
+
]);
|
|
129
179
|
|
|
130
180
|
useEffect(() => {
|
|
131
181
|
ConnectingDevice();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
3
4
|
|
|
4
5
|
import MyPinnedSharedUnit from '../index';
|
|
5
6
|
import { Text } from 'react-native';
|
|
@@ -9,9 +10,9 @@ import { mockSCStore } from '../../../../context/mockStore';
|
|
|
9
10
|
import { TESTID } from '../../../../configs/Constants';
|
|
10
11
|
import { API } from '../../../../configs';
|
|
11
12
|
import { TouchableOpacity } from 'react-native';
|
|
12
|
-
import
|
|
13
|
+
import api from '../../../../utils/Apis/axios';
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
15
16
|
|
|
16
17
|
const mockedNavigate = jest.fn();
|
|
17
18
|
jest.mock('@react-navigation/native', () => {
|
|
@@ -32,21 +33,14 @@ const wrapComponent = (route) => (
|
|
|
32
33
|
|
|
33
34
|
describe('Test MyPinnedSharedUnit', () => {
|
|
34
35
|
let tree;
|
|
35
|
-
afterEach(() => {
|
|
36
|
-
axios.get.mockClear();
|
|
37
|
-
});
|
|
38
36
|
|
|
39
37
|
test('create', async () => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
data: [{ id: 1 }],
|
|
43
|
-
};
|
|
44
|
-
axios.get.mockImplementation(async () => {
|
|
45
|
-
return response;
|
|
46
|
-
});
|
|
38
|
+
mock.onGet(API.UNIT.SHARED_UNITS()).reply(200, [{ id: 1 }]);
|
|
39
|
+
|
|
47
40
|
await act(async () => {
|
|
48
41
|
tree = await create(wrapComponent());
|
|
49
42
|
});
|
|
43
|
+
|
|
50
44
|
const instance = tree.root;
|
|
51
45
|
const texts = instance.findAllByType(Text);
|
|
52
46
|
expect(texts).toHaveLength(4);
|
|
@@ -65,6 +59,15 @@ describe('Test MyPinnedSharedUnit', () => {
|
|
|
65
59
|
goToAllSharedUnits.props.onPress();
|
|
66
60
|
});
|
|
67
61
|
expect(mockedNavigate).toHaveBeenCalled();
|
|
68
|
-
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('render without item', async () => {
|
|
65
|
+
mock.onGet(API.UNIT.SHARED_UNITS()).reply(400, []);
|
|
66
|
+
await act(async () => {
|
|
67
|
+
tree = await create(wrapComponent());
|
|
68
|
+
});
|
|
69
|
+
const instance = tree.root;
|
|
70
|
+
const texts = instance.findAllByType(Text);
|
|
71
|
+
expect(texts).toHaveLength(4);
|
|
69
72
|
});
|
|
70
73
|
});
|
|
@@ -60,7 +60,7 @@ const MyPinnedSharedUnit = () => {
|
|
|
60
60
|
{sharedUnits &&
|
|
61
61
|
Boolean(sharedUnits.length) &&
|
|
62
62
|
sharedUnits
|
|
63
|
-
.filter((sharedUnit) => sharedUnit
|
|
63
|
+
.filter((sharedUnit) => sharedUnit?.is_pin)
|
|
64
64
|
.map((item, index) => (
|
|
65
65
|
<View key={item.id}>
|
|
66
66
|
<SharedUnit
|
|
@@ -4,9 +4,7 @@ import MyUnit from '..';
|
|
|
4
4
|
import { TESTID } from '../../../../configs/Constants';
|
|
5
5
|
import { SCProvider } from '../../../../context';
|
|
6
6
|
import { mockSCStore } from '../../../../context/mockStore';
|
|
7
|
-
import axios from 'axios';
|
|
8
7
|
|
|
9
|
-
jest.mock('axios');
|
|
10
8
|
const mockedNavigate = jest.fn();
|
|
11
9
|
const mockUseIsFocused = jest.fn();
|
|
12
10
|
const mockedDispatch = jest.fn();
|
|
@@ -36,9 +34,6 @@ const wrapComponent = () => (
|
|
|
36
34
|
|
|
37
35
|
describe('Test MyUnit', () => {
|
|
38
36
|
let tree;
|
|
39
|
-
beforeEach(() => {
|
|
40
|
-
axios.get.mockClear();
|
|
41
|
-
});
|
|
42
37
|
const getElement = (instance) => {
|
|
43
38
|
const goToDetail = instance.findAll(
|
|
44
39
|
(item) => item.props.testID === TESTID.MY_UNIT_GO_TO_DETAIL
|
|
@@ -29,7 +29,7 @@ const ConnectedViewHeader = memo(
|
|
|
29
29
|
const t = useTranslations();
|
|
30
30
|
const lastUpdatedStr = lastUpdated
|
|
31
31
|
? timeDifference(new Date(), lastUpdated)
|
|
32
|
-
:
|
|
32
|
+
: `5 ${t('seconds_ago')}`;
|
|
33
33
|
return (
|
|
34
34
|
<View style={styles.statusContainer}>
|
|
35
35
|
<View style={styles.connectStatus}>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TouchableWithoutFeedback } from 'react-native';
|
|
3
|
+
import renderer, { act } from 'react-test-renderer';
|
|
4
|
+
import ItemHanetDevice from './ItemHanetDevice';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
|
|
8
|
+
const wrapComponent = (props) => (
|
|
9
|
+
<SCProvider initState={mockSCStore({})}>
|
|
10
|
+
<ItemHanetDevice {...props} />
|
|
11
|
+
</SCProvider>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const mockNavigate = jest.fn();
|
|
15
|
+
jest.mock('@react-navigation/native', () => {
|
|
16
|
+
return {
|
|
17
|
+
...jest.requireActual('@react-navigation/native'),
|
|
18
|
+
useNavigation: () => ({
|
|
19
|
+
navigate: mockNavigate,
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('Test ItemHanetDevice', () => {
|
|
25
|
+
let tree, props;
|
|
26
|
+
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
props = {
|
|
29
|
+
svgMain: 'icon',
|
|
30
|
+
title: 'title',
|
|
31
|
+
sensor: {},
|
|
32
|
+
unit: {},
|
|
33
|
+
station: {},
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('render ItemHanetDevice', () => {
|
|
38
|
+
act(() => {
|
|
39
|
+
tree = renderer.create(wrapComponent(props));
|
|
40
|
+
});
|
|
41
|
+
const instance = tree.root;
|
|
42
|
+
const touches = instance.findAllByType(TouchableWithoutFeedback);
|
|
43
|
+
act(() => {
|
|
44
|
+
tree = touches[0].props.onPress();
|
|
45
|
+
});
|
|
46
|
+
expect(mockNavigate).toBeCalled();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('render ItemHanetDevice sensor has icon', () => {
|
|
50
|
+
props.sensor.icon_kit = 'icon';
|
|
51
|
+
act(() => {
|
|
52
|
+
tree = renderer.create(wrapComponent(props));
|
|
53
|
+
});
|
|
54
|
+
const instance = tree.root;
|
|
55
|
+
const touches = instance.findAllByType(TouchableWithoutFeedback);
|
|
56
|
+
expect(touches.length).toBeGreaterThan(0);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -151,12 +151,12 @@ const HistoryChart = memo(
|
|
|
151
151
|
if (configuration.config !== 'power_consumption') {
|
|
152
152
|
return null;
|
|
153
153
|
}
|
|
154
|
-
const { price } = chartConfig;
|
|
155
|
-
if (
|
|
154
|
+
const { price: chartPrice } = chartConfig;
|
|
155
|
+
if (chartPrice === '' || isNaN(chartPrice)) {
|
|
156
156
|
return null;
|
|
157
157
|
}
|
|
158
158
|
const sum = datas[0].data.reduce((a, b) => a + b.y, 0);
|
|
159
|
-
const roundedSum = sum *
|
|
159
|
+
const roundedSum = sum * chartPrice;
|
|
160
160
|
return roundedSum.toFixed();
|
|
161
161
|
}, [configuration, datas, chartConfig]);
|
|
162
162
|
|
|
@@ -239,6 +239,8 @@ const HistoryChart = memo(
|
|
|
239
239
|
onConfirm={onConfirmStart}
|
|
240
240
|
onCancel={onCancel}
|
|
241
241
|
display="spinner"
|
|
242
|
+
cancelTextIOS={t('cancel')}
|
|
243
|
+
confirmTextIOS={t('confirm')}
|
|
242
244
|
/>
|
|
243
245
|
<DateTimePickerModal
|
|
244
246
|
isVisible={eventPicker.showModalEnd}
|
|
@@ -247,6 +249,8 @@ const HistoryChart = memo(
|
|
|
247
249
|
onConfirm={onConfirmEnd}
|
|
248
250
|
onCancel={onCancel}
|
|
249
251
|
display="spinner"
|
|
252
|
+
cancelTextIOS={t('cancel')}
|
|
253
|
+
confirmTextIOS={t('confirm')}
|
|
250
254
|
/>
|
|
251
255
|
</View>
|
|
252
256
|
);
|
|
@@ -11,8 +11,9 @@ import { useNavigation } from '@react-navigation/native';
|
|
|
11
11
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
12
12
|
import ItemQuickAction from '../../commons/Action/ItemQuickAction';
|
|
13
13
|
import Text from '../../commons/Text';
|
|
14
|
-
import { isDeviceConnected } from '../../iot/RemoteControl/Bluetooth';
|
|
14
|
+
import { isDeviceConnected as isBluetoothDeviceConnected } from '../../iot/RemoteControl/Bluetooth';
|
|
15
15
|
import { useSCContextSelector } from '../../context';
|
|
16
|
+
import { useGGHomeDeviceConnected } from '../../hooks/Common';
|
|
16
17
|
|
|
17
18
|
import { Colors } from '../../configs';
|
|
18
19
|
import { TESTID, DEVICE_TYPE, DEVICE_SIZE } from '../../configs/Constants';
|
|
@@ -26,7 +27,6 @@ const ItemDevice = memo(
|
|
|
26
27
|
sensor,
|
|
27
28
|
unit,
|
|
28
29
|
station,
|
|
29
|
-
isGGHomeConnected,
|
|
30
30
|
serverDown,
|
|
31
31
|
status,
|
|
32
32
|
wrapStyle,
|
|
@@ -39,6 +39,8 @@ const ItemDevice = memo(
|
|
|
39
39
|
const isNetworkConnected = useSCContextSelector(
|
|
40
40
|
(state) => state.app.isNetworkConnected
|
|
41
41
|
);
|
|
42
|
+
const { isConnected: isGGHomeConnected, isConnecting: isGGHomeConnecting } =
|
|
43
|
+
useGGHomeDeviceConnected(sensor);
|
|
42
44
|
|
|
43
45
|
const goToSensorDisplay = useCallback(() => {
|
|
44
46
|
navigation.navigate(Routes.DeviceDetail, {
|
|
@@ -46,29 +48,48 @@ const ItemDevice = memo(
|
|
|
46
48
|
station,
|
|
47
49
|
sensorData: sensor,
|
|
48
50
|
title,
|
|
49
|
-
isGGHomeConnected,
|
|
50
51
|
});
|
|
51
|
-
}, [navigation, sensor, station, title, unit
|
|
52
|
+
}, [navigation, sensor, station, title, unit]);
|
|
52
53
|
|
|
53
54
|
const isConnectedViaInternet =
|
|
54
55
|
status === undefined
|
|
55
56
|
? !serverDown && isNetworkConnected && sensor.is_connected
|
|
56
57
|
: !serverDown && isNetworkConnected && status.is_connected;
|
|
58
|
+
|
|
57
59
|
const isConnectedViaBLE =
|
|
58
60
|
isBluetoothEnabled &&
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
isBluetoothDeviceConnected(
|
|
62
|
+
sensor?.remote_control_options?.bluetooth?.address
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const isConnected =
|
|
66
|
+
!!sensor && sensor?.is_other_device
|
|
67
|
+
? sensor?.device_type === DEVICE_TYPE.LG_THINQ
|
|
68
|
+
? true
|
|
69
|
+
: isGGHomeConnected
|
|
70
|
+
: isConnectedViaInternet || isConnectedViaBLE;
|
|
71
|
+
|
|
72
|
+
const isConnecting =
|
|
61
73
|
!!sensor &&
|
|
62
74
|
sensor?.is_other_device &&
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const borderColor =
|
|
68
|
-
|
|
75
|
+
sensor?.device_type !== DEVICE_TYPE.LG_THINQ
|
|
76
|
+
? isGGHomeConnecting
|
|
77
|
+
: false;
|
|
78
|
+
|
|
79
|
+
const borderColor =
|
|
80
|
+
isConnected || isConnecting ? Colors.Gray4 : Colors.Red6;
|
|
81
|
+
|
|
82
|
+
const textConnected = isConnected
|
|
83
|
+
? t('connected')
|
|
84
|
+
: isConnecting
|
|
85
|
+
? ''
|
|
86
|
+
: t('disconnected');
|
|
69
87
|
|
|
70
88
|
return (
|
|
71
|
-
<TouchableWithoutFeedback
|
|
89
|
+
<TouchableWithoutFeedback
|
|
90
|
+
onPress={goToSensorDisplay}
|
|
91
|
+
testID={`${TESTID.SENSOR_NAME}-${sensor?.id}`}
|
|
92
|
+
>
|
|
72
93
|
<View
|
|
73
94
|
style={[styles.container, wrapStyle, { borderColor }]}
|
|
74
95
|
testID={TESTID.SUB_UNIT_DEVICES}
|
|
@@ -52,6 +52,21 @@ const chartOptions = {
|
|
|
52
52
|
format: '{value:%d.%m %H:%M}',
|
|
53
53
|
},
|
|
54
54
|
},
|
|
55
|
+
legend: {
|
|
56
|
+
useHTML: true,
|
|
57
|
+
labelFormatter: function () {
|
|
58
|
+
if (this.visible) {
|
|
59
|
+
return (
|
|
60
|
+
'<span style="color:#333333;font-weight:bold">' +
|
|
61
|
+
this.name +
|
|
62
|
+
'</span>'
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
return (
|
|
66
|
+
'<span style="color:#cccccc;font-weight:bold">' + this.name + '</span>'
|
|
67
|
+
);
|
|
68
|
+
},
|
|
69
|
+
},
|
|
55
70
|
};
|
|
56
71
|
|
|
57
72
|
function LinearChart({ datas }) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { memo, useCallback } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
2
3
|
import { FlatList } from 'react-native';
|
|
3
4
|
import QualityIndicatorItem from '../WaterQualitySensor/QualityIndicatorsItem';
|
|
4
5
|
import styles from './PMSensorIndicatorStyles';
|
|
@@ -26,18 +27,21 @@ const PMSensorIndicatior = memo(({ data, style }) => {
|
|
|
26
27
|
const isScrollMode = data.length > 3;
|
|
27
28
|
|
|
28
29
|
return (
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
<View style={styles.wrap}>
|
|
31
|
+
<FlatList
|
|
32
|
+
bounces={false}
|
|
33
|
+
numColumns={1}
|
|
34
|
+
horizontal={true}
|
|
35
|
+
contentContainerStyle={[
|
|
36
|
+
styles.standard,
|
|
37
|
+
!isScrollMode && styles.centerItem,
|
|
38
|
+
]}
|
|
39
|
+
data={data}
|
|
40
|
+
keyExtractor={keyExtractor}
|
|
41
|
+
renderItem={renderItem}
|
|
42
|
+
scrollIndicatorInsets={{ right: 1 }}
|
|
43
|
+
/>
|
|
44
|
+
</View>
|
|
41
45
|
);
|
|
42
46
|
});
|
|
43
47
|
|
|
@@ -37,7 +37,7 @@ const QualityIndicatorItem = memo(
|
|
|
37
37
|
>
|
|
38
38
|
<IconOutline
|
|
39
39
|
name={'info-circle'}
|
|
40
|
-
size={
|
|
40
|
+
size={18}
|
|
41
41
|
color={Colors.Gray8}
|
|
42
42
|
/>
|
|
43
43
|
</TouchableOpacity>
|
|
@@ -92,6 +92,11 @@ const styles = StyleSheet.create({
|
|
|
92
92
|
marginTop: 8,
|
|
93
93
|
},
|
|
94
94
|
iconInfo: {
|
|
95
|
-
|
|
95
|
+
width: 40,
|
|
96
|
+
height: 40,
|
|
97
|
+
justifyContent: 'center',
|
|
98
|
+
alignItems: 'center',
|
|
99
|
+
marginRight: -10,
|
|
100
|
+
marginTop: -2,
|
|
96
101
|
},
|
|
97
102
|
});
|