@eohjsc/react-native-smart-city 0.3.8 → 0.3.11

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.
Files changed (297) hide show
  1. package/README.md +36 -15
  2. package/package.json +10 -6
  3. package/react-native-smart-city.podspec +1 -0
  4. package/src/commons/Action/ItemQuickAction.js +16 -4
  5. package/src/commons/Action/__test__/ItemQuickAction.test.js +11 -6
  6. package/src/commons/ActionGroup/ColorPickerTemplate.js +37 -24
  7. package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
  8. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +4 -0
  9. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
  10. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +24 -0
  11. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +14 -0
  12. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +1 -0
  13. package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +8 -2
  14. package/src/commons/ActionGroup/SliderRangeTemplate.js +6 -2
  15. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -3
  16. package/src/commons/ActionGroup/StatesGridActionTemplate.js +22 -8
  17. package/src/commons/ActionGroup/TimerActionTemplate.js +11 -3
  18. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +1 -5
  19. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
  20. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
  21. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +53 -78
  22. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +36 -20
  23. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +77 -0
  24. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +58 -6
  25. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +49 -1
  26. package/src/commons/ActionGroup/__test__/index.test.js +135 -0
  27. package/src/commons/Auth/AccountList.js +1 -1
  28. package/src/commons/Automate/ItemAutomate.js +1 -3
  29. package/src/commons/Calendar/__test__/Calendar.test.js +33 -0
  30. package/src/commons/Connecting/__test__/Connecting.test.js +19 -2
  31. package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +7 -3
  32. package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +8 -11
  33. package/src/commons/ConnectingProcess/__test__/Connecting.test.js +136 -3
  34. package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +3 -2
  35. package/src/commons/ConnectingProcess/index.js +76 -26
  36. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +16 -13
  37. package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
  38. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +0 -5
  39. package/src/commons/Device/ConnectedViewHeader.js +1 -1
  40. package/src/commons/Device/Hanet/ItemHanetDevice.test.js +58 -0
  41. package/src/commons/Device/HistoryChart.js +7 -3
  42. package/src/commons/Device/ItemDevice.js +34 -13
  43. package/src/commons/Device/LinearChart.js +15 -0
  44. package/src/commons/Device/PMSensor/PMSensorIndicatior.js +16 -12
  45. package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -0
  46. package/src/commons/Device/SonosSpeaker/index.js +1 -1
  47. package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -0
  48. package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +7 -2
  49. package/src/commons/Explore/__test__/CityItem.test.js +33 -54
  50. package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +25 -0
  51. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +96 -0
  52. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +39 -0
  53. package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +118 -0
  54. package/src/commons/FieldTemplate/ChooseUserField/index.js +62 -0
  55. package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +30 -0
  56. package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +90 -0
  57. package/src/commons/FieldTemplate/PasscodeField/index.js +43 -0
  58. package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +13 -0
  59. package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +179 -0
  60. package/src/commons/FieldTemplate/ScheduleField/index.js +176 -0
  61. package/src/commons/Form/CurrencyInput.js +15 -1
  62. package/src/commons/Form/TextInputPassword.js +1 -1
  63. package/src/commons/FullLoading/index.js +2 -1
  64. package/src/commons/Header/HeaderCustom.js +2 -1
  65. package/src/commons/HeaderAni/index.js +6 -1
  66. package/src/commons/HorizontalPicker/index.js +2 -2
  67. package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +0 -6
  68. package/src/commons/MediaPlayerDetail/index.js +29 -47
  69. package/src/commons/MenuActionAddnew/index.js +1 -0
  70. package/src/commons/MenuActionList/index.js +1 -0
  71. package/src/commons/MenuActionMore/index.js +1 -1
  72. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +62 -0
  73. package/src/commons/PreventAccess/index.js +9 -1
  74. package/src/commons/Sharing/MemberList.js +10 -2
  75. package/src/commons/Sharing/WrapHeaderScrollable.js +2 -0
  76. package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +0 -1
  77. package/src/commons/SubUnit/Favorites/index.js +6 -3
  78. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +8 -35
  79. package/src/commons/SubUnit/OneTap/index.js +1 -2
  80. package/src/commons/SubUnit/ShortDetail.js +25 -9
  81. package/src/commons/SubUnit/__test__/Item.test.js +0 -1
  82. package/src/commons/SubUnit/__test__/ShortDetail.test.js +9 -2
  83. package/src/commons/Unit/SharedUnit.js +1 -0
  84. package/src/commons/Unit/__test__/SharedUnit.test.js +38 -183
  85. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +28 -1
  86. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +2 -13
  87. package/src/commons/UnitSummary/ConfigHistoryChart.js +55 -13
  88. package/src/commons/WheelDateTimePicker/index.js +4 -3
  89. package/src/configs/API.js +91 -143
  90. package/src/configs/Constants.js +80 -1
  91. package/src/configs/SCConfig.js +4 -0
  92. package/src/context/actionType.ts +14 -2
  93. package/src/context/mockStore.ts +26 -0
  94. package/src/context/reducer.ts +84 -5
  95. package/src/hooks/Common/index.js +2 -0
  96. package/src/hooks/Common/useGGHomeDeviceConnected.js +16 -0
  97. package/src/hooks/Common/useGetIdUser.js +1 -5
  98. package/src/hooks/Common/useSensorsStatus.js +4 -4
  99. package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +199 -0
  100. package/src/hooks/IoT/__test__/useRemoteControl.test.js +198 -0
  101. package/src/hooks/IoT/__test__/useValueEvaluation.test.js +58 -0
  102. package/src/hooks/IoT/index.js +5 -0
  103. package/src/hooks/IoT/useGGHomeConnection.js +93 -0
  104. package/src/hooks/IoT/useRemoteControl.js +79 -0
  105. package/src/hooks/IoT/useValueEvaluation.js +45 -0
  106. package/src/hooks/index.js +4 -0
  107. package/src/hooks/useReceiveNotifications.js +12 -7
  108. package/src/iot/Monitor.js +3 -2
  109. package/src/iot/RemoteControl/Bluetooth.js +1 -1
  110. package/src/iot/RemoteControl/GoogleHome.js +75 -49
  111. package/src/iot/RemoteControl/Internet.js +1 -1
  112. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +95 -48
  113. package/src/iot/RemoteControl/__test__/Internet.test.js +18 -7
  114. package/src/iot/RemoteControl/__test__/LgThinq.test.js +36 -177
  115. package/src/iot/RemoteControl/index.js +52 -52
  116. package/src/navigations/UnitStack.js +19 -20
  117. package/src/navigations/UnitStackStyles.js +21 -0
  118. package/src/screens/AQIGuide/index.js +1 -1
  119. package/src/screens/ActivityLog/FilterPopup.js +2 -0
  120. package/src/screens/ActivityLog/__test__/index.test.js +38 -23
  121. package/src/screens/ActivityLog/hooks/__test__/index.test.js +51 -90
  122. package/src/screens/ActivityLog/hooks/index.js +1 -1
  123. package/src/screens/ActivityLog/index.js +2 -2
  124. package/src/screens/AddCommon/SelectSubUnit.js +1 -0
  125. package/src/screens/AddCommon/SelectUnit.js +1 -0
  126. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +13 -24
  127. package/src/screens/AddCommon/__test__/SelectUnit.test.js +9 -33
  128. package/src/screens/AddLocationMaps/__test__/index.test.js +265 -0
  129. package/src/screens/AddLocationMaps/index.js +48 -21
  130. package/src/screens/AddNewAction/SelectAction.js +33 -13
  131. package/src/screens/AddNewAction/SelectSensorDevices.js +8 -2
  132. package/src/screens/AddNewAction/SetupSensor.js +68 -32
  133. package/src/screens/AddNewAction/__test__/SelectAction.test.js +10 -91
  134. package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +40 -26
  135. package/src/screens/AddNewAction/__test__/SetupSensor.test.js +2 -0
  136. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -1
  137. package/src/screens/AddNewAutoSmart/index.js +5 -2
  138. package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
  139. package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +42 -34
  140. package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -4
  141. package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +22 -22
  142. package/src/screens/AddNewDevice/hooks/ConnectDevices.js +1 -1
  143. package/src/screens/AddNewDevice/index.js +1 -0
  144. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +23 -17
  145. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +46 -40
  146. package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +64 -10
  147. package/src/screens/AddNewGateway/SelectGateway.js +1 -0
  148. package/src/screens/AddNewGateway/SetupGatewayWifi.js +2 -0
  149. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +4 -6
  150. package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -4
  151. package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +5 -29
  152. package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +0 -4
  153. package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -4
  154. package/src/screens/AddNewGateway/index.js +1 -0
  155. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +10 -24
  156. package/src/screens/AddNewOneTap/index.js +3 -2
  157. package/src/screens/AllCamera/index.js +4 -4
  158. package/src/screens/Automate/MultiUnits.js +8 -8
  159. package/src/screens/Automate/__test__/MultiUnits.test.js +6 -9
  160. package/src/screens/Automate/__test__/index.test.js +7 -12
  161. package/src/screens/Automate/index.js +5 -3
  162. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +36 -8
  163. package/src/screens/ConfirmUnitDeletion/index.js +7 -1
  164. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +71 -22
  165. package/src/screens/Device/EditDevice/index.js +17 -15
  166. package/src/screens/Device/__test__/detail.test.js +33 -86
  167. package/src/screens/Device/components/DetailHistoryChart.js +1 -1
  168. package/src/screens/Device/components/SensorConnectStatusViewHeader.js +44 -24
  169. package/src/screens/Device/components/SensorDisplayItem.js +5 -2
  170. package/src/screens/Device/detail.js +101 -51
  171. package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
  172. package/src/screens/Device/hooks/useEvaluateValue.js +97 -0
  173. package/src/screens/Device/hooks/useFavoriteDevice.js +7 -11
  174. package/src/screens/DeviceInfo/__test__/index.test.js +0 -2
  175. package/src/screens/EditActionsList/index.js +1 -1
  176. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +6 -3
  177. package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +7 -19
  178. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +20 -2
  179. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +40 -23
  180. package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
  181. package/src/screens/EmergencySetting/index.js +4 -1
  182. package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
  183. package/src/screens/Explore/index.js +2 -0
  184. package/src/screens/GuestInfo/__test__/index.test.js +14 -41
  185. package/src/screens/GuestInfo/components/RecurringDetail.js +1 -0
  186. package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
  187. package/src/screens/HanetCamera/Detail.js +1 -1
  188. package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +8 -12
  189. package/src/screens/HanetCamera/__test__/Detail.test.js +27 -42
  190. package/src/screens/HanetCamera/__test__/ManageAccess.test.js +8 -5
  191. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -32
  192. package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +3 -2
  193. package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +43 -35
  194. package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +10 -21
  195. package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +11 -11
  196. package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
  197. package/src/screens/ManageAccess/__test__/ManageAccess.test.js +33 -22
  198. package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +44 -45
  199. package/src/screens/ManageAccess/hooks/index.js +7 -4
  200. package/src/screens/ManageAccess/index.js +2 -1
  201. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +35 -12
  202. package/src/screens/MoveToAnotherSubUnit/index.js +6 -6
  203. package/src/screens/Notification/__test__/Notification.test.js +31 -25
  204. package/src/screens/Notification/__test__/NotificationItem.test.js +8 -7
  205. package/src/screens/Notification/components/NotificationItem.js +17 -20
  206. package/src/screens/Notification/index.js +13 -2
  207. package/src/screens/PlayBackCamera/Timer.js +2 -2
  208. package/src/screens/PlayBackCamera/__test__/index.test.js +87 -2
  209. package/src/screens/PlayBackCamera/index.js +54 -35
  210. package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +7 -20
  211. package/src/screens/ScanChipQR/components/QRScan/index.js +1 -0
  212. package/src/screens/ScanChipQR/hooks/index.js +15 -16
  213. package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +8 -24
  214. package/src/screens/ScriptDetail/__test__/index.test.js +17 -86
  215. package/src/screens/ScriptDetail/index.js +30 -15
  216. package/src/screens/SelectUnit/__test__/index.test.js +12 -55
  217. package/src/screens/SelectUnit/index.js +9 -4
  218. package/src/screens/SetSchedule/index.js +15 -11
  219. package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
  220. package/src/screens/SharedUnit/index.js +2 -0
  221. package/src/screens/Sharing/Components/SensorItem.js +10 -12
  222. package/src/screens/Sharing/InfoMemberUnit.js +1 -1
  223. package/src/screens/Sharing/MemberList.js +12 -11
  224. package/src/screens/Sharing/SelectPermission.js +136 -83
  225. package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +47 -29
  226. package/src/screens/Sharing/__test__/MemberList.test.js +13 -127
  227. package/src/screens/Sharing/__test__/MemberList2.test.js +80 -0
  228. package/src/screens/Sharing/__test__/SelectPermission.test.js +28 -38
  229. package/src/screens/Sharing/__test__/SelectUser.test.js +17 -38
  230. package/src/screens/Sharing/hooks/index.js +3 -0
  231. package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +28 -0
  232. package/src/screens/SideMenuDetail/__test__/index.test.js +154 -0
  233. package/src/screens/SideMenuDetail/index.js +148 -0
  234. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +3 -2
  235. package/src/screens/SmartIr/components/SelectBrand.js +1 -1
  236. package/src/screens/SubUnit/AddSubUnit.js +23 -17
  237. package/src/screens/SubUnit/Detail.js +1 -2
  238. package/src/screens/SubUnit/EditSubUnit.js +15 -13
  239. package/src/screens/SubUnit/ManageSubUnit.js +13 -7
  240. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +29 -89
  241. package/src/screens/SubUnit/__test__/Detail.test.js +31 -8
  242. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +21 -89
  243. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +27 -1
  244. package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +48 -45
  245. package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
  246. package/src/screens/SyncLGDevice/AddLGDevice.js +1 -0
  247. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +22 -91
  248. package/src/screens/TDSGuide/index.js +4 -1
  249. package/src/screens/UVIndexGuide/index.js +1 -1
  250. package/src/screens/Unit/ChooseLocation.js +7 -14
  251. package/src/screens/Unit/Detail.js +37 -75
  252. package/src/screens/Unit/ManageUnit.js +1 -0
  253. package/src/screens/Unit/SelectAddress.js +46 -26
  254. package/src/screens/Unit/SelectDevices.js +158 -0
  255. package/src/screens/Unit/SelectDevicesStyles.js +40 -0
  256. package/src/screens/Unit/SmartAccount.js +4 -4
  257. package/src/screens/Unit/Station/index.js +4 -0
  258. package/src/screens/Unit/Summaries.js +18 -2
  259. package/src/screens/Unit/__test__/CheckSendEmail.test.js +24 -29
  260. package/src/screens/Unit/__test__/ChooseLocation.test.js +27 -14
  261. package/src/screens/Unit/__test__/Detail.test.js +98 -199
  262. package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
  263. package/src/screens/Unit/__test__/SelectAddress.test.js +249 -50
  264. package/src/screens/Unit/__test__/SelectDevices.test.js +110 -0
  265. package/src/screens/Unit/__test__/SmartAccount.test.js +17 -9
  266. package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -1
  267. package/src/screens/Unit/__test__/Summaries.test.js +100 -0
  268. package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +36 -0
  269. package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +54 -0
  270. package/src/screens/Unit/components/MyUnitDevice/index.js +4 -4
  271. package/src/screens/Unit/components/SharedUnit/index.js +1 -0
  272. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
  273. package/src/screens/Unit/components/__test__/SharedUnit.test.js +31 -34
  274. package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +50 -0
  275. package/src/screens/Unit/styles.js +8 -0
  276. package/src/screens/UnitSummary/__test__/index.test.js +91 -30
  277. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +31 -2
  278. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +7 -4
  279. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +2 -13
  280. package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +0 -1
  281. package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +14 -16
  282. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +11 -2
  283. package/src/screens/UnitSummary/components/RunningDevices/index.js +7 -10
  284. package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
  285. package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +10 -2
  286. package/src/screens/UnitSummary/index.js +15 -1
  287. package/src/screens/WaterQualityGuide/index.js +1 -1
  288. package/src/utils/Apis/axios.js +61 -32
  289. package/src/utils/Converter/time.js +0 -18
  290. package/src/utils/I18n/translations/en.json +13 -1
  291. package/src/utils/I18n/translations/vi.json +14 -1
  292. package/src/utils/Permission/common.js +67 -0
  293. package/src/utils/Route/index.js +2 -0
  294. package/src/utils/Setting/Location.js +30 -0
  295. package/src/utils/Utils.js +12 -7
  296. package/src/utils/Validation.js +3 -0
  297. package/src/utils/__test__/Utils.test.js +12 -0
@@ -1,11 +1,14 @@
1
1
  import React from 'react';
2
2
  import { act, create } from 'react-test-renderer';
3
+ import MockAdapter from 'axios-mock-adapter';
4
+ import moment from 'moment';
5
+
3
6
  import ConfigHistoryChart from '../';
4
7
  import { SCProvider } from '../../../../../context';
5
8
  import { mockSCStore } from '../../../../../context/mockStore';
6
9
  import HistoryChart from '../../../../../commons/Device/HistoryChart';
7
- import axios from 'axios';
8
- import moment from 'moment';
10
+ import api from '../../../../../utils/Apis/axios';
11
+ import { API } from '../../../../../configs';
9
12
 
10
13
  jest.mock('react', () => {
11
14
  return {
@@ -14,7 +17,7 @@ jest.mock('react', () => {
14
17
  };
15
18
  });
16
19
 
17
- jest.mock('axios');
20
+ const mock = new MockAdapter(api.axiosInstance);
18
21
 
19
22
  const wrapComponent = (configs = []) => (
20
23
  <SCProvider initState={mockSCStore({})}>
@@ -48,7 +51,7 @@ describe('Test HistoryChart', () => {
48
51
  },
49
52
  ],
50
53
  };
51
- axios.get.mockImplementation(async () => response);
54
+ mock.onGet(API.CONFIG.DISPLAY_HISTORY).reply(200, response.data);
52
55
  const configs = [{ id: 1 }];
53
56
  await act(async () => {
54
57
  tree = await create(wrapComponent(configs));
@@ -4,6 +4,7 @@ import moment from 'moment';
4
4
  import { API } from '../../../../configs';
5
5
  import HistoryChart from '../../../../commons/Device/HistoryChart';
6
6
  import { axiosGet } from '../../../../utils/Apis/axios';
7
+ import { updateConfigChart } from '../../../../commons/UnitSummary/ConfigHistoryChart';
7
8
 
8
9
  export const dateTimeType = {
9
10
  date: 'date',
@@ -30,19 +31,7 @@ const ConfigHistoryChart = memo(({ configs }) => {
30
31
  const { success, data } = await axiosGet(API.CONFIG.DISPLAY_HISTORY, {
31
32
  params,
32
33
  });
33
- if (success) {
34
- for (let i = 0; i < data.length; i++) {
35
- for (let j = 0; j < data[i].data.length; j++) {
36
- data[i].data[j].x = moment(data[i].data[j].x).toDate();
37
- }
38
- }
39
- setChartData(
40
- configuration.map((config) => {
41
- config.data = data.find((k) => k.config === config.id).data;
42
- return config;
43
- })
44
- );
45
- }
34
+ updateConfigChart(success, data, configuration, setChartData);
46
35
  };
47
36
  fetchData();
48
37
  }, [startDate, endDate, configs]);
@@ -1,4 +1,3 @@
1
- /* eslint-disable promise/prefer-await-to-callbacks */
2
1
  import React from 'react';
3
2
  import { act, create } from 'react-test-renderer';
4
3
  import Text from '../../../../../commons/Text';
@@ -1,14 +1,17 @@
1
1
  import React from 'react';
2
2
  import renderer, { act } from 'react-test-renderer';
3
+ import MockAdapter from 'axios-mock-adapter';
4
+
3
5
  import { TESTID } from '../../../../../configs/Constants';
4
- import { Colors } from '../../../../../configs';
6
+ import { API, Colors } from '../../../../../configs';
5
7
  import ListQualityIndicator from '../../../../../commons/Device/WaterQualitySensor/ListQualityIndicator';
6
- import axios from 'axios';
7
8
  import PowerConsumption from '../index';
8
9
  import { SCProvider } from '../../../../../context';
9
10
  import { mockSCStore } from '../../../../../context/mockStore';
11
+ import api from '../../../../../utils/Apis/axios';
12
+ import { Today } from '../../../../../commons';
10
13
 
11
- jest.mock('axios');
14
+ const mock = new MockAdapter(api.axiosInstance);
12
15
 
13
16
  const wrapComponent = (summaryDetail) => (
14
17
  <SCProvider initState={mockSCStore({})}>
@@ -86,15 +89,13 @@ describe('Test PowerConsumption', () => {
86
89
  },
87
90
  };
88
91
 
89
- const response = {
90
- status: 200,
91
- };
92
- axios.get.mockImplementation(async (url) => response);
93
-
92
+ mock.onGet(API.VALUE_CONSUME.DISPLAY_HISTORY()).reply(200);
94
93
  await act(async () => {
95
94
  tree = await renderer.create(wrapComponent(summaryDetail));
96
95
  });
97
- expect(axios.get).toHaveBeenCalled();
96
+ const instance = tree.root;
97
+ const Todays = instance.findByType(Today);
98
+ expect(Todays).toBeDefined();
98
99
  });
99
100
 
100
101
  test('render with unsuccess fetch', async () => {
@@ -113,16 +114,13 @@ describe('Test PowerConsumption', () => {
113
114
  volt: 209,
114
115
  },
115
116
  };
116
-
117
- const response = {
118
- data: {},
119
- };
120
- axios.get.mockImplementation(async (url) => response);
121
-
117
+ mock.onGet(API.VALUE_CONSUME.DISPLAY_HISTORY()).reply(200, {});
122
118
  await act(async () => {
123
119
  tree = await renderer.create(wrapComponent(summaryDetail));
124
120
  });
125
- expect(axios.get).toHaveBeenCalled();
121
+ const instance = tree.root;
122
+ const Todays = instance.findByType(Today);
123
+ expect(Todays).toBeDefined();
126
124
  });
127
125
 
128
126
  test('render without value', async () => {
@@ -13,7 +13,6 @@ const wrapComponent = (unit, summaryDetail) => (
13
13
  );
14
14
 
15
15
  const mockedNavigate = jest.fn();
16
-
17
16
  jest.mock('@react-navigation/native', () => {
18
17
  return {
19
18
  ...jest.requireActual('@react-navigation/native'),
@@ -23,6 +22,16 @@ jest.mock('@react-navigation/native', () => {
23
22
  };
24
23
  });
25
24
 
25
+ const mockConnectGoogleHome = jest.fn();
26
+ jest.mock('../../../../../hooks/IoT', () => {
27
+ return {
28
+ ...jest.requireActual('../../../../../hooks/IoT'),
29
+ useGGHomeConnection: () => ({
30
+ connectGoogleHome: mockConnectGoogleHome,
31
+ }),
32
+ };
33
+ });
34
+
26
35
  describe('test RunningDevices', () => {
27
36
  afterEach(() => {
28
37
  mockedNavigate.mockClear();
@@ -73,6 +82,7 @@ describe('test RunningDevices', () => {
73
82
  act(() => {
74
83
  button[0].props.onPress();
75
84
  });
85
+ expect(mockConnectGoogleHome).toBeCalled();
76
86
  });
77
87
  });
78
88
 
@@ -112,7 +122,6 @@ describe('test RunningDevices', () => {
112
122
  button[0].props.onPress();
113
123
  });
114
124
  expect(mockedNavigate).toBeCalledWith('DeviceDetail', {
115
- isGGHomeConnected: false,
116
125
  sensorData: summaryDetail.devices[0],
117
126
  station: 'station',
118
127
  title: undefined,
@@ -1,16 +1,13 @@
1
- import React, { memo, useCallback, useEffect, useState } from 'react';
1
+ import React, { memo, useEffect } from 'react';
2
2
  import { StyleSheet, View } from 'react-native';
3
3
  import ItemDevice from '../../../../commons/Device/ItemDevice';
4
4
  import { scanBluetoothDevices } from '../../../../iot/RemoteControl/Bluetooth';
5
- import { googleHomeConnect } from '../../../../iot/RemoteControl/GoogleHome';
5
+ import { useGGHomeConnection } from '../../../../hooks/IoT';
6
6
 
7
7
  const RunningDevices = memo(({ unit, summaryDetail }) => {
8
- const [isGGHomeConnected, setIsGGHomeConnected] = useState(false);
9
8
  const { devices } = summaryDetail;
10
- const handleGoogleHomeConnect = useCallback(async (options) => {
11
- let isConnected = await googleHomeConnect(options);
12
- setIsGGHomeConnected(isConnected);
13
- }, []);
9
+
10
+ const { connectGoogleHome } = useGGHomeConnection();
14
11
 
15
12
  useEffect(() => {
16
13
  if (unit.remote_control_options) {
@@ -18,10 +15,11 @@ const RunningDevices = memo(({ unit, summaryDetail }) => {
18
15
  scanBluetoothDevices(unit.remote_control_options.bluetooth);
19
16
  }
20
17
  if (unit.remote_control_options.googlehome) {
21
- handleGoogleHomeConnect(unit.remote_control_options.googlehome);
18
+ (async () =>
19
+ await connectGoogleHome(unit.remote_control_options.googlehome))();
22
20
  }
23
21
  }
24
- }, [handleGoogleHomeConnect, unit]);
22
+ }, [connectGoogleHome, unit]);
25
23
  return (
26
24
  <View style={styles.container}>
27
25
  {!!devices &&
@@ -39,7 +37,6 @@ const RunningDevices = memo(({ unit, summaryDetail }) => {
39
37
  sensor={item}
40
38
  unit={unit}
41
39
  station={item.station}
42
- isGGHomeConnected={isGGHomeConnected}
43
40
  />
44
41
  );
45
42
  })}
@@ -1,6 +1,6 @@
1
1
  import React, { memo, useMemo } from 'react';
2
2
  import { StyleSheet, View } from 'react-native';
3
- import t, { useTranslations } from '../../../../hooks/Common/useTranslations';
3
+ import { useTranslations } from '../../../../hooks/Common/useTranslations';
4
4
 
5
5
  import { Colors } from '../../../../configs';
6
6
  import { Section, Today } from '../../../../commons';
@@ -11,7 +11,7 @@ import SvgRain from '../../../../../assets/images/Device/rain-outline.svg';
11
11
  import SvgTemperature from '../../../../../assets/images/Device/temperature.svg';
12
12
  import SvgWind from '../../../../../assets/images/Device/wind.svg';
13
13
 
14
- const getDataTemperature = (summaryDetail) => {
14
+ const getDataTemperature = (summaryDetail, t) => {
15
15
  return [
16
16
  {
17
17
  id: '0',
@@ -52,8 +52,8 @@ const Temperature = memo(({ summaryDetail }) => {
52
52
  }, [listConfigs]);
53
53
 
54
54
  const dataTemperature = useMemo(
55
- () => getDataTemperature(summaryDetail),
56
- [summaryDetail]
55
+ () => getDataTemperature(summaryDetail, t),
56
+ [summaryDetail, t]
57
57
  );
58
58
 
59
59
  const configs = useMemo(() => {
@@ -22,11 +22,11 @@ const Item = memo((props) => {
22
22
  <View size={14} color={Colors.Gray8} style={styles.textTitleX}>
23
23
  <Text>{title}</Text>
24
24
  {waterType && (
25
- <TouchableOpacity onPress={goToDetail}>
25
+ <TouchableOpacity onPress={goToDetail} style={styles.buttonInfo}>
26
26
  <IconOutline
27
27
  style={styles.row}
28
28
  name="info-circle"
29
- size={14}
29
+ size={20}
30
30
  color={Colors.Black}
31
31
  />
32
32
  </TouchableOpacity>
@@ -79,4 +79,12 @@ const styles = StyleSheet.create({
79
79
  row: {
80
80
  flexDirection: 'row',
81
81
  },
82
+ buttonInfo: {
83
+ width: 40,
84
+ height: 40,
85
+ justifyContent: 'center',
86
+ alignItems: 'center',
87
+ marginTop: -10,
88
+ marginRight: -10,
89
+ },
82
90
  });
@@ -3,9 +3,10 @@ import { View, StyleSheet } from 'react-native';
3
3
  import { useNavigation } from '@react-navigation/native';
4
4
  import { TouchableOpacity } from 'react-native';
5
5
  import { IconOutline } from '@ant-design/icons-react-native';
6
- import { useTranslations } from '../../hooks/Common/useTranslations';
7
6
  import moment from 'moment';
8
7
 
8
+ import { useTranslations } from '../../hooks/Common/useTranslations';
9
+ import { useReceiveNotifications } from '../../hooks';
9
10
  import { API, Colors } from '../../configs';
10
11
  import Routes from '../../utils/Route';
11
12
  import { axiosGet } from '../../utils/Apis/axios';
@@ -139,6 +140,19 @@ const UnitSummary = memo(({ route }) => {
139
140
  fetchSummaryDetail();
140
141
  }, [fetchSummaryDetail]);
141
142
 
143
+ const { dataNotification } = useReceiveNotifications();
144
+
145
+ useEffect(() => {
146
+ if (dataNotification) {
147
+ const { params = {} } = dataNotification;
148
+ const { summary_id } = params;
149
+ if (summary_id && summary_id === summaryId) {
150
+ fetchSummaryDetail();
151
+ }
152
+ }
153
+ // eslint-disable-next-line react-hooks/exhaustive-deps
154
+ }, [dataNotification]);
155
+
142
156
  const UnitSummaryDetail = getComponentAndGuide();
143
157
  const ComponentName = UnitSummaryDetail?.componentName;
144
158
  const GuideName = UnitSummaryDetail?.guideName;
@@ -270,7 +270,7 @@ const WaterQualityGuide = memo(({ route }) => {
270
270
 
271
271
  return (
272
272
  <SafeAreaView style={styles.container}>
273
- <ScrollView style={styles.container}>
273
+ <ScrollView style={styles.container} scrollIndicatorInsets={{ right: 1 }}>
274
274
  <View style={styles.wrapScroll}>
275
275
  {titles.map((item, index) => {
276
276
  const { title, des } = item;
@@ -1,35 +1,37 @@
1
- import axios from 'axios';
2
- import { deleteData, getData, storeData } from '../Storage';
1
+ import { create } from 'apisauce';
2
+ import { getData, storeData } from '../Storage';
3
3
  import { ToastBottomHelper } from '../Utils';
4
4
  import NetInfo from '@react-native-community/netinfo';
5
-
6
- export const replaceParams = (apiURL, params) => {
7
- let _result = apiURL;
8
- if (typeof params === 'object') {
9
- Object.keys(params).forEach((key) => {
10
- _result = _result.replace(`{${key}}`, params[key]);
11
- });
12
- }
13
- return _result;
14
- };
5
+ import { PROBLEM_CODE } from '../../configs/Constants';
6
+ import { getTranslate } from '../I18n';
7
+ import { SCConfig } from '../../configs';
8
+ import { isHTML } from '../Validation';
9
+
10
+ const api = create({
11
+ headers: {
12
+ 'Content-Type': 'application/json',
13
+ },
14
+ timeout: 30000,
15
+ });
15
16
 
16
17
  const parseErrorResponse = async (error) => {
17
18
  let message;
18
19
  let data = {};
19
- if (
20
- error.response &&
21
- error.response.data &&
22
- error.response.data instanceof Object
23
- ) {
24
- data = error.response.data;
25
- const firstKey = Object.keys(error.response.data)[0];
26
- message = error.response.data[firstKey];
20
+ if (error.data instanceof Array) {
21
+ message = error.data[0];
22
+ } else if (error.data instanceof Object) {
23
+ data = error.data;
24
+ const firstKey = Object.keys(error.data)[0];
25
+ message = error.data[firstKey];
27
26
 
28
27
  if (message instanceof Array) {
29
28
  message = message[0];
30
29
  }
30
+ if (message?.message) {
31
+ message = message.message;
32
+ }
31
33
  } else {
32
- message = error.message;
34
+ message = error.data || error.problem;
33
35
  }
34
36
 
35
37
  if (typeof message === 'string') {
@@ -41,6 +43,16 @@ const parseErrorResponse = async (error) => {
41
43
  }
42
44
  }
43
45
  if (!hideError) {
46
+ switch (error.problem) {
47
+ case PROBLEM_CODE.SERVER_ERROR:
48
+ message = getTranslate(SCConfig.language, 'server_error');
49
+ break;
50
+ case PROBLEM_CODE.CLIENT_ERROR:
51
+ if (error.status === 404 && isHTML(error.data)) {
52
+ message = getTranslate(SCConfig.language, 'not_found');
53
+ }
54
+ break;
55
+ }
44
56
  ToastBottomHelper.error(message);
45
57
  }
46
58
  }
@@ -50,7 +62,7 @@ const parseErrorResponse = async (error) => {
50
62
  error,
51
63
  message,
52
64
  data,
53
- resp_status: error?.response?.status,
65
+ resp_status: error?.status || error?.response?.status,
54
66
  };
55
67
  };
56
68
 
@@ -75,6 +87,7 @@ export async function fetchWithCache(url, config = {}, updateMethod) {
75
87
  if (cacheResponse) {
76
88
  updateMethod(cacheResponse);
77
89
  }
90
+ // eslint-disable-next-line no-empty
78
91
  } catch {}
79
92
  const response = await axiosGet(url, config, true);
80
93
  if (!response.cache) {
@@ -83,25 +96,34 @@ export async function fetchWithCache(url, config = {}, updateMethod) {
83
96
  }
84
97
 
85
98
  export async function axiosGet(URL, config = {}, cache = false) {
86
- const cacheKey = `@CACHE_REQUEST_${URL}`;
87
99
  let response;
88
100
  try {
89
- response = await axios.get(URL, config);
101
+ response = await api.get(URL, config.params, config);
90
102
  } catch (error) {
91
103
  if (cache) {
92
- // only network error or server error
93
- if (!error.response || error.response.status >= 500) {
104
+ if (error.message === 'Network Error') {
94
105
  return (
95
- (await axiosCache(URL, error.response.status)) ||
106
+ (await axiosCache(URL, 500)) || (await parseErrorResponse(error))
107
+ );
108
+ }
109
+ if (!error?.response || error?.response?.status >= 500) {
110
+ return (
111
+ (await axiosCache(URL, error?.response?.status)) ||
96
112
  (await parseErrorResponse(error))
97
113
  );
98
- } else {
99
- await deleteData(cacheKey);
100
114
  }
101
115
  }
102
116
  return await parseErrorResponse(error);
103
117
  }
104
- const { data } = response;
118
+ const { data, problem } = response;
119
+ if (problem) {
120
+ if (cache) {
121
+ return (
122
+ (await axiosCache(URL, 500)) || (await parseErrorResponse(response))
123
+ );
124
+ }
125
+ return await parseErrorResponse(response);
126
+ }
105
127
  if (response.status === 200) {
106
128
  if (cache) {
107
129
  await storeData(`@CACHE_REQUEST_${URL}`, JSON.stringify(data));
@@ -121,18 +143,23 @@ export async function axiosGet(URL, config = {}, cache = false) {
121
143
  async function axiosCall(method, ...args) {
122
144
  let response;
123
145
  try {
124
- response = await axios[method](...args);
146
+ response = await api[method](...args);
125
147
  } catch (error) {
126
148
  return await parseErrorResponse(error);
127
149
  }
128
150
 
129
- const { data } = response;
151
+ const { data, problem } = response;
152
+ if (problem) {
153
+ return await parseErrorResponse(response);
154
+ }
155
+
130
156
  if (response.status >= 200 && response.status < 300) {
131
157
  return {
132
158
  success: true,
133
159
  data,
134
160
  };
135
161
  }
162
+ await parseErrorResponse(response);
136
163
 
137
164
  return {
138
165
  success: false,
@@ -186,3 +213,5 @@ export function createFormData(data, list_file_field) {
186
213
 
187
214
  return formData;
188
215
  }
216
+
217
+ export default api;
@@ -1,24 +1,6 @@
1
1
  import t from '../../hooks/Common/useTranslations';
2
2
  import moment from 'moment';
3
3
 
4
- export const transformDatetime = (data = {}, listFieldName = []) => {
5
- listFieldName.forEach((name) => {
6
- const value = data[name];
7
- const isArray = Array.isArray(value);
8
-
9
- if (!data.hasOwnProperty(name)) {
10
- return;
11
- }
12
-
13
- if (isArray) {
14
- data[name] = value.map((item) => (item ? moment(item) : item));
15
- return;
16
- }
17
-
18
- data[name] = value ? moment(value) : value;
19
- });
20
- };
21
-
22
4
  export const timeDifference = (current, previous, symbol = false) => {
23
5
  let msPerMinute = 60 * 1000;
24
6
  let msPerHour = msPerMinute * 60;
@@ -985,5 +985,17 @@
985
985
  "you_need_to_enter_password": "You need to enter password to perform this action",
986
986
  "note": "Note",
987
987
  "back": "Back",
988
- "This {name} was removed!" : "This {name} was removed!"
988
+ "invaild_data": "Invaild data",
989
+ "This {name} was removed!" : "This {name} was removed!",
990
+ "camera_request_permission": "Camera request permission",
991
+ "camera_request_permission_des": "To use camera, please unlock camera permission",
992
+ "location_require_message": "EoH needs your location permission to get current location.",
993
+ "turn_on_location_service": "Turn on location service for your phone",
994
+ "turn_on_location_service_des": "To continue, let your device turn on location by turning on location service in Settings",
995
+ "detected": "Detected",
996
+ "not_detected": "Not detected",
997
+ "activated": "Activated",
998
+ "text_unit_add_to_favorites_no_devices": "You don't have any devices or all your devices was added to your favorites",
999
+ "not_found": "Not found",
1000
+ "not_activated": "Not activated"
989
1001
  }
@@ -985,5 +985,18 @@
985
985
  "maxmium_contacts": "Địa chỉ liên hệ tối đa",
986
986
  "note": "Lưu ý ",
987
987
  "back": "Quay lại",
988
- "This {name} was removed!" : "{Name} này đã bị xóa!"
988
+ "invaild_data": "Dữ liệu không hợp lệ",
989
+ "This {name} was removed!" : "{Name} này đã bị xóa!",
990
+ "location_perm_denied": "Ứng dụng không cho phép truy cập vị trí.",
991
+ "camera_request_permission": "Quyền yêu cầu máy ảnh",
992
+ "camera_request_permission_des": "Để sử dụng máy ảnh, vui lòng mở khóa quyền đối với máy ảnh",
993
+ "location_require_message": "Eoh cần quyền truy cập vị trí của bạn để lấy vị trí hiện tại.",
994
+ "turn_on_location_service": "Bật dịch vụ vị trí cho điện thoại của bạn",
995
+ "turn_on_location_service_des": "Để tiếp tục, bật dịch vụ vị trí cho điện thoại của bạn trong Cài Đặt",
996
+ "detected": "Phát hiện",
997
+ "not_detected": "Không phát hiện",
998
+ "activated": "Được kích hoạt",
999
+ "text_unit_add_to_favorites_no_devices": "Bạn không có thiết bị nào hoặc tất cả thiết bị của bạn đã được thêm vào yêu thích",
1000
+ "not_found": "Không tìm thấy",
1001
+ "not_activated": "Không kích hoạt"
989
1002
  }
@@ -0,0 +1,67 @@
1
+ /* eslint-disable promise/prefer-await-to-then */
2
+ /* eslint-disable promise/prefer-await-to-callbacks */
3
+
4
+ import {
5
+ check,
6
+ openSettings,
7
+ PERMISSIONS,
8
+ request,
9
+ RESULTS,
10
+ } from 'react-native-permissions';
11
+ import AlertAsync from 'react-native-alert-async';
12
+ import t from '../../hooks/Common/useTranslations';
13
+ import { Platform } from 'react-native';
14
+
15
+ const isAndroid = Platform.OS === 'android';
16
+
17
+ export const OpenSetting = async (alertTitle, alertMessage) => {
18
+ await AlertAsync(alertTitle, alertMessage, [
19
+ {
20
+ text: t('cancel'),
21
+ onPress: () => {},
22
+ style: 'cancel',
23
+ },
24
+ {
25
+ text: t('ok'),
26
+ onPress: () => {
27
+ openSettings().then();
28
+ },
29
+ },
30
+ ]);
31
+ };
32
+
33
+ export const permitPermissionFunction = (keyPermission, callback) => {
34
+ if (keyPermission) {
35
+ check(keyPermission).then((result) => {
36
+ switch (result) {
37
+ case RESULTS.DENIED:
38
+ case RESULTS.LIMITED:
39
+ request(keyPermission).then((res) => callback(res));
40
+ break;
41
+ case RESULTS.BLOCKED:
42
+ case RESULTS.GRANTED:
43
+ callback(result);
44
+ break;
45
+ default:
46
+ break;
47
+ }
48
+ });
49
+ }
50
+ };
51
+
52
+ export const keyPermission = {
53
+ SMS_RECEIVE: PERMISSIONS.ANDROID.RECEIVE_SMS,
54
+ LOCATION: isAndroid
55
+ ? PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION
56
+ : PERMISSIONS.IOS.LOCATION_WHEN_IN_USE,
57
+ CAMERA: isAndroid ? PERMISSIONS.ANDROID.CAMERA : PERMISSIONS.IOS.CAMERA,
58
+ SELECT_PHOTO: isAndroid
59
+ ? PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE
60
+ : PERMISSIONS.IOS.PHOTO_LIBRARY,
61
+ };
62
+
63
+ export const GEOLOCATION_ERROR = {
64
+ PERMISSION_DENIED: 1,
65
+ POSITION_UNAVAILABLE: 2,
66
+ TIMEOUT: 3,
67
+ };
@@ -136,6 +136,7 @@ const Routes = {
136
136
  SmartAccount: 'SmartAccount',
137
137
  SmartHomeDashboard: 'SmartHomeDashboard',
138
138
  SetupGeneratePasscode: 'SetupGeneratePasscode',
139
+ SideMenuDetail: 'SideMenuDetail',
139
140
  SelectDeviceType: 'SelectDeviceType',
140
141
  SelectBrand: 'SelectBrand',
141
142
  GroupButtonByType: 'GroupButtonByType',
@@ -145,6 +146,7 @@ const Routes = {
145
146
  ItemPasscode: 'ItemPasscode',
146
147
  UnitMemberInformation: 'UnitMemberInformation',
147
148
  EnterPassword: 'EnterPassword',
149
+ SelectDevices: 'SelectDevices',
148
150
  };
149
151
 
150
152
  export default Routes;
@@ -0,0 +1,30 @@
1
+ import { Platform } from 'react-native';
2
+ import RNAndroidLocationEnabler from 'react-native-android-location-enabler';
3
+ import AlertAsync from 'react-native-alert-async';
4
+ import t from '../../hooks/Common/useTranslations';
5
+
6
+ export const openPromptEnableLocation = async () => {
7
+ if (Platform.OS === 'android') {
8
+ try {
9
+ await RNAndroidLocationEnabler.promptForEnableLocationIfNeeded({
10
+ interval: 10000,
11
+ fastInterval: 5000,
12
+ });
13
+ return true;
14
+ } catch (err) {
15
+ return false;
16
+ }
17
+ } else {
18
+ await AlertAsync(
19
+ t('turn_on_location_service'),
20
+ t('turn_on_location_service_des'),
21
+ [
22
+ {
23
+ text: t('ok'),
24
+ onPress: () => {},
25
+ },
26
+ ]
27
+ );
28
+ return false;
29
+ }
30
+ };