@eohjsc/react-native-smart-city 0.7.7 → 0.7.9
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.
- package/assets/images/AddNewDevice/add-scan-device-icon.svg +13 -0
- package/assets/images/Email.svg +9 -0
- package/assets/images/lan.svg +3 -0
- package/assets/images/wifi-open.svg +3 -0
- package/package.json +4 -3
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +7 -3
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +7 -3
- package/src/commons/AlertAction/index.js +1 -0
- package/src/commons/Auth/AccountItem.js +17 -3
- package/src/commons/Auth/AccountList.js +3 -7
- package/src/commons/ConnectWifi/__test__/ConnectWifi.test.js +373 -0
- package/src/commons/ConnectWifi/index.js +201 -0
- package/src/commons/ConnectWifi/styles.js +69 -0
- package/src/commons/Device/LabelValue/__test__/LabelValue.test.js +74 -0
- package/src/commons/Device/LabelValue/index.js +49 -0
- package/src/commons/Device/LabelValue/styles.js +33 -0
- package/src/commons/Form/TextInputPassword.js +1 -1
- package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +6 -2
- package/src/configs/API.js +12 -0
- package/src/configs/AccessibilityLabel.js +7 -0
- package/src/configs/Constants.js +1 -0
- package/src/hooks/Common/index.js +2 -2
- package/src/hooks/Common/useBlockBack.js +36 -0
- package/src/hooks/useMqtt.js +10 -5
- package/src/navigations/AddGatewayStack.js +2 -0
- package/src/navigations/AllGatewayStack.js +4 -0
- package/src/navigations/Main.js +2 -2
- package/src/navigations/UnitStack.js +32 -0
- package/src/screens/AddNewGateway/ConnectingWifiDevice.js +7 -6
- package/src/screens/AddNewGateway/ScanDeviceLocal.js +267 -0
- package/src/screens/AddNewGateway/ScanDeviceLocalStyles.js +58 -0
- package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +10 -2
- package/src/screens/AddNewGateway/SelectDeviceType.js +19 -2
- package/src/screens/AddNewGateway/__test__/ScanDeviceLocal.test.js +475 -0
- package/src/screens/AddNewGateway/__test__/SelectDeviceType.test.js +2 -2
- package/src/screens/AddNewGateway/configs/API.js +8 -0
- package/src/screens/AddNewGateway/hooks/useConnectDevice.js +59 -0
- package/src/screens/AllGateway/GatewayInfo/__test__/index.test.js +58 -1
- package/src/screens/AllGateway/GatewayInfo/index.js +8 -6
- package/src/screens/AllGateway/GatewayWifi/__test__/index.test.js +319 -0
- package/src/screens/AllGateway/GatewayWifi/index.js +107 -0
- package/src/screens/AllGateway/Successfully/__test__/index.test.js +77 -0
- package/src/screens/AllGateway/Successfully/index.js +66 -0
- package/src/screens/AllGateway/Successfully/styles.js +35 -0
- package/src/screens/AllGateway/components/Information/index.js +17 -1
- package/src/screens/AllGateway/components/RowItem/index.js +12 -1
- package/src/screens/AllGateway/hooks/__test__/index.test.js +18 -0
- package/src/screens/AllGateway/hooks/useGateway.js +13 -0
- package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +3 -3
- package/src/screens/Automate/AddNewAction/SetupScriptEmail.js +79 -0
- package/src/screens/Automate/AddNewAction/SetupScriptReceiverEmail.js +166 -0
- package/src/screens/Automate/AddNewAction/Styles/SetupScriptEmailStyles.js +37 -0
- package/src/screens/Automate/AddNewAction/Styles/SetupScriptReceiverEmailStyles.js +79 -0
- package/src/screens/Automate/AddNewAction/__test__/ChooseAction.test.js +1 -1
- package/src/screens/Automate/AddNewAction/__test__/SetupConfigCondition.test.js +13 -5
- package/src/screens/Automate/AddNewAction/__test__/SetupScriptEmail.test.js +76 -0
- package/src/screens/Automate/AddNewAction/__test__/SetupScriptReceiverEmail.test.js +105 -0
- package/src/screens/Automate/EditActionsList/Styles/UpdateReceiverEmailScriptStyles.js +78 -0
- package/src/screens/Automate/EditActionsList/UpdateEmailScript.js +80 -0
- package/src/screens/Automate/EditActionsList/UpdateReceiverEmailScript.js +179 -0
- package/src/screens/Automate/EditActionsList/__tests__/UpdateEmailScript.test.js +81 -0
- package/src/screens/Automate/EditActionsList/__tests__/UpdateReceiverEmailScript.test.js +83 -0
- package/src/screens/Automate/EditActionsList/__tests__/index.test.js +38 -5
- package/src/screens/Automate/EditActionsList/index.js +59 -2
- package/src/screens/Automate/ScriptDetail/Components/AddActionScript.js +20 -0
- package/src/screens/Automate/ScriptDetail/Styles/indexStyles.js +5 -3
- package/src/screens/Automate/ScriptDetail/__test__/index.test.js +127 -21
- package/src/screens/Automate/ScriptDetail/index.js +57 -14
- package/src/screens/Device/__test__/sensorDisplayItem.test.js +22 -0
- package/src/screens/Device/components/SensorDisplayItem.js +10 -0
- package/src/screens/SharedUnit/index.js +2 -2
- package/src/screens/Sharing/SelectUser.js +47 -47
- package/src/screens/Sharing/__test__/SelectUser.test.js +57 -103
- package/src/screens/SubUnit/ManageSubUnit.js +94 -90
- package/src/screens/SubUnit/ManageSubUnitStyles.js +4 -6
- package/src/screens/SubUnit/RearrageSubUnit.js +90 -0
- package/src/screens/SubUnit/RearrrageSubUnitStyle.js +65 -0
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +35 -19
- package/src/screens/SubUnit/__test__/RearrangeSubUnit.test.js +129 -0
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +6 -7
- package/src/screens/SubUnit/hooks/useManageSubUnit.js +8 -16
- package/src/screens/Unit/Detail.js +2 -6
- package/src/screens/Unit/ManageUnit.js +1 -1
- package/src/utils/Functions/__test__/ShortEmail.test.js +5 -0
- package/src/utils/I18n/translations/en.js +46 -8
- package/src/utils/I18n/translations/vi.js +37 -4
- package/src/utils/Route/index.js +7 -0
- package/src/commons/Auth/__test__/AccountItem.test.js +0 -31
- package/src/hooks/Common/useBlockBackAndroid.js +0 -21
- package/src/screens/SubUnit/DetailStyles.js +0 -46
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<svg width="34" height="32" viewBox="0 0 34 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M24.7581 18.3705H23.8992L23.5948 18.0505C24.6602 16.6994 25.3017 14.9453 25.3017 13.0372C25.3017 8.78239 22.1379 5.3335 18.2348 5.3335C14.3317 5.3335 11.168 8.78239 11.168 13.0372C11.168 17.292 14.3317 20.7409 18.2348 20.7409C19.9852 20.7409 21.5943 20.0416 22.8337 18.8802L23.1273 19.212V20.1483L28.5633 26.0624L30.1833 24.2965L24.7581 18.3705V18.3705ZM18.2348 18.3705C15.5277 18.3705 13.3424 15.9883 13.3424 13.0372C13.3424 10.0861 15.5277 7.70387 18.2348 7.70387C20.942 7.70387 23.1273 10.0861 23.1273 13.0372C23.1273 15.9883 20.942 18.3705 18.2348 18.3705Z" fill="#00979D"/>
|
|
3
|
+
<path d="M22.0075 15.636C21.9871 15.7077 21.9626 15.7793 21.9422 15.8554C21.7544 16.4867 21.2359 16.8897 20.5867 16.9031C20.4561 16.9076 20.3213 16.9031 20.1703 16.9031C20.1703 17.0777 20.1703 17.2434 20.1703 17.409C20.1662 17.7135 19.9661 17.9463 19.7048 17.9418C19.4517 17.9374 19.2557 17.709 19.2517 17.4135C19.2517 17.2523 19.2517 17.0912 19.2517 16.9165C15.863 16.9165 12.4826 16.9165 9.08576 16.9165C9.08576 17.0777 9.08576 17.2479 9.08576 17.4135C9.08168 17.718 8.87754 17.9508 8.62033 17.9418C8.3672 17.9374 8.17123 17.709 8.16715 17.4135C8.16715 17.2523 8.16715 17.0912 8.16715 16.9165C7.94669 16.9031 7.73439 16.9031 7.52209 16.8762C6.86477 16.7957 6.33402 16.1554 6.32994 15.4256C6.32586 14.4182 6.32994 13.4108 6.32994 12.4034C6.32994 11.5125 6.91785 10.8588 7.7303 10.8409C8.01201 10.8364 8.28963 10.8409 8.57134 10.8409C12.5397 10.8409 16.5081 10.8409 20.4806 10.8409C21.2971 10.8409 21.7584 11.2214 21.9871 12.0811C21.9912 12.09 21.9993 12.099 22.0075 12.1035C22.0075 13.2855 22.0075 14.4585 22.0075 15.636ZM16.4958 13.872C16.4958 13.7153 16.4999 13.5586 16.4958 13.4019C16.4918 13.0885 16.2999 12.8735 16.0304 12.8735C15.7691 12.8735 15.5813 13.0885 15.5772 13.3929C15.5732 13.7108 15.5732 14.0332 15.5772 14.3511C15.5813 14.6555 15.7732 14.8704 16.0345 14.8704C16.2958 14.8704 16.4877 14.66 16.4958 14.36C16.4999 14.1943 16.4958 14.0332 16.4958 13.872ZM18.3331 13.8765C18.3331 13.7108 18.3371 13.5407 18.3331 13.375C18.3208 13.084 18.1289 12.878 17.8758 12.878C17.6227 12.878 17.4267 13.084 17.4185 13.3795C17.4104 13.7108 17.4104 14.0421 17.4185 14.369C17.4226 14.6645 17.6186 14.8704 17.8717 14.8749C18.133 14.8794 18.329 14.6689 18.3371 14.3645C18.3371 14.1988 18.3331 14.0376 18.3331 13.8765ZM19.2517 13.872C19.2517 14.0332 19.2476 14.1988 19.2517 14.36C19.2598 14.6555 19.4476 14.8659 19.7008 14.8704C19.9621 14.8749 20.1621 14.6689 20.1703 14.369C20.1784 14.0376 20.1784 13.7063 20.1703 13.3795C20.1662 13.084 19.9702 12.878 19.7171 12.878C19.4558 12.878 19.2639 13.0885 19.2557 13.3884C19.2476 13.5451 19.2517 13.7108 19.2517 13.872Z" fill="#00979D"/>
|
|
4
|
+
<path d="M18.7097 4.85407C18.5423 4.85855 18.4239 4.75109 18.3137 4.63468C17.6441 3.92279 16.8725 3.38552 15.9743 3.10345C13.7738 2.40947 11.81 2.88406 10.0912 4.55857C9.97685 4.6705 9.8462 4.78691 9.70331 4.84064C9.5155 4.91227 9.30729 4.78243 9.21338 4.59439C9.1154 4.39291 9.14398 4.16457 9.29504 3.99443C9.71964 3.52879 10.1851 3.13479 10.6995 2.80795C11.9651 2.00203 13.3287 1.66624 14.7781 1.80951C16.4275 1.97069 17.8442 2.70497 19.0241 3.97652C19.1752 4.1377 19.216 4.33023 19.1425 4.54514C19.0731 4.73766 18.9057 4.85855 18.7097 4.85407Z" fill="#00979D"/>
|
|
5
|
+
<path d="M17.878 5.68666C17.8698 5.98664 17.7841 6.14782 17.6044 6.23289C17.4166 6.32244 17.2533 6.27766 17.0941 6.13439C16.8205 5.89262 16.5592 5.62398 16.2612 5.43145C14.6649 4.3972 12.6848 4.65241 11.3293 6.04932C11.1987 6.18364 11.068 6.30005 10.8761 6.27319C10.6883 6.24632 10.5536 6.13887 10.4924 5.93739C10.427 5.73143 10.4719 5.55234 10.6108 5.40011C11.1374 4.82254 11.7457 4.37481 12.4561 4.11961C14.4158 3.41667 16.1714 3.81963 17.6902 5.36429C17.7841 5.46727 17.8371 5.6195 17.878 5.68666Z" fill="#00979D"/>
|
|
6
|
+
<path d="M9.48217 9.84627C9.15555 9.84627 8.84527 9.85075 8.53907 9.8418C8.50232 9.8418 8.45333 9.75673 8.43292 9.703C7.94708 8.46279 7.46124 7.22258 6.9754 5.97789C6.78759 5.49882 6.59571 5.01527 6.41198 4.53173C6.29767 4.2407 6.39974 3.9452 6.6447 3.83327C6.88966 3.72134 7.1387 3.84222 7.25302 4.13325C7.9879 6.00028 8.71871 7.86731 9.44951 9.73434C9.45767 9.76568 9.46584 9.79702 9.48217 9.84627Z" fill="#00979D"/>
|
|
7
|
+
<path d="M18.8477 9.85006C19.0191 9.40681 19.1824 8.99042 19.3457 8.57851C19.9214 7.10548 20.4971 5.63245 21.0727 4.1639C21.2075 3.82362 21.5137 3.69826 21.7668 3.87735C21.9668 4.02062 22.0322 4.27583 21.9301 4.53999C21.6035 5.37724 21.2769 6.2145 20.9502 7.04727C20.6073 7.9293 20.2603 8.81133 19.9173 9.69783C19.8724 9.80976 19.8234 9.85901 19.705 9.85454C19.4274 9.8411 19.1539 9.85006 18.8477 9.85006Z" fill="#00979D"/>
|
|
8
|
+
<path d="M14.1693 5.83936C15.0389 5.86622 15.786 6.15724 16.4066 6.80645C16.5413 6.94525 16.6107 7.11091 16.5617 7.31686C16.5168 7.51386 16.4025 7.63923 16.2269 7.68848C16.0473 7.74221 15.9003 7.67057 15.7697 7.53625C15.0185 6.77511 13.9243 6.62288 13.0343 7.16911C12.871 7.26761 12.7199 7.40193 12.5811 7.53625C12.3484 7.75564 12.0748 7.76907 11.887 7.54968C11.6992 7.33029 11.7237 7.03032 11.9524 6.79302C12.577 6.13933 13.3364 5.85726 14.1693 5.83936Z" fill="#00979D"/>
|
|
9
|
+
<path d="M15.2989 8.60949C15.2703 8.82887 15.1886 8.9811 15.0253 9.07065C14.8539 9.16467 14.6783 9.14676 14.5232 9.01692C14.2292 8.77515 14.0986 8.77515 13.8087 9.01692C13.6127 9.18258 13.3351 9.15571 13.1759 8.95871C13.0207 8.76619 13.0248 8.47069 13.1881 8.27369C13.6821 7.67821 14.662 7.67821 15.1437 8.27817C15.2172 8.36771 15.2499 8.49755 15.2989 8.60949Z" fill="#00979D"/>
|
|
10
|
+
<path d="M16.4959 13.8705C16.4959 14.0317 16.5 14.1973 16.4959 14.3585C16.4877 14.663 16.2958 14.8734 16.0345 14.8689C15.7732 14.8689 15.5814 14.654 15.5773 14.3496C15.5732 14.0317 15.5732 13.7093 15.5773 13.3914C15.5814 13.087 15.7733 12.8721 16.0305 12.8721C16.2999 12.8721 16.4877 13.0825 16.4959 13.4004C16.5 13.5571 16.4959 13.7138 16.4959 13.8705Z" fill="white"/>
|
|
11
|
+
<path d="M18.3315 13.8764C18.3315 14.0375 18.3356 14.2032 18.3315 14.3644C18.3234 14.6644 18.1274 14.8748 17.8661 14.8748C17.613 14.8703 17.4211 14.6599 17.4129 14.3689C17.4088 14.0375 17.4048 13.7062 17.4129 13.3794C17.4211 13.0884 17.6171 12.8779 17.8702 12.8779C18.1274 12.8779 18.3193 13.0839 18.3274 13.3749C18.3356 13.5361 18.3315 13.7062 18.3315 13.8764Z" fill="white"/>
|
|
12
|
+
<path d="M19.2521 13.8706C19.2521 13.7094 19.248 13.5437 19.2521 13.3826C19.2603 13.0826 19.4522 12.8677 19.7135 12.8721C19.9666 12.8721 20.1626 13.0826 20.1667 13.3736C20.1748 13.7049 20.1748 14.0362 20.1667 14.3631C20.1585 14.6631 19.9584 14.8735 19.6971 14.8645C19.444 14.8601 19.2562 14.6496 19.248 14.3541C19.248 14.1929 19.2521 14.0318 19.2521 13.8706Z" fill="white"/>
|
|
13
|
+
</svg>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<svg width="34" height="28" viewBox="0 0 34 28" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M30.3334 0.666656H3.66671C1.83337 0.666656 0.350041 2.16666 0.350041 3.99999L0.333374 24C0.333374 25.8333 1.83337 27.3333 3.66671 27.3333H30.3334C32.1667 27.3333 33.6667 25.8333 33.6667 24V3.99999C33.6667 2.16666 32.1667 0.666656 30.3334 0.666656ZM30.3334 7.33332L17 15.6667L3.66671 7.33332V3.99999L17 12.3333L30.3334 3.99999V7.33332Z" fill="url(#paint0_linear_3319_1483)"/>
|
|
3
|
+
<defs>
|
|
4
|
+
<linearGradient id="paint0_linear_3319_1483" x1="0.333374" y1="0.666656" x2="26.3145" y2="33.1791" gradientUnits="userSpaceOnUse">
|
|
5
|
+
<stop stop-color="#2B6B9F"/>
|
|
6
|
+
<stop offset="1" stop-color="#D5FFCB"/>
|
|
7
|
+
</linearGradient>
|
|
8
|
+
</defs>
|
|
9
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eohjsc/react-native-smart-city",
|
|
3
3
|
"title": "React Native Smart Home",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.9",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -118,8 +118,8 @@
|
|
|
118
118
|
"lint-staged": "^12.4.1",
|
|
119
119
|
"lodash": "^4.17.19",
|
|
120
120
|
"lottie-react-native": "^6.7.2",
|
|
121
|
-
"metro-react-native-babel-preset": "0.73.9",
|
|
122
121
|
"md5": "^2.3.0",
|
|
122
|
+
"metro-react-native-babel-preset": "0.73.9",
|
|
123
123
|
"moment": "^2.27.0",
|
|
124
124
|
"moment-timezone": "^0.5.32",
|
|
125
125
|
"node-html-parser": "^2.0.2",
|
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
"react-native-geocoder": "^0.5.0",
|
|
156
156
|
"react-native-gesture-handler": "^2.17.1",
|
|
157
157
|
"react-native-get-location": "^2.0.0",
|
|
158
|
-
"react-native-image-crop-picker": "^0.
|
|
158
|
+
"react-native-image-crop-picker": "^0.41.4",
|
|
159
159
|
"react-native-image-resizer": "^1.4.5",
|
|
160
160
|
"react-native-input-credit-card": "^0.5.5",
|
|
161
161
|
"react-native-iphone-x-helper": "^1.2.1",
|
|
@@ -188,6 +188,7 @@
|
|
|
188
188
|
"react-native-wheel-color-picker": "^1.2.0",
|
|
189
189
|
"react-native-wheel-scrollview-picker": "^1.2.2",
|
|
190
190
|
"react-native-wifi-reborn": "4.5.0",
|
|
191
|
+
"react-native-zeroconf": "^0.13.8",
|
|
191
192
|
"react-test-renderer": "18.3.1",
|
|
192
193
|
"string-format": "^2.0.0",
|
|
193
194
|
"sync-directory": "^5.1.7",
|
|
@@ -38,11 +38,15 @@ const GridItem = ({ item, doAction, sensor }) => {
|
|
|
38
38
|
|
|
39
39
|
const doActionAndWatchConfig = useCallback(
|
|
40
40
|
(actionData) => {
|
|
41
|
-
let data =
|
|
41
|
+
let data = { value: is_on_value };
|
|
42
42
|
if (allow_config_store_value && config) {
|
|
43
|
-
data =
|
|
43
|
+
data = {
|
|
44
|
+
config_id: config,
|
|
45
|
+
config_value: is_on_value,
|
|
46
|
+
value: is_on_value,
|
|
47
|
+
};
|
|
44
48
|
}
|
|
45
|
-
doAction(actionData, data);
|
|
49
|
+
doAction(actionData, JSON.stringify(data));
|
|
46
50
|
if (sensor?.is_managed_by_backend) {
|
|
47
51
|
if (config && sensor.device_type === DEVICE_TYPE.LG_THINQ) {
|
|
48
52
|
watchMultiConfigs([config]);
|
|
@@ -25,6 +25,7 @@ describe('Test StatesGridActionTemplate', () => {
|
|
|
25
25
|
icon_kit_data: 'icon_kit_data',
|
|
26
26
|
icon: '123',
|
|
27
27
|
action_data: mockActionData,
|
|
28
|
+
is_on_value: 1,
|
|
28
29
|
},
|
|
29
30
|
{
|
|
30
31
|
config: 2,
|
|
@@ -33,9 +34,9 @@ describe('Test StatesGridActionTemplate', () => {
|
|
|
33
34
|
icon_kit_data: 'icon_kit_data',
|
|
34
35
|
icon: 'icon',
|
|
35
36
|
action_data: mockActionData,
|
|
37
|
+
is_on_value: 0,
|
|
36
38
|
},
|
|
37
39
|
],
|
|
38
|
-
is_on_value: true,
|
|
39
40
|
},
|
|
40
41
|
title: 'Title',
|
|
41
42
|
};
|
|
@@ -74,7 +75,10 @@ describe('Test StatesGridActionTemplate', () => {
|
|
|
74
75
|
await act(async () => {
|
|
75
76
|
await touchableOpacities[0].props.onPress();
|
|
76
77
|
});
|
|
77
|
-
expect(mockDoAction).toHaveBeenCalledWith(
|
|
78
|
+
expect(mockDoAction).toHaveBeenCalledWith(
|
|
79
|
+
mockActionData,
|
|
80
|
+
JSON.stringify({ value: 1 })
|
|
81
|
+
);
|
|
78
82
|
});
|
|
79
83
|
|
|
80
84
|
it('test trigger special action', async () => {
|
|
@@ -98,7 +102,7 @@ describe('Test StatesGridActionTemplate', () => {
|
|
|
98
102
|
});
|
|
99
103
|
expect(mockDoAction).toHaveBeenCalledWith(
|
|
100
104
|
mockActionData,
|
|
101
|
-
JSON.stringify({ config_id: 1, config_value:
|
|
105
|
+
JSON.stringify({ config_id: 1, config_value: 1, value: 1 })
|
|
102
106
|
);
|
|
103
107
|
});
|
|
104
108
|
});
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
2
|
import { View, StyleSheet, Text } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { Colors } from '../../configs';
|
|
5
5
|
import { shortEmailName } from '../../utils/Utils';
|
|
6
6
|
import Avatar from '../../../assets/images/avatar.svg';
|
|
7
7
|
import AccessibilityLabel from '../../configs/AccessibilityLabel';
|
|
8
|
+
import { IconOutline } from '@ant-design/icons-react-native';
|
|
8
9
|
|
|
9
|
-
const AccountItem = ({ account }) => {
|
|
10
|
+
const AccountItem = ({ account, setUsers }) => {
|
|
10
11
|
const { name, email, phone_number } = account;
|
|
12
|
+
|
|
13
|
+
const handleRemoveUserItem = useCallback(() => {
|
|
14
|
+
setUsers((prevUsers) => prevUsers.filter((el) => el.id !== account.id));
|
|
15
|
+
}, [account.id, setUsers]);
|
|
16
|
+
|
|
11
17
|
return (
|
|
12
18
|
<View style={styles.container}>
|
|
13
19
|
<View styles={styles.wrap}>
|
|
@@ -30,15 +36,23 @@ const AccountItem = ({ account }) => {
|
|
|
30
36
|
</Text>
|
|
31
37
|
)}
|
|
32
38
|
</View>
|
|
39
|
+
|
|
40
|
+
<IconOutline
|
|
41
|
+
name={'close'}
|
|
42
|
+
color={Colors.Gray8}
|
|
43
|
+
size={22}
|
|
44
|
+
onPress={handleRemoveUserItem}
|
|
45
|
+
/>
|
|
33
46
|
</View>
|
|
34
47
|
);
|
|
35
48
|
};
|
|
36
49
|
|
|
37
50
|
const styles = StyleSheet.create({
|
|
38
51
|
container: {
|
|
39
|
-
marginBottom:
|
|
52
|
+
marginBottom: 15,
|
|
40
53
|
flexDirection: 'row',
|
|
41
54
|
alignItems: 'center',
|
|
55
|
+
justifyContent: 'space-between',
|
|
42
56
|
},
|
|
43
57
|
wrap: {
|
|
44
58
|
flex: 1,
|
|
@@ -3,18 +3,14 @@ import { ScrollView } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
import AccountItem from './AccountItem';
|
|
5
5
|
|
|
6
|
-
const AccountList = ({ accounts }) => {
|
|
6
|
+
const AccountList = ({ accounts, setUsers }) => {
|
|
7
7
|
return (
|
|
8
8
|
<ScrollView scrollIndicatorInsets={{ right: 1 }}>
|
|
9
|
-
{accounts.map((account) => (
|
|
10
|
-
<AccountItem key={account.id} account={account} />
|
|
9
|
+
{accounts.map((account, index) => (
|
|
10
|
+
<AccountItem key={account.id} account={account} setUsers={setUsers} />
|
|
11
11
|
))}
|
|
12
12
|
</ScrollView>
|
|
13
13
|
);
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
AccountList.defaultPropTypes = {
|
|
17
|
-
accounts: [],
|
|
18
|
-
};
|
|
19
|
-
|
|
20
16
|
export default AccountList;
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import { TouchableOpacity, ActivityIndicator } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
import AccessibilityLabel from '../../../configs/AccessibilityLabel';
|
|
8
|
+
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
9
|
+
import { getTranslate } from '../../../utils/I18n';
|
|
10
|
+
import { FullLoading } from '../../../commons';
|
|
11
|
+
import _TextInput from '../../Form/TextInput';
|
|
12
|
+
import _TextInputPassword from '../../Form/TextInputPassword';
|
|
13
|
+
|
|
14
|
+
import ConnectWifi from '../index';
|
|
15
|
+
|
|
16
|
+
const wrapComponent = ({ props }) => (
|
|
17
|
+
<SCProvider initState={mockSCStore({})}>
|
|
18
|
+
<ConnectWifi {...props} />
|
|
19
|
+
</SCProvider>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
describe('Test ConnectWifi', () => {
|
|
23
|
+
let tree;
|
|
24
|
+
|
|
25
|
+
const spyToastError = jest.spyOn(ToastBottomHelper, 'error');
|
|
26
|
+
|
|
27
|
+
const props = {
|
|
28
|
+
title: 'Connect to WiFi',
|
|
29
|
+
wifiList: [
|
|
30
|
+
{ ssid: 'HomeWiFi', encryption: 'WPA2/PSK' },
|
|
31
|
+
{ ssid: 'OpenWiFi', encryption: 'OPEN' },
|
|
32
|
+
],
|
|
33
|
+
onConnect: jest.fn(),
|
|
34
|
+
onGoBack: jest.fn(),
|
|
35
|
+
isShowLoading: false,
|
|
36
|
+
setIsShowLoading: jest.fn(),
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
jest.clearAllMocks();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('test shows ActivityIndicator when wifiList is empty', async () => {
|
|
44
|
+
const emptyProps = { ...props, wifiList: [] };
|
|
45
|
+
await act(async () => {
|
|
46
|
+
tree = await renderer.create(wrapComponent({ props: emptyProps }));
|
|
47
|
+
});
|
|
48
|
+
const instance = tree.root;
|
|
49
|
+
const activityIndicator = instance.findByType(ActivityIndicator);
|
|
50
|
+
expect(activityIndicator).toBeTruthy();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('test handles selecting an open WiFi network', async () => {
|
|
54
|
+
await act(async () => {
|
|
55
|
+
tree = await renderer.create(wrapComponent({ props }));
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const instance = tree.root;
|
|
59
|
+
const openWifiItem = instance.find(
|
|
60
|
+
(el) =>
|
|
61
|
+
el.props.accessibilityLabel ===
|
|
62
|
+
`${AccessibilityLabel.SELECT_WIFI}-OpenWiFi` &&
|
|
63
|
+
el.type === TouchableOpacity
|
|
64
|
+
);
|
|
65
|
+
await act(async () => {
|
|
66
|
+
openWifiItem.props.onPress();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const buttonPopup = instance.find(
|
|
70
|
+
(el) =>
|
|
71
|
+
el.props.accessibilityLabel ===
|
|
72
|
+
AccessibilityLabel.GATEWAY_WIFI_LIST.BUTTON_POPUP
|
|
73
|
+
);
|
|
74
|
+
expect(buttonPopup.props.visible).toBeTruthy();
|
|
75
|
+
expect(buttonPopup.props.mainTitle).toBe(getTranslate('en', 'connect'));
|
|
76
|
+
expect(buttonPopup.props.children[0].props.children).toBe(
|
|
77
|
+
`${getTranslate('en', 'connect_to_wifi')} 'OpenWiFi'`
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const textInput = instance.findAllByType(_TextInput);
|
|
81
|
+
expect(textInput).toHaveLength(0);
|
|
82
|
+
const textInputPassword = instance.findAllByType(_TextInputPassword);
|
|
83
|
+
expect(textInputPassword).toHaveLength(0);
|
|
84
|
+
|
|
85
|
+
await act(async () => {
|
|
86
|
+
buttonPopup.props.onPressMain();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
expect(props.onConnect).toHaveBeenCalledWith({
|
|
90
|
+
wifiSsid: 'OpenWiFi',
|
|
91
|
+
wifiPassword: '',
|
|
92
|
+
});
|
|
93
|
+
expect(props.setIsShowLoading).toHaveBeenCalledWith(true);
|
|
94
|
+
expect(buttonPopup.props.visible).toBeFalsy();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('test handles selecting a secured WiFi network', async () => {
|
|
98
|
+
await act(async () => {
|
|
99
|
+
tree = await renderer.create(wrapComponent({ props }));
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const instance = tree.root;
|
|
103
|
+
const securedWifiItem = instance.find(
|
|
104
|
+
(el) =>
|
|
105
|
+
el.props.accessibilityLabel ===
|
|
106
|
+
`${AccessibilityLabel.SELECT_WIFI}-HomeWiFi` &&
|
|
107
|
+
el.type === TouchableOpacity
|
|
108
|
+
);
|
|
109
|
+
await act(async () => {
|
|
110
|
+
securedWifiItem.props.onPress();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const buttonPopup = instance.find(
|
|
114
|
+
(el) =>
|
|
115
|
+
el.props.accessibilityLabel ===
|
|
116
|
+
AccessibilityLabel.GATEWAY_WIFI_LIST.BUTTON_POPUP
|
|
117
|
+
);
|
|
118
|
+
expect(buttonPopup.props.visible).toBeTruthy();
|
|
119
|
+
expect(buttonPopup.props.children[0].props.children).toBe(
|
|
120
|
+
`${getTranslate('en', 'enter_wifi_password')} 'HomeWiFi'`
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const textInput = instance.findAllByType(_TextInput);
|
|
124
|
+
expect(textInput).toHaveLength(0);
|
|
125
|
+
const textInputPassword = instance.findByType(_TextInputPassword);
|
|
126
|
+
expect(textInputPassword.props.placeholder).toBe(
|
|
127
|
+
getTranslate('en', 'password')
|
|
128
|
+
);
|
|
129
|
+
expect(textInputPassword.props.autoFocus).toBeTruthy();
|
|
130
|
+
expect(textInputPassword.props.value).toBe('');
|
|
131
|
+
|
|
132
|
+
// Empty password
|
|
133
|
+
await act(async () => {
|
|
134
|
+
buttonPopup.props.onPressMain();
|
|
135
|
+
});
|
|
136
|
+
expect(spyToastError).toHaveBeenCalledWith(
|
|
137
|
+
getTranslate('en', 'please_enter_wifi_password')
|
|
138
|
+
);
|
|
139
|
+
expect(props.onConnect).not.toHaveBeenCalled();
|
|
140
|
+
|
|
141
|
+
// Short password
|
|
142
|
+
await act(async () => {
|
|
143
|
+
textInputPassword.props.onChange('123');
|
|
144
|
+
});
|
|
145
|
+
expect(textInputPassword.props.value).toBe('123');
|
|
146
|
+
await act(async () => {
|
|
147
|
+
buttonPopup.props.onPressMain();
|
|
148
|
+
});
|
|
149
|
+
expect(spyToastError).toHaveBeenCalledWith(
|
|
150
|
+
getTranslate('en', 'password_must_be_at_least_8_characters')
|
|
151
|
+
);
|
|
152
|
+
expect(props.onConnect).not.toHaveBeenCalled();
|
|
153
|
+
|
|
154
|
+
await act(async () => {
|
|
155
|
+
textInputPassword.props.onChange('NewPassword123');
|
|
156
|
+
});
|
|
157
|
+
await act(async () => {
|
|
158
|
+
buttonPopup.props.onPressMain();
|
|
159
|
+
});
|
|
160
|
+
expect(props.onConnect).toHaveBeenCalledWith({
|
|
161
|
+
wifiSsid: 'HomeWiFi',
|
|
162
|
+
wifiPassword: 'NewPassword123',
|
|
163
|
+
});
|
|
164
|
+
expect(props.setIsShowLoading).toHaveBeenCalledWith(true);
|
|
165
|
+
expect(buttonPopup.props.visible).toBeFalsy();
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('test handles selecting the "Other" WiFi option and connect OPEN Wi-Fi', async () => {
|
|
169
|
+
await act(async () => {
|
|
170
|
+
tree = await renderer.create(wrapComponent({ props }));
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const instance = tree.root;
|
|
174
|
+
const otherWifiItem = instance.find(
|
|
175
|
+
(el) =>
|
|
176
|
+
el.props.accessibilityLabel ===
|
|
177
|
+
`${AccessibilityLabel.SELECT_WIFI}-other` &&
|
|
178
|
+
el.type === TouchableOpacity
|
|
179
|
+
);
|
|
180
|
+
await act(async () => {
|
|
181
|
+
otherWifiItem.props.onPress();
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const buttonPopup = instance.find(
|
|
185
|
+
(el) =>
|
|
186
|
+
el.props.accessibilityLabel ===
|
|
187
|
+
AccessibilityLabel.GATEWAY_WIFI_LIST.BUTTON_POPUP
|
|
188
|
+
);
|
|
189
|
+
expect(buttonPopup.props.visible).toBeTruthy();
|
|
190
|
+
expect(buttonPopup.props.children[0].props.children).toBe(
|
|
191
|
+
getTranslate('en', 'enter_wifi_name_password')
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
const textInput = instance.findByType(_TextInput);
|
|
195
|
+
expect(textInput.props.placeholder).toBe(getTranslate('en', 'wifi_name'));
|
|
196
|
+
expect(textInput.props.autoFocus).toBeTruthy();
|
|
197
|
+
expect(textInput.props.value).toBe('');
|
|
198
|
+
const textInputPassword = instance.findByType(_TextInputPassword);
|
|
199
|
+
expect(textInputPassword.props.placeholder).toBe(
|
|
200
|
+
getTranslate('en', 'password')
|
|
201
|
+
);
|
|
202
|
+
expect(textInputPassword.props.autoFocus).toBeFalsy();
|
|
203
|
+
expect(textInputPassword.props.value).toBe('');
|
|
204
|
+
|
|
205
|
+
// Empty name
|
|
206
|
+
await act(async () => {
|
|
207
|
+
buttonPopup.props.onPressMain();
|
|
208
|
+
});
|
|
209
|
+
expect(spyToastError).toHaveBeenCalledWith(
|
|
210
|
+
getTranslate('en', 'please_enter_wifi_name')
|
|
211
|
+
);
|
|
212
|
+
expect(props.onConnect).not.toHaveBeenCalled();
|
|
213
|
+
|
|
214
|
+
await act(async () => {
|
|
215
|
+
textInput.props.onChange('OpenWiFi');
|
|
216
|
+
});
|
|
217
|
+
expect(textInput.props.value).toBe('OpenWiFi');
|
|
218
|
+
await act(async () => {
|
|
219
|
+
buttonPopup.props.onPressMain();
|
|
220
|
+
});
|
|
221
|
+
expect(props.onConnect).toHaveBeenCalledWith({
|
|
222
|
+
wifiSsid: 'OpenWiFi',
|
|
223
|
+
wifiPassword: '',
|
|
224
|
+
});
|
|
225
|
+
expect(props.setIsShowLoading).toHaveBeenCalledWith(true);
|
|
226
|
+
expect(buttonPopup.props.visible).toBeFalsy();
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it('test handles selecting the "Other" WiFi option and connect Secured Wi-Fi', async () => {
|
|
230
|
+
await act(async () => {
|
|
231
|
+
tree = await renderer.create(wrapComponent({ props }));
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
const instance = tree.root;
|
|
235
|
+
const otherWifiItem = instance.find(
|
|
236
|
+
(el) =>
|
|
237
|
+
el.props.accessibilityLabel ===
|
|
238
|
+
`${AccessibilityLabel.SELECT_WIFI}-other` &&
|
|
239
|
+
el.type === TouchableOpacity
|
|
240
|
+
);
|
|
241
|
+
await act(async () => {
|
|
242
|
+
otherWifiItem.props.onPress();
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
const buttonPopup = instance.find(
|
|
246
|
+
(el) =>
|
|
247
|
+
el.props.accessibilityLabel ===
|
|
248
|
+
AccessibilityLabel.GATEWAY_WIFI_LIST.BUTTON_POPUP
|
|
249
|
+
);
|
|
250
|
+
expect(buttonPopup.props.visible).toBeTruthy();
|
|
251
|
+
expect(buttonPopup.props.children[0].props.children).toBe(
|
|
252
|
+
getTranslate('en', 'enter_wifi_name_password')
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
const textInput = instance.findByType(_TextInput);
|
|
256
|
+
expect(textInput.props.placeholder).toBe(getTranslate('en', 'wifi_name'));
|
|
257
|
+
expect(textInput.props.autoFocus).toBeTruthy();
|
|
258
|
+
expect(textInput.props.value).toBe('');
|
|
259
|
+
const textInputPassword = instance.findByType(_TextInputPassword);
|
|
260
|
+
expect(textInputPassword.props.placeholder).toBe(
|
|
261
|
+
getTranslate('en', 'password')
|
|
262
|
+
);
|
|
263
|
+
expect(textInputPassword.props.autoFocus).toBeFalsy();
|
|
264
|
+
expect(textInputPassword.props.value).toBe('');
|
|
265
|
+
|
|
266
|
+
// Empty name
|
|
267
|
+
await act(async () => {
|
|
268
|
+
buttonPopup.props.onPressMain();
|
|
269
|
+
});
|
|
270
|
+
expect(spyToastError).toHaveBeenCalledWith(
|
|
271
|
+
getTranslate('en', 'please_enter_wifi_name')
|
|
272
|
+
);
|
|
273
|
+
expect(props.onConnect).not.toHaveBeenCalled();
|
|
274
|
+
|
|
275
|
+
await act(async () => {
|
|
276
|
+
textInput.props.onChange('SecuredWiFi');
|
|
277
|
+
});
|
|
278
|
+
expect(textInput.props.value).toBe('SecuredWiFi');
|
|
279
|
+
// Short password
|
|
280
|
+
await act(async () => {
|
|
281
|
+
textInputPassword.props.onChange('123');
|
|
282
|
+
});
|
|
283
|
+
expect(textInputPassword.props.value).toBe('123');
|
|
284
|
+
await act(async () => {
|
|
285
|
+
buttonPopup.props.onPressMain();
|
|
286
|
+
});
|
|
287
|
+
expect(spyToastError).toHaveBeenCalledWith(
|
|
288
|
+
getTranslate('en', 'password_must_be_at_least_8_characters')
|
|
289
|
+
);
|
|
290
|
+
expect(props.onConnect).not.toHaveBeenCalled();
|
|
291
|
+
|
|
292
|
+
await act(async () => {
|
|
293
|
+
textInputPassword.props.onChange('NewPassword123');
|
|
294
|
+
});
|
|
295
|
+
await act(async () => {
|
|
296
|
+
buttonPopup.props.onPressMain();
|
|
297
|
+
});
|
|
298
|
+
expect(props.onConnect).toHaveBeenCalledWith({
|
|
299
|
+
wifiSsid: 'SecuredWiFi',
|
|
300
|
+
wifiPassword: 'NewPassword123',
|
|
301
|
+
});
|
|
302
|
+
expect(props.setIsShowLoading).toHaveBeenCalledWith(true);
|
|
303
|
+
expect(buttonPopup.props.visible).toBeFalsy();
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it('test handles cancelling the password popup', async () => {
|
|
307
|
+
await act(async () => {
|
|
308
|
+
tree = await renderer.create(wrapComponent({ props }));
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
const instance = tree.root;
|
|
312
|
+
const securedWifiItem = instance.find(
|
|
313
|
+
(el) =>
|
|
314
|
+
el.props.accessibilityLabel ===
|
|
315
|
+
`${AccessibilityLabel.SELECT_WIFI}-HomeWiFi` &&
|
|
316
|
+
el.type === TouchableOpacity
|
|
317
|
+
);
|
|
318
|
+
await act(async () => {
|
|
319
|
+
securedWifiItem.props.onPress();
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
const buttonPopup = instance.find(
|
|
323
|
+
(el) =>
|
|
324
|
+
el.props.accessibilityLabel ===
|
|
325
|
+
AccessibilityLabel.GATEWAY_WIFI_LIST.BUTTON_POPUP
|
|
326
|
+
);
|
|
327
|
+
await act(async () => {
|
|
328
|
+
buttonPopup.props.onPressSecondary();
|
|
329
|
+
});
|
|
330
|
+
expect(buttonPopup.props.visible).toBeFalsy();
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it('test handles with onConnect is not provided', async () => {
|
|
334
|
+
const emptyOnConnectProps = { ...props, onConnect: undefined };
|
|
335
|
+
await act(async () => {
|
|
336
|
+
tree = await renderer.create(
|
|
337
|
+
wrapComponent({ props: emptyOnConnectProps })
|
|
338
|
+
);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
const instance = tree.root;
|
|
342
|
+
const securedWifiItem = instance.find(
|
|
343
|
+
(el) =>
|
|
344
|
+
el.props.accessibilityLabel ===
|
|
345
|
+
`${AccessibilityLabel.SELECT_WIFI}-HomeWiFi` &&
|
|
346
|
+
el.type === TouchableOpacity
|
|
347
|
+
);
|
|
348
|
+
await act(async () => {
|
|
349
|
+
securedWifiItem.props.onPress();
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
const buttonPopup = instance.find(
|
|
353
|
+
(el) =>
|
|
354
|
+
el.props.accessibilityLabel ===
|
|
355
|
+
AccessibilityLabel.GATEWAY_WIFI_LIST.BUTTON_POPUP
|
|
356
|
+
);
|
|
357
|
+
await act(async () => {
|
|
358
|
+
buttonPopup.props.onPressMain();
|
|
359
|
+
});
|
|
360
|
+
expect(spyToastError).not.toHaveBeenCalled();
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
it('test handles with isShowLoading is true', async () => {
|
|
364
|
+
const loadingProps = { ...props, isShowLoading: true };
|
|
365
|
+
await act(async () => {
|
|
366
|
+
tree = await renderer.create(wrapComponent({ props: loadingProps }));
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
const instance = tree.root;
|
|
370
|
+
const fullLoading = instance.findByType(FullLoading);
|
|
371
|
+
expect(fullLoading).toBeTruthy();
|
|
372
|
+
});
|
|
373
|
+
});
|