@eohjsc/react-native-smart-city 0.2.20 → 0.2.26

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 (340) hide show
  1. package/README.md +1 -1
  2. package/assets/images/Add.svg +5 -0
  3. package/assets/images/AddLocationMaps/Point.svg +3 -0
  4. package/assets/images/CheckCircle.svg +4 -0
  5. package/assets/images/Close.svg +3 -0
  6. package/assets/images/HowToStart.svg +14 -0
  7. package/assets/images/OneTap.svg +14 -0
  8. package/assets/images/OneTap@1x.svg +14 -0
  9. package/assets/images/Rearrange.svg +3 -0
  10. package/assets/images/Schedule.svg +39 -0
  11. package/assets/images/WeatherChange.svg +49 -0
  12. package/package.json +12 -2
  13. package/src/Images/Common/ActiveButton.png +0 -0
  14. package/src/Images/Common/ActiveButton@2x.png +0 -0
  15. package/src/Images/Common/ActiveButton@3x.png +0 -0
  16. package/src/Images/Common/arrow-back.png +0 -0
  17. package/src/Images/Common/checked@2x.png +0 -0
  18. package/src/Images/Common/checked@3x.png +0 -0
  19. package/src/Images/Common/file.png +0 -0
  20. package/src/Images/Common/fullscreen.png +0 -0
  21. package/src/Images/Common/refresh.png +0 -0
  22. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +1 -1
  23. package/src/commons/ActionGroup/OnOffTemplate/index.js +4 -4
  24. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +7 -4
  25. package/src/commons/ActionGroup/StatesGridActionTemplate.js +12 -3
  26. package/src/commons/ActionGroup/ThreeButtonTemplate.js +13 -6
  27. package/src/commons/ActionGroup/ThreeButtonTemplateStyle.js +1 -1
  28. package/src/commons/ActionGroup/TimerActionTemplate.js +158 -33
  29. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +8 -13
  30. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +3 -3
  31. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +26 -45
  32. package/src/commons/ActionGroup/__test__/ThreeButtonTemplate.test.js +11 -5
  33. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +14 -8
  34. package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +17 -23
  35. package/src/commons/ActionGroup/__test__/__snapshots__/ThreeButtonTemplate.test.js.snap +241 -223
  36. package/src/commons/ActionGroup/__test__/index.test.js +39 -107
  37. package/src/commons/ActionGroup/hooks/useDropdownAction.js +2 -1
  38. package/src/commons/ActionTemplate/ActionTemplateStyles.js +14 -0
  39. package/src/commons/ActionTemplate/OnOffButtonAction.js +40 -0
  40. package/src/commons/ActionTemplate/OnOffButtonActionStyles.js +11 -0
  41. package/src/commons/ActionTemplate/OneButtonAction.js +26 -0
  42. package/src/commons/ActionTemplate/OneButtonActionStyles.js +11 -0
  43. package/src/commons/ActionTemplate/ThreeButtonAction.js +55 -0
  44. package/src/commons/ActionTemplate/ThreeButtonActionStyles.js +11 -0
  45. package/src/commons/ActionTemplate/__test__/OnOffButtonAction.test.js +34 -0
  46. package/src/commons/ActionTemplate/__test__/OneButtonAction.test.js +33 -0
  47. package/src/commons/ActionTemplate/__test__/ThreeButtonAction.test.js +35 -0
  48. package/src/commons/ActionTemplate/__test__/index.test.js +71 -0
  49. package/src/commons/ActionTemplate/index.js +69 -0
  50. package/src/commons/Automate/ItemAddNewScriptAction.js +30 -0
  51. package/src/commons/Automate/ItemAddNewScriptActionStyles.js +38 -0
  52. package/src/commons/Automate/ItemAutomate.js +33 -0
  53. package/src/commons/Automate/ItemAutomateStyles.js +33 -0
  54. package/src/commons/Automate/ItemScriptAction.js +45 -0
  55. package/src/commons/Automate/ItemScriptActionStyles.js +42 -0
  56. package/src/commons/BottomScrollPicker/index.js +58 -0
  57. package/src/commons/BottomScrollPicker/styles.js +13 -0
  58. package/src/commons/BottomSheet/index.js +36 -0
  59. package/src/commons/BottomSheet/styles.js +37 -0
  60. package/src/commons/Button/index.js +6 -1
  61. package/src/commons/CameraDevice/index.js +2 -1
  62. package/src/commons/ChartLoading/__test__/ChartLoading.test.js +9 -7
  63. package/src/commons/ChartLoading/index.js +2 -1
  64. package/src/commons/DateTimeRangeChange/index.js +2 -1
  65. package/src/commons/Device/ConnectedViewHeader.js +3 -1
  66. package/src/commons/Device/DeviceAlertStatus.js +5 -2
  67. package/src/commons/Device/DisconnectedView.js +34 -26
  68. package/src/commons/Device/Emergency/EmergencyButton.js +2 -1
  69. package/src/commons/Device/Emergency/EmergencyDetail.js +2 -1
  70. package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +14 -6
  71. package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +10 -2
  72. package/src/commons/Device/FlatListItems.js +3 -2
  73. package/src/commons/Device/FooterInfo.js +2 -1
  74. package/src/commons/Device/HistoryChart.js +2 -1
  75. package/src/commons/Device/ItemAddNew/index.js +6 -1
  76. package/src/commons/Device/SensorConnectedStatus.js +2 -1
  77. package/src/commons/Device/WindDirection/Compass/Compass.test.js +19 -11
  78. package/src/commons/Device/WindDirection/Compass/index.js +1 -1
  79. package/src/commons/Device/WindSpeed/LinearChart/__test__/LinearChart.test.js +9 -3
  80. package/src/commons/Device/WindSpeed/LinearChart/__test__/__snapshots__/LinearChart.test.js.snap +0 -81
  81. package/src/commons/Device/WindSpeed/LinearChart/index.js +2 -1
  82. package/src/commons/Device/__test__/ConnectedViewHeader.test.js +16 -8
  83. package/src/commons/Device/__test__/DeviceAlertStatus.test.js +13 -5
  84. package/src/commons/Device/__test__/DisconnectedView.test.js +13 -5
  85. package/src/commons/Device/__test__/FlatListItems.test.js +9 -1
  86. package/src/commons/Device/__test__/FooterInfo.test.js +13 -4
  87. package/src/commons/Device/__test__/SensorConnectedStatus.test.js +9 -1
  88. package/src/commons/Device/__test__/__snapshots__/DisconnectedView.test.js.snap +20 -20
  89. package/src/commons/DisplayChecking/__test__/DisplayChecking.test.js +28 -0
  90. package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -1
  91. package/src/commons/EmergencyButton/AlertSent.js +3 -2
  92. package/src/commons/Explore/CityItem/index.js +2 -1
  93. package/src/commons/Explore/HeaderExplore/index.js +2 -1
  94. package/src/commons/Explore/HeaderLabel/index.js +2 -1
  95. package/src/commons/Explore/SearchBox/__test__/SearchBox.test.js +9 -2
  96. package/src/commons/Explore/SearchBox/index.js +2 -1
  97. package/src/commons/Explore/__test__/CityItem.test.js +13 -15
  98. package/src/commons/Explore/__test__/HeaderLabel.test.js +15 -9
  99. package/src/commons/Header/HeaderCustom.js +17 -1
  100. package/src/commons/Header/Styles/HeaderCustomStyles.js +2 -2
  101. package/src/commons/Header/__test__/HeaderCT.test.js +12 -4
  102. package/src/commons/HeaderAni/index.js +6 -3
  103. package/src/commons/IconComponent/index.js +18 -3
  104. package/src/commons/ImagePicker/__test__/ImagePicker.test.js +19 -13
  105. package/src/commons/ImagePicker/index.js +3 -1
  106. package/src/commons/MediaPlayer/index.js +2 -1
  107. package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +14 -8
  108. package/src/commons/MediaPlayerDetail/index.js +4 -1
  109. package/src/commons/MenuActionAddnew/__test__/MenuActionAddNew.test.js +11 -20
  110. package/src/commons/MenuActionAddnew/index.js +2 -1
  111. package/src/commons/Modal/ModalBottom.js +51 -0
  112. package/src/commons/Modal/ModalFullVideo.js +2 -1
  113. package/src/commons/Modal/Styles/ModalBottomStyles.js +35 -0
  114. package/src/commons/Modal/index.js +2 -1
  115. package/src/commons/NavBar/index.js +2 -2
  116. package/src/commons/SelectActionCard/SelectActionStyles.js +16 -0
  117. package/src/commons/SelectActionCard/index.js +30 -0
  118. package/src/commons/Sharing/DevicePermissionsCheckbox.js +2 -1
  119. package/src/commons/Sharing/MemberList.js +3 -1
  120. package/src/commons/Sharing/RowMember.js +3 -2
  121. package/src/commons/Sharing/StationDevicePermissions.js +2 -1
  122. package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +15 -9
  123. package/src/commons/Sharing/__test__/MemberList.test.js +17 -25
  124. package/src/commons/Sharing/__test__/StationDevicePermission.test.js +17 -12
  125. package/src/commons/Sharing/__test__/WrapHeaderScrollable.test.js +0 -9
  126. package/src/commons/SubUnit/OneTap/ItemOneTap.js +97 -0
  127. package/src/commons/SubUnit/OneTap/ItemOneTapStyles.js +41 -0
  128. package/src/commons/SubUnit/OneTap/OneTapStyles.js +36 -0
  129. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +149 -0
  130. package/src/commons/SubUnit/OneTap/index.js +39 -0
  131. package/src/commons/SubUnit/ShortDetail.js +11 -6
  132. package/src/commons/SubUnit/__test__/ShortDetail.test.js +14 -6
  133. package/src/commons/Today/__test__/Today.test.js +9 -1
  134. package/src/commons/Today/__test__/__snapshots__/Today.test.js.snap +1 -1
  135. package/src/commons/Today/index.js +2 -1
  136. package/src/commons/Unit/SharedUnit.js +2 -1
  137. package/src/commons/UnitSummary/AirQuality/SegmentedRoundDisplay/index.js +1 -2
  138. package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +16 -17
  139. package/src/commons/UnitSummary/AirQuality/index.js +5 -120
  140. package/src/commons/UnitSummary/AirQuality/styles.js +112 -0
  141. package/src/commons/UnitSummary/TotalPowerConsumption/index.js +2 -1
  142. package/src/commons/UnitSummary/__test__/TotalPowerConsumption.test.js +15 -9
  143. package/src/commons/WheelDateTimePicker/Picker.js +57 -0
  144. package/src/commons/WheelDateTimePicker/index.js +160 -0
  145. package/src/commons/WheelDateTimePicker/styles.js +21 -0
  146. package/src/configs/API.js +25 -0
  147. package/src/configs/Colors.js +1 -0
  148. package/src/configs/Constants.js +46 -0
  149. package/src/configs/Images.js +1 -0
  150. package/src/configs/SCConfig.js +7 -0
  151. package/src/context/SCContext.tsx +7 -37
  152. package/src/context/actionType.ts +11 -0
  153. package/src/context/mockStore.ts +49 -0
  154. package/src/context/reducer.ts +23 -0
  155. package/src/hooks/Common/__test__/useTranslations.test.js +23 -0
  156. package/src/hooks/Common/index.js +2 -0
  157. package/src/hooks/Common/useGetIdUser.js +9 -0
  158. package/src/hooks/Common/useTranslations.ts +34 -0
  159. package/src/iot/Monitor.js +2 -1
  160. package/src/iot/RemoteControl/Bluetooth.js +2 -6
  161. package/src/iot/RemoteControl/GoogleHome.js +1 -1
  162. package/src/iot/RemoteControl/Internet.js +1 -1
  163. package/src/iot/RemoteControl/LG.js +57 -15
  164. package/src/iot/RemoteControl/__test__/Bluetooth.test.js +3 -5
  165. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +3 -3
  166. package/src/iot/RemoteControl/__test__/Internet.test.js +1 -8
  167. package/src/iot/RemoteControl/__test__/LgThinq.test.js +7 -10
  168. package/src/iot/RemoteControl/index.js +1 -1
  169. package/src/iot/states.js +1 -0
  170. package/src/navigations/SharedStack.js +2 -1
  171. package/src/navigations/UnitStack.js +62 -1
  172. package/src/screens/AQIGuide/__test__/AQIGuide.test.js +9 -1
  173. package/src/screens/AQIGuide/index.js +2 -2
  174. package/src/screens/ActivityLog/__test__/index.test.js +14 -39
  175. package/src/screens/ActivityLog/index.js +2 -1
  176. package/src/screens/AddCommon/SelectSubUnit.js +5 -4
  177. package/src/screens/AddCommon/SelectUnit.js +3 -2
  178. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +61 -0
  179. package/src/screens/AddCommon/__test__/SelectUnit.test.js +18 -10
  180. package/src/screens/AddLocationMaps/index.js +2 -1
  181. package/src/screens/AddNewAction/Device/DeviceStyles.js +43 -0
  182. package/src/screens/AddNewAction/Device/__test__/index.test.js +42 -0
  183. package/src/screens/AddNewAction/Device/index.js +33 -0
  184. package/src/screens/AddNewAction/SelectAction.js +152 -0
  185. package/src/screens/AddNewAction/SelectDevice.js +120 -0
  186. package/src/screens/AddNewAction/Styles/SelectActionStyles.js +24 -0
  187. package/src/screens/AddNewAction/Styles/SelectDeviceStyles.js +36 -0
  188. package/src/screens/AddNewAction/__test__/SelectAction.test.js +172 -0
  189. package/src/screens/AddNewAction/__test__/SelectDevice.test.js +191 -0
  190. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +55 -0
  191. package/src/screens/AddNewAutoSmart/index.js +85 -0
  192. package/src/screens/AddNewAutoSmart/styles/AddNewAutoSmartStyles.js +36 -0
  193. package/src/screens/AddNewDevice/ConnectDevices.js +2 -1
  194. package/src/screens/AddNewDevice/ConnectingDevices.js +2 -1
  195. package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +29 -13
  196. package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +19 -7
  197. package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +16 -6
  198. package/src/screens/AddNewDevice/hooks/useStateAlertRename.js +2 -1
  199. package/src/screens/AddNewDevice/index.js +2 -1
  200. package/src/screens/AddNewGateway/ConnectedGateway.js +2 -1
  201. package/src/screens/AddNewGateway/ConnectingGateway.js +99 -24
  202. package/src/screens/AddNewGateway/ConnectingGatewayStyles.js +92 -0
  203. package/src/screens/AddNewGateway/SetupGatewayWifi.js +3 -2
  204. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +35 -72
  205. package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +14 -4
  206. package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +20 -10
  207. package/src/screens/AddNewGateway/hooks/useStateAlertRename.js +2 -1
  208. package/src/screens/AddNewGateway/index.js +2 -1
  209. package/src/screens/AddNewOneTap/AddNewOneTapStyles.js +43 -0
  210. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +129 -0
  211. package/src/screens/AddNewOneTap/index.js +80 -0
  212. package/src/screens/AddNewScriptAction/AddNewScriptActionStyles.js +28 -0
  213. package/src/screens/AddNewScriptAction/index.js +100 -0
  214. package/src/screens/AllCamera/index.js +2 -1
  215. package/src/screens/Device/HeaderDevice/styles.js +2 -2
  216. package/src/screens/Device/__test__/detail.test.js +26 -18
  217. package/src/screens/Device/detail.js +56 -28
  218. package/src/screens/Device/hooks/useCountUp.js +4 -0
  219. package/src/screens/Device/hooks/useEmergencyButton.js +3 -2
  220. package/src/screens/Device/styles.js +5 -1
  221. package/src/screens/DeviceInfo/__test__/index.test.js +12 -3
  222. package/src/screens/DeviceInfo/index.js +2 -1
  223. package/src/screens/EditActionsList/Styles/indexStyles.js +84 -0
  224. package/src/screens/EditActionsList/index.js +186 -0
  225. package/src/screens/EmergencyContacts/EmergencyContactsAddNew.js +3 -2
  226. package/src/screens/EmergencyContacts/EmergencyContactsList.js +9 -2
  227. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +2 -1
  228. package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +15 -18
  229. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +19 -23
  230. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +10 -25
  231. package/src/screens/EmergencyContacts/hook.js +3 -2
  232. package/src/screens/Explore/index.js +3 -2
  233. package/src/screens/GuestInfo/components/AccessScheduleItem.js +27 -0
  234. package/src/screens/GuestInfo/components/AccessScheduleSheet.js +193 -0
  235. package/src/screens/GuestInfo/components/HeaderGuestInfo.js +31 -0
  236. package/src/screens/GuestInfo/components/RecurringDetail.js +99 -0
  237. package/src/screens/GuestInfo/components/RowGuestInfo.js +31 -0
  238. package/src/screens/GuestInfo/components/TemporaryDetail.js +46 -0
  239. package/src/screens/GuestInfo/constant.js +59 -0
  240. package/src/screens/GuestInfo/index.js +151 -0
  241. package/src/screens/GuestInfo/styles/AccessScheduleDetailStyles.js +31 -0
  242. package/src/screens/GuestInfo/styles/AccessScheduleItemStyles.js +22 -0
  243. package/src/screens/GuestInfo/styles/HeaderGuestInfoStyles.js +31 -0
  244. package/src/screens/GuestInfo/styles/indexStyles.js +38 -0
  245. package/src/screens/ManageAccess/__test__/ManageAccess.test.js +13 -1
  246. package/src/screens/ManageAccess/hooks/index.js +4 -0
  247. package/src/screens/ManageAccess/index.js +49 -20
  248. package/src/screens/ManageAccess/styles/ManageAccessStyles.js +3 -0
  249. package/src/screens/PlayBackCamera/index.js +9 -5
  250. package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +2 -11
  251. package/src/screens/ScanChipQR/components/QRScan/index.js +2 -1
  252. package/src/screens/ScriptDetail/Styles/indexStyles.js +143 -0
  253. package/src/screens/ScriptDetail/index.js +243 -0
  254. package/src/screens/SharedUnit/TabHeader.js +2 -1
  255. package/src/screens/SharedUnit/__test__/TabHeader.test.js +40 -0
  256. package/src/screens/SharedUnit/index.js +3 -2
  257. package/src/screens/Sharing/MemberList.js +2 -1
  258. package/src/screens/Sharing/SelectPermission.js +2 -1
  259. package/src/screens/Sharing/SelectUser.js +3 -2
  260. package/src/screens/Sharing/__test__/MemberList.test.js +17 -13
  261. package/src/screens/Sharing/__test__/SelectPermission.test.js +16 -8
  262. package/src/screens/Sharing/__test__/SelectUser.test.js +33 -15
  263. package/src/screens/Sharing/hooks/index.js +22 -17
  264. package/src/screens/SubUnit/AddSubUnit.js +3 -2
  265. package/src/screens/SubUnit/Detail.js +5 -4
  266. package/src/screens/SubUnit/ManageSubUnit.js +10 -9
  267. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +17 -11
  268. package/src/screens/SubUnit/__test__/Detail.test.js +11 -31
  269. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +42 -31
  270. package/src/screens/SyncLGDevice/AddLGDevice.js +3 -2
  271. package/src/screens/TDSGuide/__test__/TDSGuide.test.js +9 -1
  272. package/src/screens/TDSGuide/index.js +2 -1
  273. package/src/screens/UVIndexGuide/__test__/UVIndexGuide.test.js +9 -1
  274. package/src/screens/UVIndexGuide/index.js +2 -1
  275. package/src/screens/Unit/AddMenu.js +3 -2
  276. package/src/screens/Unit/Detail.js +65 -20
  277. package/src/screens/Unit/ManageUnit/index.js +4 -3
  278. package/src/screens/Unit/ManageUnit.js +5 -4
  279. package/src/screens/Unit/MoreMenu.js +3 -2
  280. package/src/screens/Unit/SelectLocation.js +8 -2
  281. package/src/screens/Unit/SelectLocationStyles.js +11 -0
  282. package/src/screens/Unit/__test__/AddMenu.test.js +15 -15
  283. package/src/screens/Unit/__test__/CheckSendEmail.test.js +19 -10
  284. package/src/screens/Unit/__test__/Detail.test.js +92 -33
  285. package/src/screens/Unit/__test__/ManageUnit.test.js +16 -23
  286. package/src/screens/Unit/components/Header/index.js +2 -1
  287. package/src/screens/Unit/components/ListMyAllUnit/index.js +2 -1
  288. package/src/screens/Unit/components/MyUnit/index.js +2 -1
  289. package/src/screens/Unit/components/SearchLocation/index.js +2 -1
  290. package/src/screens/Unit/components/SharedUnit/index.js +2 -1
  291. package/src/screens/Unit/components/__test__/SharedUnit.test.js +11 -2
  292. package/src/screens/UnitSummary/__test__/index.test.js +12 -4
  293. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +13 -3
  294. package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +2 -1
  295. package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +16 -12
  296. package/src/screens/UnitSummary/components/PowerConsumption/index.js +2 -1
  297. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -2
  298. package/src/screens/UnitSummary/components/Temperature/index.js +2 -1
  299. package/src/screens/UnitSummary/components/TotalPowerConsumption/index.js +2 -1
  300. package/src/screens/UnitSummary/components/UvIndex/__test__/__snapshots__/index.test.js.snap +37 -37
  301. package/src/screens/UnitSummary/components/UvIndex/__test__/index.test.js +14 -6
  302. package/src/screens/UnitSummary/components/UvIndex/index.js +2 -1
  303. package/src/screens/UnitSummary/components/WaterQuality/__test__/index.test.js +11 -5
  304. package/src/screens/UnitSummary/components/WaterQuality/index.js +2 -1
  305. package/src/screens/UnitSummary/components/__test__/TotalPowerConsumption.test.js +13 -7
  306. package/src/screens/UnitSummary/index.js +2 -1
  307. package/src/screens/WaterQualityGuide/__test__/index.test.js +12 -12
  308. package/src/screens/WaterQualityGuide/index.js +2 -1
  309. package/src/utils/Converter/array.js +4 -0
  310. package/src/utils/Converter/time.js +29 -4
  311. package/src/utils/I18n/index.ts +6 -0
  312. package/src/utils/I18n/translations/en.json +48 -2
  313. package/src/utils/I18n/translations/vi.json +45 -1
  314. package/src/utils/I18n/translations.ts +45 -0
  315. package/src/utils/Route/index.js +8 -0
  316. package/src/commons/ChartLoading/__test__/__snapshots__/ChartLoading.test.js.snap +0 -66
  317. package/src/commons/Device/HistoryChart/__test__/HistoryChart.test.js +0 -57
  318. package/src/commons/Device/HistoryChart/__test__/__snapshots__/HistoryChart.test.js.snap +0 -593
  319. package/src/commons/Explore/SearchBox/__test__/__snapshots__/SearchBox.test.js.snap +0 -59
  320. package/src/commons/Explore/__test__/HeaderExplore.test.js +0 -21
  321. package/src/commons/Header/__test__/Header.test.js +0 -24
  322. package/src/commons/MenuActionAddnew/__test__/__snapshots__/MenuActionAddNew.test.js.snap +0 -788
  323. package/src/commons/Sharing/__test__/__snapshots__/WrapHeaderScrollable.test.js.snap +0 -174
  324. package/src/commons/UnitSummary/AirQuality/__test__/__snapshots__/index.test.js.snap +0 -26679
  325. package/src/iot/RemoteControl/__test__/index.test.js +0 -101
  326. package/src/iot/__test__/Monitor.test.js +0 -119
  327. package/src/screens/EmergencyContacts/__test__/__snapshots__/EmergencyContactAddNew.test.js.snap +0 -1706
  328. package/src/screens/EmergencyContacts/__test__/__snapshots__/EmergencyContactList.test.js.snap +0 -4276
  329. package/src/screens/EmergencyContacts/__test__/__snapshots__/EmergencyContactsSelectContacts.test.js.snap +0 -2240
  330. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +0 -358
  331. package/src/screens/Unit/MyAllUnit/__test__/__snapshots__/index.test.js.snap +0 -1001
  332. package/src/screens/Unit/MyAllUnit/__test__/index.test.js +0 -48
  333. package/src/screens/Unit/components/MyAllUnit/__test__/__snapshots__/index.test.js.snap +0 -1001
  334. package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -48
  335. package/src/screens/Unit/components/__test__/MyUnit.test.js +0 -85
  336. package/src/screens/UnitSummary/components/WaterQuality/__test__/__snapshots__/index.test.js.snap +0 -1574
  337. package/src/screens/WaterQualityGuide/__test__/__snapshots__/index.test.js.snap +0 -3375
  338. package/src/utils/Converter/__test__/time.test.js +0 -126
  339. package/src/utils/I18n/index.js +0 -19
  340. package/src/utils/I18n/index.test.js +0 -7
@@ -24,6 +24,10 @@ const API = {
24
24
  SCConfig.apiRoot + `/property_manager/units/${id}/chip_scan/`,
25
25
  MANAGE_ACCESS: (id) =>
26
26
  SCConfig.apiRoot + `/property_manager/manage_access/${id}/`,
27
+ AUTOMATE: (id) =>
28
+ SCConfig.apiRoot + `/property_manager/units/${id}/automate/`,
29
+ DEVICE_CONTROL: (id) =>
30
+ SCConfig.apiRoot + `/property_manager/units/${id}/device_control/`,
27
31
  },
28
32
  SUB_UNIT: {
29
33
  REMOVE_SUB_UNIT: (unitId, id) =>
@@ -67,11 +71,32 @@ const API = {
67
71
  REMOVE_FROM_FAVOURITES: (unit_id, station_id, id) =>
68
72
  SCConfig.apiRoot +
69
73
  `/property_manager/${unit_id}/sub_units/${station_id}/devices/${id}/remove_from_favourites/`,
74
+ DISPLAY_ACTIONS: (id) =>
75
+ SCConfig.apiRoot + `/property_manager/sensors/${id}/display_actions/`,
76
+ },
77
+ SHARED_SENSOR: {
78
+ ACCESS: (id) =>
79
+ SCConfig.apiRoot + `/property_manager/shared_sensors/${id}/access/`,
70
80
  },
71
81
  CONFIG: {
72
82
  DISPLAY_HISTORY: () =>
73
83
  SCConfig.apiRoot + '/property_manager/configs/display_history/',
74
84
  },
85
+ AUTOMATE: {
86
+ ACTION_ONE_TAP: (id) =>
87
+ SCConfig.apiRoot + `/property_manager/automate/${id}/action_one_tap/`,
88
+ ONE_TAP_DETAIL: (id) =>
89
+ SCConfig.apiRoot + `/property_manager/automate/${id}/script/`,
90
+ ORDER_SCRIPT_ACTION: (id) =>
91
+ SCConfig.apiRoot +
92
+ `/property_manager/automate/${id}/order_script_action/`,
93
+ DELETE_SCRIPT_ACTION: (automateId, actionId) =>
94
+ SCConfig.apiRoot +
95
+ `/property_manager/automate/${automateId}/script_action/${actionId}/`,
96
+ ADD_SCRIPT_ACTION: (id) =>
97
+ SCConfig.apiRoot + `/property_manager/automate/${id}/add_script_action/`,
98
+ CREATE_AUTOMATE: () => SCConfig.apiRoot + '/property_manager/automate/',
99
+ },
75
100
  GOOGLE_HOME: {
76
101
  CHECK_SEND_EMAIL: () =>
77
102
  SCConfig.apiRoot + '/connection_manager/googlehome/check_send_email/',
@@ -129,4 +129,5 @@ export const Colors = {
129
129
  BlackTransparent6: 'rgba(0, 0, 0, 0.6)',
130
130
  BlackTransparent16: 'rgba(0, 0, 0, 0.16)',
131
131
  WhiteTransparent8: 'rgba(255, 255, 255, 0.8)',
132
+ BlueTransparent5: 'rgba(230, 247, 255, 0.5)',
132
133
  };
@@ -1,5 +1,8 @@
1
1
  import { Platform, Dimensions, StatusBar } from 'react-native';
2
2
  import { RFValue } from 'react-native-responsive-fontsize';
3
+ import OneTap from '../../assets/images/OneTap.svg';
4
+ import WeatherChange from '../../assets/images/WeatherChange.svg';
5
+ import Schedule from '../../assets/images/Schedule.svg';
3
6
 
4
7
  const X_WIDTH = 375;
5
8
  const X_HEIGHT = 812;
@@ -67,6 +70,10 @@ export const Constants = {
67
70
  DEEP_LINK,
68
71
  };
69
72
 
73
+ export const DEVICE_TYPE = {
74
+ LG_THINQ: 'LG_THINQ',
75
+ };
76
+
70
77
  export const SCANNING_STATUS = {
71
78
  BOOKING_ACTIVATED: 'booking_activated',
72
79
  WRONG_SPOT: 'wrong_spot',
@@ -76,6 +83,37 @@ export const SCANNING_STATUS = {
76
83
  SPOT_DOES_NOT_EXIST: 'spot_does_not_exist',
77
84
  };
78
85
 
86
+ export const SubUnitName = {
87
+ scenario: 'Kịch Bản',
88
+ };
89
+
90
+ export const AUTOMATE_TYPE = {
91
+ ONE_TAP: 'one_tap',
92
+ VALUE_CHANGE: 'value_change',
93
+ SCHEDULE: 'schedule',
94
+ };
95
+
96
+ export const AUTOMATES = {
97
+ one_tap: {
98
+ value: AUTOMATE_TYPE.ONE_TAP,
99
+ title: 'Launch One-Tap',
100
+ explanation: 'Do everything with just one button',
101
+ icon: OneTap,
102
+ },
103
+ value_change: {
104
+ value: AUTOMATE_TYPE.VALUE_CHANGE,
105
+ title: 'When weather change',
106
+ explanation: 'Short Explanation',
107
+ icon: WeatherChange,
108
+ },
109
+ schedule: {
110
+ value: AUTOMATE_TYPE.SCHEDULE,
111
+ title: 'Schedule',
112
+ explanation: 'Short Explanation',
113
+ icon: Schedule,
114
+ },
115
+ };
116
+
79
117
  export const TESTID = {
80
118
  // Dashboard
81
119
  DASHBOARD_TAB_HOME: 'DASHBOARD_TAB_HOME',
@@ -115,6 +153,7 @@ export const TESTID = {
115
153
  MY_UNIT_NO_UNIT: 'MY_UNIT_NO_UNIT',
116
154
 
117
155
  // sub unit
156
+ SUB_UNIT_FULL_CAMERA: 'SUB_UNIT_FULL_CAMERA',
118
157
  SUB_UNIT_CAMERA_VIEW: 'SUB_UNIT_CAMERA_VIEW',
119
158
  SUB_UNIT_BACKGROUND: 'SUB_UNIT_BACKGROUND',
120
159
  SUB_UNIT_GO_TO_DETAIL: 'SUB_UNIT_GO_TO_DETAIL',
@@ -216,6 +255,11 @@ export const TESTID = {
216
255
  ITEM_TEXT_INPUT: 'ITEM_TEXT_INPUT',
217
256
  ITEM_TEXT_ERROR: 'ITEM_TEXT_ERROR',
218
257
  SEARCH_BAR_INPUT: 'SEARCH_BAR_INPUT',
258
+ GO_DETAIL: 'GO_DETAIL',
259
+
260
+ // Automate
261
+ AUTOMATE_SCRIPT_ACTION: 'AUTOMATE_SCRIPT_ACTION',
262
+ NAME_YOUR_BUTTON: 'NAME_YOUR_BUTTON',
219
263
 
220
264
  // Parking input maunaly spot
221
265
  PARKING_SPOT_INFO_BUTTON: 'PARKING_SPOT_INFO_BUTTON',
@@ -259,6 +303,7 @@ export const TESTID = {
259
303
  SENSOR_DISPLAY_ITEM: 'SENSOR_DISPLAY_ITEM',
260
304
  ITEM_QUICK_ACTION_PRESS: 'ITEM_QUICK_ACTION_PRESS',
261
305
  TIME_COUNT_DOWN_TEXT: 'TIME_COUNT_DOWN_TEXT',
306
+ ACTION_ITEM: 'ACTION_ITEM',
262
307
 
263
308
  // DeviceInfo
264
309
  DEVICE_INFO_BATTERY: 'DEVICE_INFO_BATTERY',
@@ -389,6 +434,7 @@ export const TESTID = {
389
434
  MANAGE_UNIT: 'MANAGE_UNIT',
390
435
  MANAGE_UNIT_ALERT: 'MANAGE_UNIT_ALERT',
391
436
  SELECT_UNIT: 'SELECT_UNIT',
437
+ BUTTON_ADD_AUTO_SMART: 'BUTTON_ADD_AUTO_SMART',
392
438
  },
393
439
 
394
440
  TERM_AND_POLICY_TITLE: 'TERM_AND_POLICY_TITLE',
@@ -5,4 +5,5 @@ export default {
5
5
  arrowLeft: require('../Images/Common/arrow-back.png'),
6
6
  fullscreen: require('../Images/Common/fullscreen.png'),
7
7
  file: require('../Images/Common/file.png'),
8
+ activeButton: require('../Images/Common/ActiveButton.png'),
8
9
  };
@@ -90,6 +90,8 @@ const SCDefaultConfig = {
90
90
  LG_CLIENT_ID: '2b85aee334f046848341547894bb7c4e',
91
91
  LG_REDIRECT_URI_APP: 'app://eoh/sync-lg-device',
92
92
  LG_URL: 'https://qt-vn.m.lgaccount.com/emp/v2',
93
+ pusherAppKey: '9a591ae4a764acc08714',
94
+ pusherAppCluster: 'ap1',
93
95
  };
94
96
 
95
97
  export class SCConfig {
@@ -98,6 +100,8 @@ export class SCConfig {
98
100
  static LG_CLIENT_ID = SCDefaultConfig.LG_CLIENT_ID;
99
101
  static LG_REDIRECT_URI_APP = SCDefaultConfig.LG_REDIRECT_URI_APP;
100
102
  static LG_URL = SCDefaultConfig.LG_URL;
103
+ static pusherAppKey = SCDefaultConfig.pusherAppKey;
104
+ static pusherAppCluste = SCDefaultConfig.pusherAppCluster;
101
105
  }
102
106
 
103
107
  export const initSCConfig = (config) => {
@@ -109,4 +113,7 @@ export const initSCConfig = (config) => {
109
113
  SCConfig.LG_REDIRECT_URI_APP =
110
114
  config.LG_REDIRECT_URI_APP ?? SCDefaultConfig.LG_REDIRECT_URI_APP;
111
115
  SCConfig.LG_URL = config.LG_URL ?? SCDefaultConfig.LG_URL;
116
+ SCConfig.pusherAppKey = config.pusherAppKey ?? SCDefaultConfig.pusherAppKey;
117
+ SCConfig.pusherAppCluster =
118
+ config.pusherAppCluster ?? SCDefaultConfig.pusherAppCluster;
112
119
  };
@@ -1,10 +1,5 @@
1
1
  import React, { useContext, useReducer } from 'react';
2
- import { StyleSheet, View, Text } from 'react-native';
3
- import Toast from 'react-native-toast-message';
4
2
 
5
- import { Alert } from '../commons';
6
- import { Colors } from '../configs';
7
- import { setLanguage, updateTranslation } from '../utils/I18n';
8
3
  import {
9
4
  ActionDataMap,
10
5
  ActionType,
@@ -13,22 +8,13 @@ import {
13
8
  StatusBar,
14
9
  } from './actionType';
15
10
  import { initialState, Action, ContextData, reducer } from './reducer';
16
-
17
- const toastConfig = {
18
- // only for error for now
19
- error: (internalState) => (
20
- <View style={styles.toastContainer}>
21
- <Text style={styles.textWhite}>{internalState.text1}</Text>
22
- </View>
23
- ),
24
- };
11
+ import { setConfigGlobalState } from '../iot/states.js';
25
12
 
26
13
  type SCContextType = {
27
14
  stateData: ContextData;
28
15
  setAuth: (authData: AuthData) => void;
29
16
  setLocale: (language: Language) => void;
30
17
  setStatusBar: (statusBar: StatusBar) => void;
31
- updateLocale: (langTranslate: any) => void;
32
18
  setAction: <T extends ActionType>(
33
19
  action: T,
34
20
  payload?: ActionDataMap[T]
@@ -53,17 +39,13 @@ export const SCProvider = ({ children }) => {
53
39
  setAction('UPDATE_AUTH', authData);
54
40
  };
55
41
 
56
- const setLocale = (language: Language) => {
57
- setLanguage(language);
58
- setAction('UPDATE_LANGUAGE', language);
59
- };
60
-
61
42
  const setStatusBar = (statusBar: StatusBar) => {
62
43
  setAction('STORE_STATUS_BAR', statusBar);
63
44
  };
64
45
 
65
- const updateLocale = (langTranslate: any) => {
66
- updateTranslation(langTranslate);
46
+ const setLocale = (language: Language) => {
47
+ setConfigGlobalState('lang', language);
48
+ setAction('UPDATE_LANGUAGE', language);
67
49
  };
68
50
 
69
51
  const setAction = <T extends ActionType>(
@@ -76,17 +58,16 @@ export const SCProvider = ({ children }) => {
76
58
  const providerValue = {
77
59
  stateData,
78
60
  setAuth,
79
- setLocale,
80
61
  setAction,
62
+ setLocale,
81
63
  setStatusBar,
82
- updateLocale,
83
64
  };
84
65
 
85
66
  return (
86
67
  <SCContext.Provider value={providerValue}>
87
68
  {children}
88
- <Alert ref={(ref) => Alert.setRef(ref)} />
89
- <Toast config={toastConfig} ref={(ref) => Toast.setRef(ref)} />
69
+ {/* <Alert ref={(ref) => Alert.setRef(ref)} />
70
+ <Toast config={toastConfig} ref={(ref) => Toast.setRef(ref)} /> */}
90
71
  </SCContext.Provider>
91
72
  );
92
73
  };
@@ -97,14 +78,3 @@ export const useSCContextSelector = (
97
78
  const { stateData } = useContext(SCContext);
98
79
  return selector(stateData);
99
80
  };
100
-
101
- const styles = StyleSheet.create({
102
- toastContainer: {
103
- borderRadius: 5,
104
- padding: 10,
105
- backgroundColor: Colors.Black,
106
- },
107
- textWhite: {
108
- color: Colors.White,
109
- },
110
- });
@@ -3,6 +3,7 @@ export const Action = {
3
3
  UPDATE_LANGUAGE: 'UPDATE_LANGUAGE',
4
4
  STORE_STATUS_BAR: 'STORE_STATUS_BAR',
5
5
  LIST_DEVICE_TYPES: 'LIST_DEVICE_TYPES',
6
+ LIST_ACTION: 'LIST_ACTION',
6
7
  };
7
8
 
8
9
  export type AuthData = {
@@ -25,6 +26,15 @@ export type ListDevice = {
25
26
  sentEmail: boolean;
26
27
  };
27
28
 
29
+ export type ListAction = {
30
+ action: string;
31
+ unit_name: string;
32
+ action_name: string;
33
+ sensor_name: string;
34
+ sensor_icon_kit: string;
35
+ station_name: string;
36
+ }[];
37
+
28
38
  export type ActionType = keyof typeof Action;
29
39
 
30
40
  export type ActionDataMap = {
@@ -32,4 +42,5 @@ export type ActionDataMap = {
32
42
  UPDATE_LANGUAGE: Language;
33
43
  STORE_STATUS_BAR: StatusBar;
34
44
  LIST_DEVICE_TYPES: ListDevice;
45
+ LIST_ACTION: ListAction;
35
46
  };
@@ -0,0 +1,49 @@
1
+ import { ContextData } from './reducer';
2
+
3
+ export const mockDataStore: ContextData = {
4
+ auth: {
5
+ account: {
6
+ token: 'TOKEN',
7
+ user: {
8
+ avatar: null,
9
+ email: 'test@gmail.com',
10
+ id: 1,
11
+ is_using_social_avatar: false,
12
+ name: 'TEST',
13
+ org: 2,
14
+ phone_number: '012345678',
15
+ social_avatar_hash: '',
16
+ },
17
+ },
18
+ },
19
+ language: 'vi',
20
+ listDevice: {
21
+ sentEmail: false,
22
+ },
23
+ statusBar: {
24
+ backgroundColor: '',
25
+ barStyle: '',
26
+ },
27
+ };
28
+
29
+ export const mockSCStore = (data: ContextData): ContextData => {
30
+ return {
31
+ auth: {
32
+ account: {
33
+ ...mockDataStore.auth.account,
34
+ ...data.auth?.account,
35
+ },
36
+ },
37
+ language: data.language ? data.language : mockDataStore.language,
38
+ listDevice: {
39
+ ...mockDataStore.listDevice,
40
+ ...data.listDevice,
41
+ },
42
+ statusBar: {
43
+ backgroundColor:
44
+ data?.statusBar?.backgroundColor ||
45
+ mockDataStore?.statusBar?.backgroundColor,
46
+ barStyle: data?.statusBar?.barStyle || mockDataStore?.statusBar?.barStyle,
47
+ },
48
+ };
49
+ };
@@ -6,12 +6,15 @@ import {
6
6
  StatusBar,
7
7
  Action,
8
8
  ListDevice,
9
+ ListAction,
9
10
  } from './actionType';
10
11
 
11
12
  export type ContextData = {
12
13
  auth: AuthData;
13
14
  language: Language;
14
15
  listDevice: ListDevice;
16
+ listAction: ListAction;
17
+ statusBar: StatusBar;
15
18
  };
16
19
 
17
20
  export type Action = {
@@ -31,6 +34,7 @@ export const initialState = {
31
34
  language: 'en' as Language,
32
35
  statusBar: {} as StatusBar,
33
36
  listDevice: {} as ListDevice,
37
+ listAction: [] as ListAction,
34
38
  };
35
39
 
36
40
  export const reducer = (currentState: ContextData, action: Action) => {
@@ -41,6 +45,8 @@ export const reducer = (currentState: ContextData, action: Action) => {
41
45
  return { ...currentState, auth: payload };
42
46
  case Action.STORE_STATUS_BAR:
43
47
  return { ...currentState, statusBar: payload };
48
+ case Action.UPDATE_LANGUAGE:
49
+ return { ...currentState, language: payload };
44
50
  case Action.LIST_DEVICE_TYPES:
45
51
  if (currentState.listDevice) {
46
52
  currentState.listDevice[action.payload.chipId] = {
@@ -60,6 +66,23 @@ export const reducer = (currentState: ContextData, action: Action) => {
60
66
  };
61
67
  }
62
68
 
69
+ case Action.LIST_ACTION:
70
+ let newListAction = [...currentState.listAction];
71
+
72
+ if (Object.keys(payload).length === 0) {
73
+ newListAction = [];
74
+ } else {
75
+ const order = newListAction.length + 1;
76
+
77
+ const isHaveAction = newListAction.findIndex(
78
+ (item) => item.action === payload.action
79
+ );
80
+ if (isHaveAction < 0) {
81
+ newListAction.push({ ...payload, order });
82
+ }
83
+ }
84
+
85
+ return { ...currentState, listAction: newListAction };
63
86
  default:
64
87
  return currentState;
65
88
  }
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { renderHook } from '@testing-library/react-hooks';
3
+ import { SCProvider } from '../../../context';
4
+ import { mockSCStore } from '../../../context/mockStore';
5
+ import { useTranslations } from '../useTranslations';
6
+
7
+ const mockedSetAction = jest.fn();
8
+
9
+ const wrapper = ({ children }) => <SCProvider>{children}</SCProvider>;
10
+
11
+ const mockUseContext = jest.fn().mockImplementation(() => ({
12
+ stateData: mockSCStore({}),
13
+ setAction: mockedSetAction,
14
+ }));
15
+
16
+ React.useContext = mockUseContext;
17
+
18
+ describe('Test useTranslations', () => {
19
+ it('test useTranslations', () => {
20
+ // eslint-disable-next-line no-unused-vars
21
+ const { result } = renderHook(() => useTranslations(), { wrapper });
22
+ });
23
+ });
@@ -8,6 +8,7 @@ import useControllList from './useControllList';
8
8
  import { useBlockBackAndroid } from './useBlockBackAndroid';
9
9
  import { useIsOwnerOfUnit } from './useIsOwnerOfUnit';
10
10
  import { useStatusBar } from './useStatusBar';
11
+ import { useGetIdUser } from './useGetIdUser';
11
12
 
12
13
  export {
13
14
  useAndroidTranslucentStatusBar,
@@ -20,4 +21,5 @@ export {
20
21
  useBlockBackAndroid,
21
22
  useIsOwnerOfUnit,
22
23
  useStatusBar,
24
+ useGetIdUser,
23
25
  };
@@ -0,0 +1,9 @@
1
+ import { useSCContextSelector } from '../../context';
2
+
3
+ export const useGetIdUser = () => {
4
+ // eslint-disable-next-line react-hooks/rules-of-hooks
5
+ const idUser = useSCContextSelector(
6
+ (state) => state?.auth?.account?.user?.id
7
+ );
8
+ return idUser;
9
+ };
@@ -0,0 +1,34 @@
1
+ import {
2
+ getTranslate,
3
+ InterPolateString,
4
+ Language,
5
+ TranslationString,
6
+ } from '../../utils/I18n';
7
+ import { useCallback } from 'react';
8
+ import { useSCContextSelector } from '../../context';
9
+ import { getConfigGlobalState } from '../../iot/states.js';
10
+
11
+ export const useTranslations = () => {
12
+ const lang = useSCContextSelector((state) => state.language);
13
+
14
+ const language: Language = lang as Language;
15
+
16
+ const t = useCallback(
17
+ (translations: TranslationString, interpolateStr?: InterPolateString) =>
18
+ getTranslate(language, translations, interpolateStr),
19
+ [language]
20
+ );
21
+
22
+ return t;
23
+ };
24
+
25
+ const t = (
26
+ translations: TranslationString,
27
+ interpolateStr?: InterPolateString
28
+ ) => {
29
+ const lang = getConfigGlobalState('lang');
30
+ const language: Language = lang as Language;
31
+ return getTranslate(language, translations, interpolateStr);
32
+ };
33
+
34
+ export default t;
@@ -3,13 +3,14 @@ import { getConfigGlobalState, setConfigGlobalState } from './states';
3
3
  import _ from 'lodash';
4
4
  import Pusher from 'pusher-js/react-native';
5
5
  import { axiosPost } from '../utils/Apis/axios';
6
+ import { SCConfig } from '../configs';
6
7
 
7
8
  Pusher.logToConsole = true;
8
9
  let pusher = null;
9
10
 
10
11
  const getPusher = () => {
11
12
  if (!pusher) {
12
- pusher = new Pusher('8557fcc63959f564f1aa', {
13
+ pusher = new Pusher(SCConfig.pusherAppKey, {
13
14
  cluster: 'ap1',
14
15
  authorizer: function (channel, option) {
15
16
  return {
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable promise/prefer-await-to-then */
2
2
  /* eslint-disable promise/prefer-await-to-callbacks */
3
3
  import { BLE } from '../../configs';
4
- import { t } from 'i18n-js';
4
+ import t from '../../hooks/Common/useTranslations';
5
5
  import base64 from 'react-native-base64';
6
6
  import { BleManager } from 'react-native-ble-plx';
7
7
  import { ToastBottomHelper } from '../../utils/Utils';
@@ -68,11 +68,7 @@ const realScanBluetoothDevices = () => {
68
68
  const index = needToScanDevices.indexOf(name);
69
69
  needToScanDevices.splice(index, 1);
70
70
 
71
- ToastBottomHelper.success(
72
- t('Found bluetooth %{name} for remote control', {
73
- name,
74
- })
75
- );
71
+ ToastBottomHelper.success(t(`Found bluetooth ${name} for remote control`));
76
72
 
77
73
  bluetoothDevices[name] = device;
78
74
  if (!needToScanDevices.length) {
@@ -1,5 +1,5 @@
1
1
  import { Auth, createConnection, getStates } from 'home-assistant-js-websocket';
2
- import { t } from 'i18n-js';
2
+ import t from '../../hooks/Common/useTranslations';
3
3
  import { getConfigGlobalState, setConfigGlobalState } from '../states';
4
4
  import { ToastBottomHelper } from '../../utils/Utils';
5
5
  import { API } from '../../configs';
@@ -1,4 +1,4 @@
1
- import { t } from 'i18n-js';
1
+ import t from '../../hooks/Common/useTranslations';
2
2
 
3
3
  import { ToastBottomHelper } from '../../utils/Utils';
4
4
  import { axiosPost } from '../../utils/Apis/axios';
@@ -4,12 +4,19 @@ import { getConfigGlobalState, setConfigGlobalState } from '../states';
4
4
  import { sendCommandOverInternet } from './Internet';
5
5
 
6
6
  let deviceMaps = {};
7
- let propertyListMaps = {
7
+ const propertyListMaps = {
8
8
  temperature: 'targetTemperature',
9
9
  doorStatus: 'doorState',
10
10
  };
11
+ const propertyTimer = [
12
+ 'absoluteHourToStart',
13
+ 'absoluteMinuteToStart',
14
+ 'absoluteHourToStop',
15
+ 'absoluteMinuteToStop',
16
+ ];
11
17
 
12
18
  function updateConfigValues(device, configValues, name, value) {
19
+ // eslint-disable-next-line no-prototype-builtins
13
20
  if (device.hasOwnProperty(name)) {
14
21
  const [configId] = device[name];
15
22
  configValues[configId] = value;
@@ -17,16 +24,9 @@ function updateConfigValues(device, configValues, name, value) {
17
24
  return configValues;
18
25
  }
19
26
 
20
- export async function updateStateByLgThinq(device_id, data) {
21
- const device = deviceMaps[device_id];
22
-
23
- if (!device) {
24
- return;
25
- }
26
-
27
- let configValues = getConfigGlobalState('configValues');
28
- // eslint-disable-next-line no-unused-vars
27
+ function parseData(configValues, device, data) {
29
28
  for (const [resource, property] of Object.entries(data)) {
29
+ // base on data
30
30
  if (Array.isArray(property)) {
31
31
  const valueName = propertyListMaps[resource];
32
32
  if (valueName) {
@@ -52,6 +52,41 @@ export async function updateStateByLgThinq(device_id, data) {
52
52
  );
53
53
  }
54
54
  }
55
+
56
+ // For timer, if there is not exist in data, set undefined
57
+ for (let i = 0; i < propertyTimer.length; i++) {
58
+ // base on device
59
+ const name = propertyTimer[i];
60
+ // eslint-disable-next-line no-prototype-builtins
61
+ if (device.hasOwnProperty(name)) {
62
+ const timer = data.timer;
63
+ const value = timer ? timer[name] : -1;
64
+ const [configId] = device[name];
65
+ configValues[configId] = value;
66
+ }
67
+ }
68
+
69
+ return configValues;
70
+ }
71
+
72
+ export async function updateStateByLgThinq(device_id, data) {
73
+ const device = deviceMaps[device_id];
74
+
75
+ if (!device) {
76
+ return;
77
+ }
78
+
79
+ let configValues = getConfigGlobalState('configValues');
80
+
81
+ if (Array.isArray(data)) {
82
+ for (let i = 0; i < data.length; i++) {
83
+ const dataItem = data[i];
84
+ configValues = parseData(configValues, device, dataItem);
85
+ }
86
+ } else {
87
+ configValues = parseData(configValues, device, data);
88
+ }
89
+
55
90
  setConfigGlobalState('configValues', { ...configValues });
56
91
  }
57
92
 
@@ -110,13 +145,21 @@ export const sendCommandOverLGThinq = async (sensor, action, data) => {
110
145
 
111
146
  const item = action.lg_actions[i];
112
147
  let new_message = {};
148
+ let isFirstResourceDone = false;
113
149
  for (const [key, value] of Object.entries(item.message)) {
114
150
  let new_property = {};
115
- let index = 0;
116
- for (const [key1, value1] of Object.entries(value)) {
117
- new_property[key1] = data[index] ? data[index] : value1; // new or keep old one
118
- index += 1;
151
+
152
+ if (!isFirstResourceDone) {
153
+ let index = 0;
154
+ for (const [key1, value1] of Object.entries(value)) {
155
+ new_property[key1] = data[index] ? data[index] : value1; // new or keep old one
156
+ index += 1;
157
+ }
158
+ isFirstResourceDone = true;
159
+ } else {
160
+ new_property = value; // from next resource, keep old one
119
161
  }
162
+
120
163
  new_message[key] = new_property;
121
164
  }
122
165
 
@@ -127,5 +170,4 @@ export const sendCommandOverLGThinq = async (sensor, action, data) => {
127
170
  'lg_thinq'
128
171
  );
129
172
  }
130
- await fetchDeviceStatusLG(sensor);
131
173
  };