@eohjsc/react-native-smart-city 0.3.4 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/README.md +15 -36
  2. package/package.json +5 -9
  3. package/react-native-smart-city.podspec +0 -1
  4. package/src/commons/Action/ItemQuickAction.js +4 -16
  5. package/src/commons/Action/__test__/ItemQuickAction.test.js +6 -11
  6. package/src/commons/ActionGroup/ColorPickerTemplate.js +24 -37
  7. package/src/commons/ActionGroup/CurtainButtonTemplate.js +5 -10
  8. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +31 -12
  9. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +0 -4
  10. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
  11. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +0 -14
  12. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +0 -1
  13. package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +2 -8
  14. package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +10 -10
  15. package/src/commons/ActionGroup/OnOffTemplate/index.js +2 -3
  16. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +9 -7
  17. package/src/commons/ActionGroup/SliderRangeTemplate.js +2 -6
  18. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +3 -7
  19. package/src/commons/ActionGroup/StatesGridActionTemplate.js +8 -22
  20. package/src/commons/ActionGroup/TimerActionTemplate.js +3 -11
  21. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +5 -1
  22. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +4 -53
  23. package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +83 -3
  24. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
  25. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +78 -53
  26. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +20 -36
  27. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +57 -1
  28. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +6 -58
  29. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +1 -49
  30. package/src/commons/ActionGroup/__test__/index.test.js +4 -142
  31. package/src/commons/Auth/AccountList.js +1 -1
  32. package/src/commons/Automate/ItemAutomate.js +3 -1
  33. package/src/commons/Connecting/__test__/Connecting.test.js +2 -19
  34. package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +3 -7
  35. package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +11 -8
  36. package/src/commons/ConnectingProcess/__test__/Connecting.test.js +3 -136
  37. package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +2 -3
  38. package/src/commons/ConnectingProcess/index.js +25 -75
  39. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +13 -16
  40. package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
  41. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +5 -0
  42. package/src/commons/Device/ConnectedViewHeader.js +1 -1
  43. package/src/commons/Device/HistoryChart.js +3 -7
  44. package/src/commons/Device/ItemDevice.js +12 -19
  45. package/src/commons/Device/LinearChart.js +0 -15
  46. package/src/commons/Device/PMSensor/PMSensorIndicatior.js +12 -16
  47. package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +0 -3
  48. package/src/commons/Device/SonosSpeaker/index.js +1 -1
  49. package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +0 -1
  50. package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +2 -7
  51. package/src/commons/Explore/__test__/CityItem.test.js +54 -33
  52. package/src/commons/Form/CurrencyInput.js +1 -15
  53. package/src/commons/Form/TextInputPassword.js +1 -1
  54. package/src/commons/FullLoading/index.js +1 -2
  55. package/src/commons/Header/HeaderCustom.js +1 -2
  56. package/src/commons/HeaderAni/index.js +1 -6
  57. package/src/commons/HorizontalPicker/index.js +2 -2
  58. package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +6 -0
  59. package/src/commons/MediaPlayerDetail/index.js +47 -25
  60. package/src/commons/MenuActionAddnew/index.js +0 -1
  61. package/src/commons/MenuActionList/index.js +0 -1
  62. package/src/commons/MenuActionMore/index.js +1 -1
  63. package/src/commons/PreventAccess/index.js +1 -9
  64. package/src/commons/Sharing/MemberList.js +2 -10
  65. package/src/commons/Sharing/WrapHeaderScrollable.js +0 -2
  66. package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +1 -0
  67. package/src/commons/SubUnit/Favorites/index.js +3 -2
  68. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +35 -8
  69. package/src/commons/SubUnit/OneTap/index.js +2 -1
  70. package/src/commons/SubUnit/ShortDetail.js +9 -25
  71. package/src/commons/SubUnit/__test__/Item.test.js +1 -0
  72. package/src/commons/SubUnit/__test__/ShortDetail.test.js +2 -9
  73. package/src/commons/Unit/SharedUnit.js +0 -1
  74. package/src/commons/Unit/__test__/SharedUnit.test.js +183 -38
  75. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +13 -2
  76. package/src/commons/UnitSummary/ConfigHistoryChart.js +13 -22
  77. package/src/commons/WheelDateTimePicker/index.js +3 -4
  78. package/src/configs/API.js +143 -87
  79. package/src/configs/Constants.js +2 -57
  80. package/src/configs/SCConfig.js +0 -4
  81. package/src/context/actionType.ts +0 -8
  82. package/src/context/mockStore.ts +0 -10
  83. package/src/context/reducer.ts +2 -38
  84. package/src/hooks/Common/index.js +0 -2
  85. package/src/hooks/Common/useGetIdUser.js +5 -1
  86. package/src/hooks/Common/useSensorsStatus.js +4 -4
  87. package/src/hooks/useReceiveNotifications.js +5 -9
  88. package/src/iot/Monitor.js +2 -3
  89. package/src/iot/RemoteControl/Bluetooth.js +1 -1
  90. package/src/iot/RemoteControl/GoogleHome.js +49 -75
  91. package/src/iot/RemoteControl/Internet.js +1 -1
  92. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +48 -95
  93. package/src/iot/RemoteControl/__test__/Internet.test.js +7 -18
  94. package/src/iot/RemoteControl/__test__/LgThinq.test.js +177 -36
  95. package/src/iot/RemoteControl/index.js +52 -52
  96. package/src/navigations/UnitStack.js +20 -11
  97. package/src/screens/AQIGuide/index.js +1 -1
  98. package/src/screens/ActivityLog/FilterPopup.js +0 -2
  99. package/src/screens/ActivityLog/__test__/index.test.js +23 -38
  100. package/src/screens/ActivityLog/hooks/__test__/index.test.js +90 -51
  101. package/src/screens/ActivityLog/hooks/index.js +1 -1
  102. package/src/screens/ActivityLog/index.js +2 -2
  103. package/src/screens/AddCommon/SelectSubUnit.js +0 -1
  104. package/src/screens/AddCommon/SelectUnit.js +0 -1
  105. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +24 -13
  106. package/src/screens/AddCommon/__test__/SelectUnit.test.js +33 -9
  107. package/src/screens/AddLocationMaps/index.js +5 -9
  108. package/src/screens/AddNewAction/SelectAction.js +8 -8
  109. package/src/screens/AddNewAction/SelectSensorDevices.js +2 -8
  110. package/src/screens/AddNewAction/SetupSensor.js +7 -7
  111. package/src/screens/AddNewAction/__test__/SelectAction.test.js +91 -10
  112. package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +26 -40
  113. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +1 -3
  114. package/src/screens/AddNewAutoSmart/index.js +2 -5
  115. package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
  116. package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +34 -42
  117. package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +4 -0
  118. package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +22 -22
  119. package/src/screens/AddNewDevice/hooks/ConnectDevices.js +1 -1
  120. package/src/screens/AddNewDevice/index.js +0 -1
  121. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +17 -23
  122. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +4 -7
  123. package/src/screens/AddNewGateway/SelectGateway.js +0 -1
  124. package/src/screens/AddNewGateway/SetupGatewayWifi.js +0 -2
  125. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +6 -4
  126. package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +4 -0
  127. package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +29 -5
  128. package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +4 -0
  129. package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +4 -0
  130. package/src/screens/AddNewGateway/index.js +0 -1
  131. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +24 -10
  132. package/src/screens/AddNewOneTap/index.js +2 -3
  133. package/src/screens/AllCamera/index.js +4 -4
  134. package/src/screens/Automate/MultiUnits.js +8 -8
  135. package/src/screens/Automate/__test__/MultiUnits.test.js +9 -6
  136. package/src/screens/Automate/__test__/index.test.js +12 -7
  137. package/src/screens/Automate/index.js +3 -5
  138. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +8 -36
  139. package/src/screens/ConfirmUnitDeletion/index.js +1 -7
  140. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +22 -71
  141. package/src/screens/Device/EditDevice/index.js +15 -17
  142. package/src/screens/Device/__test__/detail.test.js +86 -33
  143. package/src/screens/Device/components/DetailHistoryChart.js +1 -1
  144. package/src/screens/Device/components/SensorConnectStatusViewHeader.js +0 -1
  145. package/src/screens/Device/components/SensorDisplayItem.js +2 -5
  146. package/src/screens/Device/detail.js +24 -80
  147. package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
  148. package/src/screens/Device/hooks/useFavoriteDevice.js +9 -5
  149. package/src/screens/DeviceInfo/__test__/index.test.js +2 -0
  150. package/src/screens/EditActionsList/index.js +1 -1
  151. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +3 -6
  152. package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +19 -7
  153. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +2 -20
  154. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +23 -40
  155. package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
  156. package/src/screens/EmergencySetting/index.js +1 -4
  157. package/src/screens/EnterPassword/__test__/EnterPassword.test.js +25 -41
  158. package/src/screens/Explore/index.js +0 -2
  159. package/src/screens/GuestInfo/__test__/index.test.js +41 -14
  160. package/src/screens/GuestInfo/components/RecurringDetail.js +0 -1
  161. package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
  162. package/src/screens/HanetCamera/Detail.js +1 -1
  163. package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +12 -8
  164. package/src/screens/HanetCamera/__test__/Detail.test.js +42 -27
  165. package/src/screens/HanetCamera/__test__/ManageAccess.test.js +5 -8
  166. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +32 -10
  167. package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -3
  168. package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +35 -43
  169. package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +21 -10
  170. package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +11 -11
  171. package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
  172. package/src/screens/ManageAccess/__test__/ManageAccess.test.js +22 -33
  173. package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +45 -44
  174. package/src/screens/ManageAccess/hooks/index.js +4 -7
  175. package/src/screens/ManageAccess/index.js +1 -2
  176. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +12 -35
  177. package/src/screens/MoveToAnotherSubUnit/index.js +6 -6
  178. package/src/screens/Notification/__test__/Notification.test.js +25 -14
  179. package/src/screens/Notification/__test__/NotificationItem.test.js +7 -8
  180. package/src/screens/Notification/components/NotificationItem.js +20 -17
  181. package/src/screens/Notification/index.js +2 -9
  182. package/src/screens/PlayBackCamera/Timer.js +2 -2
  183. package/src/screens/PlayBackCamera/__test__/index.test.js +2 -87
  184. package/src/screens/PlayBackCamera/index.js +6 -22
  185. package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +20 -7
  186. package/src/screens/ScanChipQR/components/QRScan/index.js +0 -1
  187. package/src/screens/ScanChipQR/hooks/index.js +16 -15
  188. package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +24 -8
  189. package/src/screens/ScriptDetail/__test__/index.test.js +86 -17
  190. package/src/screens/ScriptDetail/index.js +14 -19
  191. package/src/screens/SelectUnit/__test__/index.test.js +55 -12
  192. package/src/screens/SelectUnit/index.js +4 -9
  193. package/src/screens/SetSchedule/index.js +11 -15
  194. package/src/screens/SharedUnit/__test__/TabHeader.test.js +2 -0
  195. package/src/screens/SharedUnit/index.js +0 -2
  196. package/src/screens/Sharing/Components/SensorItem.js +12 -10
  197. package/src/screens/Sharing/InfoMemberUnit.js +1 -1
  198. package/src/screens/Sharing/MemberList.js +11 -12
  199. package/src/screens/Sharing/SelectPermission.js +76 -121
  200. package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +29 -47
  201. package/src/screens/Sharing/__test__/MemberList.test.js +127 -13
  202. package/src/screens/Sharing/__test__/SelectPermission.test.js +38 -28
  203. package/src/screens/Sharing/__test__/SelectUser.test.js +38 -17
  204. package/src/screens/Sharing/hooks/index.js +0 -3
  205. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +2 -3
  206. package/src/screens/SmartIr/components/SelectBrand.js +1 -1
  207. package/src/screens/SubUnit/AddSubUnit.js +17 -23
  208. package/src/screens/SubUnit/Detail.js +2 -1
  209. package/src/screens/SubUnit/EditSubUnit.js +13 -15
  210. package/src/screens/SubUnit/ManageSubUnit.js +7 -13
  211. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +89 -29
  212. package/src/screens/SubUnit/__test__/Detail.test.js +8 -31
  213. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +89 -21
  214. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +1 -27
  215. package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +45 -48
  216. package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
  217. package/src/screens/SyncLGDevice/AddLGDevice.js +0 -1
  218. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +91 -22
  219. package/src/screens/TDSGuide/index.js +1 -4
  220. package/src/screens/UVIndexGuide/index.js +1 -1
  221. package/src/screens/Unit/ChooseLocation.js +14 -7
  222. package/src/screens/Unit/Detail.js +75 -30
  223. package/src/screens/Unit/ManageUnit.js +0 -1
  224. package/src/screens/Unit/SelectAddress.js +23 -45
  225. package/src/screens/Unit/SmartAccount.js +4 -4
  226. package/src/screens/Unit/Station/index.js +0 -4
  227. package/src/screens/Unit/Summaries.js +2 -18
  228. package/src/screens/Unit/__test__/CheckSendEmail.test.js +29 -24
  229. package/src/screens/Unit/__test__/ChooseLocation.test.js +14 -27
  230. package/src/screens/Unit/__test__/Detail.test.js +200 -99
  231. package/src/screens/Unit/__test__/ManageUnit.test.js +42 -18
  232. package/src/screens/Unit/__test__/SelectAddress.test.js +49 -159
  233. package/src/screens/Unit/__test__/SmartAccount.test.js +9 -17
  234. package/src/screens/Unit/__test__/SmartAccountItem.test.js +1 -0
  235. package/src/screens/Unit/components/MyUnitDevice/index.js +4 -4
  236. package/src/screens/Unit/components/SharedUnit/index.js +0 -1
  237. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
  238. package/src/screens/Unit/components/__test__/SharedUnit.test.js +34 -31
  239. package/src/screens/Unit/styles.js +0 -4
  240. package/src/screens/UnitSummary/__test__/index.test.js +30 -91
  241. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +2 -31
  242. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +4 -7
  243. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +13 -2
  244. package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +1 -0
  245. package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +16 -14
  246. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -11
  247. package/src/screens/UnitSummary/components/RunningDevices/index.js +10 -7
  248. package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
  249. package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +2 -10
  250. package/src/screens/UnitSummary/index.js +1 -15
  251. package/src/screens/WaterQualityGuide/index.js +1 -1
  252. package/src/utils/Apis/axios.js +31 -54
  253. package/src/utils/Converter/time.js +18 -0
  254. package/src/utils/I18n/translations/en.json +1 -7
  255. package/src/utils/I18n/translations/vi.json +1 -8
  256. package/src/utils/Route/index.js +0 -1
  257. package/src/utils/Utils.js +7 -11
  258. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +0 -24
  259. package/src/commons/ActionGroup/__test__/NumberUpDownTemplateWithNullConfigValue.test.js +0 -60
  260. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +0 -77
  261. package/src/commons/Calendar/__test__/Calendar.test.js +0 -33
  262. package/src/commons/Device/Hanet/ItemHanetDevice.test.js +0 -58
  263. package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +0 -25
  264. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +0 -96
  265. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +0 -39
  266. package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +0 -118
  267. package/src/commons/FieldTemplate/ChooseUserField/index.js +0 -62
  268. package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +0 -30
  269. package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +0 -90
  270. package/src/commons/FieldTemplate/PasscodeField/index.js +0 -43
  271. package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +0 -13
  272. package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +0 -179
  273. package/src/commons/FieldTemplate/ScheduleField/index.js +0 -176
  274. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +0 -62
  275. package/src/hooks/Common/useGGHomeDeviceConnected.js +0 -16
  276. package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +0 -198
  277. package/src/hooks/IoT/__test__/useRemoteControl.test.js +0 -198
  278. package/src/hooks/IoT/index.js +0 -4
  279. package/src/hooks/IoT/useGGHomeConnection.js +0 -91
  280. package/src/hooks/IoT/useRemoteControl.js +0 -79
  281. package/src/hooks/index.js +0 -4
  282. package/src/navigations/UnitStackStyles.js +0 -21
  283. package/src/screens/Sharing/__test__/MemberList2.test.js +0 -80
  284. package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +0 -28
  285. package/src/screens/SideMenuDetail/__test__/index.test.js +0 -154
  286. package/src/screens/SideMenuDetail/index.js +0 -148
  287. package/src/screens/Unit/__test__/Summaries.test.js +0 -100
  288. package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +0 -36
  289. package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -54
  290. package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +0 -50
  291. package/src/utils/Permission/common.js +0 -67
  292. package/src/utils/Setting/Location.js +0 -30
  293. package/src/utils/__test__/Utils.test.js +0 -12
@@ -5,6 +5,7 @@ import { Card } from '../../../commons/CardShadow';
5
5
  import { TESTID } from '../../../configs/Constants';
6
6
  import { useTranslations } from '../../../hooks/Common/useTranslations';
7
7
  import { DetailHistoryChart } from './DetailHistoryChart';
8
+ import { sendRemoteCommand } from '../../../iot/RemoteControl';
8
9
  import CurrentRainSensor from '../../../commons/Device/RainningSensor/CurrentRainSensor';
9
10
  import PMSensorIndicatior from '../../../commons/Device/PMSensor/PMSensorIndicatior';
10
11
  import Anemometer from '../../../commons/Device/WindSpeed/Anemometer';
@@ -21,7 +22,6 @@ import SmartIr from '../../../screens/SmartIr';
21
22
  import { standardizeCameraScreenSize } from '../../../utils/Utils';
22
23
  import { Device } from '../../../configs';
23
24
  import { useSCContextSelector } from '../../../context';
24
- import { useRemoteControl } from '../../../hooks/IoT';
25
25
 
26
26
  const { standardizeWidth, standardizeHeight } = standardizeCameraScreenSize(
27
27
  Device.screenWidth - 32
@@ -40,14 +40,11 @@ export const SensorDisplayItem = ({
40
40
  }) => {
41
41
  const t = useTranslations();
42
42
  const userId = useSCContextSelector((state) => state.auth.account.user.id);
43
-
44
- const sendRemoteCommand = useRemoteControl();
45
-
46
43
  const doAction = useCallback(
47
44
  (action, data, actionName) => {
48
45
  sendRemoteCommand(sensor, action, data, userId, actionName);
49
46
  },
50
- [sensor, userId, sendRemoteCommand]
47
+ [sensor, userId]
51
48
  );
52
49
  if (item.configuration.type === 'compass') {
53
50
  setShowWindDirection(true);
@@ -12,7 +12,7 @@ import { get } from 'lodash';
12
12
  import { useSelector } from 'react-redux';
13
13
  import { IconFill, IconOutline } from '@ant-design/icons-react-native';
14
14
  import { Icon } from '@ant-design/react-native';
15
- import Routes from '../../utils/Route';
15
+
16
16
  import { useCountUp } from './hooks/useCountUp';
17
17
  import { getData as getLocalData } from '../../utils/Storage';
18
18
  import { API, Colors } from '../../configs';
@@ -32,19 +32,15 @@ import {
32
32
  import { useFavoriteDevice } from './hooks/useFavoriteDevice';
33
33
  import BottomButtonView from '../../commons/BottomButtonView';
34
34
  import Text from '../../commons/Text';
35
+ import { transformDatetime } from '../../utils/Converter/time';
35
36
  import { AlertAction, ButtonPopup, MenuActionMore } from '../../commons';
36
37
  import { TESTID } from '../../configs/Constants';
37
-
38
+ import Routes from '../../utils/Route';
38
39
  import { usePopover } from '../../hooks/Common';
39
40
  import { useConfigGlobalState } from '../../iot/states';
40
41
  import { useNavigation } from '@react-navigation/native';
41
42
  import styles from './styles';
42
- import {
43
- useIsOwnerOfUnit,
44
- useBoolean,
45
- useGGHomeDeviceConnected,
46
- } from '../../hooks/Common';
47
- import { useGGHomeConnection } from '../../hooks/IoT';
43
+ import { useIsOwnerOfUnit, useBoolean } from '../../hooks/Common';
48
44
  import { SensorDisplayItem } from './components/SensorDisplayItem';
49
45
  import { useSCContextSelector } from '../../context';
50
46
  import { EmergencyCountdown } from './components/EmergencyCountdown';
@@ -52,7 +48,6 @@ import { SensorConnectStatusViewHeader } from './components/SensorConnectStatusV
52
48
  import { useDisconnectedDevice } from './hooks/useDisconnectedDevice';
53
49
  import { Card } from '../../commons/CardShadow';
54
50
  import PreventAccess from '../../commons/PreventAccess';
55
- import { notImplemented } from '../../utils/Utils';
56
51
 
57
52
  const DeviceDetail = ({ route }) => {
58
53
  const t = useTranslations();
@@ -71,7 +66,8 @@ const DeviceDetail = ({ route }) => {
71
66
  // eslint-disable-next-line no-unused-vars
72
67
  const [configValues, setConfigValues] = useConfigGlobalState('configValues');
73
68
 
74
- const { unitData, unitId, sensorData, sensorId } = route.params;
69
+ const { unitData, unitId, sensorData, sensorId, isGGHomeConnected } =
70
+ route.params;
75
71
  const [unit, setUnit] = useState(unitData || { id: unitId });
76
72
  const [sensor, setSensor] = useState(sensorData || { id: sensorId });
77
73
  const [station, setStation] = useState(sensor?.station);
@@ -86,14 +82,13 @@ const DeviceDetail = ({ route }) => {
86
82
  displayTemplate: true,
87
83
  });
88
84
  const [serverDown, setServerDown] = useState(false);
89
- const [sideMenu, setSideMenu] = useState([]);
85
+
90
86
  const isNetworkConnected = useSCContextSelector(
91
87
  (state) => state.app.isNetworkConnected
92
88
  );
93
89
  const isBluetoothEnabled = useSCContextSelector((state) => {
94
90
  return state.app.isBluetoothEnabled;
95
91
  });
96
- const { isConnected: isGGHomeConnected } = useGGHomeDeviceConnected(sensor);
97
92
 
98
93
  const isDeviceConnectedViaBle = useMemo(
99
94
  () =>
@@ -136,8 +131,10 @@ const DeviceDetail = ({ route }) => {
136
131
  [display.items]
137
132
  );
138
133
 
139
- const { isFavorite, addToFavorites, removeFromFavorites } =
140
- useFavoriteDevice(sensor);
134
+ const { isFavorite, addToFavorites, removeFromFavorites } = useFavoriteDevice(
135
+ unit,
136
+ sensor
137
+ );
141
138
 
142
139
  const currentUserId = useSelector((state) =>
143
140
  get(state, 'auth.account.user.id', 0)
@@ -162,24 +159,9 @@ const DeviceDetail = ({ route }) => {
162
159
  }
163
160
  }, [fetchUnitDetail, unitId, unitData]);
164
161
 
165
- const { connectGoogleHome } = useGGHomeConnection();
166
-
167
- useEffect(() => {
168
- if (
169
- unit.remote_control_options &&
170
- unit.remote_control_options.googlehome?.length &&
171
- isNetworkConnected
172
- ) {
173
- (async () => {
174
- await connectGoogleHome(unit.remote_control_options.googlehome);
175
- })();
176
- }
177
- // eslint-disable-next-line react-hooks/exhaustive-deps
178
- }, [unit, isNetworkConnected]);
179
-
180
162
  const fetchSensorDetail = useCallback(async () => {
181
163
  const { success, data, resp_status } = await axiosGet(
182
- API.DEVICE.SENSOR_DETAIL(sensorId)
164
+ API.SENSOR.SENSOR_DETAIL(sensorId)
183
165
  );
184
166
  if (success) {
185
167
  setSensor(data);
@@ -205,20 +187,19 @@ const DeviceDetail = ({ route }) => {
205
187
  }
206
188
 
207
189
  const { success, data } = await axiosGet(
208
- API.DEVICE.DISPLAY(sensor?.id),
190
+ API.SENSOR.DISPLAY(sensor?.id),
209
191
  {},
210
192
  true
211
193
  );
212
-
213
194
  if (success) {
214
195
  setDisplay(data);
215
196
  setServerDown(false);
216
197
  if (data.items.length) {
217
198
  const config = data.items[0].configuration;
218
- if (Object.prototype.hasOwnProperty.call(config, 'max_value')) {
199
+ if (config.hasOwnProperty('max_value')) {
219
200
  setMaxValue(config.max_value);
220
201
  }
221
- if (Object.prototype.hasOwnProperty.call(config, 'device')) {
202
+ if (config.hasOwnProperty('device')) {
222
203
  // for emergency
223
204
  setDeviceId(config.device.id);
224
205
  const last_event = config.device.last_event;
@@ -229,14 +210,11 @@ const DeviceDetail = ({ route }) => {
229
210
  }
230
211
  }
231
212
  }
232
- if (data?.side_menu_items?.length) {
233
- setSideMenu(data.side_menu_items);
234
- }
235
213
  }
236
214
  setLoading((preState) => ({ ...preState, displayTemplate: false }));
237
215
 
238
216
  const controlResult = await axiosGet(
239
- API.DEVICE.REMOTE_CONTROL_OPTIONS(sensor?.id),
217
+ API.SENSOR.REMOTE_CONTROL_OPTIONS(sensor?.id),
240
218
  {},
241
219
  true
242
220
  );
@@ -327,19 +305,6 @@ const DeviceDetail = ({ route }) => {
327
305
  text: t('activity_log'),
328
306
  });
329
307
  }
330
-
331
- sideMenu.forEach((el) => {
332
- menuItems.push({
333
- route: Routes.SideMenuDetail,
334
- data: {
335
- unit,
336
- sensor,
337
- side_menu: el,
338
- },
339
- text: el.name,
340
- });
341
- });
342
-
343
308
  menuItems.push({
344
309
  route: Routes.DeviceInfo,
345
310
  text: t('device_info'),
@@ -356,13 +321,6 @@ const DeviceDetail = ({ route }) => {
356
321
  text: t('auto_lock'),
357
322
  });
358
323
  }
359
- menuItems.push({
360
- route: Routes.SmartLockStack,
361
- data: {
362
- screen: Routes.SetupGeneratePasscode,
363
- },
364
- text: t('setup_generate_passcode'),
365
- });
366
324
  if (isOwner && isShowSetUpSmartLock) {
367
325
  menuItems.push({
368
326
  route: Routes.SmartLockStack,
@@ -403,7 +361,6 @@ const DeviceDetail = ({ route }) => {
403
361
  sensor,
404
362
  unit,
405
363
  sensorName,
406
- sideMenu,
407
364
  station,
408
365
  emergencyDeviceId,
409
366
  addToFavorites,
@@ -413,7 +370,7 @@ const DeviceDetail = ({ route }) => {
413
370
  const { countUpStr } = useCountUp(lastEvent.reportedAt);
414
371
 
415
372
  useEffect(() => {
416
- if (controlOptions?.bluetooth) {
373
+ if (controlOptions.bluetooth) {
417
374
  const bluetooth = controlOptions.bluetooth;
418
375
  scanBluetoothDevices([bluetooth.address]);
419
376
  }
@@ -425,17 +382,8 @@ const DeviceDetail = ({ route }) => {
425
382
 
426
383
  const onRefresh = useCallback(() => {
427
384
  fetchDataDeviceDetail();
428
- if (
429
- unit.remote_control_options &&
430
- unit.remote_control_options.googlehome?.length &&
431
- isNetworkConnected
432
- ) {
433
- (async () => {
434
- await connectGoogleHome(unit.remote_control_options.googlehome);
435
- })();
436
- }
437
385
  // eslint-disable-next-line react-hooks/exhaustive-deps
438
- }, [sensor, unit, isNetworkConnected, fetchDataDeviceDetail]);
386
+ }, [sensor, fetchDataDeviceDetail]);
439
387
 
440
388
  const getData = useCallback(
441
389
  (item) => {
@@ -462,7 +410,6 @@ const DeviceDetail = ({ route }) => {
462
410
  if (item.type !== 'value') {
463
411
  return;
464
412
  }
465
-
466
413
  if (!item.configuration) {
467
414
  return;
468
415
  }
@@ -480,7 +427,7 @@ const DeviceDetail = ({ route }) => {
480
427
 
481
428
  const fetchValues = async () => {
482
429
  const { success, data, resp_status } = await axiosGet(
483
- API.DEVICE.DISPLAY_VALUES_V2(sensor?.id),
430
+ API.SENSOR.DISPLAY_VALUES_V2(sensor?.id),
484
431
  {
485
432
  params: params,
486
433
  }
@@ -488,10 +435,7 @@ const DeviceDetail = ({ route }) => {
488
435
  if (success) {
489
436
  setDisplayValues(data.configs);
490
437
  setConnected(data.is_connected);
491
- data.last_updated = data.last_updated
492
- ? moment(data.last_updated)
493
- : data.last_updated;
494
-
438
+ transformDatetime(data, ['last_updated']);
495
439
  setLastUpdated(data.last_updated);
496
440
  } else if (resp_status >= 500) {
497
441
  setServerDown(true);
@@ -511,7 +455,7 @@ const DeviceDetail = ({ route }) => {
511
455
  useEffect(() => {
512
456
  setDisplayValues((currentDisplayValues) => {
513
457
  for (const [configId, value] of Object.entries(configValues)) {
514
- const intId = parseInt(configId, 10);
458
+ const intId = parseInt(configId);
515
459
  const index = currentDisplayValues.findIndex(
516
460
  (element) => element.id === intId
517
461
  );
@@ -635,12 +579,12 @@ const DeviceDetail = ({ route }) => {
635
579
 
636
580
  const getDataFromLocal = async () => {
637
581
  const displayData = await getLocalData(
638
- `@CACHE_REQUEST_${API.DEVICE.DISPLAY(sensor?.id)}`
582
+ `@CACHE_REQUEST_${API.SENSOR.DISPLAY(sensor?.id)}`
639
583
  );
640
584
  displayData && setDisplay(JSON.parse(displayData));
641
585
 
642
586
  const controlOptionData = await getLocalData(
643
- `@CACHE_REQUEST_${API.DEVICE.REMOTE_CONTROL_OPTIONS(sensor?.id)}`
587
+ `@CACHE_REQUEST_${API.SENSOR.REMOTE_CONTROL_OPTIONS(sensor?.id)}`
644
588
  );
645
589
  controlOptionData && setControlOptions(JSON.parse(controlOptionData));
646
590
  setLoading((preState) => ({ ...preState, displayTemplate: false }));
@@ -652,7 +596,7 @@ const DeviceDetail = ({ route }) => {
652
596
  } else if (item.doAction) {
653
597
  item.doAction();
654
598
  } else {
655
- notImplemented(t);
599
+ alert(t('feature_under_development'));
656
600
  }
657
601
  };
658
602
 
@@ -47,7 +47,7 @@ export const useDisconnectedDevice = (
47
47
  );
48
48
 
49
49
  const checkNetworkConnect = useCallback(
50
- async () => {
50
+ async (isNetworkConnected, isBluetoothEnabled, serverDown) => {
51
51
  if (!isDeviceHasBle) {
52
52
  return;
53
53
  }
@@ -72,10 +72,10 @@ export const useDisconnectedDevice = (
72
72
  }
73
73
  },
74
74
  // eslint-disable-next-line react-hooks/exhaustive-deps
75
- [isDeviceHasBle, isNetworkConnected, isBluetoothEnabled, serverDown]
75
+ [isDeviceHasBle]
76
76
  );
77
77
 
78
78
  useEffect(() => {
79
- checkNetworkConnect();
80
- }, [checkNetworkConnect]);
79
+ checkNetworkConnect(isNetworkConnected, isBluetoothEnabled, serverDown);
80
+ }, [isNetworkConnected, isBluetoothEnabled, checkNetworkConnect, serverDown]);
81
81
  };
@@ -4,7 +4,7 @@ import { SCContext, useSCContextSelector } from '../../../context';
4
4
  import { Action } from '../../../context/actionType';
5
5
  import { axiosPost } from '../../../utils/Apis/axios';
6
6
 
7
- export const useFavoriteDevice = (device) => {
7
+ export const useFavoriteDevice = (unit, device) => {
8
8
  const { setAction } = useContext(SCContext);
9
9
  const favoriteDeviceIds = useSCContextSelector(
10
10
  (state) => state.unit.favoriteDeviceIds
@@ -14,17 +14,21 @@ export const useFavoriteDevice = (device) => {
14
14
 
15
15
  const addToFavorites = useCallback(async () => {
16
16
  const { success } = await axiosPost(
17
- API.DEVICE.ADD_TO_FAVOURITES(device?.id)
17
+ API.SENSOR.ADD_TO_FAVOURITES(unit?.id, device?.station?.id, device?.id)
18
18
  );
19
19
  success && setAction(Action.ADD_DEVICE_TO_FAVORITES, device.id);
20
- }, [device, setAction]);
20
+ }, [unit, device, setAction]);
21
21
 
22
22
  const removeFromFavorites = useCallback(async () => {
23
23
  const { success } = await axiosPost(
24
- API.DEVICE.REMOVE_FROM_FAVOURITES(device?.id)
24
+ API.SENSOR.REMOVE_FROM_FAVOURITES(
25
+ unit?.id,
26
+ device?.station?.id,
27
+ device?.id
28
+ )
25
29
  );
26
30
  success && setAction(Action.REMOVE_DEVICE_FROM_FAVORITES, device.id);
27
- }, [device, setAction]);
31
+ }, [unit, device, setAction]);
28
32
 
29
33
  return {
30
34
  isFavorite,
@@ -7,6 +7,8 @@ import { View } from 'react-native';
7
7
  import { SCProvider } from '../../../context';
8
8
  import { mockSCStore } from '../../../context/mockStore';
9
9
 
10
+ jest.mock('axios');
11
+
10
12
  jest.mock('@react-navigation/core', () => {
11
13
  return {
12
14
  ...jest.requireActual('@react-navigation/core'),
@@ -142,7 +142,7 @@ const EditActionsList = () => {
142
142
  data={actionsList}
143
143
  renderItem={renderItem}
144
144
  keyExtractor={(item) => `draggable-item-${item.key}`}
145
- onDragEnd={({ data: dragData }) => setActionList(dragData)}
145
+ onDragEnd={({ data }) => setActionList(data)}
146
146
  extraData={actionsList}
147
147
  containerStyle={styles.containerStyle}
148
148
  />
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useEffect, useState } from 'react';
2
- import { SafeAreaView, StyleSheet, View, Platform } from 'react-native';
2
+ import { SafeAreaView, StyleSheet, View } from 'react-native';
3
3
  import { IconOutline } from '@ant-design/icons-react-native';
4
4
  import { useNavigation } from '@react-navigation/native';
5
5
  import { useTranslations } from '../../hooks/Common/useTranslations';
@@ -71,11 +71,11 @@ export const EmergencyContactsSelectContacts = ({ route }) => {
71
71
  return (
72
72
  <SafeAreaView style={styles.container}>
73
73
  <WrapHeaderScrollable title={t('select_contacts')} loading={loading}>
74
- <Section type={'border'} style={styles.section}>
74
+ <Section type={'border'}>
75
75
  {dataContact.map((contact, index) => (
76
76
  <RowUser
77
77
  key={contact.id.toString()}
78
- testID={TESTID.EMERGENCY_SELECT_CONTACT + index}
78
+ testID={TESTID.EMERGENCY_SELECT_CONTACT}
79
79
  index={index}
80
80
  leftIcon={
81
81
  <IconOutline name={'user'} size={20} color={Colors.White} />
@@ -116,9 +116,6 @@ const styles = StyleSheet.create({
116
116
  flex: 1,
117
117
  backgroundColor: Colors.Gray2,
118
118
  },
119
- section: {
120
- marginTop: Platform.OS === 'ios' ? 40 : 0,
121
- },
122
119
  buttonRemove: {
123
120
  height: 40,
124
121
  width: 40,
@@ -2,15 +2,13 @@ import React from 'react';
2
2
  import { TextInput } from 'react-native';
3
3
  import { act, create } from 'react-test-renderer';
4
4
  import { EmergencyContactsAddNew } from '../EmergencyContactsAddNew';
5
- import MockAdapter from 'axios-mock-adapter';
5
+ import axios from 'axios';
6
6
  import Toast from 'react-native-toast-message';
7
7
  import { ViewButtonBottom } from '../../../commons';
8
8
  import { TESTID } from '../../../configs/Constants';
9
9
  import { getTranslate } from '../../../utils/I18n';
10
10
  import { SCProvider } from '../../../context';
11
11
  import { mockSCStore } from '../../../context/mockStore';
12
- import api from '../../../utils/Apis/axios';
13
- import { API } from '../../../configs';
14
12
 
15
13
  const wrapComponent = (route) => (
16
14
  <SCProvider initState={mockSCStore({})}>
@@ -22,7 +20,7 @@ jest.mock('react-native-toast-message');
22
20
 
23
21
  const mockedGoBack = jest.fn();
24
22
 
25
- const mock = new MockAdapter(api.axiosInstance);
23
+ jest.mock('axios');
26
24
 
27
25
  jest.mock('@react-navigation/native', () => {
28
26
  return {
@@ -107,7 +105,13 @@ describe('test EmergencyContactAddNew', () => {
107
105
  });
108
106
 
109
107
  test('onSave success', async () => {
110
- mock.onPost(API.EMERGENCY_BUTTON.CREATE_CONTACT()).reply(200);
108
+ const response = {
109
+ status: 200,
110
+ data: {},
111
+ };
112
+ axios.post.mockImplementation(async () => {
113
+ return response;
114
+ });
111
115
 
112
116
  await act(async () => {
113
117
  tree = await create(wrapComponent(route));
@@ -123,14 +127,22 @@ describe('test EmergencyContactAddNew', () => {
123
127
  });
124
128
 
125
129
  test('onSave fail', async () => {
130
+ const response = {
131
+ data: {},
132
+ };
133
+ axios.post.mockImplementation(async () => {
134
+ return response;
135
+ });
136
+
126
137
  await act(async () => {
127
138
  tree = await create(wrapComponent(route));
128
139
  });
129
140
  const instance = tree.root;
130
141
  const viewButtonBottom = instance.findByType(ViewButtonBottom);
131
142
 
132
- mock.onPost(API.EMERGENCY_BUTTON.CREATE_CONTACT()).reply(400);
133
- await viewButtonBottom.props.onRightClick();
143
+ await act(async () => {
144
+ await viewButtonBottom.props.onRightClick();
145
+ });
134
146
  expect(Toast.show).toHaveBeenCalledWith({
135
147
  type: 'error',
136
148
  position: 'bottom',
@@ -1,19 +1,13 @@
1
1
  import React from 'react';
2
2
  import { TouchableOpacity } from 'react-native';
3
3
  import { act, create } from 'react-test-renderer';
4
- import MockAdapter from 'axios-mock-adapter';
5
-
6
4
  import Routes from '../../../utils/Route';
7
- import { API } from '../../../configs';
8
5
  import { AlertAction } from '../../../commons';
9
6
  import { EmergencyContactsList } from '../EmergencyContactsList';
10
7
  import { TESTID } from '../../../configs/Constants';
11
8
  import { getTranslate } from '../../../utils/I18n';
12
9
  import { SCProvider } from '../../../context';
13
10
  import { mockSCStore } from '../../../context/mockStore';
14
- import api from '../../../utils/Apis/axios';
15
-
16
- const mock = new MockAdapter(api.axiosInstance);
17
11
 
18
12
  const wrapComponent = (route) => (
19
13
  <SCProvider initState={mockSCStore({})}>
@@ -29,7 +23,7 @@ jest.mock('@react-navigation/native', () => {
29
23
  useNavigation: () => ({
30
24
  navigate: mockedNavigate,
31
25
  }),
32
- useIsFocused: () => true,
26
+ useIsFocused: jest.fn(),
33
27
  };
34
28
  });
35
29
 
@@ -56,23 +50,11 @@ describe('test EmergencyContactList', () => {
56
50
  });
57
51
  const instance = tree.root;
58
52
  const alertAction = instance.findByType(AlertAction);
59
- mock.onDelete(API.EMERGENCY_BUTTON.REMOVE_CONTACTS()).reply(204);
60
- act(() => {
61
- alertAction.props.rightButtonClick();
62
- });
63
- expect(alertAction.props.visible).toBe(false);
64
- });
65
53
 
66
- test('handleRemove failure', async () => {
67
- act(() => {
68
- tree = create(wrapComponent(route));
69
- });
70
- const instance = tree.root;
71
- const alertAction = instance.findByType(AlertAction);
72
- mock.onDelete(API.EMERGENCY_BUTTON.REMOVE_CONTACTS()).reply(400);
73
54
  act(() => {
74
55
  alertAction.props.rightButtonClick();
75
56
  });
57
+
76
58
  expect(alertAction.props.visible).toBe(false);
77
59
  });
78
60
 
@@ -1,18 +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 Toast from 'react-native-toast-message';
5
-
3
+ import axios from 'axios';
6
4
  import { EmergencyContactsSelectContacts } from '../EmergencyContactsSelectContacts';
7
5
  import { TESTID } from '../../../configs/Constants';
8
6
  import { SCProvider } from '../../../context';
9
7
  import { mockSCStore } from '../../../context/mockStore';
10
8
  import { API } from '../../../configs';
11
9
  import { ViewButtonBottom } from '../../../commons';
12
- import api from '../../../utils/Apis/axios';
13
- import { getTranslate } from '../../../utils/I18n';
14
10
 
15
- const mock = new MockAdapter(api.axiosInstance);
11
+ jest.mock('axios');
16
12
 
17
13
  const mockedNavigate = jest.fn();
18
14
  jest.mock('@react-navigation/native', () => {
@@ -49,6 +45,7 @@ describe('test EmergencyContactsSelectContacts', () => {
49
45
  tree = create(wrapComponent(route));
50
46
  });
51
47
  const instance = tree.root;
48
+
52
49
  const rowUser = instance.findAllByProps(
53
50
  (item) => item.props.testID === TESTID.EMERGENCY_SELECT_CONTACT
54
51
  );
@@ -57,41 +54,32 @@ describe('test EmergencyContactsSelectContacts', () => {
57
54
 
58
55
  test('render emergencyContactsSelectContacts success', async () => {
59
56
  jest.useFakeTimers();
60
- mock.onGet(API.SHARE.UNITS_MEMBERS(1, 1)).reply(200, {
61
- id: 1,
62
- name: 'test',
63
- phone_number: 1,
64
- });
65
- act(() => {
66
- tree = create(wrapComponent(route));
67
- });
68
- const instance = tree.root;
69
- const rowUser = instance.findAllByProps(
70
- (item) => item.props.testID === TESTID.EMERGENCY_SELECT_CONTACT + 0
71
- );
72
- expect(rowUser[0]).toBeDefined();
73
- });
57
+ const response = {
58
+ status: 200,
59
+ data: {
60
+ data: {},
61
+ },
62
+ };
63
+ axios.get.mockImplementation(() => Promise.resolve(response));
74
64
 
75
- test('test onSave emergencyContactsSelectContacts', async () => {
76
- mock.onPost(API.EMERGENCY_BUTTON.CREATE_BATCH()).reply(200);
77
65
  act(() => {
78
66
  tree = create(wrapComponent(route));
79
67
  });
80
- const instance = tree.root;
81
- const viewButtonBottom = instance.findByType(ViewButtonBottom);
82
- await act(async () => {
83
- viewButtonBottom.props.onRightClick();
84
- });
85
- expect(Toast.show).toBeCalledWith({
86
- type: 'success',
87
- position: 'bottom',
88
- text1: getTranslate('en', 'saving_contact_successful'),
89
- visibilityTime: 1000,
68
+ act(() => {
69
+ jest.runOnlyPendingTimers();
90
70
  });
71
+ expect(axios.get).toHaveBeenCalled();
72
+ expect(axios.get).toHaveBeenCalledWith(API.SHARE.UNITS_MEMBERS(1, 1), {});
91
73
  });
92
74
 
93
- test('test onSave emergencyContactsSelectContacts fail', async () => {
94
- mock.onPost(API.EMERGENCY_BUTTON.CREATE_BATCH()).reply(500);
75
+ test('test onSave emergencyContactsSelectContacts', async () => {
76
+ const response = {
77
+ status: 200,
78
+ success: true,
79
+ };
80
+ axios.post.mockImplementation(async () => {
81
+ return response;
82
+ });
95
83
  act(() => {
96
84
  tree = create(wrapComponent(route));
97
85
  });
@@ -101,11 +89,6 @@ describe('test EmergencyContactsSelectContacts', () => {
101
89
  await act(async () => {
102
90
  viewButtonBottom.props.onRightClick();
103
91
  });
104
- expect(Toast.show).toBeCalledWith({
105
- type: 'error',
106
- position: 'bottom',
107
- text1: getTranslate('en', 'create_contact_failed'),
108
- visibilityTime: 1000,
109
- });
92
+ expect(axios.post).toHaveBeenCalled();
110
93
  });
111
94
  });
@@ -34,11 +34,11 @@ const DropDownItem = ({ label, data, onSelectItem, isOpen, onOpen, index }) => {
34
34
 
35
35
  {isOpen && (
36
36
  <View style={[styles.dropDownItem]}>
37
- {data.map((item, i) => (
37
+ {data.map((item, index) => (
38
38
  <Text
39
39
  style={styles.dropDownText}
40
40
  onPress={handleSelectItem(item)}
41
- key={i}
41
+ key={index}
42
42
  testID={TESTID.DROP_DOWN_PICKER_ITEM}
43
43
  >
44
44
  {item?.label}
@@ -63,10 +63,7 @@ const EmergencySetting = () => {
63
63
  <View style={styles.wrap}>
64
64
  <HeaderCustom title={t('setting')} isShowSeparator />
65
65
 
66
- <ScrollView
67
- contentContainerStyle={styles.contentContainerStyle}
68
- scrollIndicatorInsets={{ right: 1 }}
69
- >
66
+ <ScrollView contentContainerStyle={styles.contentContainerStyle}>
70
67
  {listData.map((item, index) => (
71
68
  <DropDownItem
72
69
  {...item}