Skip to content

Commit

Permalink
feat: hotfix for not populating surveyor names
Browse files Browse the repository at this point in the history
  • Loading branch information
hopetambala committed Dec 10, 2020
1 parent 907a6ec commit ae0103b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 23 deletions.
9 changes: 3 additions & 6 deletions domains/Auth/SignIn/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,9 @@ const SignIn = ({ navigation }) => {
};

const storeUserInformation = async () => {
const currentUser = await retrieveCurrentUserAsyncFunction();
getData('organization').then((asyncOrg) => {
if (asyncOrg !== currentUser.organization) {
storeData(currentUser.organization, 'organization');
storeData(currentUser, 'currentUser');
}
await retrieveCurrentUserAsyncFunction().then((currentUser) => {
storeData(currentUser.organization, 'organization');
storeData(currentUser, 'currentUser');
});
};

Expand Down
11 changes: 6 additions & 5 deletions domains/DataCollection/Forms/IdentificationForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ import { postObjectsToClass } from '../../../../services/parse/crud';

import { storeData } from '../../../../modules/async-storage';
import checkOnlineStatus from '../../../../modules/offline';
import generateRandomID from '../../../../modules/utils';
import { generateRandomID } from '../../../../modules/utils';
import { layout } from '../../../../modules/theme';
import I18n from '../../../../modules/i18n';

import PaperButton from '../../../../components/Button';
import PaperInputPicker from '../../../../components/FormikFields/PaperInputPicker';
import yupValidationPicker from '../../../../components/FormikFields/YupValidation';

import backgroundPostPatient from './utils';
import { backgroundPostPatient, surveyingUserFailsafe } from './utils';
import configArray from './config/config';

const IdentificationForm = ({
scrollViewScroll, setScrollViewScroll,
setSelectedForm, setSurveyee, surveyingOrganization, surveyingUser
setSelectedForm, setSurveyee, surveyingOrganization
}) => {
useEffect(() => {
const interval = setInterval(() => {
Expand All @@ -49,12 +49,13 @@ const IdentificationForm = ({
<TouchableWithoutFeedback onPress={Keyboard.dismiss()} accessible={false}>
<Formik
initialValues={{}}
onSubmit={(values, actions) => {
onSubmit={async (values, actions) => {
setPhotoFile('Submitted Photo String');

const formObject = values;
formObject.surveyingOrganization = surveyingOrganization;
formObject.surveyingUser = surveyingUser;
formObject.surveyingUser = await surveyingUserFailsafe();

formObject.latitude = values.location?.latitude || 0;
formObject.longitude = values.location?.longitude || 0;
formObject.altitude = values.location?.altitude || 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ const backgroundPostPatient = () => {
});
};

export default backgroundPostPatient;
const surveyingUserFailsafe = async () => {
const user = await getData('currentUser');
return user.username || user.email || user.id || user.firstname || user.lastname;
};

export { backgroundPostPatient, surveyingUserFailsafe };
16 changes: 8 additions & 8 deletions domains/DataCollection/Forms/SupplementaryForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ const SupplementaryForm = ({
{formikProps.isSubmitting ? (
<ActivityIndicator />
) : (
<Button
disabled={!surveyee.objectId}
onPress={formikProps.handleSubmit}
>
{surveyee.objectId && <Text>{I18n.t('global.submit')}</Text>}
{!surveyee.objectId && <Text>{I18n.t('supplementaryForms.attachResident')}</Text>}
</Button>
)}
<Button
disabled={!surveyee.objectId}
onPress={formikProps.handleSubmit}
>
{surveyee.objectId && <Text>{I18n.t('global.submit')}</Text>}
{!surveyee.objectId && <Text>{I18n.t('supplementaryForms.attachResident')}</Text>}
</Button>
)}
</View>
)}
</Formik>
Expand Down
2 changes: 0 additions & 2 deletions domains/DataCollection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ const DataCollection = ({ navigation }) => {
useEffect(() => {
getData('currentUser').then((user) => {
setSurveyingUser(`${user.firstname || ''} ${user.lastname || ''}`);
}).catch(() => {
setSurveyingUser(`${''} ${''}`);
});

getData('organization').then((org) => {
Expand Down
3 changes: 2 additions & 1 deletion modules/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const generateRandomID = () => Math.random().toString(20).substr(2, 12);
const isEmpty = (str) => (!str || str.length === 0);

export default generateRandomID;
export { isEmpty, generateRandomID };

0 comments on commit ae0103b

Please sign in to comment.