From d77fef2254c14421eb9760cc67cf5126f984ec95 Mon Sep 17 00:00:00 2001
From: Ahmad Azizi <91204996+its-aazizi@users.noreply.github.com>
Date: Mon, 12 Aug 2024 22:58:33 +0500
Subject: [PATCH 1/7] updated service filename convention, updated creds and
websocket logic
---
package-lock.json | 298 ++++++++++++++--
package.json | 2 +-
.../ConnectAwsAccountModal.test.tsx | 32 +-
.../ConnectAwsAccountModal.tsx | 41 +--
.../molecules/MapButtons/MapButtons.test.tsx | 38 +--
.../molecules/MapButtons/MapButtons.tsx | 8 +-
src/atomicui/molecules/Marker/Marker.tsx | 4 +-
src/atomicui/molecules/Popup/Popup.test.tsx | 8 +-
src/atomicui/molecules/Popup/Popup.tsx | 8 +-
.../SignInModal/SignInModal.test.tsx | 8 +-
.../molecules/SignInModal/SignInModal.tsx | 6 +-
.../molecules/StepCard/StepCard.test.tsx | 4 +-
src/atomicui/molecules/StepCard/StepCard.tsx | 6 +-
.../SuggestionMarker/SuggestionMarker.tsx | 4 +-
.../organisms/AboutModal/AboutModal.tsx | 4 +-
.../AuthGeofenceBox/AuthGeofenceBox.test.tsx | 32 +-
.../AuthGeofenceBox/AuthGeofenceBox.tsx | 8 +-
.../AuthTrackerBox/AuthTrackerBox.test.tsx | 14 +-
.../AuthTrackerBox/AuthTrackerBox.tsx | 14 +-
.../AuthTrackerBox/AuthTrackerSimulation.tsx | 10 +-
src/atomicui/organisms/Explore/Explore.tsx | 29 +-
.../ResponsiveBottomSheet.tsx | 26 +-
.../organisms/RouteBox/RouteBox.test.tsx | 12 +-
src/atomicui/organisms/RouteBox/RouteBox.tsx | 12 +-
.../organisms/SearchBox/SearchBox.test.tsx | 14 +-
.../organisms/SearchBox/SearchBox.tsx | 13 +-
.../organisms/SettingsModal/SettingsModal.tsx | 115 +++----
src/atomicui/organisms/Sidebar/Sidebar.tsx | 34 +-
.../UnauthGeofencesSimulation.tsx | 4 +-
.../UnauthRouteSimulation.tsx | 4 +-
.../UnauthSimulation.test.tsx | 4 +-
.../UnauthSimulation/UnauthSimulation.tsx | 10 +-
src/atomicui/pages/DemoPage/DemoPage.tsx | 40 +--
src/core/AppWrapper/AppWrapper.tsx | 50 +--
src/core/constants/appConfig.ts | 4 +-
src/hooks/index.ts | 16 +-
src/hooks/{useAmplifyAuth.ts => useAuth.ts} | 236 +++++--------
src/hooks/{useAws.ts => useClient.ts} | 26 +-
src/hooks/useCredsManager.ts | 155 +++++----
.../{useAwsGeofence.ts => useGeofence.ts} | 16 +-
src/hooks/{useAwsIot.ts => useIot.ts} | 8 +-
src/hooks/{useAmplifyMap.ts => useMap.ts} | 10 +-
src/hooks/useMapManager.ts | 77 +++--
src/hooks/{useAwsPlace.ts => usePlace.ts} | 34 +-
src/hooks/{useAwsRoute.ts => useRoute.ts} | 20 +-
src/hooks/{useAwsTracker.ts => useTracker.ts} | 10 +-
src/hooks/useWebsocketBanner.tsx | 11 +-
src/index.ts | 28 +-
src/locales/ar/ar.json | 6 +
src/locales/de/de.json | 6 +
src/locales/en/en.json | 6 +
src/locales/es/es.json | 6 +
src/locales/fr/fr.json | 6 +
src/locales/he/he.json | 6 +
src/locales/hi/hi.json | 6 +
src/locales/it/it.json | 6 +
src/locales/ja/ja.json | 6 +
src/locales/ko/ko.json | 6 +
src/locales/pt-BR/pt-BR.json | 6 +
src/locales/zh-CN/zh-CN.json | 6 +
src/locales/zh-TW/zh-TW.json | 6 +
src/services/index.ts | 12 +-
src/services/useAmplifyAuthService.ts | 36 --
src/services/useAuthService.ts | 56 +++
.../{useAwsService.ts => useClientService.ts} | 12 +-
...ofenceService.ts => useGeofenceService.ts} | 8 +-
.../{useAwsIotService.ts => useIotService.ts} | 8 +-
...eAwsPlaceService.ts => usePlaceService.ts} | 10 +-
...eAwsRouteService.ts => useRouteService.ts} | 8 +-
src/services/useWebSocketService.ts | 321 ++++++++++--------
src/setupTests.ts | 4 +-
src/stores/index.ts | 14 +-
...useAmplifyAuthStore.ts => useAuthStore.ts} | 18 +-
.../{useAwsStore.ts => useClientStore.ts} | 6 +-
...wsGeofenceStore.ts => useGeofenceStore.ts} | 6 +-
.../{useAmplifyMapStore.ts => useMapStore.ts} | 10 +-
.../{useAwsPlaceStore.ts => usePlaceStore.ts} | 6 +-
.../{useAwsRouteStore.ts => useRouteStore.ts} | 6 +-
...eAwsTrackerStore.ts => useTrackerStore.ts} | 6 +-
.../{AmplifyAuthModel.ts => AwsAuthModel.ts} | 16 +-
src/types/Enums.ts | 12 +
src/types/index.ts | 5 +-
src/utils/analyticsUtils.ts | 9 +-
src/utils/errorHandler.ts | 4 +-
src/utils/index.ts | 1 +
src/utils/regionUtils.ts | 2 +-
vite.library.ts | 3 +-
87 files changed, 1284 insertions(+), 960 deletions(-)
rename src/hooks/{useAmplifyAuth.ts => useAuth.ts} (63%)
rename src/hooks/{useAws.ts => useClient.ts} (54%)
rename src/hooks/{useAwsGeofence.ts => useGeofence.ts} (91%)
rename src/hooks/{useAwsIot.ts => useIot.ts} (83%)
rename src/hooks/{useAmplifyMap.ts => useMap.ts} (92%)
rename src/hooks/{useAwsPlace.ts => usePlace.ts} (89%)
rename src/hooks/{useAwsRoute.ts => useRoute.ts} (81%)
rename src/hooks/{useAwsTracker.ts => useTracker.ts} (83%)
delete mode 100644 src/services/useAmplifyAuthService.ts
create mode 100644 src/services/useAuthService.ts
rename src/services/{useAwsService.ts => useClientService.ts} (56%)
rename src/services/{useAwsGeofenceService.ts => useGeofenceService.ts} (92%)
rename src/services/{useAwsIotService.ts => useIotService.ts} (85%)
rename src/services/{useAwsPlaceService.ts => usePlaceService.ts} (92%)
rename src/services/{useAwsRouteService.ts => useRouteService.ts} (85%)
rename src/stores/{useAmplifyAuthStore.ts => useAuthStore.ts} (56%)
rename src/stores/{useAwsStore.ts => useClientStore.ts} (68%)
rename src/stores/{useAwsGeofenceStore.ts => useGeofenceStore.ts} (79%)
rename src/stores/{useAmplifyMapStore.ts => useMapStore.ts} (75%)
rename src/stores/{useAwsPlaceStore.ts => usePlaceStore.ts} (80%)
rename src/stores/{useAwsRouteStore.ts => useRouteStore.ts} (75%)
rename src/stores/{useAwsTrackerStore.ts => useTrackerStore.ts} (68%)
rename src/types/{AmplifyAuthModel.ts => AwsAuthModel.ts} (50%)
diff --git a/package-lock.json b/package-lock.json
index 891c5d80..e7aa0787 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -16,6 +16,7 @@
"@aws-sdk/credential-providers": "3.370.0",
"@turf/turf": "6.5.0",
"aws-amplify": "5.3.19",
+ "aws-iot-device-sdk-v2": "1.20.0",
"date-fns": "2.29.3",
"i18next": "23.2.8",
"i18next-browser-languagedetector": "7.1.0",
@@ -43,7 +44,6 @@
"@types/ramda": "0.28.18",
"@types/react": "18.0.17",
"@types/react-dom": "18.0.6",
- "@types/zen-observable": "0.8.3",
"@typescript-eslint/eslint-plugin": "5.33.1",
"@typescript-eslint/parser": "5.33.1",
"@vitejs/plugin-react": "2.1.0",
@@ -13876,6 +13876,21 @@
"integrity": "sha512-sTcG+QZ6fdEUObICavU+aB3Mp8HY4n14wYHdxK4fXjPmv3PXZZeY5RaguJmGyeH/CJQhX3fqKUtS4qc1LoHwhQ==",
"license": "MIT"
},
+ "node_modules/@httptoolkit/websocket-stream": {
+ "version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/@httptoolkit/websocket-stream/-/websocket-stream-6.0.1.tgz",
+ "integrity": "sha512-A0NOZI+Glp3Xgcz6Na7i7o09+/+xm2m0UCU8gdtM2nIv6/cjLmhMZMqehSpTlgbx9omtLmV8LVqOskPEyWnmZQ==",
+ "dependencies": {
+ "@types/ws": "*",
+ "duplexify": "^3.5.1",
+ "inherits": "^2.0.1",
+ "isomorphic-ws": "^4.0.1",
+ "readable-stream": "^2.3.3",
+ "safe-buffer": "^5.1.2",
+ "ws": "*",
+ "xtend": "^4.0.0"
+ }
+ },
"node_modules/@humanwhocodes/config-array": {
"version": "0.10.7",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.10.7.tgz",
@@ -20510,7 +20525,6 @@
"version": "8.5.11",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.11.tgz",
"integrity": "sha512-4+q7P5h3SpJxaBft0Dzpbr6lmMaqh0Jr2tbhJZ/luAwvD7ohSCniYkwz/pLxuT2h0EOa6QADgJj1Ko+TzRfZ+w==",
- "dev": true,
"license": "MIT",
"dependencies": {
"@types/node": "*"
@@ -20544,13 +20558,6 @@
"@types/node": "*"
}
},
- "node_modules/@types/zen-observable": {
- "version": "0.8.3",
- "resolved": "https://registry.npmjs.org/@types/zen-observable/-/zen-observable-0.8.3.tgz",
- "integrity": "sha512-fbF6oTd4sGGy0xjHPKAt+eS2CrxJ3+6gQ3FGcBoIJR2TLAyCkCyI8JqZNy+FeON0AhVgNJoUumVoZQjBFUqHkw==",
- "dev": true,
- "license": "MIT"
- },
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "5.33.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.33.1.tgz",
@@ -22000,6 +22007,53 @@
"tslib": "^2.0.0"
}
},
+ "node_modules/aws-crt": {
+ "version": "1.21.2",
+ "resolved": "https://registry.npmjs.org/aws-crt/-/aws-crt-1.21.2.tgz",
+ "integrity": "sha512-/jq5yJwdethIaC+HyqCrgW2ZqxjUURBo/6CIfnD0HbpIE+vLIPQxENW/pp3Atu20Hm2WkjM9diJD4zJycK+olA==",
+ "hasInstallScript": true,
+ "dependencies": {
+ "@aws-sdk/util-utf8-browser": "^3.109.0",
+ "@httptoolkit/websocket-stream": "^6.0.1",
+ "axios": "^1.6.8",
+ "buffer": "^6.0.3",
+ "crypto-js": "^4.2.0",
+ "mqtt": "^4.3.8",
+ "process": "^0.11.10"
+ }
+ },
+ "node_modules/aws-crt/node_modules/buffer": {
+ "version": "6.0.3",
+ "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
+ "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/feross"
+ },
+ {
+ "type": "patreon",
+ "url": "https://www.patreon.com/feross"
+ },
+ {
+ "type": "consulting",
+ "url": "https://feross.org/support"
+ }
+ ],
+ "dependencies": {
+ "base64-js": "^1.3.1",
+ "ieee754": "^1.2.1"
+ }
+ },
+ "node_modules/aws-iot-device-sdk-v2": {
+ "version": "1.20.0",
+ "resolved": "https://registry.npmjs.org/aws-iot-device-sdk-v2/-/aws-iot-device-sdk-v2-1.20.0.tgz",
+ "integrity": "sha512-qwt7vMLlqZK8XKADODoyNMGjlmj5xsSloq/SAh/o7s4PvQ9qiLK3luHDfw0BfayZKYfcRMPah5YERrskESbSow==",
+ "dependencies": {
+ "@aws-sdk/util-utf8-browser": "^3.109.0",
+ "aws-crt": "1.21.2"
+ }
+ },
"node_modules/aws-sign2": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz",
@@ -22473,7 +22527,6 @@
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz",
"integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==",
- "dev": true,
"license": "MIT",
"dependencies": {
"buffer": "^5.5.0",
@@ -22485,7 +22538,6 @@
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
- "dev": true,
"funding": [
{
"type": "github",
@@ -22510,7 +22562,6 @@
"version": "3.6.2",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
"integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
- "dev": true,
"license": "MIT",
"dependencies": {
"inherits": "^2.0.3",
@@ -23565,6 +23616,23 @@
"node": ">= 6"
}
},
+ "node_modules/commist": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/commist/-/commist-1.1.0.tgz",
+ "integrity": "sha512-rraC8NXWOEjhADbZe9QBNzLAN5Q3fsTPQtBV+fEVj6xKIgDgNiEVE6ZNfHpZOqfQ21YUzfVNUXLOEZquYvQPPg==",
+ "dependencies": {
+ "leven": "^2.1.0",
+ "minimist": "^1.1.0"
+ }
+ },
+ "node_modules/commist/node_modules/leven": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz",
+ "integrity": "sha512-nvVPLpIHUxCUoRLrFqTgSxXJ614d8AgQoWl7zPe/2VadE8+1dpU3LBhowRuBAcuwruWtOdD8oYC9jDNJjXDPyA==",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
"node_modules/common-path-prefix": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/common-path-prefix/-/common-path-prefix-3.0.0.tgz",
@@ -23884,6 +23952,11 @@
"node": ">= 8"
}
},
+ "node_modules/crypto-js": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz",
+ "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
+ },
"node_modules/crypto-random-string": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz",
@@ -24724,7 +24797,6 @@
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz",
"integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==",
- "dev": true,
"license": "MIT",
"dependencies": {
"ms": "2.1.2"
@@ -25520,6 +25592,17 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/duplexify": {
+ "version": "3.7.1",
+ "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz",
+ "integrity": "sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==",
+ "dependencies": {
+ "end-of-stream": "^1.0.0",
+ "inherits": "^2.0.1",
+ "readable-stream": "^2.0.0",
+ "stream-shift": "^1.0.0"
+ }
+ },
"node_modules/earcut": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/earcut/-/earcut-2.2.4.tgz",
@@ -25710,7 +25793,6 @@
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
"integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
- "dev": true,
"license": "MIT",
"dependencies": {
"once": "^1.4.0"
@@ -28835,6 +28917,28 @@
"tslib": "^2.0.3"
}
},
+ "node_modules/help-me": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/help-me/-/help-me-3.0.0.tgz",
+ "integrity": "sha512-hx73jClhyk910sidBB7ERlnhMlFsJJIBqSVMFDwPN8o2v9nmp5KgLq1Xz1Bf1fCMMZ6mPrX159iG0VLy/fPMtQ==",
+ "dependencies": {
+ "glob": "^7.1.6",
+ "readable-stream": "^3.6.0"
+ }
+ },
+ "node_modules/help-me/node_modules/readable-stream": {
+ "version": "3.6.2",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
+ "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
+ "dependencies": {
+ "inherits": "^2.0.3",
+ "string_decoder": "^1.1.1",
+ "util-deprecate": "^1.0.1"
+ },
+ "engines": {
+ "node": ">= 6"
+ }
+ },
"node_modules/hoopy": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz",
@@ -30153,6 +30257,14 @@
"unfetch": "^4.2.0"
}
},
+ "node_modules/isomorphic-ws": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz",
+ "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==",
+ "peerDependencies": {
+ "ws": "*"
+ }
+ },
"node_modules/isstream": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
@@ -32959,6 +33071,15 @@
"resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-2.2.1.tgz",
"integrity": "sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ=="
},
+ "node_modules/js-sdsl": {
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.3.0.tgz",
+ "integrity": "sha512-mifzlm2+5nZ+lEcLJMoBK0/IH/bDg8XnJfd/Wq6IP+xoCjLZsTOnV2QpxlVbX9bMnkl5PdEjNtBJ9Cj1NjifhQ==",
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/js-sdsl"
+ }
+ },
"node_modules/js-string-escape": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz",
@@ -34612,6 +34733,102 @@
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
+ "node_modules/mqtt": {
+ "version": "4.3.8",
+ "resolved": "https://registry.npmjs.org/mqtt/-/mqtt-4.3.8.tgz",
+ "integrity": "sha512-2xT75uYa0kiPEF/PE0VPdavmEkoBzMT/UL9moid0rAvlCtV48qBwxD62m7Ld/4j8tSkIO1E/iqRl/S72SEOhOw==",
+ "dependencies": {
+ "commist": "^1.0.0",
+ "concat-stream": "^2.0.0",
+ "debug": "^4.1.1",
+ "duplexify": "^4.1.1",
+ "help-me": "^3.0.0",
+ "inherits": "^2.0.3",
+ "lru-cache": "^6.0.0",
+ "minimist": "^1.2.5",
+ "mqtt-packet": "^6.8.0",
+ "number-allocator": "^1.0.9",
+ "pump": "^3.0.0",
+ "readable-stream": "^3.6.0",
+ "reinterval": "^1.1.0",
+ "rfdc": "^1.3.0",
+ "split2": "^3.1.0",
+ "ws": "^7.5.5",
+ "xtend": "^4.0.2"
+ },
+ "bin": {
+ "mqtt": "bin/mqtt.js",
+ "mqtt_pub": "bin/pub.js",
+ "mqtt_sub": "bin/sub.js"
+ },
+ "engines": {
+ "node": ">=10.0.0"
+ }
+ },
+ "node_modules/mqtt-packet": {
+ "version": "6.10.0",
+ "resolved": "https://registry.npmjs.org/mqtt-packet/-/mqtt-packet-6.10.0.tgz",
+ "integrity": "sha512-ja8+mFKIHdB1Tpl6vac+sktqy3gA8t9Mduom1BA75cI+R9AHnZOiaBQwpGiWnaVJLDGRdNhQmFaAqd7tkKSMGA==",
+ "dependencies": {
+ "bl": "^4.0.2",
+ "debug": "^4.1.1",
+ "process-nextick-args": "^2.0.1"
+ }
+ },
+ "node_modules/mqtt/node_modules/concat-stream": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz",
+ "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==",
+ "engines": [
+ "node >= 6.0"
+ ],
+ "dependencies": {
+ "buffer-from": "^1.0.0",
+ "inherits": "^2.0.3",
+ "readable-stream": "^3.0.2",
+ "typedarray": "^0.0.6"
+ }
+ },
+ "node_modules/mqtt/node_modules/duplexify": {
+ "version": "4.1.3",
+ "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-4.1.3.tgz",
+ "integrity": "sha512-M3BmBhwJRZsSx38lZyhE53Csddgzl5R7xGJNk7CVddZD6CcmwMCH8J+7AprIrQKH7TonKxaCjcv27Qmf+sQ+oA==",
+ "dependencies": {
+ "end-of-stream": "^1.4.1",
+ "inherits": "^2.0.3",
+ "readable-stream": "^3.1.1",
+ "stream-shift": "^1.0.2"
+ }
+ },
+ "node_modules/mqtt/node_modules/lru-cache": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
+ "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
+ "dependencies": {
+ "yallist": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/mqtt/node_modules/readable-stream": {
+ "version": "3.6.2",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
+ "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
+ "dependencies": {
+ "inherits": "^2.0.3",
+ "string_decoder": "^1.1.1",
+ "util-deprecate": "^1.0.1"
+ },
+ "engines": {
+ "node": ">= 6"
+ }
+ },
+ "node_modules/mqtt/node_modules/yallist": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
+ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
+ },
"node_modules/mrmime": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.0.tgz",
@@ -34626,7 +34843,6 @@
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
- "dev": true,
"license": "MIT"
},
"node_modules/multicast-dns": {
@@ -34894,6 +35110,15 @@
"url": "https://github.com/fb55/nth-check?sponsor=1"
}
},
+ "node_modules/number-allocator": {
+ "version": "1.0.14",
+ "resolved": "https://registry.npmjs.org/number-allocator/-/number-allocator-1.0.14.tgz",
+ "integrity": "sha512-OrL44UTVAvkKdOdRQZIJpLkAdjXGTRda052sN4sO77bKEzYYqWKMBjQvrJFzqygI99gL6Z4u2xctPW1tB8ErvA==",
+ "dependencies": {
+ "debug": "^4.3.1",
+ "js-sdsl": "4.3.0"
+ }
+ },
"node_modules/nwsapi": {
"version": "2.2.12",
"resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.12.tgz",
@@ -37412,6 +37637,14 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/process": {
+ "version": "0.11.10",
+ "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
+ "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==",
+ "engines": {
+ "node": ">= 0.6.0"
+ }
+ },
"node_modules/process-nextick-args": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
@@ -37507,7 +37740,6 @@
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
"integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==",
- "dev": true,
"license": "MIT",
"dependencies": {
"end-of-stream": "^1.1.0",
@@ -38658,6 +38890,11 @@
"jsesc": "bin/jsesc"
}
},
+ "node_modules/reinterval": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/reinterval/-/reinterval-1.1.0.tgz",
+ "integrity": "sha512-QIRet3SYrGp0HUHO88jVskiG6seqUGC5iAG7AwI/BV4ypGcuqk9Du6YQBUOUqm9c8pw1eyLoIaONifRua1lsEQ=="
+ },
"node_modules/relateurl": {
"version": "0.2.7",
"resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz",
@@ -38915,7 +39152,6 @@
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.4.1.tgz",
"integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==",
- "dev": true,
"license": "MIT"
},
"node_modules/rimraf": {
@@ -39130,7 +39366,6 @@
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
- "dev": true,
"funding": [
{
"type": "github",
@@ -39881,6 +40116,27 @@
"integrity": "sha512-4OM2BJgC5UzrhVnnJA4BkHKGtjXNzzUfpQjCO8I05xYPsfS/VuQDwjCGGMi8rYQilHEV4j8NBqTFbls/PZEE7A==",
"license": "MIT"
},
+ "node_modules/split2": {
+ "version": "3.2.2",
+ "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz",
+ "integrity": "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==",
+ "dependencies": {
+ "readable-stream": "^3.0.0"
+ }
+ },
+ "node_modules/split2/node_modules/readable-stream": {
+ "version": "3.6.2",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
+ "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
+ "dependencies": {
+ "inherits": "^2.0.3",
+ "string_decoder": "^1.1.1",
+ "util-deprecate": "^1.0.1"
+ },
+ "engines": {
+ "node": ">= 6"
+ }
+ },
"node_modules/sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
@@ -40083,6 +40339,11 @@
"node": ">= 0.4"
}
},
+ "node_modules/stream-shift": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.3.tgz",
+ "integrity": "sha512-76ORR0DO1o1hlKwTbi/DM3EXWGf3ZJYO8cXX5RJwnul2DEg2oyoZyjLNoQM8WsvZiFKCRfC1O0J7iCvie3RZmQ=="
+ },
"node_modules/string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
@@ -44008,7 +44269,6 @@
"version": "7.5.10",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
"integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=8.3.0"
diff --git a/package.json b/package.json
index 9c2ede05..d9c225f7 100644
--- a/package.json
+++ b/package.json
@@ -46,6 +46,7 @@
"@aws-sdk/credential-providers": "3.370.0",
"@turf/turf": "6.5.0",
"aws-amplify": "5.3.19",
+ "aws-iot-device-sdk-v2": "1.20.0",
"date-fns": "2.29.3",
"i18next": "23.2.8",
"i18next-browser-languagedetector": "7.1.0",
@@ -73,7 +74,6 @@
"@types/ramda": "0.28.18",
"@types/react": "18.0.17",
"@types/react-dom": "18.0.6",
- "@types/zen-observable": "0.8.3",
"@typescript-eslint/eslint-plugin": "5.33.1",
"@typescript-eslint/parser": "5.33.1",
"@vitejs/plugin-react": "2.1.0",
diff --git a/src/atomicui/molecules/ConnectAwsAccountModal/ConnectAwsAccountModal.test.tsx b/src/atomicui/molecules/ConnectAwsAccountModal/ConnectAwsAccountModal.test.tsx
index 1423688d..d2ee4036 100644
--- a/src/atomicui/molecules/ConnectAwsAccountModal/ConnectAwsAccountModal.test.tsx
+++ b/src/atomicui/molecules/ConnectAwsAccountModal/ConnectAwsAccountModal.test.tsx
@@ -18,7 +18,7 @@ const mockProps: ConnectAwsAccountModalProps = {
handleCurrentLocationAndViewpoint: jest.fn()
};
-const mockUseAmplifyAuthData = {
+const mockUseAuthData = {
region: "ap-southeast-1",
isUserAwsAccountConnected: false,
setConnectFormValues: jest.fn(),
@@ -31,20 +31,20 @@ const mockUseAmplifyAuthData = {
handleStackRegion: jest.fn()
};
-const mockUseAmplifyMapData = {
+const mockUseMapData = {
mapProvider: "Grab",
setMapProvider: jest.fn(),
setMapStyle: jest.fn()
};
-const mockUseAwsData = {
+const mockUseClientData = {
resetStore: jest.fn()
};
jest.mock("@demo/hooks", () => ({
- useAmplifyAuth: () => mockUseAmplifyAuthData,
- useAmplifyMap: () => mockUseAmplifyMapData,
- useAws: () => mockUseAwsData,
+ useAuth: () => mockUseAuthData,
+ useMap: () => mockUseMapData,
+ useClient: () => mockUseClientData,
useMediaQuery: () => true
}));
@@ -65,7 +65,7 @@ describe("", () => {
);
beforeEach(() => {
- mockUseAmplifyAuthData.isUserAwsAccountConnected = false;
+ mockUseAuthData.isUserAwsAccountConnected = false;
i18n.changeLanguage("en");
});
@@ -128,11 +128,11 @@ describe("", () => {
() => {
expect(getByTestId("connect-button")).toBeEnabled();
fireEvent.click(getByTestId("connect-button"));
- expect(mockUseAmplifyAuthData.validateFormValues).toHaveBeenCalledWith();
- expect(mockUseAmplifyAuthData.setConnectFormValues).toHaveBeenCalled();
- expect(mockUseAmplifyAuthData.clearCredentials).toHaveBeenCalled();
- expect(mockUseAwsData.resetStore).toHaveBeenCalled();
- expect(mockUseAmplifyAuthData.setIsUserAwsAccountConnected).toHaveBeenCalled();
+ expect(mockUseAuthData.validateFormValues).toHaveBeenCalledWith();
+ expect(mockUseAuthData.setConnectFormValues).toHaveBeenCalled();
+ expect(mockUseAuthData.clearCredentials).toHaveBeenCalled();
+ expect(mockUseClientData.resetStore).toHaveBeenCalled();
+ expect(mockUseAuthData.setIsUserAwsAccountConnected).toHaveBeenCalled();
},
{
timeout: 10000,
@@ -146,7 +146,7 @@ describe("", () => {
});
it("should allow to continue to explore page after connecting successfully", () => {
- mockUseAmplifyAuthData.isUserAwsAccountConnected = true;
+ mockUseAuthData.isUserAwsAccountConnected = true;
const { getByTestId } = renderComponent();
waitFor(
@@ -169,7 +169,7 @@ describe("", () => {
});
it("should allow to signin after connecting successfully", () => {
- mockUseAmplifyAuthData.isUserAwsAccountConnected = true;
+ mockUseAuthData.isUserAwsAccountConnected = true;
const { getByTestId } = renderComponent();
waitFor(
@@ -178,7 +178,7 @@ describe("", () => {
expect(getByTestId("continue-to-explore")).toBeInTheDocument();
fireEvent.click(getByTestId("sign-in-button"));
expect(mockProps.onClose).toHaveBeenCalled();
- expect(mockUseAmplifyAuthData.onLogin).toHaveBeenCalled();
+ expect(mockUseAuthData.onLogin).toHaveBeenCalled();
},
{
timeout: 10000,
@@ -205,7 +205,7 @@ describe("", () => {
expect(getByTestId("modal-container")).toBeInTheDocument();
fireEvent.click(getByTestId("modal-container"));
expect(mockProps.onClose).toHaveBeenCalled();
- expect(mockUseAmplifyAuthData.onLogin).toHaveBeenCalled();
+ expect(mockUseAuthData.onLogin).toHaveBeenCalled();
},
{
timeout: 10000,
diff --git a/src/atomicui/molecules/ConnectAwsAccountModal/ConnectAwsAccountModal.tsx b/src/atomicui/molecules/ConnectAwsAccountModal/ConnectAwsAccountModal.tsx
index 2682195b..48e6b0ea 100644
--- a/src/atomicui/molecules/ConnectAwsAccountModal/ConnectAwsAccountModal.tsx
+++ b/src/atomicui/molecules/ConnectAwsAccountModal/ConnectAwsAccountModal.tsx
@@ -8,7 +8,7 @@ import { IconAwsCloudFormation, IconCheckMarkCircle } from "@demo/assets/svgs";
import { DropdownEl, Modal } from "@demo/atomicui/atoms";
import { InputField } from "@demo/atomicui/molecules";
import { appConfig, regionsData } from "@demo/core/constants";
-import { useAmplifyAuth, useAmplifyMap, useAws } from "@demo/hooks";
+import { useAuth, useClient, useMap } from "@demo/hooks";
import useDeviceMediaQuery from "@demo/hooks/useDeviceMediaQuery";
import { ConnectFormValuesType, EsriMapEnum, MapProviderEnum } from "@demo/types";
import { AnalyticsEventActionsEnum, EventTypeEnum, TriggeredByEnum } from "@demo/types/Enums";
@@ -52,9 +52,9 @@ const ConnectAwsAccountModal: FC = ({
stackRegion,
cloudFormationLink,
handleStackRegion
- } = useAmplifyAuth();
- const { resetStore: resetAwsStore } = useAws();
- const { mapProvider: currentMapProvider, setMapProvider, setMapStyle } = useAmplifyMap();
+ } = useAuth();
+ const { resetStore: resetClientStore } = useClient();
+ const { mapProvider: currentMapProvider, setMapProvider, setMapStyle } = useMap();
const keyArr = Object.keys(formValues);
const { t, i18n } = useTranslation();
const langDir = i18n.dir();
@@ -125,20 +125,10 @@ const ConnectAwsAccountModal: FC = ({
};
const onConnect = () => {
- const {
- IdentityPoolId: identityPoolId,
- UserPoolId: userPoolId,
- UserPoolClientId: userPoolWebClientId,
- UserDomain: domain,
- WebSocketUrl: webSocketUrl
- } = formValues;
+ const { IdentityPoolId: identityPoolId } = formValues;
validateFormValues(
identityPoolId,
- userPoolId,
- userPoolWebClientId,
- domain,
- webSocketUrl,
/* Success callback */
() => {
if (
@@ -152,17 +142,12 @@ const ConnectAwsAccountModal: FC = ({
setConnectFormValues(formValues);
clearCredentials();
- resetAwsStore();
+ resetClientStore();
setIsUserAwsAccountConnected(true);
}
);
};
- const _onLogin = async () => {
- onClose();
- await onLogin();
- };
-
const handleModalClose = () => {
_onClose();
@@ -327,8 +312,8 @@ const ConnectAwsAccountModal: FC = ({
height="3.08rem"
variation="primary"
fontFamily="AmazonEmber-Bold"
- onClick={async () => {
- await record(
+ onClick={() => {
+ record(
[
{
EventType: EventTypeEnum.SIGN_IN_STARTED,
@@ -337,7 +322,8 @@ const ConnectAwsAccountModal: FC = ({
],
["userAWSAccountConnectionStatus", "userAuthenticationStatus"]
);
- await _onLogin();
+ onClose();
+ onLogin();
}}
>
{t("sign_in.text")}
@@ -348,8 +334,9 @@ const ConnectAwsAccountModal: FC = ({
className="continue-to-explore"
width="100%"
height="3.08rem"
- onClick={async () => {
- await record(
+ onClick={() => {
+ _onClose();
+ record(
[
{
EventType: EventTypeEnum.CONTINUE_TO_DEMO_CLICKED,
@@ -358,8 +345,6 @@ const ConnectAwsAccountModal: FC = ({
],
["userAWSAccountConnectionStatus", "userAuthenticationStatus"]
);
-
- _onClose();
}}
>
{t("caam__continue_to_demo.text")}
diff --git a/src/atomicui/molecules/MapButtons/MapButtons.test.tsx b/src/atomicui/molecules/MapButtons/MapButtons.test.tsx
index 65358aa8..b65b9f32 100644
--- a/src/atomicui/molecules/MapButtons/MapButtons.test.tsx
+++ b/src/atomicui/molecules/MapButtons/MapButtons.test.tsx
@@ -49,7 +49,7 @@ const mockProps: MapButtonsProps = {
onSetShowUnauthTrackerBox: jest.fn()
};
-const mockUseAmplifyAuthData = {
+const mockUseAuthData = {
credentials: {
accessKeyId: faker.random.word(),
sessionToken: faker.random.word(),
@@ -61,12 +61,12 @@ const mockUseAmplifyAuthData = {
isUserAwsAccountConnected: false
};
-const mockUseAmplifyMapData = {
+const mockUseMapData = {
mapProvider: MapProviderEnum.ESRI,
mapStyle: EsriMapEnum.ESRI_STREET_MAP
};
-const mockUseAwsGeofenceData = {
+const mockUseGeofenceData = {
isAddingGeofence: false,
setIsAddingGeofence: jest.fn()
};
@@ -76,9 +76,9 @@ const mockUseUnauthSimulationData = {
};
jest.mock("@demo/hooks", () => ({
- useAmplifyAuth: () => mockUseAmplifyAuthData,
- useAmplifyMap: () => mockUseAmplifyMapData,
- useAwsGeofence: () => mockUseAwsGeofenceData,
+ useAuth: () => mockUseAuthData,
+ useMap: () => mockUseMapData,
+ useGeofence: () => mockUseGeofenceData,
useUnauthSimulation: () => mockUseUnauthSimulationData
}));
@@ -93,9 +93,9 @@ describe("", () => {
beforeEach(() => {
mockProps.onlyMapStyles = false;
- mockUseAmplifyAuthData.isUserAwsAccountConnected = false;
- mockUseAmplifyAuthData.credentials.authenticated = false;
- mockUseAmplifyMapData.mapProvider = MapProviderEnum.ESRI;
+ mockUseAuthData.isUserAwsAccountConnected = false;
+ mockUseAuthData.credentials.authenticated = false;
+ mockUseMapData.mapProvider = MapProviderEnum.ESRI;
});
it("renders map style when onlyMapStyles prop set to true", () => {
@@ -187,8 +187,8 @@ describe("", () => {
it("should reset filters when click on", () => {});
it("renders geofence button and executes correctly when user AWS account connected and authenticated", () => {
- mockUseAmplifyAuthData.isUserAwsAccountConnected = true;
- mockUseAmplifyAuthData.credentials.authenticated = true;
+ mockUseAuthData.isUserAwsAccountConnected = true;
+ mockUseAuthData.credentials.authenticated = true;
const { getByTestId } = renderComponent();
expect(getByTestId("geofence-control-button")).toBeInTheDocument();
act(() => {
@@ -198,7 +198,7 @@ describe("", () => {
expect(mockProps.onCloseSidebar).toHaveBeenCalled();
expect(mockProps.onSetShowAuthTrackerBox).toHaveBeenCalled();
expect(mockProps.onSetShowAuthGeofenceBox).toHaveBeenCalled();
- expect(mockUseAwsGeofenceData.setIsAddingGeofence).toHaveBeenCalled();
+ expect(mockUseGeofenceData.setIsAddingGeofence).toHaveBeenCalled();
});
});
@@ -215,7 +215,7 @@ describe("", () => {
});
it("renders geofence button and executes correctly when user AWS account not connected and map is Grab", () => {
- mockUseAmplifyMapData.mapProvider = MapProviderEnum.GRAB;
+ mockUseMapData.mapProvider = MapProviderEnum.GRAB;
const { getByTestId } = renderComponent();
expect(getByTestId("geofence-control-button")).toBeInTheDocument();
act(() => {
@@ -241,8 +241,8 @@ describe("", () => {
});
it("renders tracker button and executes correctly when user AWS account connected and authenticated and map is Esri", () => {
- mockUseAmplifyAuthData.isUserAwsAccountConnected = true;
- mockUseAmplifyAuthData.credentials.authenticated = true;
+ mockUseAuthData.isUserAwsAccountConnected = true;
+ mockUseAuthData.credentials.authenticated = true;
const { getByTestId } = renderComponent();
expect(getByTestId("tracker-control-button")).toBeInTheDocument();
act(() => {
@@ -250,16 +250,16 @@ describe("", () => {
});
waitFor(() => {
expect(mockProps.onCloseSidebar).toHaveBeenCalled();
- expect(mockUseAwsGeofenceData.setIsAddingGeofence).toHaveBeenCalled();
+ expect(mockUseGeofenceData.setIsAddingGeofence).toHaveBeenCalled();
expect(mockProps.onSetShowAuthGeofenceBox).toHaveBeenCalled();
expect(mockProps.onShowAuthTrackerDisclaimerModal).toHaveBeenCalled();
});
});
it("renders tracker button and executes correctly when user AWS account not connected", () => {
- mockUseAmplifyAuthData.isUserAwsAccountConnected = true;
- mockUseAmplifyAuthData.credentials.authenticated = true;
- mockUseAmplifyMapData.mapProvider = MapProviderEnum.GRAB;
+ mockUseAuthData.isUserAwsAccountConnected = true;
+ mockUseAuthData.credentials.authenticated = true;
+ mockUseMapData.mapProvider = MapProviderEnum.GRAB;
const { getByTestId } = renderComponent();
expect(getByTestId("tracker-control-button")).toBeInTheDocument();
act(() => {
diff --git a/src/atomicui/molecules/MapButtons/MapButtons.tsx b/src/atomicui/molecules/MapButtons/MapButtons.tsx
index f51a221e..0469a186 100644
--- a/src/atomicui/molecules/MapButtons/MapButtons.tsx
+++ b/src/atomicui/molecules/MapButtons/MapButtons.tsx
@@ -38,7 +38,7 @@ import {
} from "@demo/assets/svgs";
import { appConfig } from "@demo/core/constants";
import BottomSheetHeights from "@demo/core/constants/bottomSheetHeights";
-import { useAmplifyAuth, useAmplifyMap, useAwsGeofence, useUnauthSimulation } from "@demo/hooks";
+import { useAuth, useGeofence, useMap, useUnauthSimulation } from "@demo/hooks";
import useBottomSheet from "@demo/hooks/useBottomSheet";
import useDeviceMediaQuery from "@demo/hooks/useDeviceMediaQuery";
import {
@@ -158,9 +158,9 @@ const MapButtons: FC = ({
const [searchWidth, setSearchWidth] = useState(isHandDevice ? searchHandDeviceWidth : searchDesktopWidth);
const stylesCardRef = useRef(null);
const stylesCardTogglerRef = useRef(null);
- const { credentials, isUserAwsAccountConnected } = useAmplifyAuth();
- const { mapProvider: currentMapProvider, mapStyle: currentMapStyle } = useAmplifyMap();
- const { isAddingGeofence, setIsAddingGeofence } = useAwsGeofence();
+ const { credentials, isUserAwsAccountConnected } = useAuth();
+ const { mapProvider: currentMapProvider, mapStyle: currentMapStyle } = useMap();
+ const { isAddingGeofence, setIsAddingGeofence } = useGeofence();
const isAuthenticated = !!credentials?.authenticated;
const { isTablet, isMobile, isDesktop, isDesktopBrowser } = useDeviceMediaQuery();
const { t, i18n } = useTranslation();
diff --git a/src/atomicui/molecules/Marker/Marker.tsx b/src/atomicui/molecules/Marker/Marker.tsx
index 7226f40f..95fcd61b 100644
--- a/src/atomicui/molecules/Marker/Marker.tsx
+++ b/src/atomicui/molecules/Marker/Marker.tsx
@@ -3,7 +3,7 @@
import { FC, lazy, memo, useCallback, useEffect, useState } from "react";
-import { useAwsPlace } from "@demo/hooks";
+import { usePlace } from "@demo/hooks";
import { SuggestionType } from "@demo/types";
import { uuid } from "@demo/utils/uuid";
@@ -20,7 +20,7 @@ interface Props {
const Marker: FC = ({ latitude, longitude, searchValue, setSearchValue }) => {
const [info, setInfo] = useState();
- const { getPlaceDataByCoordinates, setMarker, marker, selectedMarker } = useAwsPlace();
+ const { getPlaceDataByCoordinates, setMarker, marker, selectedMarker } = usePlace();
if (marker && selectedMarker) setMarker(undefined);
diff --git a/src/atomicui/molecules/Popup/Popup.test.tsx b/src/atomicui/molecules/Popup/Popup.test.tsx
index da1e9570..c2d351c4 100644
--- a/src/atomicui/molecules/Popup/Popup.test.tsx
+++ b/src/atomicui/molecules/Popup/Popup.test.tsx
@@ -15,7 +15,7 @@ jest.mock("react-map-gl", () => ({
Popup: PopupMock
}));
-const useAmplifyMapReturnValue: {
+const useMapReturnValue: {
currentLocationData: {
error: null | string;
};
@@ -34,9 +34,9 @@ const useAmplifyMapReturnValue: {
};
jest.mock("hooks", () => ({
- useAmplifyMap: () => useAmplifyMapReturnValue,
- useAwsPlace: () => ({}),
- useAwsRoute: () => ({
+ useMap: () => useMapReturnValue,
+ usePlace: () => ({}),
+ useRoute: () => ({
getRoute: () => {}
}),
useMediaQuery: () => true
diff --git a/src/atomicui/molecules/Popup/Popup.tsx b/src/atomicui/molecules/Popup/Popup.tsx
index a611a75c..93f997e0 100644
--- a/src/atomicui/molecules/Popup/Popup.tsx
+++ b/src/atomicui/molecules/Popup/Popup.tsx
@@ -7,7 +7,7 @@ import { Button, Flex, Placeholder, Text, View } from "@aws-amplify/ui-react";
import { CalculateRouteRequest, CalculateRouteResponse } from "@aws-sdk/client-location";
import { IconCar, IconClose, IconCopyPages, IconDirections, IconInfo } from "@demo/assets/svgs";
import BottomSheetHeights from "@demo/core/constants/bottomSheetHeights";
-import { useAmplifyMap, useAwsPlace, useAwsRoute } from "@demo/hooks";
+import { useMap, usePlace, useRoute } from "@demo/hooks";
import useBottomSheet from "@demo/hooks/useBottomSheet";
import useDeviceMediaQuery from "@demo/hooks/useDeviceMediaQuery";
import { DistanceUnitEnum, MapProviderEnum, MapUnitEnum, SuggestionType, TravelMode } from "@demo/types";
@@ -40,9 +40,9 @@ const Popup: FC = ({ active, info, select, onClosePopUp, setInfo }) => {
mapProvider: currentMapProvider,
mapUnit: currentMapUnit,
isCurrentLocationDisabled
- } = useAmplifyMap();
- const { clearPoiList } = useAwsPlace();
- const { getRoute, setDirections, isFetchingRoute } = useAwsRoute();
+ } = useMap();
+ const { clearPoiList } = usePlace();
+ const { getRoute, setDirections, isFetchingRoute } = useRoute();
const [longitude, latitude] = useMemo(() => info.Place?.Geometry?.Point as number[], [info]);
const { isDesktop } = useDeviceMediaQuery();
const { t, i18n } = useTranslation();
diff --git a/src/atomicui/molecules/SignInModal/SignInModal.test.tsx b/src/atomicui/molecules/SignInModal/SignInModal.test.tsx
index af50bb81..141a941f 100644
--- a/src/atomicui/molecules/SignInModal/SignInModal.test.tsx
+++ b/src/atomicui/molecules/SignInModal/SignInModal.test.tsx
@@ -4,15 +4,15 @@ import { I18nextProvider } from "react-i18next";
import SignInModal from "./SignInModal";
-const useAmplifyAuthReturnValue = {
+const useAuthReturnValue = {
onLogin: jest.fn()
};
-const useAmplifyAuth = () => useAmplifyAuthReturnValue;
+const useAuth = () => useAuthReturnValue;
const delay = (cb: () => void, ms: number) => setTimeout(cb, ms);
const onClose = jest.fn();
jest.mock("hooks", () => ({
- useAmplifyAuth
+ useAuth
}));
describe("", () => {
@@ -48,7 +48,7 @@ describe("", () => {
it("should call `onLogin` when `sign in` button is clicked", () => {
const { getByTestId } = renderComponent();
act(() => getByTestId("sign-in-button").click());
- delay(() => expect(useAmplifyAuthReturnValue.onLogin).toBeCalled(), 500);
+ delay(() => expect(useAuthReturnValue.onLogin).toBeCalled(), 500);
});
it("should call `onClose` when `Maybe later` button is clicked", () => {
diff --git a/src/atomicui/molecules/SignInModal/SignInModal.tsx b/src/atomicui/molecules/SignInModal/SignInModal.tsx
index 80e28a85..850d2226 100644
--- a/src/atomicui/molecules/SignInModal/SignInModal.tsx
+++ b/src/atomicui/molecules/SignInModal/SignInModal.tsx
@@ -5,7 +5,7 @@ import { FC, lazy } from "react";
import { Button, Flex, Text } from "@aws-amplify/ui-react";
import { IconGeofence, IconRoute } from "@demo/assets/svgs";
-import { useAmplifyAuth } from "@demo/hooks";
+import { useAuth } from "@demo/hooks";
import useDeviceMediaQuery from "@demo/hooks/useDeviceMediaQuery";
import { EventTypeEnum, TriggeredByEnum } from "@demo/types/Enums";
import { record } from "@demo/utils/analyticsUtils";
@@ -20,7 +20,7 @@ interface SignInModalProps {
}
const SignInModal: FC = ({ open, onClose }) => {
- const { onLogin } = useAmplifyAuth();
+ const { onLogin } = useAuth();
const { t } = useTranslation();
const { isMobile } = useDeviceMediaQuery();
@@ -61,7 +61,7 @@ const SignInModal: FC = ({ open, onClose }) => {
],
["userAWSAccountConnectionStatus", "userAuthenticationStatus"]
);
-
+ onClose();
onLogin();
}}
>
diff --git a/src/atomicui/molecules/StepCard/StepCard.test.tsx b/src/atomicui/molecules/StepCard/StepCard.test.tsx
index 6464eb73..9cd7e433 100644
--- a/src/atomicui/molecules/StepCard/StepCard.test.tsx
+++ b/src/atomicui/molecules/StepCard/StepCard.test.tsx
@@ -6,7 +6,7 @@ import { I18nextProvider } from "react-i18next";
import StepCard from "./StepCard";
-const useAwsPlace = () => ({
+const usePlace = () => ({
getPlaceDataByCoordinates: () => ({
Results: [
{
@@ -19,7 +19,7 @@ const useAwsPlace = () => ({
})
});
-jest.mock("hooks", () => ({ useAwsPlace, useAmplifyMap: () => ({ mapUnit: "Metric" }) }));
+jest.mock("hooks", () => ({ usePlace, useMap: () => ({ mapUnit: "Metric" }) }));
describe("", () => {
let stepCardContainer: HTMLElement;
diff --git a/src/atomicui/molecules/StepCard/StepCard.tsx b/src/atomicui/molecules/StepCard/StepCard.tsx
index c78646e0..d398418b 100644
--- a/src/atomicui/molecules/StepCard/StepCard.tsx
+++ b/src/atomicui/molecules/StepCard/StepCard.tsx
@@ -5,7 +5,7 @@ import { FC, memo, useCallback, useEffect, useRef, useState } from "react";
import { Flex, Text, View } from "@aws-amplify/ui-react";
import { Step } from "@aws-sdk/client-location";
-import { useAmplifyMap, useAwsPlace } from "@demo/hooks";
+import { useMap, usePlace } from "@demo/hooks";
import useDeviceMediaQuery from "@demo/hooks/useDeviceMediaQuery";
import { MapUnitEnum, SuggestionType, TravelMode } from "@demo/types";
import { uuid } from "@demo/utils/uuid";
@@ -23,8 +23,8 @@ interface StepCardProps {
const StepCard: FC = ({ step, isFirst, isLast }) => {
const [placeData, setPlaceData] = useState(undefined);
- const { mapUnit: currentMapUnit } = useAmplifyMap();
- const { getPlaceDataByCoordinates } = useAwsPlace();
+ const { mapUnit: currentMapUnit } = useMap();
+ const { getPlaceDataByCoordinates } = usePlace();
const onlyOneEl = isFirst && isLast;
const { t, i18n } = useTranslation();
const { isDesktop } = useDeviceMediaQuery();
diff --git a/src/atomicui/molecules/SuggestionMarker/SuggestionMarker.tsx b/src/atomicui/molecules/SuggestionMarker/SuggestionMarker.tsx
index 87575812..d4270a7c 100644
--- a/src/atomicui/molecules/SuggestionMarker/SuggestionMarker.tsx
+++ b/src/atomicui/molecules/SuggestionMarker/SuggestionMarker.tsx
@@ -5,7 +5,7 @@ import { FC, memo, useCallback, useEffect, useMemo, useState } from "react";
import { View } from "@aws-amplify/ui-react";
import { IconSelected, IconSuggestion } from "@demo/assets/svgs";
-import { useAwsPlace } from "@demo/hooks";
+import { usePlace } from "@demo/hooks";
import { SuggestionType } from "@demo/types";
import { Marker } from "react-map-gl";
@@ -30,7 +30,7 @@ const SuggestionMarker: FC = ({
...rest
}) => {
const [info, setInfo] = useState(undefined);
- const { getPlaceData, setSelectedMarker, suggestions, hoveredMarker, setHoveredMarker, clearPoiList } = useAwsPlace();
+ const { getPlaceData, setSelectedMarker, suggestions, hoveredMarker, setHoveredMarker, clearPoiList } = usePlace();
const getPlaceInfo = useCallback(
async (placeId: string) => {
diff --git a/src/atomicui/organisms/AboutModal/AboutModal.tsx b/src/atomicui/organisms/AboutModal/AboutModal.tsx
index 4b757f33..4baa511d 100644
--- a/src/atomicui/organisms/AboutModal/AboutModal.tsx
+++ b/src/atomicui/organisms/AboutModal/AboutModal.tsx
@@ -6,7 +6,7 @@ import { FC, lazy, useCallback, useEffect, useMemo, useState } from "react";
import { Button, Divider, Flex, Text } from "@aws-amplify/ui-react";
import { IconArrow, IconBackArrow, IconPoweredByAws1 } from "@demo/assets/svgs";
import { aboutModalData, appConfig } from "@demo/core/constants";
-import { useAmplifyMap } from "@demo/hooks";
+import { useMap } from "@demo/hooks";
import useDeviceMediaQuery from "@demo/hooks/useDeviceMediaQuery";
import { AboutOptionEnum, MapProviderEnum } from "@demo/types/Enums";
import { useTranslation } from "react-i18next";
@@ -37,7 +37,7 @@ interface AboutModalProps {
const AboutModal: FC = ({ open, onClose }) => {
const [selectedOption, setSelectedOption] = useState(AboutOptionEnum.ATTRIBUTION);
- const { mapProvider } = useAmplifyMap();
+ const { mapProvider } = useMap();
const { t, i18n } = useTranslation();
const langDir = i18n.dir();
const isLtr = langDir === "ltr";
diff --git a/src/atomicui/organisms/AuthGeofenceBox/AuthGeofenceBox.test.tsx b/src/atomicui/organisms/AuthGeofenceBox/AuthGeofenceBox.test.tsx
index 764f93f5..66cd55ce 100644
--- a/src/atomicui/organisms/AuthGeofenceBox/AuthGeofenceBox.test.tsx
+++ b/src/atomicui/organisms/AuthGeofenceBox/AuthGeofenceBox.test.tsx
@@ -50,7 +50,7 @@ const mockGeofencesData = [
}
];
-const mockUseAwsGeofenceData: {
+const mockUseGeofenceData: {
getGeofencesList: () => {};
isFetchingGeofences: boolean;
geofences?: Array;
@@ -68,18 +68,18 @@ const mockUseAwsGeofenceData: {
setIsAddingGeofence: jest.fn()
};
-const mockUseAwsPlaceData = {
+const mockUsePlaceData = {
getPlaceData: jest.fn(),
search: jest.fn()
};
jest.mock("@demo/hooks", () => ({
- useAmplifyMap: () => ({
+ useMap: () => ({
mapUnit: "METRIC",
mapProvider: "SomeProvider"
}),
- useAwsGeofence: () => mockUseAwsGeofenceData,
- useAwsPlace: () => mockUseAwsPlaceData,
+ useGeofence: () => mockUseGeofenceData,
+ usePlace: () => mockUsePlaceData,
useMediaQuery: () => true
}));
@@ -92,9 +92,9 @@ describe("", () => {
);
beforeEach(() => {
- mockUseAwsGeofenceData.isFetchingGeofences = false;
- mockUseAwsGeofenceData.geofences = undefined;
- mockUseAwsGeofenceData.isAddingGeofence = false;
+ mockUseGeofenceData.isFetchingGeofences = false;
+ mockUseGeofenceData.geofences = undefined;
+ mockUseGeofenceData.isAddingGeofence = false;
});
it("renders the component correctly", () => {
@@ -116,14 +116,14 @@ describe("", () => {
});
it("should show the loader when fetching geofences", () => {
- mockUseAwsGeofenceData.isFetchingGeofences = true;
+ mockUseGeofenceData.isFetchingGeofences = true;
const { getByTestId } = renderComponent();
waitFor(
() => {
expect(getByTestId("geofences-list-container")).toBeInTheDocument();
expect(getByTestId("auth-geofence-box-loader")).toBeInTheDocument();
- expect(mockUseAwsGeofenceData.getGeofencesList).toHaveBeenCalled();
+ expect(mockUseGeofenceData.getGeofencesList).toHaveBeenCalled();
},
{
timeout: 10000,
@@ -137,7 +137,7 @@ describe("", () => {
});
it("should render the geofences list", () => {
- mockUseAwsGeofenceData.geofences = [...mockGeofencesData];
+ mockUseGeofenceData.geofences = [...mockGeofencesData];
const { getByTestId } = renderComponent();
waitFor(
@@ -183,7 +183,7 @@ describe("", () => {
() => {
expect(getByTestId("auth-geofence-box-add-button")).toBeInTheDocument();
fireEvent.click(getByTestId("auth-geofence-box-add-button"));
- expect(mockUseAwsGeofenceData.setIsAddingGeofence).toHaveBeenCalled();
+ expect(mockUseGeofenceData.setIsAddingGeofence).toHaveBeenCalled();
},
{
timeout: 10000,
@@ -197,7 +197,7 @@ describe("", () => {
});
it("should render add geofence and allow to use search", () => {
- mockUseAwsGeofenceData.isAddingGeofence = true;
+ mockUseGeofenceData.isAddingGeofence = true;
const { getByTestId } = renderComponent();
waitFor(
@@ -206,7 +206,7 @@ describe("", () => {
expect(getByTestId("auth-geofence-box-search-input")).toBeInTheDocument();
fireEvent.change(getByTestId("auth-geofence-box-search-input"), { target: { value: "test" } });
expect(getByTestId("auth-geofence-box-search-input")).toHaveValue("test");
- expect(mockUseAwsPlaceData.search).toHaveBeenCalled();
+ expect(mockUsePlaceData.search).toHaveBeenCalled();
},
{
timeout: 10000,
@@ -220,7 +220,7 @@ describe("", () => {
});
it("should allow to select geofence and edit it", () => {
- mockUseAwsGeofenceData.geofences = [...mockGeofencesData];
+ mockUseGeofenceData.geofences = [...mockGeofencesData];
const { getByTestId } = renderComponent();
waitFor(
@@ -228,7 +228,7 @@ describe("", () => {
expect(getByTestId("geofences-list-container")).toBeInTheDocument();
expect(getByTestId("test_geofence_1")).toBeInTheDocument();
fireEvent.click(getByTestId("test_geofence_1"));
- mockUseAwsGeofenceData.isAddingGeofence = true;
+ mockUseGeofenceData.isAddingGeofence = true;
expect(getByTestId("auth-geofence-box-name-field")).toHaveValue("test_geofence_1");
expect(getByTestId("geofence-radius-slider")).toBeInTheDocument();
},
diff --git a/src/atomicui/organisms/AuthGeofenceBox/AuthGeofenceBox.tsx b/src/atomicui/organisms/AuthGeofenceBox/AuthGeofenceBox.tsx
index 5c7c00d5..e3304c93 100644
--- a/src/atomicui/organisms/AuthGeofenceBox/AuthGeofenceBox.tsx
+++ b/src/atomicui/organisms/AuthGeofenceBox/AuthGeofenceBox.tsx
@@ -20,7 +20,7 @@ import { ListGeofenceResponseEntry, Place } from "@aws-sdk/client-location";
import { IconBackArrow, IconClose, IconPin, IconPlus, IconSearch, IconTrash } from "@demo/assets/svgs";
import { showToast } from "@demo/core/Toast";
import { appConfig } from "@demo/core/constants";
-import { useAmplifyMap, useAwsGeofence, useAwsPlace } from "@demo/hooks";
+import { useGeofence, useMap, usePlace } from "@demo/hooks";
import useBottomSheet from "@demo/hooks/useBottomSheet";
import useDeviceMediaQuery from "@demo/hooks/useDeviceMediaQuery";
import {
@@ -85,7 +85,7 @@ const AuthGeofenceBox: FC = ({
const timeoutIdRef = useRef | null>(null);
const [value, setValue] = useState("");
const [name, setName] = useState("");
- const { mapUnit: currentMapUnit, mapProvider: currentMapProvider } = useAmplifyMap();
+ const { mapUnit: currentMapUnit, mapProvider: currentMapProvider } = useMap();
const [unit, setUnit] = useState(currentMapUnit === METRIC ? METERS_SHORT : FEET_SHORT);
/* Radius must be greater than 0 and not greater than 100,000 m (API requirement) */
const [radiusInM, setRadiusInM] = useState(RadiusInM.DEFAULT);
@@ -97,7 +97,7 @@ const AuthGeofenceBox: FC = ({
radiusInM: undefined
});
const { isDesktop } = useDeviceMediaQuery();
- const { search, getPlaceData } = useAwsPlace();
+ const { search, getPlaceData } = usePlace();
const {
getGeofencesList,
isFetchingGeofences,
@@ -106,7 +106,7 @@ const AuthGeofenceBox: FC = ({
deleteGeofence,
isAddingGeofence,
setIsAddingGeofence
- } = useAwsGeofence();
+ } = useGeofence();
const { t, i18n } = useTranslation();
const langDir = i18n.dir();
const isLtr = langDir === "ltr";
diff --git a/src/atomicui/organisms/AuthTrackerBox/AuthTrackerBox.test.tsx b/src/atomicui/organisms/AuthTrackerBox/AuthTrackerBox.test.tsx
index 0e5da744..88e37b41 100644
--- a/src/atomicui/organisms/AuthTrackerBox/AuthTrackerBox.test.tsx
+++ b/src/atomicui/organisms/AuthTrackerBox/AuthTrackerBox.test.tsx
@@ -21,7 +21,7 @@ const props: AuthTrackerBoxProps = {
fitBounds: () => {}
},
setShowAuthTrackerBox: jest.fn(),
- clearCredsAndLocationClient: jest.fn()
+ clearCredsAndClients: jest.fn()
};
const mockGeofencesData = [
@@ -51,16 +51,16 @@ const mockGeofencesData = [
}
];
-const mockUseAwsGeofenceData = {
+const mockUseGeofenceData = {
geofences: mockGeofencesData,
getGeofencesList: jest.fn()
};
-const mockUseAwsRouteData = {
+const mockUseRouteData = {
isFetchingRoute: false
};
-const mockUseAwsTrackerData = {
+const mockUseTrackerData = {
selectedTrackerType: TrackerType.CAR,
setSelectedTrackerType: jest.fn(),
isEditingRoute: false,
@@ -70,9 +70,9 @@ const mockUseAwsTrackerData = {
};
jest.mock("@demo/hooks", () => ({
- useAwsGeofence: () => mockUseAwsGeofenceData,
- useAwsRoute: () => mockUseAwsRouteData,
- useAwsTracker: () => mockUseAwsTrackerData,
+ useGeofence: () => mockUseGeofenceData,
+ useRoute: () => mockUseRouteData,
+ useTracker: () => mockUseTrackerData,
useMediaQuery: () => true,
useWebSocketBanner: () => ({
Connection: ,
diff --git a/src/atomicui/organisms/AuthTrackerBox/AuthTrackerBox.tsx b/src/atomicui/organisms/AuthTrackerBox/AuthTrackerBox.tsx
index c81a2b30..0deb12fa 100644
--- a/src/atomicui/organisms/AuthTrackerBox/AuthTrackerBox.tsx
+++ b/src/atomicui/organisms/AuthTrackerBox/AuthTrackerBox.tsx
@@ -13,7 +13,7 @@ import {
IconSegment,
IconWalking
} from "@demo/assets/svgs";
-import { useAwsGeofence, useAwsRoute, useAwsTracker, useWebSocketBanner } from "@demo/hooks";
+import { useGeofence, useRoute, useTracker, useWebSocketBanner } from "@demo/hooks";
import useBottomSheet from "@demo/hooks/useBottomSheet";
import useDeviceMediaQuery from "@demo/hooks/useDeviceMediaQuery";
import { RouteDataType, TrackerType } from "@demo/types";
@@ -42,17 +42,17 @@ export const trackerTypes = [
export interface AuthTrackerBoxProps {
mapRef: MapRef | null;
setShowAuthTrackerBox: (b: boolean) => void;
- clearCredsAndLocationClient?: () => void;
+ clearCredsAndClients?: () => void;
}
-const AuthTrackerBox: FC = ({ mapRef, setShowAuthTrackerBox, clearCredsAndLocationClient }) => {
+const AuthTrackerBox: FC = ({ mapRef, setShowAuthTrackerBox, clearCredsAndClients }) => {
const [isSaved, setIsSaved] = useState(false);
const [isPlaying, setIsPlaying] = useState(false);
const [routeData, setRouteData] = useState(undefined);
const [points, setPoints] = useState(undefined);
const [trackerPos, setTrackerPos] = useState(undefined);
- const { isFetchingRoute } = useAwsRoute();
- const { geofences, getGeofencesList } = useAwsGeofence();
+ const { isFetchingRoute } = useRoute();
+ const { geofences, getGeofencesList } = useGeofence();
const {
selectedTrackerType,
setSelectedTrackerType,
@@ -60,7 +60,7 @@ const AuthTrackerBox: FC = ({ mapRef, setShowAuthTrackerBox
setIsEditingRoute,
trackerPoints,
setTrackerPoints
- } = useAwsTracker();
+ } = useTracker();
const { Connection } = useWebSocketBanner();
const { t, i18n } = useTranslation();
const langDir = i18n.dir();
@@ -89,7 +89,7 @@ const AuthTrackerBox: FC = ({ mapRef, setShowAuthTrackerBox
};
const onClose = () => {
- clearCredsAndLocationClient && clearCredsAndLocationClient();
+ clearCredsAndClients && clearCredsAndClients();
setIsEditingRoute(false);
setTrackerPoints(undefined);
setShowAuthTrackerBox(false);
diff --git a/src/atomicui/organisms/AuthTrackerBox/AuthTrackerSimulation.tsx b/src/atomicui/organisms/AuthTrackerBox/AuthTrackerSimulation.tsx
index be026f33..ae618a53 100644
--- a/src/atomicui/organisms/AuthTrackerBox/AuthTrackerSimulation.tsx
+++ b/src/atomicui/organisms/AuthTrackerBox/AuthTrackerSimulation.tsx
@@ -4,7 +4,7 @@
import { FC, memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
import { CalculateRouteRequest } from "@aws-sdk/client-location";
-import { useAmplifyMap, useAwsGeofence, useAwsRoute, useAwsTracker, usePersistedData } from "@demo/hooks";
+import { useGeofence, useMap, usePersistedData, useRoute, useTracker } from "@demo/hooks";
import useDeviceMediaQuery from "@demo/hooks/useDeviceMediaQuery";
import { DistanceUnitEnum, MapUnitEnum, RouteDataType, TrackerType, TravelMode } from "@demo/types";
import { TriggeredByEnum } from "@demo/types/Enums";
@@ -45,10 +45,10 @@ const AuthTrackerSimulation: FC = ({
}) => {
const [idx, setIdx] = useState(0);
const timeoutId = useRef(null);
- const { mapUnit: currentMapUnit } = useAmplifyMap();
- const { getRoute } = useAwsRoute();
- const { evaluateGeofence } = useAwsGeofence();
- const { trackerPoints } = useAwsTracker();
+ const { mapUnit: currentMapUnit } = useMap();
+ const { getRoute } = useRoute();
+ const { evaluateGeofence } = useGeofence();
+ const { trackerPoints } = useTracker();
const { defaultRouteOptions } = usePersistedData();
const { isDesktop, isTablet } = useDeviceMediaQuery();
diff --git a/src/atomicui/organisms/Explore/Explore.tsx b/src/atomicui/organisms/Explore/Explore.tsx
index 34f05207..2f1c0ce1 100644
--- a/src/atomicui/organisms/Explore/Explore.tsx
+++ b/src/atomicui/organisms/Explore/Explore.tsx
@@ -18,7 +18,7 @@ import {
} from "@demo/assets/svgs";
import { appConfig } from "@demo/core/constants";
import BottomSheetHeights from "@demo/core/constants/bottomSheetHeights";
-import { useAmplifyAuth, useAmplifyMap, useAwsIot } from "@demo/hooks";
+import { useAuth, useIot, useMap } from "@demo/hooks";
import useBottomSheet from "@demo/hooks/useBottomSheet";
import useDeviceMediaQuery from "@demo/hooks/useDeviceMediaQuery";
import {
@@ -104,10 +104,9 @@ const Explore: FC = ({
const isLtr = langDir === "ltr";
const { setBottomSheetMinHeight, setBottomSheetHeight, bottomSheetCurrentHeight = 0 } = useBottomSheet();
const { isDesktop, isDesktopBrowser } = useDeviceMediaQuery();
- const { isUserAwsAccountConnected, credentials, onLogin, onLogout, onDisconnectAwsAccount, setAuthTokens } =
- useAmplifyAuth();
- const { mapProvider: currentMapProvider } = useAmplifyMap();
- const { detachPolicy } = useAwsIot();
+ const { isUserAwsAccountConnected, credentials, onLogin, onLogout, onDisconnectAwsAccount } = useAuth();
+ const { mapProvider: currentMapProvider } = useMap();
+ const { detachPolicy } = useIot();
const isAuthenticated = !!credentials?.authenticated;
const disconnectButtonText = t("disconnect_aws_account.text");
const navigate = useNavigate();
@@ -178,14 +177,6 @@ const Explore: FC = ({
}
};
- const _onLogout = async () => {
- setAuthTokens(undefined);
- await detachPolicy(credentials!.identityId);
- await onLogout();
- };
-
- const _onLogin = async () => await onLogin();
-
const onClickSettings = useCallback(() => {
onCloseSidebar();
onShowSettings();
@@ -238,14 +229,18 @@ const Explore: FC = ({
textAlign="center"
onClick={async () => {
if (isAuthenticated) {
- _onLogout();
+ record(
+ [{ EventType: EventTypeEnum.SIGN_OUT_STARTED, Attributes: { triggeredBy: TriggeredByEnum.SIDEBAR } }],
+ ["userAWSAccountConnectionStatus", "userAuthenticationStatus"]
+ );
+ await detachPolicy(credentials!.identityId);
+ onLogout();
} else {
- await record(
+ record(
[{ EventType: EventTypeEnum.SIGN_IN_STARTED, Attributes: { triggeredBy: TriggeredByEnum.SIDEBAR } }],
["userAWSAccountConnectionStatus", "userAuthenticationStatus"]
);
-
- _onLogin();
+ onLogin();
}
}}
className={isFooter ? "auth-footer-button" : ""}
diff --git a/src/atomicui/organisms/ResponsiveBottomSheet/ResponsiveBottomSheet.tsx b/src/atomicui/organisms/ResponsiveBottomSheet/ResponsiveBottomSheet.tsx
index 240827ec..b14eca43 100644
--- a/src/atomicui/organisms/ResponsiveBottomSheet/ResponsiveBottomSheet.tsx
+++ b/src/atomicui/organisms/ResponsiveBottomSheet/ResponsiveBottomSheet.tsx
@@ -19,7 +19,7 @@ import { Flex, Loader, Text } from "@aws-amplify/ui-react";
import { IconClose, IconNotificationBell } from "@demo/assets/svgs";
import appConfig from "@demo/core/constants/appConfig";
import BottomSheetHeights from "@demo/core/constants/bottomSheetHeights";
-import { useAmplifyMap, useAwsGeofence, useAwsRoute, useAwsTracker, usePersistedData } from "@demo/hooks";
+import { useGeofence, useMap, usePersistedData, useRoute, useTracker } from "@demo/hooks";
import useBottomSheet from "@demo/hooks/useBottomSheet";
import useDeviceMediaQuery from "@demo/hooks/useDeviceMediaQuery";
import { ShowStateType } from "@demo/types";
@@ -78,7 +78,7 @@ interface IProps {
confirmCloseSimulation: boolean;
setConfirmCloseSimulation: Dispatch>;
setShowAuthTrackerBox: (b: boolean) => void;
- clearCredsAndLocationClient?: () => void;
+ clearCredsAndClients?: () => void;
setShowAuthGeofenceBox: (b: boolean) => void;
setTriggerOnClose: Dispatch>;
setTriggerOnReset: Dispatch>;
@@ -123,7 +123,7 @@ const ResponsiveBottomSheet: FC = ({
confirmCloseSimulation,
setConfirmCloseSimulation,
setShowAuthTrackerBox,
- clearCredsAndLocationClient,
+ clearCredsAndClients,
setTriggerOnClose,
setTriggerOnReset,
isEditingAuthRoute,
@@ -134,7 +134,7 @@ const ResponsiveBottomSheet: FC = ({
geolocateControlRef
}) => {
const { isDesktop, isMobile, isTablet, isMax556, isDesktopBrowser } = useDeviceMediaQuery();
- const { unauthNotifications, isAddingGeofence } = useAwsGeofence();
+ const { unauthNotifications, isAddingGeofence } = useGeofence();
const { t } = useTranslation();
const location = useLocation();
const isDemoUrl = location.pathname === DEMO;
@@ -149,9 +149,9 @@ const ResponsiveBottomSheet: FC = ({
setBottomSheetMinHeight
} = useBottomSheet();
const { setSettingsOptions } = usePersistedData();
- const { resetStore: resetAwsRouteStore } = useAwsRoute();
- const { setIsEditingRoute, setTrackerPoints } = useAwsTracker();
- const { mapStyle } = useAmplifyMap();
+ const { resetStore: resetRouteStore } = useRoute();
+ const { setIsEditingRoute, setTrackerPoints } = useTracker();
+ const { mapStyle } = useMap();
const [arrowDirection, setArrowDirection] = useState("no-dragging");
const prevBottomSheetHeightRef = useRef(bottomSheetCurrentHeight);
const bottomSheetRef = useRef(null);
@@ -306,11 +306,11 @@ const ResponsiveBottomSheet: FC = ({
);
const onCloseRouteBox = useCallback(() => {
- resetAwsRouteStore();
+ resetRouteStore();
setShowRouteBox(false);
setUI(ResponsiveUIEnum.explore);
setSearchBoxValue("");
- }, [setUI, resetAwsRouteStore, setShowRouteBox, setSearchBoxValue]);
+ }, [setUI, resetRouteStore, setShowRouteBox, setSearchBoxValue]);
const handleClose = useCallback(() => {
from === MenuItemEnum.GEOFENCE
@@ -320,12 +320,12 @@ const ResponsiveBottomSheet: FC = ({
}, [from, resetToExplore, setShow]);
const onCloseAuthTracker = useCallback(() => {
- clearCredsAndLocationClient && clearCredsAndLocationClient();
+ clearCredsAndClients && clearCredsAndClients();
setIsEditingRoute(false);
setTrackerPoints(undefined);
setShowAuthTrackerBox(false);
setUI(ResponsiveUIEnum.explore);
- }, [clearCredsAndLocationClient, setIsEditingRoute, setShowAuthTrackerBox, setTrackerPoints, setUI]);
+ }, [clearCredsAndClients, setIsEditingRoute, setShowAuthTrackerBox, setTrackerPoints, setUI]);
const onBackUnauthHandler = useCallback(() => {
if (isNotifications) {
@@ -557,13 +557,13 @@ const ResponsiveBottomSheet: FC = ({
const footerHeight = useCallback((maxHeight: number) => calculatePixelValue(maxHeight, 50), [calculatePixelValue]);
const onCloseHandler = useCallback(() => {
- clearCredsAndLocationClient && clearCredsAndLocationClient();
+ clearCredsAndClients && clearCredsAndClients();
setShowStartUnauthSimulation(false);
from === MenuItemEnum.GEOFENCE ? setShowUnauthGeofenceBox(false) : setShowUnauthTrackerBox(false);
setConfirmCloseSimulation(false);
resetToExplore();
}, [
- clearCredsAndLocationClient,
+ clearCredsAndClients,
from,
resetToExplore,
setConfirmCloseSimulation,
diff --git a/src/atomicui/organisms/RouteBox/RouteBox.test.tsx b/src/atomicui/organisms/RouteBox/RouteBox.test.tsx
index 762bb631..1f6916f3 100644
--- a/src/atomicui/organisms/RouteBox/RouteBox.test.tsx
+++ b/src/atomicui/organisms/RouteBox/RouteBox.test.tsx
@@ -7,7 +7,7 @@ import { I18nextProvider } from "react-i18next";
import RouteBox from "./RouteBox";
-const useAwsPlaceReturnValue = {
+const usePlaceReturnValue = {
getPlaceDataByCoordinates: () => ({
Results: [
{
@@ -57,8 +57,8 @@ const useAwsPlaceReturnValue = {
}
})
};
-const useAwsPlace = () => useAwsPlaceReturnValue;
-const useAwsRouteServiceReturnValue = {
+const usePlace = () => usePlaceReturnValue;
+const useRouteServiceReturnValue = {
calculateRoute: () => ({
Legs: [
{
@@ -92,11 +92,11 @@ const useAwsRouteServiceReturnValue = {
}
})
};
-const servicesObj = { useAwsRouteService: () => useAwsRouteServiceReturnValue };
+const servicesObj = { useRouteService: () => useRouteServiceReturnValue };
const MarkerMock = ({ ...props }) => ;
-jest.mock("hooks/useAmplifyMap", () => () => ({}));
-jest.mock("hooks/useAwsPlace", () => useAwsPlace);
+jest.mock("hooks/useMap", () => () => ({}));
+jest.mock("hooks/usePlace", () => usePlace);
jest.mock("services", () => servicesObj);
jest.mock("react-map-gl", () => ({
...jest.requireActual("react-map-gl"),
diff --git a/src/atomicui/organisms/RouteBox/RouteBox.tsx b/src/atomicui/organisms/RouteBox/RouteBox.tsx
index c7282718..493e2acd 100644
--- a/src/atomicui/organisms/RouteBox/RouteBox.tsx
+++ b/src/atomicui/organisms/RouteBox/RouteBox.tsx
@@ -23,7 +23,7 @@ import {
import { NotFoundCard, StepCard } from "@demo/atomicui/molecules";
import { appConfig } from "@demo/core/constants";
import BottomSheetHeights from "@demo/core/constants/bottomSheetHeights";
-import { useAmplifyMap, useAwsPlace, useAwsRoute, usePersistedData } from "@demo/hooks";
+import { useMap, usePersistedData, usePlace, useRoute } from "@demo/hooks";
import useBottomSheet from "@demo/hooks/useBottomSheet";
import useDeviceMediaQuery from "@demo/hooks/useDeviceMediaQuery";
import {
@@ -107,8 +107,8 @@ const RouteBox: FC = ({
mapUnit: currentMapUnit,
isCurrentLocationDisabled,
mapProvider: currentMapProvider
- } = useAmplifyMap();
- const { search, getPlaceData } = useAwsPlace();
+ } = useMap();
+ const { search, getPlaceData } = usePlace();
const {
setUI,
setBottomSheetMinHeight,
@@ -121,12 +121,12 @@ const RouteBox: FC = ({
setRoutePositions,
getRoute,
setRouteData,
- resetStore: resetAwsRouteStore,
+ resetStore: resetRouteStore,
routePositions,
routeData,
directions,
setDirections
- } = useAwsRoute();
+ } = useRoute();
const { defaultRouteOptions } = usePersistedData();
const [expandRouteOptions, setExpandRouteOptions] = useState(false);
const [routeOptions, setRouteOptions] = useState({ ...defaultRouteOptions });
@@ -379,7 +379,7 @@ const RouteBox: FC = ({
]);
const onClose = () => {
- resetAwsRouteStore();
+ resetRouteStore();
setShowRouteBox(false);
setUI(ResponsiveUIEnum.explore);
};
diff --git a/src/atomicui/organisms/SearchBox/SearchBox.test.tsx b/src/atomicui/organisms/SearchBox/SearchBox.test.tsx
index 18481835..bda5ca9b 100644
--- a/src/atomicui/organisms/SearchBox/SearchBox.test.tsx
+++ b/src/atomicui/organisms/SearchBox/SearchBox.test.tsx
@@ -19,7 +19,7 @@ const mockProps = {
isStylesCardOpen: false
};
-const mockUseAmplifyMapData = {
+const mockUseMapData = {
currentLocationData: {
error: null
},
@@ -29,7 +29,7 @@ const mockUseAmplifyMapData = {
isCurrentLocationDisabled: false
};
-const mockUseAwsPlaceData = {
+const mockUsePlaceData = {
clusters: [],
suggestions: [{}],
selectedMarker: null,
@@ -45,8 +45,8 @@ const mockUseAwsPlaceData = {
};
jest.mock("@demo/hooks", () => ({
- useAmplifyMap: () => mockUseAmplifyMapData,
- useAwsPlace: () => mockUseAwsPlaceData
+ useMap: () => mockUseMapData,
+ usePlace: () => mockUsePlaceData
}));
describe("", () => {
@@ -73,7 +73,7 @@ describe("", () => {
mockProps.isRouteBoxOpen = true;
const {} = renderComponent();
waitFor(() => {
- expect(mockUseAwsPlaceData.clearPoiList).toHaveBeenCalled();
+ expect(mockUsePlaceData.clearPoiList).toHaveBeenCalled();
});
});
@@ -94,8 +94,8 @@ describe("", () => {
fireEvent.change(getByTestId("search-box-input"), { target: { value: "search query" } });
});
waitFor(() => {
- expect(mockUseAwsPlaceData.clearPoiList).toHaveBeenCalled();
- expect(mockUseAwsPlaceData.search).toHaveBeenCalled();
+ expect(mockUsePlaceData.clearPoiList).toHaveBeenCalled();
+ expect(mockUsePlaceData.search).toHaveBeenCalled();
});
});
});
diff --git a/src/atomicui/organisms/SearchBox/SearchBox.tsx b/src/atomicui/organisms/SearchBox/SearchBox.tsx
index 1c90119f..124acb06 100644
--- a/src/atomicui/organisms/SearchBox/SearchBox.tsx
+++ b/src/atomicui/organisms/SearchBox/SearchBox.tsx
@@ -20,7 +20,7 @@ import { NLSearchLoader } from "@demo/atomicui/atoms";
import { InputField, Marker, NotFoundCard, SuggestionMarker } from "@demo/atomicui/molecules";
import { appConfig } from "@demo/core/constants";
import BottomSheetHeights from "@demo/core/constants/bottomSheetHeights";
-import { useAmplifyMap, useAwsPlace } from "@demo/hooks";
+import { useMap, usePlace } from "@demo/hooks";
import useBottomSheet from "@demo/hooks/useBottomSheet";
import useDeviceMediaQuery from "@demo/hooks/useDeviceMediaQuery";
import { DistanceUnitEnum, MapProviderEnum, MapUnitEnum, SuggestionType } from "@demo/types";
@@ -85,8 +85,13 @@ const SearchBox: FC = ({
const timeoutIdRef = useRef | null>(null);
const [isNLChecked, setIsNLChecked] = useState(false);
const autocompleteRef = useRef(null);
- const { mapUnit: currentMapUnit, isCurrentLocationDisabled, currentLocationData, viewpoint } = useAmplifyMap();
- const { mapProvider: currentMapProvider } = useAmplifyMap();
+ const {
+ mapProvider: currentMapProvider,
+ mapUnit: currentMapUnit,
+ isCurrentLocationDisabled,
+ currentLocationData,
+ viewpoint
+ } = useMap();
const {
clusters,
suggestions,
@@ -99,7 +104,7 @@ const SearchBox: FC = ({
setHoveredMarker,
setSearchingState,
setIsSearching
- } = useAwsPlace();
+ } = usePlace();
const { t, i18n } = useTranslation();
const langDir = i18n.dir();
const currentLang = i18n.language;
diff --git a/src/atomicui/organisms/SettingsModal/SettingsModal.tsx b/src/atomicui/organisms/SettingsModal/SettingsModal.tsx
index b65f2112..5a698b28 100644
--- a/src/atomicui/organisms/SettingsModal/SettingsModal.tsx
+++ b/src/atomicui/organisms/SettingsModal/SettingsModal.tsx
@@ -17,7 +17,7 @@ import {
IconShuffle
} from "@demo/assets/svgs";
import { appConfig, languageSwitcherData, regionsData } from "@demo/core/constants";
-import { useAmplifyAuth, useAmplifyMap, useAws, useAwsIot, usePersistedData } from "@demo/hooks";
+import { useAuth, useClient, useIot, useMap, usePersistedData } from "@demo/hooks";
import useDeviceMediaQuery from "@demo/hooks/useDeviceMediaQuery";
import {
ConnectFormValuesType,
@@ -91,7 +91,6 @@ const SettingsModal: FC = ({
setConnectFormValues,
credentials,
onLogin,
- setAuthTokens,
onLogout,
autoRegion,
region: currentRegion,
@@ -99,7 +98,7 @@ const SettingsModal: FC = ({
stackRegion,
cloudFormationLink,
handleStackRegion
- } = useAmplifyAuth();
+ } = useAuth();
const {
autoMapUnit,
setIsAutomaticMapUnit,
@@ -110,10 +109,10 @@ const SettingsModal: FC = ({
setMapProvider,
setMapStyle,
resetStore: resetMapStore
- } = useAmplifyMap();
+ } = useMap();
const { defaultRouteOptions, setDefaultRouteOptions, setSettingsOptions, settingsOptions } = usePersistedData();
- const { resetStore: resetAwsStore } = useAws();
- const { detachPolicy } = useAwsIot();
+ const { resetStore: resetClientStore } = useClient();
+ const { detachPolicy } = useIot();
const keyArr = Object.keys(formValues);
const isAuthenticated = !!credentials?.authenticated;
const { t, i18n } = useTranslation();
@@ -140,14 +139,6 @@ const SettingsModal: FC = ({
[setIsAutomaticMapUnit, setMapUnit, resetAppState]
);
- const _onLogin = useCallback(async () => await onLogin(), [onLogin]);
-
- const _onLogout = useCallback(async () => {
- setAuthTokens(undefined);
- await detachPolicy(credentials!.identityId);
- await onLogout();
- }, [setAuthTokens, detachPolicy, credentials, onLogout]);
-
const isBtnEnabled = useMemo(
() => keyArr.filter(key => !!formValues[key as keyof typeof formValues]).length === keyArr.length,
[formValues, keyArr]
@@ -161,20 +152,10 @@ const SettingsModal: FC = ({
);
const onConnect = useCallback(() => {
- const {
- IdentityPoolId: identityPoolId,
- UserPoolId: userPoolId,
- UserPoolClientId: userPoolWebClientId,
- UserDomain: domain,
- WebSocketUrl: webSocketUrl
- } = formValues;
+ const { IdentityPoolId: identityPoolId } = formValues;
validateFormValues(
identityPoolId,
- userPoolId,
- userPoolWebClientId,
- domain,
- webSocketUrl,
/* Success callback */
() => {
if (
@@ -188,7 +169,7 @@ const SettingsModal: FC = ({
setConnectFormValues(formValues);
clearCredentials();
- resetAwsStore();
+ resetClientStore();
setIsUserAwsAccountConnected(true);
}
);
@@ -201,7 +182,7 @@ const SettingsModal: FC = ({
handleCurrentLocationAndViewpoint,
setConnectFormValues,
clearCredentials,
- resetAwsStore,
+ resetClientStore,
setIsUserAwsAccountConnected
]);
@@ -254,11 +235,11 @@ const SettingsModal: FC = ({
const handleRegionChange = useCallback(
(region: "Automatic" | RegionEnum) => {
setAutoRegion(region === "Automatic", region);
- resetAwsStore();
+ resetClientStore();
resetAppState();
resetMapStore();
},
- [setAutoRegion, resetAwsStore, resetAppState, resetMapStore]
+ [setAutoRegion, resetClientStore, resetAppState, resetMapStore]
);
const optionItems: Array = useMemo(
@@ -650,8 +631,8 @@ const SettingsModal: FC = ({
variation="primary"
fontFamily="AmazonEmber-Bold"
width="100%"
- onClick={async () => {
- await record(
+ onClick={() => {
+ record(
[
{
EventType: EventTypeEnum.SIGN_IN_STARTED,
@@ -660,8 +641,7 @@ const SettingsModal: FC = ({
],
["userAWSAccountConnectionStatus", "userAuthenticationStatus"]
);
-
- _onLogin();
+ onLogin();
}}
>
{t("sign_in.text")}
@@ -678,7 +658,24 @@ const SettingsModal: FC = ({
>
) : (
-