@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
@@ -12,12 +12,20 @@ import RepeatOptionsPopup from './components/RepeatOptionsPopup';
12
12
  import RowItem from './components/RowItem';
13
13
  import SelectWeekday from './components/SelectWeekday';
14
14
  import { useBoolean } from '../../hooks/Common';
15
- import { useTranslations } from '../../hooks/Common/useTranslations';
15
+ import t, { useTranslations } from '../../hooks/Common/useTranslations';
16
16
  import styles from './styles/indexStyles';
17
17
  import { REPEAT_OPTIONS } from './components/RepeatOptionsPopup';
18
18
  import Routes from '../../utils/Route';
19
19
  import { popAction } from '../../navigations/utils';
20
20
 
21
+ const getDateString = (date) => {
22
+ const today = moment();
23
+ if (date.isSame(today, 'day')) {
24
+ return date.format(`[${t('today')}], D MMMM YYYY `);
25
+ }
26
+ return date.format('ddd, D MMMM YYYY');
27
+ };
28
+
21
29
  const SetSchedule = ({ route }) => {
22
30
  const t = useTranslations();
23
31
  const {
@@ -28,19 +36,10 @@ const SetSchedule = ({ route }) => {
28
36
  automateId, // wilk=l remove later
29
37
  automate = {},
30
38
  scriptName,
31
- oldType,
32
39
  } = route.params;
33
40
  const { navigate, dispatch, goBack } = useNavigation();
34
41
  const [repeat, setRepeat] = useState(automate.repeat || REPEAT_OPTIONS.ONCE);
35
42
 
36
- const getDateString = (date) => {
37
- const today = moment();
38
- if (date.isSame(today, 'day')) {
39
- return date.format(`[${t('today')}], D MMMM YYYY `);
40
- }
41
- return date.format('ddd, D MMMM YYYY');
42
- };
43
-
44
43
  const [time, setTime] = useState(
45
44
  automate.time_repeat
46
45
  ? moment(automate.time_repeat, 'HH:mm:ss')
@@ -120,7 +119,7 @@ const SetSchedule = ({ route }) => {
120
119
  navigate(Routes.ScriptDetail, {
121
120
  id: automateId,
122
121
  name: scriptName,
123
- type: oldType,
122
+ type: type,
124
123
  havePermission: true,
125
124
  unit,
126
125
  isMultiUnits,
@@ -137,10 +136,7 @@ const SetSchedule = ({ route }) => {
137
136
  <>
138
137
  <View style={styles.container}>
139
138
  <HeaderCustom isShowClose onClose={onClose} />
140
- <ScrollView
141
- contentContainerStyle={styles.scollView}
142
- scrollIndicatorInsets={{ right: 1 }}
143
- >
139
+ <ScrollView contentContainerStyle={styles.scollView}>
144
140
  <Text type="H2" bold style={styles.title}>
145
141
  {t('set_schedule')}
146
142
  </Text>
@@ -6,6 +6,8 @@ import { TouchableOpacity } from 'react-native';
6
6
  import { SCProvider } from '../../../context';
7
7
  import { mockSCStore } from '../../../context/mockStore';
8
8
 
9
+ jest.mock('axios');
10
+
9
11
  const wrapComponent = (current, getCurrentTab, showModal, textFilter) => (
10
12
  <SCProvider initState={mockSCStore({})}>
11
13
  <TabHeader
@@ -139,7 +139,6 @@ const Shared = () => {
139
139
  keyExtractor={(item, index) => item.id.toString()}
140
140
  ItemSeparatorComponent={() => <View style={styles.seperator} />}
141
141
  contentContainerStyle={styles.scrollView}
142
- scrollIndicatorInsets={{ right: 1 }}
143
142
  />
144
143
  ) : (
145
144
  <FlatList
@@ -163,7 +162,6 @@ const Shared = () => {
163
162
  keyExtractor={(item, index) => item.id.toString()}
164
163
  ItemSeparatorComponent={() => <View style={styles.seperator} />}
165
164
  contentContainerStyle={styles.scrollView}
166
- scrollIndicatorInsets={{ right: 1 }}
167
165
  />
168
166
  )}
169
167
  </View>
@@ -42,20 +42,20 @@ const SensorItem = ({
42
42
  }
43
43
  };
44
44
 
45
- const handleOnTickedChild = (group, checked, childId) => {
45
+ const handleOnTickedChild = (idGroup, isChecked, childId) => {
46
46
  const dataTemp = [...dataConfig];
47
47
  const indexTemp = dataTemp.findIndex((i) => i.id === childId);
48
48
  dataTemp.splice(indexTemp, 1, {
49
49
  ...dataTemp[indexTemp],
50
- isChecked: checked,
50
+ isChecked,
51
51
  });
52
52
  setDataConfig(dataTemp);
53
53
  onTickedChild &&
54
54
  onTickedChild(
55
- group,
55
+ idGroup,
56
56
  id,
57
57
  childId,
58
- checked,
58
+ isChecked,
59
59
  Boolean(dataTemp[indexTemp]?.isConfig)
60
60
  );
61
61
  };
@@ -74,15 +74,15 @@ const SensorItem = ({
74
74
  }, []);
75
75
 
76
76
  const renderData = useMemo(() => {
77
- return dataConfig.map((i) => (
77
+ return dataConfig.map((item) => (
78
78
  <TitleCheckBox
79
- title={i.name}
79
+ title={item.name}
80
80
  wrapCheckBoxStyle={styles.wrapCheckBoxStyle}
81
81
  onPress={handleOnTickedChild}
82
- isChecked={i.isChecked}
83
- id={i.id}
82
+ isChecked={item.isChecked}
83
+ id={item.id}
84
84
  titleStyle={styles.titleStyle}
85
- key={i.id}
85
+ key={item.id}
86
86
  idGroup={idGroup}
87
87
  />
88
88
  ));
@@ -95,7 +95,9 @@ const SensorItem = ({
95
95
  source={{ uri: icon_kit }}
96
96
  style={styles.viewLeft}
97
97
  tintColor={
98
- dataConfig.some((i) => i.isChecked) ? Colors.Primary : Colors.Gray
98
+ dataConfig.some((item) => item.isChecked)
99
+ ? Colors.Primary
100
+ : Colors.Gray
99
101
  }
100
102
  />
101
103
  <View style={styles.wrapRight}>
@@ -149,7 +149,7 @@ const InfoMemberUnit = memo(({ route }) => {
149
149
  screen: Routes.SharingSelectPermission,
150
150
  params: {
151
151
  unit: { id: unit?.id },
152
- type: 'update_shared',
152
+ type: 'share_device',
153
153
  member: memberInfo,
154
154
  },
155
155
  });
@@ -21,8 +21,10 @@ const MemberList = ({ route }) => {
21
21
  const isFocused = useIsFocused();
22
22
  const account = useSCContextSelector((state) => state.auth.account);
23
23
  const { unitId, unit } = route.params;
24
- const { dataMembers, isRefresh, onRefresh, leaveUnit, loading } =
25
- useDataMember(unitId, unit?.user_id);
24
+ const { dataMembers, isRefresh, onRefresh, leaveUnit } = useDataMember(
25
+ unitId,
26
+ unit?.user_id
27
+ );
26
28
  const { isOwner } = useIsOwnerOfUnit(unit?.user_id);
27
29
 
28
30
  const { stateAlertSharingMenu, hideStateAlertSharingMenu, stateLeaveUnit } =
@@ -65,7 +67,6 @@ const MemberList = ({ route }) => {
65
67
  />
66
68
  </TouchableOpacity>
67
69
  );
68
-
69
70
  return (
70
71
  <View style={styles.container}>
71
72
  <WrapHeaderScrollable
@@ -76,15 +77,13 @@ const MemberList = ({ route }) => {
76
77
  headerAniStyle={styles.headerAniStyle}
77
78
  styleScrollView={{ backgroundColor: Colors.White }}
78
79
  >
79
- {!loading && (
80
- <SharingMembers
81
- testID={TESTID.SHARING_MEMBER}
82
- dataMember={dataMembers}
83
- unit={unit}
84
- ownerId={unit.user_id}
85
- currentUserId={account.user.id}
86
- />
87
- )}
80
+ <SharingMembers
81
+ testID={TESTID.SHARING_MEMBER}
82
+ dataMember={dataMembers}
83
+ unit={unit}
84
+ ownerId={unit.user_id}
85
+ currentUserId={account.user.id}
86
+ />
88
87
  </WrapHeaderScrollable>
89
88
  <AlertAction
90
89
  visible={stateAlertSharingMenu.visible}
@@ -1,4 +1,4 @@
1
- import React, { memo, useCallback, useEffect, useMemo, useState } from 'react';
1
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
2
2
  import {
3
3
  SafeAreaView,
4
4
  View,
@@ -32,12 +32,8 @@ const SelectPermission = ({ route }) => {
32
32
  const [isTickAllDevices, setIsTickAllDevices] = useState(false);
33
33
  const [activeItemId, setActiveItemId] = useState(-1);
34
34
  const [loading, setLoading] = useState(true);
35
- const [hasDataChecked, setHasDataChecked] = useState(false);
36
35
  const [dataDeviceShared, setDataDeviceShared] = useState([]);
37
-
38
- const isUpdateSharedDevice = useMemo(() => {
39
- return type === 'update_shared';
40
- }, [type]);
36
+ const [hasDataChecked, setHasDataChecked] = useState(false);
41
37
 
42
38
  const onTickTitle = (idGroup, isChecked, id) => {
43
39
  if (!idGroup) {
@@ -70,7 +66,7 @@ const SelectPermission = ({ route }) => {
70
66
  data[index] = {
71
67
  ...data[index],
72
68
  isChecked,
73
- devices: data[index]?.sensors.map((i) => ({
69
+ sensors: data[index]?.sensors.map((i) => ({
74
70
  ...i,
75
71
  isChecked,
76
72
  actions: i.actions.map((j) => ({ ...j, isChecked })),
@@ -102,10 +98,6 @@ const SelectPermission = ({ route }) => {
102
98
  sensor.actions.some((i) => !i.isChecked)
103
99
  );
104
100
 
105
- stationCheck(data);
106
- };
107
-
108
- const stationCheck = (data) => {
109
101
  for (let station of data) {
110
102
  if (station.sensors.length) {
111
103
  station.isChecked = !station.sensors.some((i) => !i.isChecked);
@@ -123,82 +115,53 @@ const SelectPermission = ({ route }) => {
123
115
 
124
116
  sensor.isChecked = isChecked;
125
117
 
126
- stationCheck(data);
118
+ for (let station of data) {
119
+ if (station.sensors.length) {
120
+ station.isChecked = !station.sensors.some((i) => !i.isChecked);
121
+ }
122
+ }
123
+ setIsTickAllDevices(!dataStationTemp.some((i) => !i.isChecked));
124
+ dataStationTemp = data;
125
+ setDataStations(data);
127
126
  };
128
127
 
129
128
  const autoCheckedGroup = useCallback(async () => {
130
- if (isUpdateSharedDevice) {
129
+ if (type === 'share_device') {
131
130
  if (hasDataChecked) {
132
131
  const stationIds = object_Ids(dataDeviceShared)?.stationIds;
133
132
  const sensorIds = object_Ids(dataDeviceShared)?.sensorIds;
134
133
  const actionIds = object_Ids(dataDeviceShared)?.actionIds;
135
134
  const configIds = object_Ids(dataDeviceShared)?.configIds;
136
- const sensor_checked = [];
137
- const action_checked = [];
138
- const config_checked = [];
139
- const action_temp = [];
140
- const config_temp = [];
141
- for (let station in dataStations) {
142
- for (let item in dataStations[station].sensors) {
143
- const itemTemp = dataStations[station].sensors[item];
144
- dataStations[station].sensors[item] = {
135
+ const data = dataStations?.map((i) => ({
136
+ ...i,
137
+ isChecked: stationIds.includes(i.id),
138
+ }));
139
+ for (let station in data) {
140
+ for (let item in data[station].sensors) {
141
+ const itemTemp = data[station].sensors[item];
142
+ data[station].sensors[item] = {
145
143
  ...itemTemp,
146
144
  isChecked: sensorIds.includes(itemTemp?.id),
147
- actions: itemTemp.actions.map((i) => {
148
- if (actionIds?.includes(i.id)) {
149
- action_checked.push(i);
150
- }
151
- action_temp.push(i);
152
- return {
153
- ...i,
154
- isChecked: actionIds?.includes(i.id),
155
- };
156
- }),
157
- read_configs: itemTemp.read_configs.map((i) => {
158
- if (configIds?.includes(i.id)) {
159
- config_checked.push(i);
160
- }
161
- config_temp.push(i);
162
- return {
163
- ...i,
164
- isChecked: configIds?.includes(i.id),
165
- };
166
- }),
145
+ actions: itemTemp.actions.map((i) => ({
146
+ ...i,
147
+ isChecked: actionIds?.includes(i.id),
148
+ })),
149
+ read_configs: itemTemp.read_configs.map((i) => ({
150
+ ...i,
151
+ isChecked: configIds?.includes(i.id),
152
+ })),
167
153
  };
168
- if (dataStations[station].sensors[item]?.isChecked) {
169
- sensor_checked.push(dataStations[station].sensors[item]);
170
- }
171
154
  }
172
155
  }
173
- const check_action_config = () => {
174
- return (
175
- action_checked?.length === action_temp?.length &&
176
- config_checked?.length === config_temp?.length
177
- );
178
- };
179
- const data = dataStations?.map((i) => {
180
- return {
181
- ...i,
182
- isChecked:
183
- check_action_config() &&
184
- i?.sensors?.length === sensor_checked?.length &&
185
- stationIds.includes(i.id),
186
- };
187
- });
188
156
  const sensorIdsDefault = object_Ids(data)?.sensorIds;
189
- const stationIdsDefault = object_Ids(data)?.stationIds;
190
157
  setDataStations(data);
191
- setIsTickAllDevices(
192
- check_action_config() &&
193
- sensorIdsDefault?.length === sensorIds?.length &&
194
- stationIdsDefault?.length === stationIds?.length
195
- );
158
+ setIsTickAllDevices(sensorIdsDefault?.length === sensorIds?.length);
196
159
  setHasDataChecked(false);
197
160
  }
198
161
  }
199
- }, [dataDeviceShared, dataStations, hasDataChecked, isUpdateSharedDevice]);
162
+ }, [dataDeviceShared, dataStations, hasDataChecked, type]);
200
163
 
201
- const GroupSenSorItem = ({ item = {} }) => {
164
+ const GroupSenSorItem = ({ item = {}, index }) => {
202
165
  const { name = '', sensors = [], isChecked, id = '' } = item;
203
166
  return (
204
167
  <View style={styles.viewGroup}>
@@ -211,11 +174,11 @@ const SelectPermission = ({ route }) => {
211
174
  idGroup={id}
212
175
  />
213
176
  <View style={styles.wrapSensor}>
214
- {sensors?.map((i, index) => (
177
+ {sensors.map((i, index) => (
215
178
  <SensorItem
216
179
  item={i}
217
180
  key={i.id}
218
- isRenderSeparated={index !== sensors?.length - 1}
181
+ isRenderSeparated={index !== sensors.length - 1}
219
182
  onTickedChild={onTickedChild}
220
183
  onTickedSensor={onTickedSensor}
221
184
  titleGroup={name}
@@ -236,47 +199,38 @@ const SelectPermission = ({ route }) => {
236
199
  for (let item of station.sensors) {
237
200
  let arrIdControlTemp = [],
238
201
  arrIdReadTemp = [];
239
-
240
202
  for (let i of item.actions) {
241
203
  i.isChecked && arrIdControlTemp.push(i.id);
242
204
  }
243
205
  for (let i of item.read_configs) {
244
206
  i.isChecked && arrIdReadTemp.push(i.id);
245
207
  }
246
-
247
- if (arrIdControlTemp.length) {
208
+ arrIdControlTemp.length &&
248
209
  control_permissions.push({ id: item.id, values: arrIdControlTemp });
249
- }
250
-
251
- if (arrIdReadTemp.length) {
210
+ arrIdReadTemp.length &&
252
211
  read_permissions.push({ id: item.id, values: arrIdReadTemp });
253
- }
254
-
255
- if (
256
- !arrIdControlTemp.length &&
212
+ !arrIdControlTemp.length &&
257
213
  !arrIdReadTemp.length &&
258
- item.isChecked
259
- ) {
214
+ item.isChecked &&
260
215
  read_permissions.push({ id: item.id, values: [] });
261
- }
262
216
  }
263
217
  }
264
218
  if (!read_permissions.length && !control_permissions.length) {
265
219
  Alert.alert('', t('choose_at_least_one'));
266
220
  return;
267
221
  }
268
- if (isUpdateSharedDevice) {
222
+ if (type === 'share_device') {
269
223
  const phone =
270
224
  member?.phone_number && member?.email
271
225
  ? member?.phone_number
272
226
  : member?.phone_number || '';
273
227
  const email = member?.phone_number ? '' : member?.email || '';
228
+
274
229
  const { success } = await axiosPost(API.SHARE.SHARE(), {
275
230
  phone,
276
231
  email,
277
232
  unit: unit?.id,
278
233
  permissions: { read_permissions, control_permissions },
279
- is_remove_old_permission: true,
280
234
  });
281
235
  if (success) {
282
236
  navigation.goBack();
@@ -295,46 +249,47 @@ const SelectPermission = ({ route }) => {
295
249
 
296
250
  const renderFlatList = useMemo(() => {
297
251
  return (
298
- <FlatList
299
- keyExtractor={(item) => item.id}
300
- extraData={dataStations}
301
- data={dataStations}
302
- renderItem={renderGroupItem}
303
- ListHeaderComponent={
304
- dataStations?.length > 0 ? (
305
- <TitleCheckBox
306
- title={t('text_all_devices')}
307
- wrapStyle={styles.wrapAllDevices}
308
- onPress={onTickTitle}
309
- titleStyle={styles.textAllDevice}
310
- isChecked={isTickAllDevices}
311
- />
312
- ) : (
313
- <></>
314
- )
315
- }
316
- scrollIndicatorInsets={{ right: 1 }}
317
- />
252
+ Boolean(dataStations.length) && (
253
+ <FlatList
254
+ keyExtractor={(item) => item.id}
255
+ extraData={dataStations}
256
+ data={dataStations}
257
+ renderItem={renderGroupItem}
258
+ ListHeaderComponent={
259
+ Boolean(dataStations?.length) && (
260
+ <TitleCheckBox
261
+ title={t('text_all_devices')}
262
+ wrapStyle={styles.wrapAllDevices}
263
+ onPress={onTickTitle}
264
+ titleStyle={styles.textAllDevice}
265
+ isChecked={isTickAllDevices}
266
+ />
267
+ )
268
+ }
269
+ />
270
+ )
318
271
  );
319
-
320
272
  // eslint-disable-next-line react-hooks/exhaustive-deps
321
273
  }, [dataStations, isTickAllDevices, activeItemId]);
322
274
 
323
- useEffect(() => {
324
- autoCheckedGroup();
325
- }, [autoCheckedGroup]);
326
-
327
275
  const getShareUnitPermission = useCallback(async () => {
328
- if (isUpdateSharedDevice && dataStations?.length > 0) {
329
- const response = await axiosGet(
330
- API.SHARE.UNIT_MEMBER_SHARE_DEVICE(unit?.id, member?.id)
331
- );
332
- if (response?.success) {
333
- setDataDeviceShared(response?.data);
334
- setHasDataChecked(true);
276
+ if (type === 'share_device') {
277
+ if (dataStations?.length > 0) {
278
+ const response = await axiosGet(
279
+ API.SHARE.UNIT_MEMBER_SHARE_DEVICE(unit?.id, member?.id)
280
+ );
281
+ if (response.success) {
282
+ setDataDeviceShared(response.data);
283
+ setHasDataChecked(true);
284
+ }
335
285
  }
286
+ setLoading(false);
336
287
  }
337
- }, [dataStations?.length, isUpdateSharedDevice, member?.id, unit?.id]);
288
+ }, [dataStations?.length, member?.id, type, unit?.id]);
289
+
290
+ useEffect(() => {
291
+ autoCheckedGroup();
292
+ }, [autoCheckedGroup]);
338
293
 
339
294
  useEffect(() => {
340
295
  getShareUnitPermission();
@@ -354,7 +309,7 @@ const SelectPermission = ({ route }) => {
354
309
  }
355
310
  setLoading(false);
356
311
  })();
357
- }, [dataStations?.length, isUpdateSharedDevice, member?.id, unit]);
312
+ }, [unit]);
358
313
 
359
314
  useEffect(() => {
360
315
  dataStationTemp = dataStations;
@@ -386,7 +341,7 @@ const SelectPermission = ({ route }) => {
386
341
  testIDPrefix={TESTID.PREFIX.SHARING_SELECT_PERMISSION}
387
342
  leftTitle={t('cancel')}
388
343
  onLeftClick={() => navigation.goBack()}
389
- rightTitle={isUpdateSharedDevice ? t('done') : t('next')}
344
+ rightTitle={type === 'share_device' ? t('done') : t('next')}
390
345
  rightDisabled={false}
391
346
  onRightClick={onPressBottom}
392
347
  />
@@ -395,4 +350,4 @@ const SelectPermission = ({ route }) => {
395
350
  );
396
351
  };
397
352
 
398
- export default memo(SelectPermission);
353
+ export default SelectPermission;
@@ -1,18 +1,14 @@
1
1
  import React from 'react';
2
2
  import { create, act } from 'react-test-renderer';
3
3
  import { TouchableOpacity } from 'react-native';
4
- import MockAdapter from 'axios-mock-adapter';
5
-
6
4
  import InfoMemberUnit from '../InfoMemberUnit';
7
5
  import { HeaderCustom } from '../../../commons/Header';
6
+ import axios from 'axios';
8
7
  import { SCProvider } from '../../../context';
9
8
  import { mockSCStore } from '../../../context/mockStore';
10
9
  import { AlertAction } from '../../../commons';
11
10
  import API from '../../../configs/API';
12
11
  import { TESTID } from '../../../configs/Constants';
13
- import api from '../../../utils/Apis/axios';
14
-
15
- const mock = new MockAdapter(api.axiosInstance);
16
12
 
17
13
  jest.mock('../../../hooks/Common', () => {
18
14
  return {
@@ -28,20 +24,20 @@ jest.mock('react', () => {
28
24
  };
29
25
  });
30
26
 
31
- const mockGoBack = jest.fn();
32
-
33
27
  jest.mock('@react-navigation/native', () => {
34
28
  return {
35
29
  ...jest.requireActual('@react-navigation/native'),
36
30
  useRoute: jest.fn(),
37
31
  useNavigation: () => ({
38
- goBack: mockGoBack,
32
+ goBack: jest.fn(),
39
33
  navigate: mockedNavigate,
40
34
  }),
41
35
  useIsFocused: () => mockUseIsFocused,
42
36
  };
43
37
  });
44
38
 
39
+ jest.mock('axios');
40
+
45
41
  const wrapComponent = (route) => (
46
42
  <SCProvider initState={mockSCStore({})}>
47
43
  <InfoMemberUnit route={route} />
@@ -53,6 +49,7 @@ describe('Test InfoMemberUnit', () => {
53
49
  let route;
54
50
 
55
51
  beforeEach(() => {
52
+ axios.get.mockClear();
56
53
  mockedNavigate.mockClear();
57
54
  route = {
58
55
  params: {
@@ -68,35 +65,20 @@ describe('Test InfoMemberUnit', () => {
68
65
  },
69
66
  };
70
67
  });
71
-
72
- it('render InfoMemberUnit without params', async () => {
73
- mock.onGet(API.SHARE.UNIT_MEMBER_INFO(1, 1)).reply(200, {
74
- id: 1,
75
- identity: 'owner',
76
- phone_number: '88888',
77
- name: 'user',
78
- email: 'abc@gmail.com',
79
- });
80
- await act(async () => {
81
- tree = await create(wrapComponent({}));
82
- });
83
- const instance = tree.root;
84
- const header = instance.findAllByType(HeaderCustom);
85
- const alertAction = instance.findAllByType(AlertAction);
86
- expect(header).toHaveLength(1);
87
- expect(alertAction).toHaveLength(1);
88
- await act(async () => {
89
- alertAction[0].props.rightButtonClick();
90
- });
91
- });
92
-
93
68
  it('render InfoMemberUnit', async () => {
94
- mock.onGet(API.SHARE.UNIT_MEMBER_INFO(1, 1)).reply(200, {
95
- id: 1,
96
- identity: 'owner',
97
- phone_number: '88888',
98
- name: 'user',
99
- email: 'abc@gmail.com',
69
+ mockUseIsFocused.mockImplementation(() => true);
70
+ const response = {
71
+ status: 200,
72
+ data: {
73
+ id: 1,
74
+ identity: 'owner',
75
+ phone_number: '88888',
76
+ name: 'user',
77
+ email: 'abc@gmail.com',
78
+ },
79
+ };
80
+ axios.get.mockImplementation(async () => {
81
+ return response;
100
82
  });
101
83
  await act(async () => {
102
84
  tree = await create(wrapComponent(route));
@@ -104,20 +86,19 @@ describe('Test InfoMemberUnit', () => {
104
86
  const instance = tree.root;
105
87
  const header = instance.findAllByType(HeaderCustom);
106
88
  const alertAction = instance.findAllByType(AlertAction);
89
+ expect(header).toHaveLength(1);
90
+ expect(alertAction).toHaveLength(1);
107
91
  await act(async () => {
108
92
  alertAction[0].props.rightButtonClick();
109
93
  });
110
- expect(header).toHaveLength(1);
111
- expect(alertAction).toHaveLength(1);
112
94
  });
113
-
114
95
  it('render InfoMemberUnit delete member', async () => {
115
- mock.onGet(API.SHARE.UNIT_MEMBER_INFO(1, 1)).reply(200, {
116
- id: 1,
117
- identity: 'owner',
118
- phone_number: '88888',
119
- name: 'user',
120
- email: 'abc@gmail.com',
96
+ mockUseIsFocused.mockImplementation(() => true);
97
+ const response = {
98
+ status: 200,
99
+ };
100
+ axios.delete.mockImplementation(async () => {
101
+ return response;
121
102
  });
122
103
  await act(async () => {
123
104
  tree = await create(wrapComponent(route));
@@ -130,10 +111,11 @@ describe('Test InfoMemberUnit', () => {
130
111
  );
131
112
  expect(header).toHaveLength(1);
132
113
  expect(buttonRemove).toHaveLength(1);
133
- mock.onDelete(API.SHARE.UNITS_MEMBER_DETAIL(1)).reply(200);
134
114
  await act(async () => {
135
115
  buttonRemove[0].props.onPress();
136
116
  });
137
- expect(mockGoBack).toBeCalled();
117
+ expect(axios.delete).toHaveBeenCalledWith(
118
+ API.SHARE.UNITS_MEMBER_DETAIL(1, undefined)
119
+ );
138
120
  });
139
121
  });