@eohjsc/react-native-smart-city 0.5.9 → 0.6.0-rc2

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 (305) hide show
  1. package/README.md +1 -1
  2. package/android/build.gradle +8 -10
  3. package/package.json +52 -69
  4. package/src/commons/Action/__test__/ItemQuickAction.test.js +2 -2
  5. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +3 -3
  6. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapper.js +3 -3
  7. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/index.test.js +3 -3
  8. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +3 -3
  9. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/ButtonWrapper.js +2 -2
  10. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +0 -15
  11. package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +2 -2
  12. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +2 -2
  13. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +2 -2
  14. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/CircleButton.js +5 -5
  15. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/ControlPlay.js +3 -3
  16. package/src/commons/ActionGroup/TerminalBoxTemplate.js +2 -2
  17. package/src/commons/ActionGroup/TextBoxTemplate.js +2 -2
  18. package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonTemplate.test.js +4 -4
  19. package/src/commons/ActionGroup/TimerActionTemplate.js +3 -4
  20. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +2 -2
  21. package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +2 -9
  22. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +4 -11
  23. package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +2 -9
  24. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +4 -18
  25. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +2 -2
  26. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +1 -8
  27. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +0 -7
  28. package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +4 -15
  29. package/src/commons/ActionGroup/__test__/TerminalBoxTemplate.test.js +0 -7
  30. package/src/commons/ActionGroup/__test__/TextBoxTemplate.test.js +1 -8
  31. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +1 -8
  32. package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +1 -8
  33. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +2 -9
  34. package/src/commons/ActionGroup/__test__/index.test.js +14 -21
  35. package/src/commons/ActionTemplate/__test__/index.test.js +2 -0
  36. package/src/commons/ActionTemplate/__test__/utils.js +21 -0
  37. package/src/commons/ActionTemplate/index.js +1 -2
  38. package/src/commons/BackDefault/index.js +2 -2
  39. package/src/commons/ButtonPopup/index.js +2 -2
  40. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +1 -12
  41. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +27 -20
  42. package/src/commons/Dashboard/MyUnit/index.js +0 -1
  43. package/src/commons/DateTimeRangeChange/DateTimeButton.js +2 -2
  44. package/src/commons/Device/ConnectedViewHeader.js +2 -2
  45. package/src/commons/Device/DisconnectedView.js +2 -2
  46. package/src/commons/Device/Emergency/EmergencyDetail.js +3 -3
  47. package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +2 -2
  48. package/src/commons/Device/FlatListItems.js +3 -3
  49. package/src/commons/Device/Hanet/ItemHanetDevice.js +3 -3
  50. package/src/commons/Device/Hanet/ItemHanetDevice.test.js +3 -11
  51. package/src/commons/Device/HorizontalBarChart.js +1 -1
  52. package/src/commons/Device/ItemAddNew/index.js +2 -2
  53. package/src/commons/Device/ItemDevice.js +2 -2
  54. package/src/commons/Device/PowerConsumptionChart.js +154 -0
  55. package/src/commons/Device/SonosSpeaker/index.js +3 -3
  56. package/src/commons/Device/WaterPurifierStatus/AlertStatusMachine.js +2 -2
  57. package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +2 -6
  58. package/src/commons/DisplayChecking/index.js +2 -2
  59. package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -2
  60. package/src/commons/EmergencyButton/AlertSent.js +2 -2
  61. package/src/commons/FieldTemplate/ChooseUserField/index.js +2 -2
  62. package/src/commons/Form/CurrencyInput.js +1 -15
  63. package/src/commons/Header/HeaderCustom.js +3 -3
  64. package/src/commons/HeaderAni/index.js +2 -2
  65. package/src/commons/IconComponent/index.js +3 -3
  66. package/src/commons/MenuActionAddnew/__test__/MenuActionAddNew.test.js +1 -1
  67. package/src/commons/MenuActionList/__test__/MenuActionList.test.js +1 -0
  68. package/src/commons/NavBar/index.js +2 -2
  69. package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +3 -3
  70. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +1 -13
  71. package/src/commons/Processing/__test__/Connecting.test.js +3 -14
  72. package/src/commons/SearchLocation/index.js +2 -2
  73. package/src/commons/SelectActionCard/index.js +2 -2
  74. package/src/commons/SelectSubUnit/__test__/SelectSubUnit.test.js +1 -18
  75. package/src/commons/SelectSubUnit/index.js +2 -2
  76. package/src/commons/SelectUnit/__test__/SelectUnit.test.js +1 -13
  77. package/src/commons/Sharing/BtnRemoveMember.js +2 -2
  78. package/src/commons/Sharing/StationDevicePermissions.js +2 -2
  79. package/src/commons/Sharing/WrapHeaderScrollable.js +1 -1
  80. package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +1 -1
  81. package/src/commons/SubUnit/DeviceTemplate/ConfigAndEvaluation/ConfigAndEvaluation.js +2 -2
  82. package/src/commons/SubUnit/DeviceTemplate/ConfigValue/ConfigValue.js +2 -2
  83. package/src/commons/SubUnit/DeviceTemplate/EvaluationOverConfig/EvaluationOverConfig.js +2 -2
  84. package/src/commons/SubUnit/Item/index.js +2 -2
  85. package/src/commons/SubUnit/OneTap/ItemOneTap.js +2 -2
  86. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +11 -8
  87. package/src/commons/SubUnit/__test__/Favorites.test.js +1 -13
  88. package/src/commons/SubUnit/__test__/ShortDetail.test.js +5 -16
  89. package/src/commons/Tabbar/__test__/index.test.js +0 -11
  90. package/src/commons/Unit/HeaderUnit/index.js +4 -4
  91. package/src/commons/Unit/SharedUnit.js +5 -5
  92. package/src/commons/Unit/__test__/HeaderUnit.test.js +3 -15
  93. package/src/commons/Unit/__test__/SharedUnit.test.js +94 -105
  94. package/src/commons/UnitSummary/AirQuality/SegmentedRoundDisplay/index.js +11 -30
  95. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +6 -61
  96. package/src/commons/Widgets/IFrame/IFrame.js +54 -0
  97. package/src/commons/Widgets/IFrame/IFrameStyles.js +35 -0
  98. package/src/commons/Widgets/IFrame/__tests__/IFrame.test.js +74 -0
  99. package/src/commons/Widgets/IFrame/index.js +0 -0
  100. package/src/commons/Widgets/IFrameWithConfig/IFrameWithConfig.js +163 -0
  101. package/src/commons/Widgets/IFrameWithConfig/IFrameWithConfigStyles.js +9 -0
  102. package/src/commons/Widgets/IFrameWithConfig/__tests__/IFrameWithConfig.test.js +284 -0
  103. package/src/commons/Widgets/IFrameWithConfig/index.js +0 -0
  104. package/src/commons/Widgets/Widget.js +0 -0
  105. package/src/commons/Widgets/index.js +0 -0
  106. package/src/configs/Constants.js +5 -0
  107. package/src/hooks/Common/__test__/useAndroidTranslucentStatusBar.test.js +4 -15
  108. package/src/hooks/Common/useDevicesStatus.js +23 -23
  109. package/src/hooks/IoT/__test__/useRemoteControl.test.js +1 -1
  110. package/src/hooks/IoT/__test__/useWatchConfigs.test.js +0 -7
  111. package/src/iot/RemoteControl/HomeAssistant.js +1 -1
  112. package/src/iot/RemoteControl/__test__/Bluetooth.test.js +234 -232
  113. package/src/navigations/AutomateStack.js +2 -2
  114. package/src/navigations/EmergencyContactsStack.js +2 -2
  115. package/src/navigations/SharedStack.js +2 -2
  116. package/src/navigations/UnitStack.js +2 -2
  117. package/src/screens/ActivityLog/hooks/index.js +7 -4
  118. package/src/screens/ActivityLog/index.js +2 -2
  119. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +4 -21
  120. package/src/screens/AddCommon/__test__/SelectUnit.test.js +7 -19
  121. package/src/screens/AddLocationMaps/__test__/index.test.js +3 -13
  122. package/src/screens/AddLocationMaps/index.js +4 -4
  123. package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +3 -20
  124. package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +11 -18
  125. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ZigbeeDeviceConnectGuide.test.js +4 -21
  126. package/src/screens/AddNewGateway/RenameNewDevices.js +2 -2
  127. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +3 -3
  128. package/src/screens/AddNewGateway/__test__/ConnectingModbusDevice.test.js +0 -17
  129. package/src/screens/AddNewGateway/__test__/ConnectingWifiDevice.test.js +4 -19
  130. package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +3 -15
  131. package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +31 -51
  132. package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +9 -22
  133. package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +12 -19
  134. package/src/screens/AddNewGateway/__test__/ScanModbusQR.test.js +6 -16
  135. package/src/screens/AddNewGateway/__test__/ScanWifiDeviceQR.test.js +4 -15
  136. package/src/screens/AddNewGateway/__test__/SelectDeviceSubUnit.test.js +3 -3
  137. package/src/screens/AddNewGateway/__test__/SelectDeviceType.test.js +18 -10
  138. package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +1 -1
  139. package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +12 -9
  140. package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +12 -9
  141. package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +7 -21
  142. package/src/screens/AddNewGateway/hooks/__Tests__/index.test.js +1 -10
  143. package/src/screens/AllGateway/DetailConfigActionInternal/__test__/index.test.js +0 -20
  144. package/src/screens/AllGateway/DetailConfigActionModbus/__test__/index.test.js +7 -24
  145. package/src/screens/AllGateway/DeviceGatewayInfo/__test__/index.test.js +0 -17
  146. package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +84 -100
  147. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +64 -82
  148. package/src/screens/AllGateway/DeviceZigbeeDetail/__test__/index.test.js +36 -55
  149. package/src/screens/AllGateway/GatewayConnectionMethods/__test__/index.test.js +9 -18
  150. package/src/screens/AllGateway/GatewayDetail/__test__/index.test.js +10 -37
  151. package/src/screens/AllGateway/GatewayInfo/__test__/index.test.js +7 -32
  152. package/src/screens/AllGateway/__test__/index.test.js +1 -14
  153. package/src/screens/AllGateway/components/GatewayItem/__test__/index.test.js +0 -12
  154. package/src/screens/AllGateway/components/TabPaneCT/__test__/index.test.js +1 -13
  155. package/src/screens/AllGateway/components/TabPaneCT/index.js +1 -1
  156. package/src/screens/AllGateway/hooks/__test__/index.test.js +1 -8
  157. package/src/screens/AllGateway/test-utils.js +1 -1
  158. package/src/screens/Automate/AddNewAction/NewActionWrapper.js +2 -2
  159. package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +27 -28
  160. package/src/screens/Automate/AddNewAction/__test__/ChooseAction.test.js +3 -3
  161. package/src/screens/Automate/AddNewAction/__test__/ChooseConfig.test.js +8 -5
  162. package/src/screens/Automate/AddNewAction/__test__/SelectControlDevices.test.js +2 -2
  163. package/src/screens/Automate/AddNewAction/__test__/SelectMonitorDevices.test.js +1 -18
  164. package/src/screens/Automate/AddNewAction/__test__/SetupConfigCondition.test.js +17 -15
  165. package/src/screens/Automate/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +4 -4
  166. package/src/screens/Automate/EditActionsList/__tests__/UpdateActionScript.test.js +38 -55
  167. package/src/screens/Automate/EditActionsList/__tests__/UpdateDelayScript.test.js +0 -18
  168. package/src/screens/Automate/EditActionsList/__tests__/UpdateNotifyScript.test.js +1 -19
  169. package/src/screens/Automate/EditActionsList/__tests__/index.test.js +14 -11
  170. package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +3 -3
  171. package/src/screens/Automate/Scenario/__test__/AddNewOneTap.test.js +2 -2
  172. package/src/screens/Automate/ScriptDetail/Components/AddActionScript.js +2 -2
  173. package/src/screens/Automate/ScriptDetail/__test__/index.test.js +33 -25
  174. package/src/screens/Automate/ScriptDetail/index.js +5 -6
  175. package/src/screens/Automate/SetSchedule/__test__/index.test.js +4 -4
  176. package/src/screens/Automate/SetSchedule/components/RowItem.js +3 -3
  177. package/src/screens/Automate/__test__/MultiUnits.test.js +5 -5
  178. package/src/screens/Automate/__test__/index.test.js +6 -6
  179. package/src/screens/Automate/index.js +2 -2
  180. package/src/screens/ChangePosition/__test__/index.test.js +1 -14
  181. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +0 -12
  182. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +1 -11
  183. package/src/screens/Device/EditDevice/index.js +2 -2
  184. package/src/screens/Device/__test__/detail.test.js +11 -11
  185. package/src/screens/Device/__test__/sensorDisplayItem.test.js +3 -15
  186. package/src/screens/Device/components/SensorDisplayItem.js +23 -5
  187. package/src/screens/Device/components/__test__/VisualChart.test.js +2 -9
  188. package/src/screens/Device/detail.js +11 -10
  189. package/src/screens/Drawer/Drawer.test.js +3 -11
  190. package/src/screens/Drawer/index.js +3 -4
  191. package/src/screens/EmergencyContacts/EmergencyContactsList.js +4 -8
  192. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +3 -3
  193. package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +4 -17
  194. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +3 -14
  195. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +0 -10
  196. package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
  197. package/src/screens/EnterPassword/__test__/EnterPassword.test.js +4 -17
  198. package/src/screens/GuestInfo/__test__/index.test.js +0 -11
  199. package/src/screens/GuestInfo/components/RowGuestInfo.js +2 -2
  200. package/src/screens/GuestInfo/index.js +2 -2
  201. package/src/screens/HanetCamera/Detail.js +2 -2
  202. package/src/screens/HanetCamera/ManageAccess.js +3 -4
  203. package/src/screens/HanetCamera/MemberInfo.js +4 -4
  204. package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +2 -16
  205. package/src/screens/HanetCamera/__test__/Detail.test.js +1 -12
  206. package/src/screens/HanetCamera/__test__/ManageAccess.test.js +5 -16
  207. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +5 -18
  208. package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -2
  209. package/src/screens/ManageAccess/__test__/ManageAccess.test.js +3 -19
  210. package/src/screens/ManageAccess/index.js +3 -3
  211. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +5 -5
  212. package/src/screens/Notification/__test__/NotificationItem.test.js +9 -19
  213. package/src/screens/Notification/index.js +3 -3
  214. package/src/screens/PlayBackCamera/Styles/index.js +2 -4
  215. package/src/screens/PlayBackCamera/Timer.js +65 -47
  216. package/src/screens/PlayBackCamera/__test__/index.test.js +32 -33
  217. package/src/screens/PlayBackCamera/index.js +115 -112
  218. package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +0 -11
  219. package/src/screens/ScanChipQR/components/QRScan/index.js +3 -3
  220. package/src/screens/SelectUnit/__test__/index.test.js +1 -21
  221. package/src/screens/SelectUnit/index.js +2 -2
  222. package/src/screens/SharedUnit/TabHeader.js +2 -2
  223. package/src/screens/Sharing/Components/EndDevice.js +3 -3
  224. package/src/screens/Sharing/UnitMemberList.js +2 -2
  225. package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +9 -4
  226. package/src/screens/Sharing/__test__/SelectShareDevice.test.js +2 -15
  227. package/src/screens/Sharing/__test__/SelectUser.test.js +2 -22
  228. package/src/screens/Sharing/__test__/UnitMemberList.test.js +2 -2
  229. package/src/screens/Sharing/__test__/UpdateShareDevice.test.js +4 -17
  230. package/src/screens/Sharing/hooks/__test__/index.test.js +2 -13
  231. package/src/screens/SmartAccount/Connecting/index.js +0 -2
  232. package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +3 -18
  233. package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +11 -21
  234. package/src/screens/SmartAccount/SuccessfullyConnected/index.js +3 -4
  235. package/src/screens/SmartAccount/__test__/Connecting.test.js +30 -36
  236. package/src/screens/SmartAccount/__test__/SmartAccount.test.js +12 -21
  237. package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +7 -17
  238. package/src/screens/SmartIr/__test__/SelectBrand.test.js +1 -11
  239. package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +1 -12
  240. package/src/screens/SmartIr/__test__/SmartIr.test.js +3 -11
  241. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +3 -3
  242. package/src/screens/SmartIr/components/SelectBrand.js +2 -2
  243. package/src/screens/SubUnit/AddSubUnit.js +1 -0
  244. package/src/screens/SubUnit/EditSubUnit.js +3 -2
  245. package/src/screens/SubUnit/ManageSubUnit.js +4 -5
  246. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +9 -31
  247. package/src/screens/SubUnit/__test__/Detail.test.js +4 -28
  248. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +12 -30
  249. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +2 -2
  250. package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +0 -12
  251. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +7 -20
  252. package/src/screens/Template/__test__/EditTemplate.test.js +2 -13
  253. package/src/screens/Template/__test__/GatewayList.test.js +0 -9
  254. package/src/screens/Template/__test__/detail.test.js +4 -4
  255. package/src/screens/Template/__test__/index.test.js +1 -12
  256. package/src/screens/Template/detail.js +2 -2
  257. package/src/screens/Unit/SelectAddToFavorites.js +2 -2
  258. package/src/screens/Unit/SelectAddress.js +4 -4
  259. package/src/screens/Unit/SmartAccountItem.js +2 -2
  260. package/src/screens/Unit/Summaries.js +3 -2
  261. package/src/screens/Unit/__test__/AddMenu.test.js +5 -2
  262. package/src/screens/Unit/__test__/CheckSendEmail.test.js +0 -12
  263. package/src/screens/Unit/__test__/ChooseLocation.test.js +1 -4
  264. package/src/screens/Unit/__test__/Detail.test.js +5 -5
  265. package/src/screens/Unit/__test__/ManageUnit.test.js +2 -17
  266. package/src/screens/Unit/__test__/MoreMenu.test.js +1 -11
  267. package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +3 -14
  268. package/src/screens/Unit/__test__/SelectAddress.test.js +4 -17
  269. package/src/screens/Unit/__test__/SmartAccount.test.js +14 -11
  270. package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -11
  271. package/src/screens/Unit/__test__/Summaries.test.js +2 -14
  272. package/src/screens/Unit/components/AutomateScript/index.js +2 -2
  273. package/src/screens/Unit/components/ButtonWrapper/index.js +3 -4
  274. package/src/screens/Unit/components/Header/index.js +3 -3
  275. package/src/screens/Unit/components/SharedUnit/index.js +5 -5
  276. package/src/screens/Unit/components/__test__/Header.test.js +1 -14
  277. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +1 -11
  278. package/src/screens/Unit/components/__test__/SharedUnit.test.js +1 -11
  279. package/src/screens/UnitSummary/__test__/index.test.js +51 -17
  280. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +0 -12
  281. package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +10 -23
  282. package/src/screens/UnitSummary/components/AirQuality/__test__/index.test.js +1 -7
  283. package/src/screens/UnitSummary/components/AirQuality/index.js +3 -3
  284. package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +38 -14
  285. package/src/screens/UnitSummary/components/PowerConsumption/index.js +21 -30
  286. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +1 -16
  287. package/src/screens/UnitSummary/components/Temperature/index.js +5 -1
  288. package/src/screens/UnitSummary/components/UvIndex/__test__/index.test.js +0 -8
  289. package/src/screens/UnitSummary/components/UvIndex/index.js +2 -2
  290. package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +2 -2
  291. package/src/screens/UnitSummary/components/WaterQuality/__test__/index.test.js +14 -18
  292. package/src/screens/UnitSummary/index.js +4 -8
  293. package/src/utils/Converter/__test__/timer.test.js +8 -0
  294. package/src/utils/Functions/preloadImages.js +13 -14
  295. package/src/utils/Monitor.js +4 -4
  296. package/src/utils/Storage.js +1 -1
  297. package/src/commons/Device/HistoryChart.js +0 -225
  298. package/src/commons/Device/WindSpeed/LinearChart/__test__/LinearChart.test.js +0 -48
  299. package/src/commons/Device/WindSpeed/LinearChart/index.js +0 -155
  300. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +0 -289
  301. package/src/screens/Device/__test__/DetailHistoryChart.test.js +0 -69
  302. package/src/screens/Device/components/DetailHistoryChart.js +0 -118
  303. package/src/screens/UnitSummary/components/Temperature/ChartAverage/index.js +0 -62
  304. package/src/screens/UnitSummary/components/Temperature/__test__/ChartAverage.test.js +0 -17
  305. package/src/utils/dateHelper/getTickValues.js +0 -22
@@ -19,17 +19,6 @@ const wrapComponent = (props) => (
19
19
  </SCProvider>
20
20
  );
21
21
 
22
- const mockedNavigate = jest.fn();
23
- jest.mock('@react-navigation/native', () => {
24
- return {
25
- ...jest.requireActual('@react-navigation/native'),
26
- useIsFocused: jest.fn(),
27
- useNavigation: () => ({
28
- navigate: mockedNavigate,
29
- }),
30
- };
31
- });
32
-
33
22
  jest.mock('react-native-onesignal', () => {
34
23
  return {
35
24
  setNotificationWillShowInForegroundHandler: jest.fn(),
@@ -52,7 +41,6 @@ describe('Test Summaries', () => {
52
41
  id: 1,
53
42
  },
54
43
  };
55
- mockedNavigate.mockReset();
56
44
  mock.reset();
57
45
  });
58
46
 
@@ -76,7 +64,7 @@ describe('Test Summaries', () => {
76
64
  await act(async () => {
77
65
  items[0].props.goToSummary({ id: 1 });
78
66
  });
79
- expect(mockedNavigate).toBeCalled();
67
+ expect(global.mockedNavigate).toBeCalled();
80
68
  });
81
69
 
82
70
  it('render Summaries receive noti with summary_id then not reload', async () => {
@@ -92,7 +80,7 @@ describe('Test Summaries', () => {
92
80
  await act(async () => {
93
81
  tree = await renderer.create(wrapComponent(props));
94
82
  });
95
- expect(mockedNavigate).not.toBeCalled();
83
+ expect(global.mockedNavigate).not.toBeCalled();
96
84
  });
97
85
 
98
86
  it('fetch data non-stop', async () => {
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { View, TouchableWithoutFeedback } from 'react-native';
3
- import { IconOutline } from '@ant-design/icons-react-native';
3
+ import AntDesign from 'react-native-vector-icons/AntDesign';
4
4
  import { useTranslations } from '../../../../hooks/Common/useTranslations';
5
5
  import Text from '../../../../commons/Text';
6
6
  import FImage from '../../../../commons/FImage';
@@ -61,7 +61,7 @@ const AutomateScript = ({ automate, onPress, isSelected }) => {
61
61
  <Text numberOfLines={1} type={'Label'} color={Colors.Gray7}>
62
62
  {t('created_by', { name: author })}
63
63
  </Text>
64
- <IconOutline name="right" size={12} />
64
+ <AntDesign name="right" size={12} />
65
65
  </View>
66
66
  </View>
67
67
  </View>
@@ -2,8 +2,7 @@ import React, { memo } from 'react';
2
2
  import { View, TouchableOpacity, Image } from 'react-native';
3
3
  import Text from '../../../../commons/Text';
4
4
  import { Colors } from '../../../../configs';
5
- import { Icon } from '@ant-design/react-native';
6
- import { IconOutline } from '@ant-design/icons-react-native';
5
+ import AntDesign from 'react-native-vector-icons/AntDesign';
7
6
  import { AccessibilityLabel } from '../../../../configs/Constants';
8
7
  import styles from './styles';
9
8
 
@@ -47,10 +46,10 @@ const ButtonWrapper = ({
47
46
  <Image source={{ uri: value }} style={styles.avatar} />
48
47
  ) : (
49
48
  <View style={styles.avatar}>
50
- <Icon name={'user'} size={27} />
49
+ <AntDesign name={'user'} size={27} />
51
50
  </View>
52
51
  )}
53
- <IconOutline name="right" size={20} color={Colors.Gray7} />
52
+ <AntDesign name="right" size={20} color={Colors.Gray7} />
54
53
  </View>
55
54
  </View>
56
55
  {children}
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useRef, useState } from 'react';
2
2
  import { Dimensions, View, TouchableOpacity, StyleSheet } from 'react-native';
3
3
  import Popover from '../../../../commons/Popover';
4
- import { IconOutline } from '@ant-design/icons-react-native';
4
+ import AntDesign from 'react-native-vector-icons/AntDesign';
5
5
  import { useTranslations } from '../../../../hooks/Common/useTranslations';
6
6
 
7
7
  import { Colors } from '../../../../configs';
@@ -97,7 +97,7 @@ const HeaderComponent = ({ title, goBack, dark, hideRight, style }) => {
97
97
  onPress={() => setShowModal(true)}
98
98
  style={styles.rightHeader}
99
99
  >
100
- <IconOutline
100
+ <AntDesign
101
101
  name="plus"
102
102
  size={32}
103
103
  color={dark ? Colors.Black : Colors.White}
@@ -107,7 +107,7 @@ const HeaderComponent = ({ title, goBack, dark, hideRight, style }) => {
107
107
  onPress={() => setMenu(true)}
108
108
  style={styles.rightHeader}
109
109
  >
110
- <IconOutline
110
+ <AntDesign
111
111
  name="more"
112
112
  size={30}
113
113
  color={dark ? Colors.Black : Colors.White}
@@ -1,7 +1,7 @@
1
1
  import React, { Fragment, useCallback } from 'react';
2
2
  import { View, Image, TouchableOpacity } from 'react-native';
3
3
  import { useTranslations } from '../../../../hooks/Common/useTranslations';
4
- import { IconOutline, IconFill } from '@ant-design/icons-react-native';
4
+ import AntDesign from 'react-native-vector-icons/AntDesign';
5
5
 
6
6
  import { API, Colors, Images } from '../../../../configs';
7
7
  import Text from '../../../../commons/Text';
@@ -88,7 +88,7 @@ const SharedUnit = ({
88
88
  {isOptions && (
89
89
  <Fragment>
90
90
  {item.is_pin ? (
91
- <IconFill
91
+ <AntDesign
92
92
  name="pushpin"
93
93
  size={20}
94
94
  color={Colors.Blue10}
@@ -98,7 +98,7 @@ const SharedUnit = ({
98
98
  }
99
99
  />
100
100
  ) : (
101
- <IconOutline
101
+ <AntDesign
102
102
  name="pushpin"
103
103
  size={20}
104
104
  onPress={addPinSharedUnit}
@@ -106,7 +106,7 @@ const SharedUnit = ({
106
106
  />
107
107
  )}
108
108
  {item.is_star ? (
109
- <IconFill
109
+ <AntDesign
110
110
  name="star"
111
111
  size={20}
112
112
  color={Colors.Yellow6}
@@ -116,7 +116,7 @@ const SharedUnit = ({
116
116
  }
117
117
  />
118
118
  ) : (
119
- <IconOutline
119
+ <AntDesign
120
120
  name="star"
121
121
  size={20}
122
122
  onPress={addStarSharedUnit}
@@ -17,19 +17,6 @@ const wrapComponent = (title, goBack, dark, hideRight) => (
17
17
  </SCProvider>
18
18
  );
19
19
 
20
- const mockedNavigate = jest.fn();
21
- const mockedGoBack = jest.fn();
22
- jest.mock('@react-navigation/native', () => {
23
- return {
24
- ...jest.requireActual('@react-navigation/native'),
25
- useNavigation: () => ({
26
- navigate: mockedNavigate,
27
- goBack: mockedGoBack,
28
- }),
29
- useIsFocused: () => true,
30
- };
31
- });
32
-
33
20
  describe('Test Header', () => {
34
21
  let tree;
35
22
  it('test hideModal', async () => {
@@ -97,6 +84,6 @@ describe('Test Header', () => {
97
84
  await act(async () => {
98
85
  touchableOpacity[0].props.onPress();
99
86
  });
100
- expect(mockedGoBack).toHaveBeenCalled();
87
+ expect(global.mockedGoBack).toHaveBeenCalled();
101
88
  });
102
89
  });
@@ -7,16 +7,6 @@ import MyUnitDevice from '../MyUnitDevice';
7
7
  import ItemQuickAction from '../../../../commons/Action/ItemQuickAction';
8
8
  import Text from '../../../../commons/Text';
9
9
 
10
- const mockNavigate = jest.fn();
11
- jest.mock('@react-navigation/native', () => {
12
- return {
13
- ...jest.requireActual('@react-navigation/native'),
14
- useNavigation: () => ({
15
- navigate: mockNavigate,
16
- }),
17
- };
18
- });
19
-
20
10
  jest.mock('react', () => {
21
11
  return {
22
12
  ...jest.requireActual('react'),
@@ -57,7 +47,7 @@ describe('Test MyUnitDevice', () => {
57
47
  await act(async () => {
58
48
  await touches[0].props.onPress();
59
49
  });
60
- expect(mockNavigate).toHaveBeenCalled();
50
+ expect(global.mockedNavigate).toHaveBeenCalled();
61
51
  });
62
52
 
63
53
  it('Test render without status', async () => {
@@ -25,16 +25,6 @@ const wrapComponent = (item, navigation) => (
25
25
  </SCProvider>
26
26
  );
27
27
 
28
- const mockNavigate = jest.fn();
29
- jest.mock('@react-navigation/native', () => {
30
- return {
31
- ...jest.requireActual('@react-navigation/native'),
32
- useNavigation: () => ({
33
- navigate: mockNavigate,
34
- }),
35
- };
36
- });
37
-
38
28
  describe('Test SharedUnit', () => {
39
29
  let tree;
40
30
 
@@ -70,7 +60,7 @@ describe('Test SharedUnit', () => {
70
60
  await act(async () => {
71
61
  touchSharedUnit.props.onPress();
72
62
  });
73
- expect(mockNavigate).toHaveBeenCalledWith(Routes.UnitStack, {
63
+ expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.UnitStack, {
74
64
  screen: Routes.UnitDetail,
75
65
  params: {
76
66
  unitId: 3,
@@ -20,22 +20,11 @@ import { mockSCStore } from '../../../context/mockStore';
20
20
  import api from '../../../utils/Apis/axios';
21
21
  import { WrapHeaderScrollable } from '../../../commons';
22
22
  import AirQuality from '../components/AirQuality';
23
+ import Text from '../../../commons/Text';
24
+ import { useConfigGlobalState } from '../../../iot/states';
23
25
 
24
26
  const mock = new MockAdapter(api.axiosInstance);
25
27
 
26
- const mockedNavigate = jest.fn();
27
-
28
- jest.mock('@react-navigation/native', () => {
29
- return {
30
- ...jest.requireActual('@react-navigation/native'),
31
- useNavigation: () => ({
32
- navigate: mockedNavigate,
33
- }),
34
- useIsFocused: () => true,
35
- useFocusEffect: (func) => func(),
36
- };
37
- });
38
-
39
28
  jest.mock('react-native-onesignal', () => {
40
29
  return {
41
30
  setNotificationWillShowInForegroundHandler: jest.fn(),
@@ -49,6 +38,10 @@ jest.mock('../../../hooks', () => {
49
38
  };
50
39
  });
51
40
 
41
+ jest.mock('../../../iot/states', () => ({
42
+ useConfigGlobalState: jest.fn(),
43
+ }));
44
+
52
45
  const wrapComponent = (route) => (
53
46
  <SCProvider initState={mockSCStore({})}>
54
47
  <UnitSummary route={route} />
@@ -60,6 +53,7 @@ describe('Test UnitSummary', () => {
60
53
 
61
54
  beforeEach(() => {
62
55
  mock.reset();
56
+ useConfigGlobalState.mockReturnValue([{}]);
63
57
  Date.now = jest.fn(() => new Date('2021-01-24T12:00:00.000Z'));
64
58
  route = {
65
59
  params: {
@@ -79,7 +73,9 @@ describe('Test UnitSummary', () => {
79
73
  let tree;
80
74
 
81
75
  it('onRefresh', async () => {
82
- mock.onGet(API.UNIT.UNIT_SUMMARY_DETAIL(1, 1)).reply(200);
76
+ mock.onGet(API.UNIT.UNIT_SUMMARY_DETAIL(1, 1)).reply(200, {
77
+ data: {},
78
+ });
83
79
  await act(async () => {
84
80
  tree = await create(wrapComponent(route));
85
81
  });
@@ -188,7 +184,9 @@ describe('Test UnitSummary', () => {
188
184
 
189
185
  it('test receive notification with summary_id then reload data', async () => {
190
186
  jest.useFakeTimers();
191
- mock.onGet(API.UNIT.UNIT_SUMMARY_DETAIL(1, 1)).reply(200);
187
+ mock.onGet(API.UNIT.UNIT_SUMMARY_DETAIL(1, 1)).reply(200, {
188
+ data: {},
189
+ });
192
190
  const dataNotification = {
193
191
  params: {
194
192
  summary_id: 1,
@@ -207,7 +205,9 @@ describe('Test UnitSummary', () => {
207
205
 
208
206
  it('test receive notification with other summary_id then not reload data', async () => {
209
207
  jest.useFakeTimers();
210
- mock.onGet(API.UNIT.UNIT_SUMMARY_DETAIL(1, 1)).reply(200);
208
+ mock.onGet(API.UNIT.UNIT_SUMMARY_DETAIL(1, 1)).reply(200, {
209
+ data: {},
210
+ });
211
211
  const dataNotification = {
212
212
  params: {
213
213
  summary_id: 2,
@@ -222,6 +222,7 @@ describe('Test UnitSummary', () => {
222
222
  await act(async () => {
223
223
  jest.runOnlyPendingTimers();
224
224
  });
225
+ expect(mock.history.get.length).toBe(1);
225
226
  });
226
227
 
227
228
  let list_value = [
@@ -286,13 +287,46 @@ describe('Test UnitSummary', () => {
286
287
  await act(async () => {
287
288
  await touch.props.onPress();
288
289
  });
289
- expect(mockedNavigate).toHaveBeenLastCalledWith(
290
+ expect(global.mockedNavigate).toHaveBeenLastCalledWith(
290
291
  UnitSummaryDetail.guideName
291
292
  );
292
293
  }
293
294
  });
294
295
  });
295
296
 
297
+ test('create Unit Summary temperature value', async () => {
298
+ mock
299
+ .onGet(
300
+ API.UNIT.UNIT_SUMMARY_DETAIL(
301
+ route.params.unitId,
302
+ route.params.summaryData.id
303
+ )
304
+ )
305
+ .reply(200, {
306
+ data: {
307
+ listConfigs: {
308
+ temp: 1,
309
+ },
310
+ },
311
+ });
312
+ route.params.summaryData.screen = Routes.Temperature;
313
+ useConfigGlobalState.mockReturnValue([
314
+ {
315
+ 1: {
316
+ value: 50,
317
+ },
318
+ },
319
+ ]);
320
+ await act(async () => {
321
+ tree = await create(wrapComponent(route));
322
+ });
323
+ const instance = tree.root;
324
+ const texts = instance.findAll((el) => {
325
+ return el.type === Text && el.props.children === '50 °C';
326
+ });
327
+ expect(texts).toHaveLength(1);
328
+ });
329
+
296
330
  it('Test render without params', async () => {
297
331
  useReceiveNotifications.mockImplementationOnce(() => ({
298
332
  dataNotification: {},
@@ -18,18 +18,6 @@ jest.mock('react', () => {
18
18
  };
19
19
  });
20
20
 
21
- const mockedNavigate = jest.fn();
22
-
23
- jest.mock('@react-navigation/native', () => {
24
- return {
25
- ...jest.requireActual('@react-navigation/native'),
26
- useNavigation: () => ({
27
- navigate: mockedNavigate,
28
- }),
29
- useFocusEffect: (func) => func(),
30
- };
31
- });
32
-
33
21
  useState.mockImplementation((init) => [init, mockSetState]);
34
22
 
35
23
  const wrapComponent = (summaryDetail) => (
@@ -1,4 +1,4 @@
1
- import React, { memo, useEffect, useMemo, useState } from 'react';
1
+ import React, { memo, useCallback, useMemo, useState } from 'react';
2
2
  import { View, StyleSheet } from 'react-native';
3
3
  import Text from '../../../../commons/Text';
4
4
  import { API, Colors } from '../../../../configs';
@@ -8,7 +8,7 @@ import ListQualityIndicator from '../../../../commons/Device/WaterQualitySensor/
8
8
  import PMSensorIndicator from '../../../../commons/Device/PMSensor/PMSensorIndicator';
9
9
  import VisualChart from '../../../Device/components/VisualChart';
10
10
  import { useTranslations } from '../../../../hooks/Common/useTranslations';
11
- import HistoryChart from '../../../../commons/Device/HistoryChart';
11
+ import PowerConsumptionChart from '../../../../commons/Device/PowerConsumptionChart';
12
12
  import { axiosGet } from '../../../../utils/Apis/axios';
13
13
  import { AccessibilityLabel } from '../../../../configs/Constants';
14
14
  import { useWatchConfigs } from '../../../../hooks/IoT';
@@ -114,10 +114,6 @@ const ThreePhasePowerConsumption = memo(({ summaryDetail }) => {
114
114
  return !!listConfigs;
115
115
  }, [listConfigs]);
116
116
 
117
- const [startDate, setStartDate] = useState(
118
- moment().subtract(6, 'days').valueOf()
119
- );
120
- const [endDate, setEndDate] = useState(moment().valueOf());
121
117
  const [groupBy, setGroupBy] = useState('date');
122
118
  const [getData, setData] = useState({});
123
119
  const [chartConfig, setChartConfig] = useState({
@@ -125,8 +121,8 @@ const ThreePhasePowerConsumption = memo(({ summaryDetail }) => {
125
121
  price: '',
126
122
  });
127
123
 
128
- useEffect(() => {
129
- const fetchData = async () => {
124
+ const fetchData = useCallback(
125
+ async (startDate, endDate) => {
130
126
  let params = new URLSearchParams();
131
127
  params.append('config', total_power);
132
128
  params.append('group_by', groupBy);
@@ -143,11 +139,9 @@ const ThreePhasePowerConsumption = memo(({ summaryDetail }) => {
143
139
  if (success) {
144
140
  setData(data);
145
141
  }
146
- };
147
- if (total_power) {
148
- fetchData();
149
- }
150
- }, [startDate, endDate, total_power, groupBy]);
142
+ },
143
+ [groupBy, total_power]
144
+ );
151
145
 
152
146
  const dataTotal = useMemo(() => {
153
147
  return total_power
@@ -191,21 +185,14 @@ const ThreePhasePowerConsumption = memo(({ summaryDetail }) => {
191
185
  </Text>
192
186
 
193
187
  <PMSensorIndicator data={dataTotal} style={styles.styleTotalPower} />
194
- {!!getData?.length && (
195
- <HistoryChart
188
+ {total_power && (
189
+ <PowerConsumptionChart
190
+ onChangeDate={fetchData}
196
191
  datas={getData}
197
192
  chartConfig={chartConfig}
198
193
  setChartConfig={setChartConfig}
199
- formatType={'date'}
200
- startDate={startDate}
201
- setEndDate={setEndDate}
202
- setStartDate={setStartDate}
203
194
  groupBy={groupBy}
204
195
  setGroupBy={setGroupBy}
205
- configuration={{
206
- type: 'horizontal_bar_chart',
207
- config: 'power_consumption',
208
- }}
209
196
  />
210
197
  )}
211
198
  </Section>
@@ -12,13 +12,7 @@ import { Section, Text } from '../../../../../commons';
12
12
  import AccessibilityLabel from '../../../../../configs/AccessibilityLabel';
13
13
 
14
14
  new MockAdapter(api.axiosInstance);
15
- jest.mock('@react-navigation/native', () => {
16
- return {
17
- ...jest.requireActual('@react-navigation/native'),
18
- useRoute: jest.fn(),
19
- useFocusEffect: (func) => func(),
20
- };
21
- });
15
+
22
16
  const wrapComponent = (data) => (
23
17
  <SCProvider initState={mockSCStore({})}>
24
18
  <AirQuality {...data} />
@@ -1,6 +1,6 @@
1
1
  import React, { memo, useCallback, useMemo, useState } from 'react';
2
2
  import { TouchableOpacity, View } from 'react-native';
3
- import { IconOutline } from '@ant-design/icons-react-native';
3
+ import AntDesign from 'react-native-vector-icons/AntDesign';
4
4
 
5
5
  import styles from './styles';
6
6
 
@@ -79,7 +79,7 @@ const AirQuality = memo(({ summaryDetail }) => {
79
79
  <View
80
80
  style={[styles.boxEmotion, { backgroundColor: outdoorColor }]}
81
81
  >
82
- <IconOutline name={outdoorIcon} size={35} />
82
+ <AntDesign name={outdoorIcon} size={35} />
83
83
  </View>
84
84
  <View
85
85
  style={[
@@ -121,7 +121,7 @@ const AirQuality = memo(({ summaryDetail }) => {
121
121
  {<SegmentedRoundChart data={outdoor} />}
122
122
  {!!advices?.length && (
123
123
  <View style={styles.boxHealth}>
124
- <IconOutline name="alert" size={20} style={styles.iconMargin} />
124
+ <AntDesign name="alert" size={20} style={styles.iconMargin} />
125
125
  <Text semibold color={Colors.Gray9} type="H4">
126
126
  {t('Health advices:')}
127
127
  </Text>
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import renderer, { act } from 'react-test-renderer';
2
+ import renderer, { act, create } from 'react-test-renderer';
3
3
  import MockAdapter from 'axios-mock-adapter';
4
4
 
5
5
  import { AccessibilityLabel } from '../../../../../configs/Constants';
@@ -13,17 +13,6 @@ import { Today } from '../../../../../commons';
13
13
 
14
14
  const mock = new MockAdapter(api.axiosInstance);
15
15
 
16
- const mockedNavigate = jest.fn();
17
-
18
- jest.mock('@react-navigation/native', () => {
19
- return {
20
- ...jest.requireActual('@react-navigation/native'),
21
- useNavigation: () => ({
22
- navigate: mockedNavigate,
23
- }),
24
- useFocusEffect: (func) => func(),
25
- };
26
- });
27
16
  const wrapComponent = (summaryDetail) => (
28
17
  <SCProvider initState={mockSCStore({})}>
29
18
  <PowerConsumption summaryDetail={summaryDetail} />
@@ -104,9 +93,44 @@ describe('Test PowerConsumption', () => {
104
93
  },
105
94
  };
106
95
 
107
- mock.onGet(API.VALUE_CONSUME.DISPLAY_HISTORY()).reply(200);
96
+ const data = [
97
+ {
98
+ config: 207,
99
+ data: [
100
+ {
101
+ x: 'Thu-20.06',
102
+ y: 7.94,
103
+ },
104
+ {
105
+ x: 'Wed-19.06',
106
+ y: 9.73,
107
+ },
108
+ {
109
+ x: 'Tue-18.06',
110
+ y: 4.11,
111
+ },
112
+ {
113
+ x: 'Mon-17.06',
114
+ y: 8.52,
115
+ },
116
+ {
117
+ x: 'Sun-16.06',
118
+ y: 5.72,
119
+ },
120
+ {
121
+ x: 'Sat-15.06',
122
+ y: 9.53,
123
+ },
124
+ {
125
+ x: 'Fri-14.06',
126
+ y: 11.83,
127
+ },
128
+ ],
129
+ },
130
+ ];
131
+ mock.onGet(API.VALUE_CONSUME.DISPLAY_HISTORY()).reply(200, data);
108
132
  await act(async () => {
109
- tree = await renderer.create(wrapComponent(summaryDetail));
133
+ tree = await create(wrapComponent(summaryDetail));
110
134
  });
111
135
  const instance = tree.root;
112
136
  const Todays = instance.findByType(Today);
@@ -1,4 +1,4 @@
1
- import React, { memo, useMemo, useEffect, useState } from 'react';
1
+ import React, { memo, useMemo, useState, useCallback } from 'react';
2
2
  import { StyleSheet } from 'react-native';
3
3
  import { useTranslations } from '../../../../hooks/Common/useTranslations';
4
4
  import moment from 'moment';
@@ -8,7 +8,7 @@ import Text from '../../../../commons/Text';
8
8
  import { Section, Today } from '../../../../commons';
9
9
  import ListQualityIndicator from '../../../../commons/Device/WaterQualitySensor/ListQualityIndicator';
10
10
  import PMSensorIndicator from '../../../../commons/Device/PMSensor/PMSensorIndicator';
11
- import HistoryChart from '../../../../commons/Device/HistoryChart';
11
+ import PowerConsumptionChart from '../../../../commons/Device/PowerConsumptionChart';
12
12
  import { AccessibilityLabel } from '../../../../configs/Constants';
13
13
  import { axiosGet } from '../../../../utils/Apis/axios';
14
14
  import VisualChart from '../../../Device/components/VisualChart';
@@ -20,8 +20,7 @@ const PowerConsumption = memo(({ summaryDetail }) => {
20
20
  const { volt, current, active_power, power_factor, total_power } =
21
21
  listConfigs || {};
22
22
  useWatchConfigs([volt, current, active_power, power_factor, total_power]);
23
- const [startDate, setStartDate] = useState(moment().subtract(6, 'days'));
24
- const [endDate, setEndDate] = useState(moment());
23
+
25
24
  const [groupBy, setGroupBy] = useState('date');
26
25
  const [getData, setData] = useState([]);
27
26
  const [chartConfig, setChartConfig] = useState({
@@ -32,13 +31,15 @@ const PowerConsumption = memo(({ summaryDetail }) => {
32
31
  return !!listConfigs;
33
32
  }, [listConfigs]);
34
33
 
35
- // eslint-disable-next-line react-hooks/exhaustive-deps
36
- const createDataItem = (id, color, title, measure) => ({
37
- id,
38
- color,
39
- title,
40
- measure,
41
- });
34
+ const createDataItem = useCallback(
35
+ (id, color, title, measure) => ({
36
+ id,
37
+ color,
38
+ title,
39
+ measure,
40
+ }),
41
+ []
42
+ );
42
43
 
43
44
  const configs = useMemo(() => {
44
45
  const data = [];
@@ -77,10 +78,10 @@ const PowerConsumption = memo(({ summaryDetail }) => {
77
78
  ),
78
79
  ]
79
80
  : [];
80
- }, [total_power]);
81
+ }, [createDataItem, total_power]);
81
82
 
82
- useEffect(() => {
83
- const fetchData = async () => {
83
+ const fetchData = useCallback(
84
+ async (startDate, endDate) => {
84
85
  let params = new URLSearchParams();
85
86
  params.append('config', total_power);
86
87
  params.append('group_by', groupBy);
@@ -97,11 +98,9 @@ const PowerConsumption = memo(({ summaryDetail }) => {
97
98
  if (success) {
98
99
  setData(data);
99
100
  }
100
- };
101
- if (total_power) {
102
- fetchData();
103
- }
104
- }, [startDate, endDate, total_power, groupBy]);
101
+ },
102
+ [groupBy, total_power]
103
+ );
105
104
 
106
105
  return (
107
106
  <>
@@ -123,22 +122,14 @@ const PowerConsumption = memo(({ summaryDetail }) => {
123
122
  </Text>
124
123
 
125
124
  <PMSensorIndicator data={dataTotal} style={styles.styleTotalPower} />
126
- {!!getData?.length && (
127
- <HistoryChart
125
+ {total_power && (
126
+ <PowerConsumptionChart
127
+ onChangeDate={fetchData}
128
128
  datas={getData}
129
129
  chartConfig={chartConfig}
130
130
  setChartConfig={setChartConfig}
131
- formatType={'date'}
132
- startDate={startDate}
133
- endDate={endDate}
134
- setEndDate={setEndDate}
135
- setStartDate={setStartDate}
136
131
  groupBy={groupBy}
137
132
  setGroupBy={setGroupBy}
138
- configuration={{
139
- type: 'horizontal_bar_chart',
140
- config: 'power_consumption',
141
- }}
142
133
  />
143
134
  )}
144
135
  </Section>