From c441ebfd13f382d312bebf55b026677da9967682 Mon Sep 17 00:00:00 2001 From: Ninjas Code - 4 Date: Wed, 29 Mar 2023 12:52:59 +0500 Subject: [PATCH] Delete account button --- CustomerApp/app.json | 6 +- CustomerApp/environment.js | 11 +- CustomerApp/package-lock.json | 316 ++++++++++++++++-- CustomerApp/package.json | 1 + CustomerApp/src/apollo/index.js | 98 +++--- CustomerApp/src/apollo/server.js | 56 ++-- CustomerApp/src/components/Sidebar/Sidebar.js | 132 ++++---- CustomerApp/src/screens/Login/Login.js | 240 +++++++------ CustomerApp/src/screens/Settings/Settings.js | 111 +++++- .../Settings/components/SettingModal.js | 53 +-- 10 files changed, 700 insertions(+), 324 deletions(-) diff --git a/CustomerApp/app.json b/CustomerApp/app.json index 9b54e6a..ca35c33 100644 --- a/CustomerApp/app.json +++ b/CustomerApp/app.json @@ -1,7 +1,7 @@ { "expo": { "name": "Enatega", - "version": "1.0.18", + "version": "1.0.19", "scheme": "enategasinglevendor", "description": "Enatega is a starter kit food ordering app built in React Native using Expo for IOS and Android. It's made keeping good aesthetics in mind as well keeping the best coding practices in mind. Its fully customisable to easily help you in your next food delivery project. https://market.nativebase.io/view/react-native-food-delivery-backend-app", "slug": "enategasinglevendor", @@ -46,12 +46,12 @@ "androidCollapsedTitle": "Enatega" }, "android": { - "versionCode": 23, + "versionCode": 24, "package": "com.enatega.vendor", "googleServicesFile": "./google-services-prod.json", "config": { "googleMaps": { - "apiKey": "" + "apiKey": "AIzaSyCzNP5qQql2a5y8lOoO-1yj1lj_tzjVImA" } }, "adaptiveIcon": { diff --git a/CustomerApp/environment.js b/CustomerApp/environment.js index 761fe5b..9317db5 100644 --- a/CustomerApp/environment.js +++ b/CustomerApp/environment.js @@ -7,9 +7,14 @@ import Constants from "expo-constants"; const ENV = { development: { - GRAPHQL_URL: "http://10.97.28.88.90:8000/graphql", - WS_GRAPHQL_URL: "ws://10.97.28.88.90:8000/graphql", - SERVER_URL: "http://10.97.28.88.90:8000/", // put / at the end of server url + GRAPHQL_URL: "http://10.97.28.39:8000/graphql", + WS_GRAPHQL_URL: "ws://110.97.28.39.90:8000/graphql", + SERVER_URL: "http://110.97.28.39.90:8000/", // put / at the end of server url + // GRAPHQL_URL: "https://prod-enatega-single-api.herokuapp.com/graphql", + // WS_GRAPHQL_URL: "wss://prod-enatega-single-api.herokuapp.com/graphql", + // SERVER_URL: "https://prod-enatega-single-api.herokuapp.com/", + Expo_CLIENT_ID_GOOGLE: + "630195385603-82e52jpb722a8l0huhkspq3tqh2d6r6f.apps.googleusercontent.com", IOS_CLIENT_ID_GOOGLE: "967541328677-uq7f7odvmeea2pb2sq0l7q320ds86536.apps.googleusercontent.com", ANDROID_CLIENT_ID_GOOGLE: diff --git a/CustomerApp/package-lock.json b/CustomerApp/package-lock.json index 32b8cac..aaf6879 100644 --- a/CustomerApp/package-lock.json +++ b/CustomerApp/package-lock.json @@ -31,6 +31,7 @@ "apollo-utilities": "^1.3.4", "deprecated-react-native-prop-types": "^4.0.0", "expo": "^47.0.12", + "expo-app-auth": "~11.1.0", "expo-app-loading": "~2.1.1", "expo-apple-authentication": "~5.0.1", "expo-application": "~5.0.1", @@ -2141,9 +2142,9 @@ } }, "node_modules/@eslint-community/eslint-utils": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.3.0.tgz", - "integrity": "sha512-v3oplH6FYCULtFuCeqyuTd9D2WKO937Dxdq+GmHOLL72TTRriLxz2VLlNfkZRsvj6PKnOPAtuT6dwrs/pA5DvA==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", "dev": true, "dependencies": { "eslint-visitor-keys": "^3.3.0" @@ -2156,9 +2157,9 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.4.0.tgz", - "integrity": "sha512-A9983Q0LnDGdLPjxyXQ00sbV+K+O+ko2Dr+CZigbHWtX9pNfxlaBkMR8X1CztI73zuEyEBXTVjx7CE+/VSwDiQ==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.4.1.tgz", + "integrity": "sha512-BISJ6ZE4xQsuL/FmsyRaiffpq977bMlsKfGHTQrOGFErfByxIe6iZTxPf/00Zon9b9a7iUykfQwejN3s2ZW/Bw==", "dev": true, "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" @@ -6033,9 +6034,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "18.15.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.3.tgz", - "integrity": "sha512-p6ua9zBxz5otCmbpb5D3U4B5Nanw6Pk3PPyX05xnxbB/fRv71N7CPmORg7uAD5P70T0xmx1pzAx/FUfa5X+3cw==" + "version": "18.15.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.7.tgz", + "integrity": "sha512-LFmUbFunqmBn26wJZgZPYZPrDR1RwGOu2v79Mgcka1ndO6V0/cwjivPTc4yoK6n9kmw4/ls1r8cLrvh2iMibFA==" }, "node_modules/@types/prettier": { "version": "2.7.2", @@ -6064,9 +6065,9 @@ } }, "node_modules/@types/scheduler": { - "version": "0.16.2", - "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz", - "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==" + "version": "0.16.3", + "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.3.tgz", + "integrity": "sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==" }, "node_modules/@types/stack-utils": { "version": "2.0.1", @@ -6075,9 +6076,9 @@ "dev": true }, "node_modules/@types/yargs": { - "version": "17.0.22", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.22.tgz", - "integrity": "sha512-pet5WJ9U8yPVRhkwuEIp5ktAeAqRZOq4UdAyWLWzxbtpyXnzbtLdKiXAjJzi/KLmPGS9wk86lUFWZFN6sISo4g==", + "version": "17.0.23", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.23.tgz", + "integrity": "sha512-yuogunc04OnzGQCrfHx+Kk883Q4X0aSwmYZhKjI21m+SVYzjIbrWl8dOOwSv5hf2Um2pdCOXWo9isteZTNXUZQ==", "dependencies": { "@types/yargs-parser": "*" } @@ -8248,9 +8249,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001468", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001468.tgz", - "integrity": "sha512-zgAo8D5kbOyUcRAgSmgyuvBkjrGk5CGYG5TYgFdpQv+ywcyEpo1LOWoG8YmoflGnh+V+UsNuKYedsoYs0hzV5A==", + "version": "1.0.30001469", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001469.tgz", + "integrity": "sha512-Rcp7221ScNqQPP3W+lVOYDyjdR6dC+neEQCttoNr5bAyz54AboB4iwpnWgyi8P4YUsPybVzT4LgWiBbI3drL4g==", "funding": [ { "type": "opencollective", @@ -9278,9 +9279,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.4.333", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.333.tgz", - "integrity": "sha512-YyE8+GKyGtPEP1/kpvqsdhD6rA/TP1DUFDN4uiU/YI52NzDxmwHkEb3qjId8hLBa5siJvG0sfC3O66501jMruQ==" + "version": "1.4.339", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.339.tgz", + "integrity": "sha512-MSXHBJGcbBydq/DQDlpBeUKnJ6C7aTiNCTRpfDV5Iz0sNr/Ng6RJFloq82AAicp/SrmDq4zF6XsKG0B8Xwn1UQ==" }, "node_modules/emittery": { "version": "0.13.1", @@ -10383,6 +10384,249 @@ "expo-error-recovery": "~4.0.1" } }, + "node_modules/expo-app-auth": { + "version": "11.1.1", + "resolved": "https://registry.npmjs.org/expo-app-auth/-/expo-app-auth-11.1.1.tgz", + "integrity": "sha512-BYsVJ54GySnpVjRLmUX//XkDkqlqigpOS+MWBARURecPu038Ei2tsIsboLqbaa6oyoWhtU9OfYacVHczE/BFmQ==", + "deprecated": "Please migrate to expo-auth-session", + "dependencies": { + "@expo/config-plugins": "^4.0.2", + "invariant": "^2.2.4" + }, + "peerDependencies": { + "expo": "*" + } + }, + "node_modules/expo-app-auth/node_modules/@babel/code-frame": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz", + "integrity": "sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==", + "dependencies": { + "@babel/highlight": "^7.10.4" + } + }, + "node_modules/expo-app-auth/node_modules/@expo/config-plugins": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/@expo/config-plugins/-/config-plugins-4.1.5.tgz", + "integrity": "sha512-RVvU40RtZt12HavuDAe+LDIq9lHj7sheOfMEHdmpJ/uTA8pgvkbc56XF6JHQD+yRr6+uhhb+JnAasGq49dsQbw==", + "dependencies": { + "@expo/config-types": "^45.0.0", + "@expo/json-file": "8.2.36", + "@expo/plist": "0.0.18", + "@expo/sdk-runtime-versions": "^1.0.0", + "@react-native/normalize-color": "^2.0.0", + "chalk": "^4.1.2", + "debug": "^4.3.1", + "find-up": "~5.0.0", + "getenv": "^1.0.0", + "glob": "7.1.6", + "resolve-from": "^5.0.0", + "semver": "^7.3.5", + "slash": "^3.0.0", + "xcode": "^3.0.1", + "xml2js": "0.4.23" + } + }, + "node_modules/expo-app-auth/node_modules/@expo/config-types": { + "version": "45.0.0", + "resolved": "https://registry.npmjs.org/@expo/config-types/-/config-types-45.0.0.tgz", + "integrity": "sha512-/QGhhLWyaGautgEyU50UJr5YqKJix5t77ePTwreOVAhmZH+ff3nrrtYTTnccx+qF08ZNQmfAyYMCD3rQfzpiJA==" + }, + "node_modules/expo-app-auth/node_modules/@expo/json-file": { + "version": "8.2.36", + "resolved": "https://registry.npmjs.org/@expo/json-file/-/json-file-8.2.36.tgz", + "integrity": "sha512-tOZfTiIFA5KmMpdW9KF7bc6CFiGjb0xnbieJhTGlHrLL+ps2G0OkqmuZ3pFEXBOMnJYUVpnSy++52LFxvpa5ZQ==", + "dependencies": { + "@babel/code-frame": "~7.10.4", + "json5": "^1.0.1", + "write-file-atomic": "^2.3.0" + } + }, + "node_modules/expo-app-auth/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/expo-app-auth/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/expo-app-auth/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/expo-app-auth/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/expo-app-auth/node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/expo-app-auth/node_modules/glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/expo-app-auth/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/expo-app-auth/node_modules/json5": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", + "dependencies": { + "minimist": "^1.2.0" + }, + "bin": { + "json5": "lib/cli.js" + } + }, + "node_modules/expo-app-auth/node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/expo-app-auth/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/expo-app-auth/node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/expo-app-auth/node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "engines": { + "node": ">=8" + } + }, + "node_modules/expo-app-auth/node_modules/semver": { + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/expo-app-auth/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/expo-app-auth/node_modules/write-file-atomic": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.3.tgz", + "integrity": "sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ==", + "dependencies": { + "graceful-fs": "^4.1.11", + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.2" + } + }, + "node_modules/expo-app-auth/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/expo-app-loading": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/expo-app-loading/-/expo-app-loading-2.1.1.tgz", @@ -14846,9 +15090,9 @@ "integrity": "sha512-dZ6Ra7u1G8c4Letq/B5EzAxj4tLFHL+cGtdpR+PVm4yzPDj+lCk+AbivWt1eOM+ikzkowtyV7qSqX6qr3t71Ww==" }, "node_modules/joi": { - "version": "17.8.4", - "resolved": "https://registry.npmjs.org/joi/-/joi-17.8.4.tgz", - "integrity": "sha512-jjdRHb5WtL+KgSHvOULQEPPv4kcl+ixd1ybOFQq3rWLgEEqc03QMmilodL0GVJE14U/SQDXkUhQUSZANGDH/AA==", + "version": "17.9.1", + "resolved": "https://registry.npmjs.org/joi/-/joi-17.9.1.tgz", + "integrity": "sha512-FariIi9j6QODKATGBrEX7HZcja8Bsh3rfdGYy/Sb65sGlZWK/QWesU1ghk7aJWDj95knjXlQfSmzFSPPkLVsfw==", "dependencies": { "@hapi/hoek": "^9.0.0", "@hapi/topo": "^5.0.0", @@ -14863,9 +15107,9 @@ "integrity": "sha512-bF7vcQxbODoGK1imE2P9GS9aw4zD0Sd+Hni68IMZLj7zRnquH7dXUmMw9hDI5S/Jzt7q+IyTXN0rSg2GI0IKhQ==" }, "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==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.4.0.tgz", + "integrity": "sha512-FfVSdx6pJ41Oa+CF7RDaFmTnCaFhua+SNYQX74riGOpl96x+2jQCqEfQ2bnXu/5DPCqlRuiqyvTJM0Qjz26IVg==", "dev": true, "funding": { "type": "opencollective", @@ -18837,9 +19081,9 @@ } }, "node_modules/prettier": { - "version": "2.8.5", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.5.tgz", - "integrity": "sha512-3gzuxrHbKUePRBB4ZeU08VNkUcqEHaUaouNt0m7LGP4Hti/NuB07C7PPTM/LkWqXoJYJn2McEo5+kxPNrtQkLQ==", + "version": "2.8.7", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz", + "integrity": "sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==", "dev": true, "bin": { "prettier": "bin-prettier.js" @@ -20273,9 +20517,9 @@ "deprecated": "https://github.com/lydell/resolve-url#deprecated" }, "node_modules/resolve.exports": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.1.tgz", - "integrity": "sha512-OEJWVeimw8mgQuj3HfkNl4KqRevH7lzeQNaWRPfx0PPse7Jk6ozcsG4FKVgtzDsC1KUF+YlTHh17NcgHOPykLw==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz", + "integrity": "sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==", "dev": true, "engines": { "node": ">=10" @@ -21391,9 +21635,9 @@ } }, "node_modules/sucrase": { - "version": "3.29.0", - "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.29.0.tgz", - "integrity": "sha512-bZPAuGA5SdFHuzqIhTAqt9fvNEo9rESqXIG3oiKdF8K4UmkQxC4KlNL3lVyAErXp+mPvUqZ5l13qx6TrDIGf3A==", + "version": "3.30.0", + "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.30.0.tgz", + "integrity": "sha512-7d37d3vLF0IeH2dzvHpzDNDxUqpbDHJXTJOAnQ8jvMW04o2Czps6mxtaSnKWpE+hUS/eczqfWPUgQTrazKZPnQ==", "dependencies": { "commander": "^4.0.0", "glob": "7.1.6", diff --git a/CustomerApp/package.json b/CustomerApp/package.json index a5035b2..d66d0bc 100644 --- a/CustomerApp/package.json +++ b/CustomerApp/package.json @@ -46,6 +46,7 @@ "deprecated-react-native-prop-types": "^4.0.0", "expo": "^47.0.12", "expo-app-loading": "~2.1.1", + "expo-app-auth": "~11.1.0", "expo-apple-authentication": "~5.0.1", "expo-application": "~5.0.1", "expo-asset": "~8.7.0", diff --git a/CustomerApp/src/apollo/index.js b/CustomerApp/src/apollo/index.js index aacc619..d30e88b 100644 --- a/CustomerApp/src/apollo/index.js +++ b/CustomerApp/src/apollo/index.js @@ -1,92 +1,92 @@ -import AsyncStorage from '@react-native-async-storage/async-storage' -import { defaultDataIdFromObject, InMemoryCache } from 'apollo-cache-inmemory' -import { persistCache } from 'apollo-cache-persist' -import { ApolloClient } from 'apollo-client' -import { ApolloLink, concat, Observable, split } from 'apollo-link' -import { createHttpLink } from 'apollo-link-http' -import { WebSocketLink } from 'apollo-link-ws' -import { getMainDefinition } from 'apollo-utilities' -import getEnvVars from '../../environment' +import AsyncStorage from "@react-native-async-storage/async-storage"; +import { defaultDataIdFromObject, InMemoryCache } from "apollo-cache-inmemory"; +import { persistCache } from "apollo-cache-persist"; +import { ApolloClient } from "apollo-client"; +import { ApolloLink, concat, Observable, split } from "apollo-link"; +import { createHttpLink } from "apollo-link-http"; +import { WebSocketLink } from "apollo-link-ws"; +import { getMainDefinition } from "apollo-utilities"; +import getEnvVars from "../../environment"; -const { GRAPHQL_URL, WS_GRAPHQL_URL } = getEnvVars() +const { GRAPHQL_URL, WS_GRAPHQL_URL } = getEnvVars(); const cache = new InMemoryCache({ - dataIdFromObject: object => { + dataIdFromObject: (object) => { switch (object.__typename) { - case 'CartItem': - return object.key // use `key` as the primary key + case "CartItem": + return object.key; // use `key` as the primary key default: - return defaultDataIdFromObject(object) // fall back to default handling + return defaultDataIdFromObject(object); // fall back to default handling } - } -}) + }, +}); const httpLink = createHttpLink({ - uri: GRAPHQL_URL -}) + uri: GRAPHQL_URL, +}); const wsLink = new WebSocketLink({ uri: WS_GRAPHQL_URL, options: { - reconnect: true - } -}) - -const request = async operation => { - const token = await AsyncStorage.getItem('token') + reconnect: true, + }, +}); +const request = async (operation) => { + const token = await AsyncStorage.getItem("token"); + console.log("token", token); operation.setContext({ // get the authentication token from local storage if it exists // return the headers to the context so httpLink can read them headers: { - authorization: token ? `Bearer ${token}` : '' - } - }) -} + authorization: token ? `Bearer ${token}` : "", + }, + }); +}; const requestLink = new ApolloLink( (operation, forward) => - new Observable(observer => { + new Observable((observer) => { // console.log(observer) - let handle + let handle; Promise.resolve(operation) - .then(oper => request(oper)) + .then((oper) => request(oper)) .then(() => { handle = forward(operation).subscribe({ next: observer.next.bind(observer), error: observer.error.bind(observer), - complete: observer.complete.bind(observer) - }) + complete: observer.complete.bind(observer), + }); }) - .catch(observer.error.bind(observer)) + .catch(observer.error.bind(observer)); return () => { - if (handle) handle.unsubscribe() - } + if (handle) handle.unsubscribe(); + }; }) -) +); const terminatingLink = split(({ query }) => { - const { kind, operation } = getMainDefinition(query) - return kind === 'OperationDefinition' && operation === 'subscription' -}, wsLink) + const { kind, operation } = getMainDefinition(query); + return kind === "OperationDefinition" && operation === "subscription"; +}, wsLink); -const setupApollo = async() => { +const setupApollo = async () => { await persistCache({ cache, - storage: AsyncStorage - }) + storage: AsyncStorage, + }); const client = new ApolloClient({ link: concat(ApolloLink.from([terminatingLink, requestLink]), httpLink), cache, - resolvers: {} - }) + resolvers: {}, + }); // set ref for global use // eslint-disable-next-line no-undef - clientRef = client + clientRef = client; - return client -} + return client; +}; -export default setupApollo +export default setupApollo; diff --git a/CustomerApp/src/apollo/server.js b/CustomerApp/src/apollo/server.js index aa0510e..6f0793e 100644 --- a/CustomerApp/src/apollo/server.js +++ b/CustomerApp/src/apollo/server.js @@ -3,13 +3,14 @@ mutation Login($facebookId:String,$email:String,$password:String,$type:String!,$ login(facebookId:$facebookId,email:$email,password:$password,type:$type,appleId:$appleId,name:$name,notificationToken:$notificationToken){ userId token + is_active tokenExpiration name email phone } } -` +`; export const categories = ` { @@ -19,7 +20,7 @@ export const categories = ` description img_menu } -}` +}`; export const foods = ` query FoodByCategory($category:String!,$onSale:Boolean,$inStock:Boolean,$min:Float,$max:Float,$search:String){ @@ -50,7 +51,7 @@ query FoodByCategory($category:String!,$onSale:Boolean,$inStock:Boolean,$min:Flo img_url stock } - }` + }`; export const createUser = ` mutation CreateUser($facebookId:String,$phone:String,$email:String,$password:String,$name:String,$notificationToken:String,$appleId:String){ @@ -71,16 +72,17 @@ export const createUser = ` phone notificationToken } - }` + }`; export const updateUser = ` - mutation UpdateUser($name:String!,$phone:String!){ - updateUser(updateUserInput:{name:$name,phone:$phone}){ + mutation UpdateUser($name:String!,$phone:String!,$is_active:Boolean!){ + updateUser(updateUserInput:{name:$name,phone:$phone,is_active:$is_active}){ _id name phone + is_active } - }` + }`; export const updateNotificationStatus = ` mutation UpdateNotificationStatus($offerNotification:Boolean!,$orderNotification:Boolean!){ @@ -90,7 +92,7 @@ export const updateNotificationStatus = ` is_order_notification is_offer_notification } - }` + }`; export const profile = ` query{ profile{ @@ -98,6 +100,8 @@ export const profile = ` name phone email + is_active + notificationToken is_order_notification is_offer_notification @@ -111,7 +115,7 @@ export const profile = ` selected } } - }` + }`; export const order = `query Order($id:String!){ order(id:$id){ @@ -184,7 +188,7 @@ export const order = `query Order($id:String!){ } } } -` +`; export const myOrders = `query Orders($offset:Int){ orders(offset:$offset){ @@ -257,7 +261,7 @@ export const myOrders = `query Orders($offset:Int){ } } } -` +`; // // can we get userId from request instead?? @@ -340,7 +344,7 @@ export const orderStatusChanged = `subscription OrderStatusChanged($userId:Strin } } } -` +`; // // status queue?? @@ -417,7 +421,7 @@ mutation PlaceOrder($orderInput:[OrderInput!]!,$paymentMethod:String!,$couponCod description } } -}` +}`; export const reviewOrder = `mutation ReviewOrder( $orderId:String!, @@ -440,7 +444,7 @@ export const reviewOrder = `mutation ReviewOrder( updatedAt is_active } -}` +}`; // // use this to push token instead of login, signup mutation? @@ -451,7 +455,7 @@ export const pushToken = `mutation PushToken($token:String!){ _id notificationToken } -}` +}`; export const getConfiguration = `query Configuration{ configuration{ @@ -460,7 +464,7 @@ export const getConfiguration = `query Configuration{ currency_symbol delivery_charges } -}` +}`; export const foodByIds = `query FoodByIds($ids:[String!]!){ foodByIds(ids: $ids) { @@ -492,7 +496,7 @@ export const foodByIds = `query FoodByIds($ids:[String!]!){ } } } -}` +}`; export const getCoupon = `mutation Coupon($coupon:String!){ coupon(coupon:$coupon){ @@ -501,7 +505,7 @@ export const getCoupon = `mutation Coupon($coupon:String!){ discount enabled } -}` +}`; export const deleteAddress = `mutation DeleteAddress($id:ID!){ deleteAddress(id:$id){ @@ -516,7 +520,7 @@ export const deleteAddress = `mutation DeleteAddress($id:ID!){ selected } } -}` +}`; export const createAddress = `mutation CreateAddress($addressInput:AddressInput!){ createAddress(addressInput:$addressInput){ @@ -531,7 +535,7 @@ export const createAddress = `mutation CreateAddress($addressInput:AddressInput! selected } } -}` +}`; export const editAddress = `mutation EditAddress($addressInput:AddressInput!){ editAddress(addressInput:$addressInput){ @@ -542,17 +546,17 @@ export const editAddress = `mutation EditAddress($addressInput:AddressInput!){ longitude latitude } -}` +}`; export const changePassword = `mutation ChangePassword($oldPassword:String!,$newPassword:String!){ changePassword(oldPassword:$oldPassword,newPassword:$newPassword) -}` +}`; export const forgotPassword = `mutation ForgotPassword($email:String!){ forgotPassword(email:$email){ result } -}` +}`; export const selectAddress = `mutation SelectAddress($id:String!){ selectAddress(id:$id){ @@ -567,7 +571,7 @@ export const selectAddress = `mutation SelectAddress($id:String!){ selected } } -}` +}`; export const subscriptionRiderLocation = `subscription SubscriptionRiderLocation($riderId:String!){ subscriptionRiderLocation(riderId:$riderId) { @@ -577,7 +581,7 @@ export const subscriptionRiderLocation = `subscription SubscriptionRiderLocation longitude } } -}` +}`; export const rider = `query Rider($id:String){ rider(id:$id){ @@ -587,4 +591,4 @@ export const rider = `query Rider($id:String){ longitude } } -}` +}`; diff --git a/CustomerApp/src/components/Sidebar/Sidebar.js b/CustomerApp/src/components/Sidebar/Sidebar.js index e2de142..78028cd 100755 --- a/CustomerApp/src/components/Sidebar/Sidebar.js +++ b/CustomerApp/src/components/Sidebar/Sidebar.js @@ -1,49 +1,49 @@ /* eslint-disable react/prop-types */ -import { SimpleLineIcons } from '@expo/vector-icons' -import { DrawerContentScrollView, DrawerItem } from '@react-navigation/drawer' +import { SimpleLineIcons } from "@expo/vector-icons"; +import { DrawerContentScrollView, DrawerItem } from "@react-navigation/drawer"; import { DrawerActions, useNavigation, - useTheme -} from '@react-navigation/native' -import React, { useContext } from 'react' -import { Animated, View } from 'react-native' -import { useSafeAreaInsets } from 'react-native-safe-area-context' -import i18n from '../../../i18n' -import UserContext from '../../context/User' -import NavigationService from '../../routes/navigationService' -import { alignment } from '../../utils/alignment' -import { ICONS_NAME, NAVIGATION_SCREEN } from '../../utils/constant' -import { scale } from '../../utils/scaling' -import { CustomIcon } from '../CustomIcon' -import SideDrawerProfile from '../Drawer/Profile/DrawerProfile' -import { TextDefault } from '../Text' -import useStyle from './styles' + useTheme, +} from "@react-navigation/native"; +import React, { useContext } from "react"; +import { Animated, View } from "react-native"; +import { useSafeAreaInsets } from "react-native-safe-area-context"; +import i18n from "../../../i18n"; +import UserContext from "../../context/User"; +import NavigationService from "../../routes/navigationService"; +import { alignment } from "../../utils/alignment"; +import { ICONS_NAME, NAVIGATION_SCREEN } from "../../utils/constant"; +import { scale } from "../../utils/scaling"; +import { CustomIcon } from "../CustomIcon"; +import SideDrawerProfile from "../Drawer/Profile/DrawerProfile"; +import { TextDefault } from "../Text"; +import useStyle from "./styles"; const MENU = [ { - title: 'home', + title: "home", icon: ICONS_NAME.Home, navigateTo: NAVIGATION_SCREEN.Menu, - isAuth: false + isAuth: false, }, { - title: 'titleProfile', - icon: 'user', - navigateTo: 'Profile', - isAuth: true + title: "titleProfile", + icon: "user", + navigateTo: "Profile", + isAuth: true, }, { - title: 'titleOrders', + title: "titleOrders", icon: ICONS_NAME.Cart, navigateTo: NAVIGATION_SCREEN.MyOrders, - isAuth: true + isAuth: true, }, { - title: 'myAddresses', + title: "myAddresses", icon: ICONS_NAME.Location, navigateTo: NAVIGATION_SCREEN.Addresses, - isAuth: true + isAuth: true, }, // { // title: 'titleChat', @@ -52,36 +52,38 @@ const MENU = [ // isAuth: false // }, { - title: 'titleHelp', + title: "titleHelp", icon: ICONS_NAME.Info, navigateTo: NAVIGATION_SCREEN.Help, - isAuth: false + isAuth: false, }, { - title: 'titleSettings', + title: "titleSettings", icon: ICONS_NAME.Setting, navigateTo: NAVIGATION_SCREEN.Settings, - isAuth: true - } -] + isAuth: true, + }, +]; function SidebBar(props) { - const styles = useStyle() - const { colors } = useTheme() - const navigation = useNavigation() - const inset = useSafeAreaInsets() - const { isLoggedIn, logout } = useContext(UserContext) - const navigationName = NavigationService.currentRoute()?.name + const styles = useStyle(); + const { colors } = useTheme(); + const navigation = useNavigation(); + const inset = useSafeAreaInsets(); + const { isLoggedIn, logout } = useContext(UserContext); + const navigationName = NavigationService.currentRoute()?.name; return ( + contentContainerStyle={styles.scrollContent} + > + backgroundColor: "transparent", + marginBottom: inset.bottom, + }} + > @@ -89,31 +91,32 @@ function SidebBar(props) { {MENU.map((item, index) => ( ( + label={(props) => ( + style={[styles.textView, styles.flex]} + > {i18n.t(item.title)} )} - icon={props => { - if (item.icon !== 'user') { + icon={(props) => { + if (item.icon !== "user") { return ( - ) + ); } else { return ( - ) + ); } }} - onPress={async() => { + onPress={async () => { if (item.isAuth && !isLoggedIn) { - navigation.navigate(NAVIGATION_SCREEN.CreateAccount) + navigation.navigate(NAVIGATION_SCREEN.CreateAccount); } else { - navigation.navigate(item.navigateTo) + navigation.navigate(item.navigateTo); } }} /> @@ -137,15 +140,16 @@ function SidebBar(props) { {isLoggedIn && ( ( - {i18n.t('titleLogout')} + style={[styles.textView, styles.flex]} + > + {i18n.t("titleLogout")} )} icon={() => ( @@ -155,12 +159,12 @@ function SidebBar(props) { size={scale(22)} /> )} - onPress={async() => { - logout() + onPress={async () => { + logout(); navigation.reset({ - routes: [{ name: 'Menu' }] - }) - navigation.dispatch(DrawerActions.closeDrawer()) + routes: [{ name: "Menu" }], + }); + navigation.dispatch(DrawerActions.closeDrawer()); // await client.resetStore(); }} /> @@ -169,6 +173,6 @@ function SidebBar(props) { - ) + ); } -export default SidebBar +export default SidebBar; diff --git a/CustomerApp/src/screens/Login/Login.js b/CustomerApp/src/screens/Login/Login.js index c19b8da..d3ee6c9 100755 --- a/CustomerApp/src/screens/Login/Login.js +++ b/CustomerApp/src/screens/Login/Login.js @@ -1,9 +1,9 @@ -import { useMutation } from '@apollo/react-hooks' -import { useNavigation, useTheme } from '@react-navigation/native' -import * as Notifications from 'expo-notifications' -import Constants from 'expo-constants' -import gql from 'graphql-tag' -import React, { useContext, useEffect, useState } from 'react' +import { useMutation } from "@apollo/react-hooks"; +import { useNavigation, useTheme } from "@react-navigation/native"; +import * as Notifications from "expo-notifications"; +import Constants from "expo-constants"; +import gql from "graphql-tag"; +import React, { useContext, useEffect, useState } from "react"; import { ActivityIndicator, BackHandler, @@ -11,141 +11,157 @@ import { Platform, ScrollView, TouchableOpacity, - View -} from 'react-native' -import { FilledTextField } from 'react-native-material-textfield' -import { useSafeAreaInsets } from 'react-native-safe-area-context' -import i18n from '../../../i18n' -import { login } from '../../apollo/server' + View, +} from "react-native"; +import { FilledTextField } from "react-native-material-textfield"; +import { useSafeAreaInsets } from "react-native-safe-area-context"; +import i18n from "../../../i18n"; +import { login } from "../../apollo/server"; import { EnategaImage, FlashMessage, RegistrationHeader, TextDefault, - WrapperView -} from '../../components' -import UserContext from '../../context/User' -import { alignment } from '../../utils/alignment' -import Analytics from '../../utils/analytics' -import { NAVIGATION_SCREEN } from '../../utils/constant' -import { scale, verticalScale } from '../../utils/scaling' -import useStyle from './styles' + WrapperView, +} from "../../components"; +import UserContext from "../../context/User"; +import { alignment } from "../../utils/alignment"; +import Analytics from "../../utils/analytics"; +import { NAVIGATION_SCREEN } from "../../utils/constant"; +import { scale, verticalScale } from "../../utils/scaling"; +import useStyle from "./styles"; // Constants const LOGIN = gql` ${login} -` +`; -const Logo = require('../../../assets/logo.png') +const Logo = require("../../../assets/logo.png"); function Login() { - let _didFocusSubscription = null - let _willBlurSubscription = null - const styles = useStyle() - const inset = useSafeAreaInsets() - const { colors } = useTheme() - const navigation = useNavigation() - const [email, setEmail] = useState('john@test.com') - const [loading, setLoading] = useState(false) - const [password, setPassword] = useState('123123') - const [emailError, setEmailError] = useState('') - const { setTokenAsync } = useContext(UserContext) - const [passwordError, setPasswordError] = useState(null) + let _didFocusSubscription = null; + let _willBlurSubscription = null; + const styles = useStyle(); + const inset = useSafeAreaInsets(); + const { colors } = useTheme(); + const navigation = useNavigation(); + const [email, setEmail] = useState("john@test.com"); + const [loading, setLoading] = useState(false); + const [password, setPassword] = useState("123123"); + const [emailError, setEmailError] = useState(""); + const { setTokenAsync } = useContext(UserContext); + const [passwordError, setPasswordError] = useState(null); - const [mutate] = useMutation(LOGIN, { onCompleted, onError }) + const [mutate] = useMutation(LOGIN, { onCompleted, onError }); useEffect(() => { - _didFocusSubscription = navigation.addListener('didFocus', () => { + _didFocusSubscription = navigation.addListener("didFocus", () => { BackHandler.addEventListener( - 'hardwareBackPress', + "hardwareBackPress", onBackButtonPressAndroid - ) - }) - _willBlurSubscription = navigation.addListener('willBlur', () => { + ); + }); + _willBlurSubscription = navigation.addListener("willBlur", () => { BackHandler.removeEventListener( - 'hardwareBackPress', + "hardwareBackPress", onBackButtonPressAndroid - ) - }) + ); + }); return () => { - _didFocusSubscription && _didFocusSubscription() - _willBlurSubscription && _willBlurSubscription() + _didFocusSubscription && _didFocusSubscription(); + _willBlurSubscription && _willBlurSubscription(); BackHandler.removeEventListener( - 'hardwareBackPress', + "hardwareBackPress", onBackButtonPressAndroid - ) - } - }, []) + ); + }; + }, []); function validateCredentials() { - let result = true - setEmailError(null) - setPasswordError(null) + let result = true; + setEmailError(null); + setPasswordError(null); if (!email) { - setEmailError('Email/Phone is required') - result = false + setEmailError("Email/Phone is required"); + result = false; } else { - const emailRegex = /^\w+([\\.-]?\w+)*@\w+([\\.-]?\w+)*(\.\w{2,3})+$/ - const phoneRegex = /^[+]\d{6,15}$/ + const emailRegex = /^\w+([\\.-]?\w+)*@\w+([\\.-]?\w+)*(\.\w{2,3})+$/; + const phoneRegex = /^[+]\d{6,15}$/; if (emailRegex.test(email) !== true && phoneRegex.test(email) !== true) { - setEmailError('Invalid Email/Phone') - result = false + setEmailError("Invalid Email/Phone"); + result = false; } } if (!password) { - setPasswordError('Password is required') - result = false + setPasswordError("Password is required"); + result = false; } - return result + return result; } async function onCompleted(data) { try { const trackingOpts = { id: data.login.userId, - usernameOrEmail: data.login.email + usernameOrEmail: data.login.email, + }; + + Analytics.identify(data.login.userId, trackingOpts); + Analytics.track(Analytics.events.USER_LOGGED_IN, trackingOpts); + setTokenAsync(data.login.token); + console.log("Data Before Navigation:", data.login.is_active); + if (!data.login.is_active) { + FlashMessage({ + message: "Can't Login,This Account is Deleted!", + }); } - Analytics.identify(data.login.userId, trackingOpts) - Analytics.track(Analytics.events.USER_LOGGED_IN, trackingOpts) - setTokenAsync(data.login.token) - navigation.navigate(NAVIGATION_SCREEN.Menu) + { + data.login.is_active && navigation.navigate(NAVIGATION_SCREEN.Menu); + } + + // { + // FlashMessage({ + // message: "Can't Login,This Account is Deleted!", + // }); + // } } catch (e) { - console.log(e) + console.log(e); } finally { - setLoading(false) + setLoading(false); } } function onError(error) { try { - console.log(JSON.stringify(error)) + console.log(JSON.stringify(error)); FlashMessage({ - message: error.graphQLErrors[0].message - }) + message: error.graphQLErrors[0].message, + }); } catch (e) { - console.log(e) + console.log(e); } finally { - setLoading(false) + setLoading(false); } } function onBackButtonPressAndroid() { - navigation.navigate(NAVIGATION_SCREEN.Menu) - return true + navigation.navigate(NAVIGATION_SCREEN.Menu); + return true; } async function mutateLogin(user) { try { - setLoading(true) - let notificationToken = null + setLoading(true); + let notificationToken = null; if (Constants.isDevice) { const { status: existingStatus } = - await Notifications.getPermissionsAsync() - if (existingStatus === 'granted') { - notificationToken = (await Notifications.getExpoPushTokenAsync()).data + await Notifications.getPermissionsAsync(); + if (existingStatus === "granted") { + notificationToken = (await Notifications.getExpoPushTokenAsync()) + .data; } } - mutate({ variables: { ...user, notificationToken } }) + mutate({ variables: { ...user, notificationToken } }); } catch (e) { - console.log(e) + console.log(e); } finally { } } @@ -155,41 +171,44 @@ function Login() { { + onPress={async () => { const user = { email: email, password: password, - type: 'default' - } + type: "default", + }; if (validateCredentials()) { - mutateLogin(user) + mutateLogin(user); } - }}> + }} + > {loading ? ( ) : ( - {i18n.t('loginBtn')} + {i18n.t("loginBtn")} )} - ) + ); } return ( + behavior={Platform.OS === "ios" ? "padding" : "height"} + style={styles.flex} + > + alwaysBounceVertical={false} + > - + { - setEmail(text.toLowerCase().trim()) + onChangeText={(text) => { + setEmail(text.toLowerCase().trim()); }} /> { - setPassword(text.trim()) + onChangeText={(text) => { + setPassword(text.trim()); }} /> navigation.navigate(NAVIGATION_SCREEN.ForgotPassword) - }> + } + > + center + > Forgot Password? @@ -262,7 +283,8 @@ function Login() { style={[alignment.MTlarge, styles.loginBtn, styles.whiteBtn]} onPress={() => navigation.navigate(NAVIGATION_SCREEN.CreateAccount) - }> + } + > Create New Account @@ -273,7 +295,7 @@ function Login() { - ) + ); } -export default Login +export default Login; diff --git a/CustomerApp/src/screens/Settings/Settings.js b/CustomerApp/src/screens/Settings/Settings.js index 73a5b78..9e3bf82 100644 --- a/CustomerApp/src/screens/Settings/Settings.js +++ b/CustomerApp/src/screens/Settings/Settings.js @@ -16,9 +16,14 @@ import { TouchableOpacity, View, } from "react-native"; + import { Modalize } from "react-native-modalize"; +import { async } from "validate.js"; import i18n from "../../../i18n"; +import { moderateScale } from "../../utils/scaling"; + import { + updateUser, profile, pushToken, updateNotificationStatus, @@ -55,24 +60,23 @@ const UPDATE_NOTIFICATION_TOKEN = gql` const PROFILE = gql` ${profile} `; - +const UPDATEUSER = gql` + ${updateUser} +`; function Settings() { const styles = useStyle(); const { colors } = useTheme(); const navigation = useNavigation(); - const { profile } = useContext(UserContext); + const { profile, logout } = useContext(UserContext); const [languageName, languageNameSetter] = useState("English"); - const [offerNotification, offerNotificationSetter] = useState( - profile.is_offer_notification - ); - const [orderNotification, orderNotificationSetter] = useState( - profile.is_order_notification - ); + const [offerNotification, offerNotificationSetter] = useState(); + const [orderNotification, orderNotificationSetter] = useState(); const [activeRadio, activeRadioSetter] = useState(languageTypes[0].index); // eslint-disable-next-line no-unused-vars const [appState, setAppState] = useState(AppState.currentState); const [uploadToken] = useMutation(PUSH_TOKEN); + const [updateUserInfo] = useMutation(UPDATEUSER); const [mutate, { loading }] = useMutation(UPDATE_NOTIFICATION_TOKEN, { onCompleted, onError, @@ -203,7 +207,22 @@ function Settings() { }, }); } - + // console.log(profile.name); + // console.log(profile.phone); + // console.log(profile.is_active); + //console.log(profile.is_activated); + async function updateUserInformation() { + updateUserInfo({ + variables: { + //updateUserInput: { + name: profile.name, + phone: profile.phone, + is_active: false, + //is_activated: false, + // }, + }, + }); + } return ( {loading && ( @@ -289,6 +308,34 @@ function Settings() { /> + + modalizeRef.current.open("top")} + // onPress={ + // async () => { + // await updateUserInformation(); + // logout(); + // navigation.reset({ + // routes: [{ name: "Menu" }], + // } + // ); + // //navigation.dispatch(DrawerActions.closeDrawer()); + // }} + style={[styles.notificationContainer, styles.shadow]} + > + + + {" "} + Delete Account{" "} + + + + Version: {Constants.manifest.version} @@ -322,6 +369,52 @@ function Settings() { activeRadio={activeRadio} /> + {/* Modal for Delete Account */} + + + + Are you Sure you want to delete Account? + + { + await updateUserInformation(); + logout(); + navigation.reset({ + routes: [{ name: "Menu" }], + }); + }} + > + Delete Account + + onClose()} + > + Cancel + + + ); } diff --git a/CustomerApp/src/screens/Settings/components/SettingModal.js b/CustomerApp/src/screens/Settings/components/SettingModal.js index a4f9930..8bed035 100644 --- a/CustomerApp/src/screens/Settings/components/SettingModal.js +++ b/CustomerApp/src/screens/Settings/components/SettingModal.js @@ -1,24 +1,24 @@ -import { useTheme } from '@react-navigation/native' -import PropTypes from 'prop-types' -import React, { useState } from 'react' -import { TouchableOpacity, View } from 'react-native' -import RadioButton from '../../../components/FdRadioBtn/RadioBtn' -import TextDefault from '../../../components/Text/TextDefault/TextDefault' -import { alignment } from '../../../utils/alignment' -import useStyle from './styles' +import { useTheme } from "@react-navigation/native"; +import PropTypes from "prop-types"; +import React, { useState } from "react"; +import { TouchableOpacity, View } from "react-native"; +import RadioButton from "../../../components/FdRadioBtn/RadioBtn"; +import TextDefault from "../../../components/Text/TextDefault/TextDefault"; +import { alignment } from "../../../utils/alignment"; +import useStyle from "./styles"; const languageTypes = [ - { value: 'English', code: 'en', index: 0 }, - { value: 'français', code: 'fr', index: 1 }, - { value: 'ភាសាខ្មែរ', code: 'km', index: 2 }, - { value: '中文', code: 'zh', index: 3 }, - { value: 'Deutsche', code: 'de', index: 4 } -] + { value: "English", code: "en", index: 0 }, + { value: "français", code: "fr", index: 1 }, + { value: "ភាសាខ្មែរ", code: "km", index: 2 }, + { value: "中文", code: "zh", index: 3 }, + { value: "Deutsche", code: "de", index: 4 }, +]; function SettingModal(props) { - const styles = useStyle() - const { colors } = useTheme() - const [activeRadio, activeRadioSetter] = useState(props.activeRadio) + const styles = useStyle(); + const { colors } = useTheme(); + const [activeRadio, activeRadioSetter] = useState(props.activeRadio); return ( @@ -31,12 +31,13 @@ function SettingModal(props) { activeOpacity={0.7} key={item.index} onPress={() => activeRadioSetter(item.index)} - style={[styles.radioContainer]}> + style={[styles.radioContainer]} + > {item.value} props.onSelectedLanguage(activeRadio)}> + onPress={() => props.onSelectedLanguage(activeRadio)} + > Done @@ -59,17 +61,18 @@ function SettingModal(props) { props.onClose()}> + onPress={() => props.onClose()} + > Cancel {/* */} - ) + ); } SettingModal.propTypes = { activeRadio: PropTypes.number, onSelectedLanguage: PropTypes.func, - onClose: PropTypes.func -} -export default SettingModal + onClose: PropTypes.func, +}; +export default SettingModal;