From 649b58ff135f9b024dffb99ced2bdb52672df3be Mon Sep 17 00:00:00 2001 From: Joseph McCombs Date: Wed, 17 Feb 2021 22:06:41 -0500 Subject: [PATCH 1/5] feat: appVersion stored in async and added to all frm submissions --- .../Forms/IdentificationForm/index.js | 18 ++++++++++-------- .../Forms/SupplementaryForm/index.js | 18 ++++++++++-------- modules/cached-resources/populate-cache.js | 11 +++++++++++ 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/domains/DataCollection/Forms/IdentificationForm/index.js b/domains/DataCollection/Forms/IdentificationForm/index.js index f0a9d5a2d..fc48c3c2b 100644 --- a/domains/DataCollection/Forms/IdentificationForm/index.js +++ b/domains/DataCollection/Forms/IdentificationForm/index.js @@ -10,6 +10,7 @@ import PaperButton from '../../../../components/Button'; import ErrorPicker from '../../../../components/FormikFields/ErrorPicker'; import PaperInputPicker from '../../../../components/FormikFields/PaperInputPicker'; import yupValidationPicker from '../../../../components/FormikFields/YupValidation'; +import { getData } from '../../../../modules/async-storage'; import { postIdentificationForm } from '../../../../modules/cached-resources'; import I18n from '../../../../modules/i18n'; import { layout, theme } from '../../../../modules/theme'; @@ -46,6 +47,7 @@ const IdentificationForm = ({ const formObject = values; formObject.surveyingOrganization = surveyingOrganization; formObject.surveyingUser = await surveyingUserFailsafe(surveyingUser, isEmpty); + formObject.appVersion = await getData('appVersion'); formObject.latitude = values.location?.latitude || 0; formObject.longitude = values.location?.longitude || 0; @@ -109,14 +111,14 @@ const IdentificationForm = ({ color={theme.colors.primary} /> ) : ( - - // - )} + + // + )} )} diff --git a/domains/DataCollection/Forms/SupplementaryForm/index.js b/domains/DataCollection/Forms/SupplementaryForm/index.js index f815c44d5..9f48d4f07 100644 --- a/domains/DataCollection/Forms/SupplementaryForm/index.js +++ b/domains/DataCollection/Forms/SupplementaryForm/index.js @@ -19,6 +19,7 @@ import envConfig from './configs/envhealth.config'; import medConfig from './configs/medical-evaluation.config'; import vitalsConfig from './configs/vitals.config'; import { addSelectTextInputs, vitalsBloodPressue } from './utils'; +import { getData } from '../../../../modules/async-storage' const SupplementaryForm = ({ navigation, selectedForm, setSelectedForm, surveyee, surveyingUser, surveyingOrganization, @@ -59,6 +60,7 @@ const SupplementaryForm = ({ const formObject = values; formObject.surveyingUser = await surveyingUserFailsafe(surveyingUser, isEmpty); formObject.surveyingOrganization = surveyingOrganization; + formObject.appVersion = await getData('appVersion'); let formObjectUpdated = addSelectTextInputs(values, formObject); if (selectedForm === 'vitals') { @@ -134,14 +136,14 @@ const SupplementaryForm = ({ color={theme.colors.primary} /> ) : ( - - )} + + )} )} diff --git a/modules/cached-resources/populate-cache.js b/modules/cached-resources/populate-cache.js index 2db2aa648..7864f1030 100644 --- a/modules/cached-resources/populate-cache.js +++ b/modules/cached-resources/populate-cache.js @@ -1,6 +1,7 @@ import { retrieveCurrentUserAsyncFunction } from '../../services/parse/auth'; import { getData, storeData } from '../async-storage'; import { cacheAutofillData, cacheResidentData, customFormsQuery } from './read'; +import Constants from 'expo-constants'; export default function populateCache(user) { // communities called since we need a paramter, all data would be cached in the @@ -45,5 +46,15 @@ export default function populateCache(user) { }) .then(async () => { await customFormsQuery(user.get('organization')); + }) + .then(async () => { + // store current app version + const appVersion = Constants.manifest.version; + await getData('appVersion').then(async (currentAppVersion) => { + if (appVersion !== currentAppVersion && appVersion !== null && appVersion !== undefined) { + await storeData(appVersion, 'appVersion') + } + }) + }); } From a0a49bf632169e9cc6832b7ab429adc15581b4ac Mon Sep 17 00:00:00 2001 From: Joseph McCombs Date: Wed, 17 Feb 2021 22:34:31 -0500 Subject: [PATCH 2/5] chore: revert modal commit --- domains/Auth/SignIn/index.js | 3 +-- package-lock.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/domains/Auth/SignIn/index.js b/domains/Auth/SignIn/index.js index 87295ab8e..894f956f7 100644 --- a/domains/Auth/SignIn/index.js +++ b/domains/Auth/SignIn/index.js @@ -187,8 +187,7 @@ const SignIn = ({ navigation }) => { // need some pincode verification handleSignIn(values, actions.resetForm()); } else { - // incorrect usernmae/password offline - handleFailedAttempt(); + // cannot log in offline without saved credentials, connect to internet } }); } diff --git a/package-lock.json b/package-lock.json index 69cf333a4..3ff10acd7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "puente-reactnative", - "version": "10.5.4", + "version": "10.5.0", "lockfileVersion": 1, "requires": true, "dependencies": { From d1360b187a4b1baaa524acf4aded49436d9b2e67 Mon Sep 17 00:00:00 2001 From: Joseph McCombs Date: Wed, 17 Feb 2021 22:35:40 -0500 Subject: [PATCH 3/5] chore: linting --- .../Forms/IdentificationForm/index.js | 16 ++++++++-------- .../Forms/SupplementaryForm/index.js | 18 +++++++++--------- modules/cached-resources/populate-cache.js | 8 ++++---- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/domains/DataCollection/Forms/IdentificationForm/index.js b/domains/DataCollection/Forms/IdentificationForm/index.js index fc48c3c2b..ea4df6b7a 100644 --- a/domains/DataCollection/Forms/IdentificationForm/index.js +++ b/domains/DataCollection/Forms/IdentificationForm/index.js @@ -111,14 +111,14 @@ const IdentificationForm = ({ color={theme.colors.primary} /> ) : ( - - // - )} + + // + )} )} diff --git a/domains/DataCollection/Forms/SupplementaryForm/index.js b/domains/DataCollection/Forms/SupplementaryForm/index.js index 9f48d4f07..1fb82f30d 100644 --- a/domains/DataCollection/Forms/SupplementaryForm/index.js +++ b/domains/DataCollection/Forms/SupplementaryForm/index.js @@ -10,6 +10,7 @@ import { Button, Text } from 'react-native-paper'; import ErrorPicker from '../../../../components/FormikFields/ErrorPicker'; import PaperInputPicker from '../../../../components/FormikFields/PaperInputPicker'; import yupValidationPicker from '../../../../components/FormikFields/YupValidation'; +import { getData } from '../../../../modules/async-storage'; import { postSupplementaryForm } from '../../../../modules/cached-resources'; import I18n from '../../../../modules/i18n'; import { layout, theme } from '../../../../modules/theme'; @@ -19,7 +20,6 @@ import envConfig from './configs/envhealth.config'; import medConfig from './configs/medical-evaluation.config'; import vitalsConfig from './configs/vitals.config'; import { addSelectTextInputs, vitalsBloodPressue } from './utils'; -import { getData } from '../../../../modules/async-storage' const SupplementaryForm = ({ navigation, selectedForm, setSelectedForm, surveyee, surveyingUser, surveyingOrganization, @@ -136,14 +136,14 @@ const SupplementaryForm = ({ color={theme.colors.primary} /> ) : ( - - )} + + )} )} diff --git a/modules/cached-resources/populate-cache.js b/modules/cached-resources/populate-cache.js index 7864f1030..2ab22080f 100644 --- a/modules/cached-resources/populate-cache.js +++ b/modules/cached-resources/populate-cache.js @@ -1,7 +1,8 @@ +import Constants from 'expo-constants'; + import { retrieveCurrentUserAsyncFunction } from '../../services/parse/auth'; import { getData, storeData } from '../async-storage'; import { cacheAutofillData, cacheResidentData, customFormsQuery } from './read'; -import Constants from 'expo-constants'; export default function populateCache(user) { // communities called since we need a paramter, all data would be cached in the @@ -52,9 +53,8 @@ export default function populateCache(user) { const appVersion = Constants.manifest.version; await getData('appVersion').then(async (currentAppVersion) => { if (appVersion !== currentAppVersion && appVersion !== null && appVersion !== undefined) { - await storeData(appVersion, 'appVersion') + await storeData(appVersion, 'appVersion'); } - }) - + }); }); } From d5e4e338159ab634d9c945fab82c121e33d050d0 Mon Sep 17 00:00:00 2001 From: Joseph McCombs Date: Wed, 17 Feb 2021 22:46:44 -0500 Subject: [PATCH 4/5] chore: add failed attempt modal again.. --- domains/Auth/SignIn/index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/domains/Auth/SignIn/index.js b/domains/Auth/SignIn/index.js index 894f956f7..424cc3bc5 100644 --- a/domains/Auth/SignIn/index.js +++ b/domains/Auth/SignIn/index.js @@ -71,8 +71,8 @@ const SignIn = ({ navigation }) => { Alert.alert( I18n.t('signIn.unableLogin'), I18n.t('signIn.usernamePasswordIncorrect'), [ - { text: 'OK' } - ], + { text: 'OK' } + ], { cancelable: true } ); }; @@ -187,7 +187,8 @@ const SignIn = ({ navigation }) => { // need some pincode verification handleSignIn(values, actions.resetForm()); } else { - // cannot log in offline without saved credentials, connect to internet + // incorrect usernmae/password offline + handleFailedAttempt(); } }); } @@ -242,8 +243,8 @@ const SignIn = ({ navigation }) => { {formikProps.isSubmitting ? ( ) : ( - - )} + + )} Date: Wed, 17 Feb 2021 22:50:16 -0500 Subject: [PATCH 5/5] chore: linting --- domains/Auth/SignIn/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/domains/Auth/SignIn/index.js b/domains/Auth/SignIn/index.js index 424cc3bc5..87295ab8e 100644 --- a/domains/Auth/SignIn/index.js +++ b/domains/Auth/SignIn/index.js @@ -71,8 +71,8 @@ const SignIn = ({ navigation }) => { Alert.alert( I18n.t('signIn.unableLogin'), I18n.t('signIn.usernamePasswordIncorrect'), [ - { text: 'OK' } - ], + { text: 'OK' } + ], { cancelable: true } ); }; @@ -243,8 +243,8 @@ const SignIn = ({ navigation }) => { {formikProps.isSubmitting ? ( ) : ( - - )} + + )}